aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/channel
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2018-10-19 13:26:42 -0700
committerGravatar ncteisen <ncteisen@gmail.com>2018-10-19 14:02:10 -0700
commita3400a8fcb8b5b8d4559e6466623ba69c4d2320b (patch)
tree28ef9e0a90349fd4a56969d9bba3688cd3f17861 /test/core/channel
parentd6d5d21c0af5b4e739cf3cfa35f64ceaa92424be (diff)
Add a test with more edge cases
Diffstat (limited to 'test/core/channel')
-rw-r--r--test/core/channel/channelz_test.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc
index 4a1f53b924..5f27320512 100644
--- a/test/core/channel/channelz_test.cc
+++ b/test/core/channel/channelz_test.cc
@@ -423,6 +423,33 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsNoHitUuid) {
gpr_free(json_str);
}
+TEST_F(ChannelzRegistryBasedTest, GetTopChannelsMoreGaps) {
+ grpc_core::ExecCtx exec_ctx;
+ ChannelFixture channel_with_uuid1;
+ { ServerFixture channel_with_uuid2; }
+ ChannelFixture channel_with_uuid3;
+ { ServerFixture server_with_uuid4; }
+ ChannelFixture channel_with_uuid5;
+ // Current state of list: [1, NULL, 3, NULL, 5]
+ char* json_str = ChannelzRegistry::GetTopChannels(2);
+ grpc_json* parsed_json = grpc_json_parse_string(json_str);
+ ValidateJsonArraySize(parsed_json, "channel", 2);
+ grpc_json* json_channels = GetJsonChild(parsed_json, "channel");
+ std::vector<intptr_t> uuids = GetUuidListFromArray(json_channels);
+ EXPECT_EQ(static_cast<intptr_t>(3), uuids[0]);
+ EXPECT_EQ(static_cast<intptr_t>(5), uuids[1]);
+ grpc_json_destroy(parsed_json);
+ gpr_free(json_str);
+ json_str = ChannelzRegistry::GetTopChannels(4);
+ parsed_json = grpc_json_parse_string(json_str);
+ ValidateJsonArraySize(parsed_json, "channel", 1);
+ json_channels = GetJsonChild(parsed_json, "channel");
+ uuids = GetUuidListFromArray(json_channels);
+ EXPECT_EQ(static_cast<intptr_t>(5), uuids[0]);
+ grpc_json_destroy(parsed_json);
+ gpr_free(json_str);
+}
+
TEST_F(ChannelzRegistryBasedTest, GetTopChannelsUuidAfterCompaction) {
const intptr_t kLoopIterations = 50;
grpc_core::ExecCtx exec_ctx;