|
|
|
@ -199,7 +199,7 @@ class HybridEnd2endTest : public ::testing::Test { |
|
|
|
|
HybridEnd2endTest() {} |
|
|
|
|
|
|
|
|
|
void SetUpServer(::grpc::Service* service1, ::grpc::Service* service2, |
|
|
|
|
AsyncGenericService* generic_service) { |
|
|
|
|
AsyncGenericService* generic_service, int max_message_size = 0) { |
|
|
|
|
int port = grpc_pick_unused_port_or_die(); |
|
|
|
|
server_address_ << "localhost:" << port; |
|
|
|
|
|
|
|
|
@ -217,6 +217,11 @@ class HybridEnd2endTest : public ::testing::Test { |
|
|
|
|
if (generic_service) { |
|
|
|
|
builder.RegisterAsyncGenericService(generic_service); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (max_message_size != 0) { |
|
|
|
|
builder.SetMaxMessageSize(max_message_size); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Create a separate cq for each potential handler.
|
|
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
|
cqs_.push_back(builder.AddCompletionQueue(false)); |
|
|
|
@ -415,6 +420,38 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) { |
|
|
|
|
request_stream_handler_thread.join(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add a second service with one sync FCUnary method.
|
|
|
|
|
class FCUnaryDupPkg : public duplicate::EchoTestService::WithFCUnaryMethod_Echo<TestServiceImplDupPkg> { |
|
|
|
|
public: |
|
|
|
|
Status FCEcho(ServerContext* context, FCUnary<EchoRequest,EchoResponse>* fc_unary) GRPC_OVERRIDE { |
|
|
|
|
EchoRequest req; |
|
|
|
|
EchoResponse resp; |
|
|
|
|
gpr_log(GPR_INFO, "FC Unary Next Message Size is %u", fc_unary->NextMessageSize()); |
|
|
|
|
GPR_ASSERT(fc_unary->Read(&req)); |
|
|
|
|
resp.set_message(req.message() + "_dup"); |
|
|
|
|
GPR_ASSERT(fc_unary->Write(resp)); |
|
|
|
|
return Status::OK; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFCUnaryDupService) { |
|
|
|
|
typedef EchoTestService::WithAsyncMethod_RequestStream< |
|
|
|
|
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>> |
|
|
|
|
SType; |
|
|
|
|
SType service; |
|
|
|
|
FCUnaryDupPkg dup_service; |
|
|
|
|
SetUpServer(&service, &dup_service, nullptr, 8192); |
|
|
|
|
ResetStub(); |
|
|
|
|
std::thread response_stream_handler_thread(HandleServerStreaming<SType>, |
|
|
|
|
&service, cqs_[0].get()); |
|
|
|
|
std::thread request_stream_handler_thread(HandleClientStreaming<SType>, |
|
|
|
|
&service, cqs_[1].get()); |
|
|
|
|
TestAllMethods(); |
|
|
|
|
SendEchoToDupService(); |
|
|
|
|
response_stream_handler_thread.join(); |
|
|
|
|
request_stream_handler_thread.join(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add a second service with one async method.
|
|
|
|
|
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) { |
|
|
|
|
typedef EchoTestService::WithAsyncMethod_RequestStream< |
|
|
|
|