MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / ShowNameServer

Function ShowNameServer

src/nameserver/new_server_env_test.cc:113–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113void ShowNameServer(std::map<std::string, std::string>* map) {
114 std::shared_ptr<::fedb::zk::ZkClient> zk_client;
115 zk_client = std::make_shared<::fedb::zk::ZkClient>(
116 FLAGS_zk_cluster, "", 1000, "", FLAGS_zk_root_path);
117 if (!zk_client->Init()) {
118 ASSERT_TRUE(false);
119 }
120 std::string node_path = FLAGS_zk_root_path + "/leader";
121 std::vector<std::string> children;
122 if (!zk_client->GetChildren(node_path, children) || children.empty()) {
123 ASSERT_TRUE(false);
124 }
125 for (auto path : children) {
126 std::string endpoint;
127 std::string real_path = node_path + "/" + path;
128 if (!zk_client->GetNodeValue(real_path, endpoint)) {
129 ASSERT_TRUE(false);
130 }
131 map->insert(std::make_pair(endpoint, ""));
132 }
133 for (auto& kv : *map) {
134 std::string real_endpoint;
135 std::string name = "/map/names/" + kv.first;
136 if (zk_client->IsExistNode(FLAGS_zk_root_path + name) == 0) {
137 if (!zk_client->GetNodeValue(FLAGS_zk_root_path + name,
138 real_endpoint) || real_endpoint.empty()) {
139 ASSERT_TRUE(false);
140 }
141 }
142 kv.second = real_endpoint;
143 }
144}
145
146TEST_F(NewServerEnvTest, ShowRealEndpoint) {
147 FLAGS_zk_cluster = "127.0.0.1:6181";

Callers 1

TEST_FFunction · 0.85

Calls 6

GetChildrenMethod · 0.80
GetNodeValueMethod · 0.80
insertMethod · 0.80
IsExistNodeMethod · 0.80
InitMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected