diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/cpp/end2end/client_lb_end2end_test.cc | 33 | ||||
-rw-r--r-- | test/cpp/qps/client_async.cc | 1 |
2 files changed, 24 insertions, 10 deletions
diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index f8bb12fde1..2696826ed8 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -156,7 +156,7 @@ class ClientLbEnd2endTest : public ::testing::Test { stub_ = grpc::testing::EchoTestService::NewStub(channel_); } - Status SendRpc(EchoResponse* response = nullptr) { + bool SendRpc(EchoResponse* response = nullptr) { const bool local_response = (response == nullptr); if (local_response) response = new EchoResponse; EchoRequest request; @@ -164,19 +164,19 @@ class ClientLbEnd2endTest : public ::testing::Test { ClientContext context; Status status = stub_->Echo(&context, request, response); if (local_response) delete response; - return status; + return status.ok(); } void CheckRpcSendOk() { EchoResponse response; - const Status status = SendRpc(&response); - EXPECT_TRUE(status.ok()); + const bool success = SendRpc(&response); + EXPECT_TRUE(success); EXPECT_EQ(response.message(), kRequestMessage_); } void CheckRpcSendFailure() { - const Status status = SendRpc(); - EXPECT_FALSE(status.ok()); + const bool success = SendRpc(); + EXPECT_FALSE(success); } struct ServerData { @@ -573,15 +573,28 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) { CheckRpcSendOk(); } // Kill all servers + gpr_log(GPR_INFO, "****** ABOUT TO KILL SERVERS *******"); for (size_t i = 0; i < servers_.size(); ++i) { servers_[i]->Shutdown(false); } - // Client request should fail. - CheckRpcSendFailure(); + gpr_log(GPR_INFO, "****** SERVERS KILLED *******"); + gpr_log(GPR_INFO, "****** SENDING DOOMED REQUESTS *******"); + // Client requests should fail. Send enough to tickle all subchannels. + for (size_t i = 0; i < servers_.size(); ++i) CheckRpcSendFailure(); + gpr_log(GPR_INFO, "****** DOOMED REQUESTS SENT *******"); // Bring servers back up on the same port (we aren't recreating the channel). + gpr_log(GPR_INFO, "****** RESTARTING SERVERS *******"); StartServers(kNumServers, ports); - // Client request should succeed. - CheckRpcSendOk(); + gpr_log(GPR_INFO, "****** SERVERS RESTARTED *******"); + gpr_log(GPR_INFO, "****** SENDING REQUEST TO SUCCEED *******"); + // Client request should eventually (but still fairly soon) succeed. + const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + while (gpr_time_cmp(deadline, now) > 0) { + if (SendRpc()) break; + now = gpr_now(GPR_CLOCK_MONOTONIC); + } + GPR_ASSERT(gpr_time_cmp(deadline, now) > 0); } } // namespace diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 07888214e7..7cf9d3ea7e 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -280,6 +280,7 @@ class AsyncClient : public ClientImpl<StubType, RequestType> { }, &got_tag, &ok, gpr_inf_future(GPR_CLOCK_REALTIME))) { t->UpdateHistogram(entry_ptr); + entry = HistogramEntry(); shutdown_mu->lock(); ctx = ProcessTag(thread_idx, got_tag); if (ctx == nullptr) { |