|
|
@ -84,7 +84,8 @@ class ServiceImpl GRPC_FINAL |
|
|
|
gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); |
|
|
|
gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); |
|
|
|
response.set_message(request.message()); |
|
|
|
response.set_message(request.message()); |
|
|
|
stream->Write(response); |
|
|
|
stream->Write(response); |
|
|
|
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(1))); |
|
|
|
gpr_sleep_until( |
|
|
|
|
|
|
|
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(1))); |
|
|
|
} |
|
|
|
} |
|
|
|
return Status::OK; |
|
|
|
return Status::OK; |
|
|
|
} |
|
|
|
} |
|
|
@ -98,7 +99,8 @@ class ServiceImpl GRPC_FINAL |
|
|
|
msg << "Hello " << i; |
|
|
|
msg << "Hello " << i; |
|
|
|
response.set_message(msg.str()); |
|
|
|
response.set_message(msg.str()); |
|
|
|
if (!writer->Write(response)) break; |
|
|
|
if (!writer->Write(response)) break; |
|
|
|
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(1))); |
|
|
|
gpr_sleep_until( |
|
|
|
|
|
|
|
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(1))); |
|
|
|
} |
|
|
|
} |
|
|
|
return Status::OK; |
|
|
|
return Status::OK; |
|
|
|
} |
|
|
|
} |
|
|
@ -145,7 +147,8 @@ class CrashTest : public ::testing::Test { |
|
|
|
TEST_F(CrashTest, ResponseStream) { |
|
|
|
TEST_F(CrashTest, ResponseStream) { |
|
|
|
auto server = CreateServerAndClient("response"); |
|
|
|
auto server = CreateServerAndClient("response"); |
|
|
|
|
|
|
|
|
|
|
|
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5))); |
|
|
|
gpr_sleep_until( |
|
|
|
|
|
|
|
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(5))); |
|
|
|
KillClient(); |
|
|
|
KillClient(); |
|
|
|
server->Shutdown(); |
|
|
|
server->Shutdown(); |
|
|
|
GPR_ASSERT(HadOneResponseStream()); |
|
|
|
GPR_ASSERT(HadOneResponseStream()); |
|
|
@ -154,7 +157,8 @@ TEST_F(CrashTest, ResponseStream) { |
|
|
|
TEST_F(CrashTest, BidiStream) { |
|
|
|
TEST_F(CrashTest, BidiStream) { |
|
|
|
auto server = CreateServerAndClient("bidi"); |
|
|
|
auto server = CreateServerAndClient("bidi"); |
|
|
|
|
|
|
|
|
|
|
|
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5))); |
|
|
|
gpr_sleep_until( |
|
|
|
|
|
|
|
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(5))); |
|
|
|
KillClient(); |
|
|
|
KillClient(); |
|
|
|
server->Shutdown(); |
|
|
|
server->Shutdown(); |
|
|
|
GPR_ASSERT(HadOneBidiStream()); |
|
|
|
GPR_ASSERT(HadOneBidiStream()); |
|
|
|