|
|
|
@ -35,10 +35,14 @@ |
|
|
|
|
#include "test/core/util/test_config.h" |
|
|
|
|
#include "test/cpp/end2end/test_service_impl.h" |
|
|
|
|
|
|
|
|
|
#include <google/protobuf/text_format.h> |
|
|
|
|
|
|
|
|
|
#include <gtest/gtest.h> |
|
|
|
|
|
|
|
|
|
using grpc::channelz::v1::GetChannelRequest; |
|
|
|
|
using grpc::channelz::v1::GetChannelResponse; |
|
|
|
|
using grpc::channelz::v1::GetSubchannelRequest; |
|
|
|
|
using grpc::channelz::v1::GetSubchannelResponse; |
|
|
|
|
using grpc::channelz::v1::GetTopChannelsRequest; |
|
|
|
|
using grpc::channelz::v1::GetTopChannelsResponse; |
|
|
|
|
|
|
|
|
@ -355,6 +359,54 @@ TEST_F(ChannelzServerTest, ManyRequestsManyChannels) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(ChannelzServerTest, ManySubchannels) { |
|
|
|
|
ResetStubs(); |
|
|
|
|
const int kNumChannels = 4; |
|
|
|
|
ConfigureProxy(kNumChannels); |
|
|
|
|
const int kNumSuccess = 10; |
|
|
|
|
const int kNumFailed = 11; |
|
|
|
|
for (int i = 0; i < kNumSuccess; ++i) { |
|
|
|
|
SendSuccessfulEcho(0); |
|
|
|
|
SendSuccessfulEcho(2); |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < kNumFailed; ++i) { |
|
|
|
|
SendFailedEcho(1); |
|
|
|
|
SendFailedEcho(2); |
|
|
|
|
} |
|
|
|
|
GetTopChannelsRequest gtc_request; |
|
|
|
|
GetTopChannelsResponse gtc_response; |
|
|
|
|
gtc_request.set_start_channel_id(0); |
|
|
|
|
ClientContext context; |
|
|
|
|
Status s = |
|
|
|
|
channelz_stub_->GetTopChannels(&context, gtc_request, >c_response); |
|
|
|
|
EXPECT_TRUE(s.ok()) << s.error_message(); |
|
|
|
|
EXPECT_EQ(gtc_response.channel_size(), kNumChannels); |
|
|
|
|
for (int i = 0; i < gtc_response.channel_size(); ++i) { |
|
|
|
|
// if the channel sent no RPCs, then expect no subchannels to have been
|
|
|
|
|
// created.
|
|
|
|
|
if (gtc_response.channel(i).data().calls_started() == 0) { |
|
|
|
|
EXPECT_EQ(gtc_response.channel(i).subchannel_ref_size(), 0); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// The resolver must return at least one address.
|
|
|
|
|
ASSERT_GT(gtc_response.channel(i).subchannel_ref_size(), 0); |
|
|
|
|
GetSubchannelRequest gsc_request; |
|
|
|
|
GetSubchannelResponse gsc_response; |
|
|
|
|
gsc_request.set_subchannel_id( |
|
|
|
|
gtc_response.channel(i).subchannel_ref(0).subchannel_id()); |
|
|
|
|
ClientContext context; |
|
|
|
|
Status s = |
|
|
|
|
channelz_stub_->GetSubchannel(&context, gsc_request, &gsc_response); |
|
|
|
|
EXPECT_TRUE(s.ok()) << s.error_message(); |
|
|
|
|
EXPECT_EQ(gtc_response.channel(i).data().calls_started(), |
|
|
|
|
gsc_response.subchannel().data().calls_started()); |
|
|
|
|
EXPECT_EQ(gtc_response.channel(i).data().calls_succeeded(), |
|
|
|
|
gsc_response.subchannel().data().calls_succeeded()); |
|
|
|
|
EXPECT_EQ(gtc_response.channel(i).data().calls_failed(), |
|
|
|
|
gsc_response.subchannel().data().calls_failed()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace testing
|
|
|
|
|
} // namespace grpc
|
|
|
|
|
|
|
|
|
|