|
|
|
@ -64,7 +64,7 @@ class ClientCallbackEnd2endTest : public ::testing::Test { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SendRpcs(int num_rpcs) { |
|
|
|
|
void SendRpcs(int num_rpcs, bool maybe_except) { |
|
|
|
|
const grpc::string kMethodName("/grpc.testing.EchoTestService/Echo"); |
|
|
|
|
grpc::string test_string(""); |
|
|
|
|
for (int i = 0; i < num_rpcs; i++) { |
|
|
|
@ -82,7 +82,7 @@ class ClientCallbackEnd2endTest : public ::testing::Test { |
|
|
|
|
bool done = false; |
|
|
|
|
stub_->experimental().UnaryCall( |
|
|
|
|
&cli_ctx, kMethodName, send_buf.get(), &recv_buf, |
|
|
|
|
[&request, &recv_buf, &done, &mu, &cv](Status s) { |
|
|
|
|
[&request, &recv_buf, &done, &mu, &cv, maybe_except](Status s) { |
|
|
|
|
GPR_ASSERT(s.ok()); |
|
|
|
|
|
|
|
|
|
EchoResponse response; |
|
|
|
@ -91,6 +91,11 @@ class ClientCallbackEnd2endTest : public ::testing::Test { |
|
|
|
|
std::lock_guard<std::mutex> l(mu); |
|
|
|
|
done = true; |
|
|
|
|
cv.notify_one(); |
|
|
|
|
#if GRPC_ALLOW_EXCEPTIONS |
|
|
|
|
if (maybe_except) { |
|
|
|
|
throw - 1; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
}); |
|
|
|
|
std::unique_lock<std::mutex> l(mu); |
|
|
|
|
while (!done) { |
|
|
|
@ -107,14 +112,21 @@ class ClientCallbackEnd2endTest : public ::testing::Test { |
|
|
|
|
|
|
|
|
|
TEST_F(ClientCallbackEnd2endTest, SimpleRpc) { |
|
|
|
|
ResetStub(); |
|
|
|
|
SendRpcs(1); |
|
|
|
|
SendRpcs(1, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(ClientCallbackEnd2endTest, SequentialRpcs) { |
|
|
|
|
ResetStub(); |
|
|
|
|
SendRpcs(10); |
|
|
|
|
SendRpcs(10, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if GRPC_ALLOW_EXCEPTIONS |
|
|
|
|
TEST_F(ClientCallbackEnd2endTest, ExceptingRpc) { |
|
|
|
|
ResetStub(); |
|
|
|
|
SendRpcs(10, true); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
} // namespace testing
|
|
|
|
|
} // namespace grpc
|
|
|
|
|