From d6d5d21c0af5b4e739cf3cfa35f64ceaa92424be Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 19 Oct 2018 12:25:19 -0700 Subject: Add bin search to gettopchannels and getservers --- test/core/channel/channelz_test.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/core/channel') diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index 48e558dfc0..4a1f53b924 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -402,6 +402,27 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsMiddleUuidCheck) { gpr_free(json_str); } +TEST_F(ChannelzRegistryBasedTest, GetTopChannelsNoHitUuid) { + grpc_core::ExecCtx exec_ctx; + ChannelFixture pre_channels[40]; // will take uuid[1, 40] + (void)pre_channels; // suppress unused variable error + ServerFixture servers[10]; // will take uuid[41, 50] + (void)servers; // suppress unused variable error + ChannelFixture channels[10]; // will take uuid[51, 60] + (void)channels; // suppress unused variable error + // query in the middle of the server channels + char* json_str = ChannelzRegistry::GetTopChannels(45); + grpc_json* parsed_json = grpc_json_parse_string(json_str); + ValidateJsonArraySize(parsed_json, "channel", 10); + grpc_json* json_channels = GetJsonChild(parsed_json, "channel"); + std::vector uuids = GetUuidListFromArray(json_channels); + for (size_t i = 0; i < uuids.size(); ++i) { + EXPECT_EQ(static_cast(51 + i), uuids[i]); + } + grpc_json_destroy(parsed_json); + gpr_free(json_str); +} + TEST_F(ChannelzRegistryBasedTest, GetTopChannelsUuidAfterCompaction) { const intptr_t kLoopIterations = 50; grpc_core::ExecCtx exec_ctx; -- cgit v1.2.3