From 50409fea277bfcb93d4c192f6fe6c295c5962558 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 10 Jul 2018 16:10:28 -0700 Subject: [PATCH] Simplified the test significantly. No more threads --- test/cpp/end2end/client_lb_end2end_test.cc | 32 ++++++++-------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index f22f3f2f2cb4c..8fe47db172445 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -539,33 +539,23 @@ TEST_F(ClientLbEnd2endTest, RoundRobin) { EXPECT_EQ("round_robin", channel->GetLoadBalancingPolicyName()); } -// TODO(juanlishen): Investigate getting rid of threads once -// https://github.com/grpc/grpc/pull/15841 is in. TEST_F(ClientLbEnd2endTest, RoundRobinProcessPending) { StartServers(1); // Single server auto channel = BuildChannel("round_robin"); auto stub = BuildStub(channel); SetNextResolution({servers_[0]->port_}); WaitForServer(stub, 0, DEBUG_LOCATION); - constexpr int kIterations = 4; - constexpr int kNumThreads = 4; - std::vector threads; - // Create and destroy several channels concurrently, executing an RPC each - // time. The creation of new channels and their corresponding RR LB policies - // is the important part: new channels/RR policies will pick the subchannels - // in READY state (from a previous RPC against the same target). Progress - // should happen without any transition from this READY state. - threads.push_back(std::thread([=]() { - for (int i = 0; i < kNumThreads; ++i) { - auto channel = BuildChannel("round_robin"); - auto stub = BuildStub(channel); - SetNextResolution({servers_[0]->port_}); - for (int i = 0; i < kIterations; ++i) { - CheckRpcSendOk(stub, DEBUG_LOCATION); - } - } - })); - for (auto& thread : threads) thread.join(); + // Create a new channel and its corresponding RR LB policy, which will pick + // the subchannels in READY state from a the previous RPC against the same + // target (even if it happened over a different channel, because subchannels + // are globally reused). Progress should happen without any transition from + // this READY state. + { + auto second_channel = BuildChannel("round_robin"); + auto second_stub = BuildStub(second_channel); + SetNextResolution({servers_[0]->port_}); + CheckRpcSendOk(second_stub, DEBUG_LOCATION); + } } TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) {