|
|
|
@ -199,7 +199,8 @@ class HybridEnd2endTest : public ::testing::Test { |
|
|
|
|
HybridEnd2endTest() {} |
|
|
|
|
|
|
|
|
|
void SetUpServer(::grpc::Service* service1, ::grpc::Service* service2, |
|
|
|
|
AsyncGenericService* generic_service) { |
|
|
|
|
AsyncGenericService* generic_service, |
|
|
|
|
int num_cqs_frequently_polled) { |
|
|
|
|
int port = grpc_pick_unused_port_or_die(); |
|
|
|
|
server_address_ << "localhost:" << port; |
|
|
|
|
|
|
|
|
@ -216,7 +217,7 @@ class HybridEnd2endTest : public ::testing::Test { |
|
|
|
|
} |
|
|
|
|
// Create a separate cq for each potential handler.
|
|
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
|
cqs_.push_back(builder.AddCompletionQueue(false)); |
|
|
|
|
cqs_.push_back(builder.AddCompletionQueue(i < num_cqs_frequently_polled)); |
|
|
|
|
} |
|
|
|
|
server_ = builder.BuildAndStart(); |
|
|
|
|
} |
|
|
|
@ -346,7 +347,7 @@ class HybridEnd2endTest : public ::testing::Test { |
|
|
|
|
|
|
|
|
|
TEST_F(HybridEnd2endTest, AsyncEcho) { |
|
|
|
|
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> service; |
|
|
|
|
SetUpServer(&service, nullptr, nullptr); |
|
|
|
|
SetUpServer(&service, nullptr, nullptr, 1); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread echo_handler_thread( |
|
|
|
|
[this, &service] { HandleEcho(&service, cqs_[0].get(), false); }); |
|
|
|
@ -358,7 +359,7 @@ TEST_F(HybridEnd2endTest, AsyncEchoRequestStream) { |
|
|
|
|
EchoTestService::WithAsyncMethod_RequestStream< |
|
|
|
|
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> > |
|
|
|
|
service; |
|
|
|
|
SetUpServer(&service, nullptr, nullptr); |
|
|
|
|
SetUpServer(&service, nullptr, nullptr, 2); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread echo_handler_thread( |
|
|
|
|
[this, &service] { HandleEcho(&service, cqs_[0].get(), false); }); |
|
|
|
@ -373,7 +374,7 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream) { |
|
|
|
|
EchoTestService::WithAsyncMethod_RequestStream< |
|
|
|
|
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > |
|
|
|
|
service; |
|
|
|
|
SetUpServer(&service, nullptr, nullptr); |
|
|
|
|
SetUpServer(&service, nullptr, nullptr, 2); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread response_stream_handler_thread( |
|
|
|
|
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); }); |
|
|
|
@ -390,7 +391,7 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) { |
|
|
|
|
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > |
|
|
|
|
service; |
|
|
|
|
TestServiceImplDupPkg dup_service; |
|
|
|
|
SetUpServer(&service, &dup_service, nullptr); |
|
|
|
|
SetUpServer(&service, &dup_service, nullptr, 2); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread response_stream_handler_thread( |
|
|
|
|
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); }); |
|
|
|
@ -408,7 +409,7 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) { |
|
|
|
|
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > |
|
|
|
|
service; |
|
|
|
|
duplicate::EchoTestService::AsyncService dup_service; |
|
|
|
|
SetUpServer(&service, &dup_service, nullptr); |
|
|
|
|
SetUpServer(&service, &dup_service, nullptr, 3); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread response_stream_handler_thread( |
|
|
|
|
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); }); |
|
|
|
@ -426,7 +427,7 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) { |
|
|
|
|
TEST_F(HybridEnd2endTest, GenericEcho) { |
|
|
|
|
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> service; |
|
|
|
|
AsyncGenericService generic_service; |
|
|
|
|
SetUpServer(&service, nullptr, &generic_service); |
|
|
|
|
SetUpServer(&service, nullptr, &generic_service, 1); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread generic_handler_thread([this, &generic_service] { |
|
|
|
|
HandleGenericCall(&generic_service, cqs_[0].get()); |
|
|
|
@ -440,7 +441,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream) { |
|
|
|
|
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> > |
|
|
|
|
service; |
|
|
|
|
AsyncGenericService generic_service; |
|
|
|
|
SetUpServer(&service, nullptr, &generic_service); |
|
|
|
|
SetUpServer(&service, nullptr, &generic_service, 2); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread generic_handler_thread([this, &generic_service] { |
|
|
|
|
HandleGenericCall(&generic_service, cqs_[0].get()); |
|
|
|
@ -459,7 +460,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_SyncDupService) { |
|
|
|
|
service; |
|
|
|
|
AsyncGenericService generic_service; |
|
|
|
|
TestServiceImplDupPkg dup_service; |
|
|
|
|
SetUpServer(&service, &dup_service, &generic_service); |
|
|
|
|
SetUpServer(&service, &dup_service, &generic_service, 2); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread generic_handler_thread([this, &generic_service] { |
|
|
|
|
HandleGenericCall(&generic_service, cqs_[0].get()); |
|
|
|
@ -479,7 +480,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_AsyncDupService) { |
|
|
|
|
service; |
|
|
|
|
AsyncGenericService generic_service; |
|
|
|
|
duplicate::EchoTestService::AsyncService dup_service; |
|
|
|
|
SetUpServer(&service, &dup_service, &generic_service); |
|
|
|
|
SetUpServer(&service, &dup_service, &generic_service, 3); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread generic_handler_thread([this, &generic_service] { |
|
|
|
|
HandleGenericCall(&generic_service, cqs_[0].get()); |
|
|
|
@ -501,7 +502,7 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStreamResponseStream) { |
|
|
|
|
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > > |
|
|
|
|
service; |
|
|
|
|
AsyncGenericService generic_service; |
|
|
|
|
SetUpServer(&service, nullptr, &generic_service); |
|
|
|
|
SetUpServer(&service, nullptr, &generic_service, 3); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread generic_handler_thread([this, &generic_service] { |
|
|
|
|
HandleGenericCall(&generic_service, cqs_[0].get()); |
|
|
|
@ -522,7 +523,7 @@ TEST_F(HybridEnd2endTest, GenericEchoRequestStreamAsyncResponseStream) { |
|
|
|
|
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > > |
|
|
|
|
service; |
|
|
|
|
AsyncGenericService generic_service; |
|
|
|
|
SetUpServer(&service, nullptr, &generic_service); |
|
|
|
|
SetUpServer(&service, nullptr, &generic_service, 3); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread generic_handler_thread([this, &generic_service] { |
|
|
|
|
HandleGenericCall(&generic_service, cqs_[0].get()); |
|
|
|
@ -545,7 +546,7 @@ TEST_F(HybridEnd2endTest, GenericMethodWithoutGenericService) { |
|
|
|
|
EchoTestService::WithGenericMethod_Echo< |
|
|
|
|
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > > |
|
|
|
|
service; |
|
|
|
|
SetUpServer(&service, nullptr, nullptr); |
|
|
|
|
SetUpServer(&service, nullptr, nullptr, 0); |
|
|
|
|
EXPECT_EQ(nullptr, server_.get()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|