| 111 | } |
| 112 | |
| 113 | void 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 | |
| 146 | TEST_F(NewServerEnvTest, ShowRealEndpoint) { |
| 147 | FLAGS_zk_cluster = "127.0.0.1:6181"; |
no test coverage detected