Commit 9dc41522 authored by zhujiashun's avatar zhujiashun

make json string in NamingServiceTest.discovery_parse_function more readable

parent 80938ef7
...@@ -424,7 +424,70 @@ TEST(NamingServiceTest, discovery_parse_function) { ...@@ -424,7 +424,70 @@ TEST(NamingServiceTest, discovery_parse_function) {
std::vector<brpc::ServerNode> servers; std::vector<brpc::ServerNode> servers;
brpc::policy::DiscoveryNamingService dcns; brpc::policy::DiscoveryNamingService dcns;
butil::IOBuf buf; butil::IOBuf buf;
buf.append(R"({"code":0,"message":"0","ttl":1,"data":{"admin.test":{"instances":[{"region":"","zone":"sh001","env":"uat","appid":"admin.test","treeid":0,"hostname":"host123","http":"","rpc":"","version":"123","metadata":{},"addrs":["http://127.0.0.1:8999", "gorpc://127.0.1.1:9000"],"status":1,"reg_timestamp":1539001034551496412,"up_timestamp":1539001034551496412,"renew_timestamp":1539001034551496412,"dirty_timestamp":1539001034551496412,"latest_timestamp":1539001034551496412}],"zone_instances":{"sh001":[{"region":"","zone":"sh001","env":"uat","appid":"admin.test","treeid":0,"hostname":"host123","http":"","rpc":"","version":"123","metadata":{},"addrs":["http://127.0.0.1:8999", "gorpc://127.0.1.1:9000"],"status":1,"reg_timestamp":1539001034551496412,"up_timestamp":1539001034551496412,"renew_timestamp":1539001034551496412,"dirty_timestamp":1539001034551496412,"latest_timestamp":1539001034551496412}]},"latest_timestamp":1539001034551496412,"latest_timestamp_str":"1539001034"}}})"); buf.append(R"({
"code":0,
"message":"0",
"ttl":1,
"data":{
"admin.test":{
"instances":[
{
"region":"",
"zone":"sh001",
"env":"uat",
"appid":"admin.test",
"treeid":0,
"hostname":"host123",
"http":"",
"rpc":"",
"version":"123",
"metadata":{
},
"addrs":[
"http://127.0.0.1:8999",
"gorpc://127.0.1.1:9000"
],
"status":1,
"reg_timestamp":1539001034551496412,
"up_timestamp":1539001034551496412,
"renew_timestamp":1539001034551496412,
"dirty_timestamp":1539001034551496412,
"latest_timestamp":1539001034551496412
}
],
"zone_instances":{
"sh001":[
{
"region":"",
"zone":"sh001",
"env":"uat",
"appid":"admin.test",
"treeid":0,
"hostname":"host123",
"http":"",
"rpc":"",
"version":"123",
"metadata":{
},
"addrs":[
"http://127.0.0.1:8999",
"gorpc://127.0.1.1:9000"
],
"status":1,
"reg_timestamp":1539001034551496412,
"up_timestamp":1539001034551496412,
"renew_timestamp":1539001034551496412,
"dirty_timestamp":1539001034551496412,
"latest_timestamp":1539001034551496412
}
]
},
"latest_timestamp":1539001034551496412,
"latest_timestamp_str":"1539001034"
}
}})");
ASSERT_EQ(0, dcns.parse_fetchs_result(buf, "admin.test", &servers)); ASSERT_EQ(0, dcns.parse_fetchs_result(buf, "admin.test", &servers));
ASSERT_EQ((size_t)2, servers.size()); ASSERT_EQ((size_t)2, servers.size());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment