Merge pull request #13682 from dgquintas/send_rpc_status_return

Make it possible to ignore result of SendRPC() in test
pull/13716/head
David G. Quintas 7 years ago committed by GitHub
commit 495476a5db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      test/cpp/end2end/client_lb_end2end_test.cc

@ -156,7 +156,7 @@ class ClientLbEnd2endTest : public ::testing::Test {
stub_ = grpc::testing::EchoTestService::NewStub(channel_); stub_ = grpc::testing::EchoTestService::NewStub(channel_);
} }
Status SendRpc(EchoResponse* response = nullptr) { bool SendRpc(EchoResponse* response = nullptr) {
const bool local_response = (response == nullptr); const bool local_response = (response == nullptr);
if (local_response) response = new EchoResponse; if (local_response) response = new EchoResponse;
EchoRequest request; EchoRequest request;
@ -164,19 +164,19 @@ class ClientLbEnd2endTest : public ::testing::Test {
ClientContext context; ClientContext context;
Status status = stub_->Echo(&context, request, response); Status status = stub_->Echo(&context, request, response);
if (local_response) delete response; if (local_response) delete response;
return status; return status.ok();
} }
void CheckRpcSendOk() { void CheckRpcSendOk() {
EchoResponse response; EchoResponse response;
const Status status = SendRpc(&response); const bool success = SendRpc(&response);
EXPECT_TRUE(status.ok()); EXPECT_TRUE(success);
EXPECT_EQ(response.message(), kRequestMessage_); EXPECT_EQ(response.message(), kRequestMessage_);
} }
void CheckRpcSendFailure() { void CheckRpcSendFailure() {
const Status status = SendRpc(); const bool success = SendRpc();
EXPECT_FALSE(status.ok()); EXPECT_FALSE(success);
} }
struct ServerData { struct ServerData {
@ -591,7 +591,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) {
const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5);
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
while (gpr_time_cmp(deadline, now) > 0) { while (gpr_time_cmp(deadline, now) > 0) {
if (SendRpc().ok()) break; if (SendRpc()) break;
now = gpr_now(GPR_CLOCK_MONOTONIC); now = gpr_now(GPR_CLOCK_MONOTONIC);
} }
GPR_ASSERT(gpr_time_cmp(deadline, now) > 0); GPR_ASSERT(gpr_time_cmp(deadline, now) > 0);

Loading…
Cancel
Save