Test all split streamed variations

pull/8365/head
Vijay Pai 8 years ago
parent 075b18e77f
commit 8d08b1d9ee
  1. 94
      test/cpp/end2end/hybrid_end2end_test.cc

@ -562,6 +562,100 @@ TEST_F(HybridEnd2endTest,
request_stream_handler_thread.join();
}
// Add a second service that is fully split server streamed
class FullySplitStreamedDupPkg
: public duplicate::EchoTestService::SplitStreamedService {
public:
Status StreamedResponseStream(ServerContext* context,
ServerSplitStreamer<EchoRequest, EchoResponse>* stream)
GRPC_OVERRIDE {
EchoRequest req;
EchoResponse resp;
uint32_t next_msg_sz;
stream->NextMessageSize(&next_msg_sz);
gpr_log(GPR_INFO, "Split Streamed Next Message Size is %u", next_msg_sz);
GPR_ASSERT(stream->Read(&req));
for (int i = 0; i < kNumResponseStreamsMsgs; i++) {
resp.set_message(req.message() + grpc::to_string(i) + "_dup");
GPR_ASSERT(stream->Write(resp));
}
return Status::OK;
}
};
TEST_F(HybridEnd2endTest,
AsyncRequestStreamResponseStream_FullySplitStreamedDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
SType service;
FullySplitStreamedDupPkg 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();
SendSimpleServerStreamingToDupService();
response_stream_handler_thread.join();
request_stream_handler_thread.join();
}
// Add a second service that is fully server streamed
class FullyStreamedDupPkg
: public duplicate::EchoTestService::StreamedService {
public:
Status StreamedEcho(ServerContext* context,
ServerUnaryStreamer<EchoRequest, EchoResponse>* stream)
GRPC_OVERRIDE {
EchoRequest req;
EchoResponse resp;
uint32_t next_msg_sz;
stream->NextMessageSize(&next_msg_sz);
gpr_log(GPR_INFO, "Streamed Unary Next Message Size is %u", next_msg_sz);
GPR_ASSERT(stream->Read(&req));
resp.set_message(req.message() + "_dup");
GPR_ASSERT(stream->Write(resp));
return Status::OK;
}
Status StreamedResponseStream(ServerContext* context,
ServerSplitStreamer<EchoRequest, EchoResponse>* stream)
GRPC_OVERRIDE {
EchoRequest req;
EchoResponse resp;
uint32_t next_msg_sz;
stream->NextMessageSize(&next_msg_sz);
gpr_log(GPR_INFO, "Split Streamed Next Message Size is %u", next_msg_sz);
GPR_ASSERT(stream->Read(&req));
for (int i = 0; i < kNumResponseStreamsMsgs; i++) {
resp.set_message(req.message() + grpc::to_string(i) + "_dup");
GPR_ASSERT(stream->Write(resp));
}
return Status::OK;
}
};
TEST_F(HybridEnd2endTest,
AsyncRequestStreamResponseStream_FullyStreamedDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
SType service;
FullyStreamedDupPkg 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();
SendSimpleServerStreamingToDupService();
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<

Loading…
Cancel
Save