diff options
Diffstat (limited to 'test/cpp/interop/interop_client.cc')
-rw-r--r-- | test/cpp/interop/interop_client.cc | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index b53535bd46..3a28c704b5 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -43,6 +43,8 @@ #include <grpc++/client_context.h> #include <grpc++/status.h> #include <grpc++/stream.h> + +#include "test/cpp/interop/client_helper.h" #include "test/proto/test.grpc.pb.h" #include "test/proto/empty.grpc.pb.h" #include "test/proto/messages.grpc.pb.h" @@ -93,24 +95,18 @@ void InteropClient::PerformLargeUnary(SimpleRequest* request, std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_)); ClientContext context; - // XXX: add UNCOMPRESSABLE to the mix - // - // XXX: 1) set request.response_compression to all the diff available - // compression values. We can't check the compression method used at the - // application level, but if something is wrong, two different implementations - // of gRPC (java vs c) won't be able to communicate. - // - // 2) for UNCOMPRESSABLE, verify that the response can be whatever, most - // likely uncompressed - request->set_response_type(PayloadType::COMPRESSABLE); + InteropClientContextInspector inspector(context); request->set_response_size(kLargeResponseSize); grpc::string payload(kLargeRequestSize, '\0'); request->mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); Status s = stub->UnaryCall(&context, *request, response); + GPR_ASSERT(request->response_compression() == + GetInteropCompressionTypeFromCompressionAlgorithm( + inspector.GetCallCompressionAlgorithm())); AssertOkOrPrintErrorStatus(s); - GPR_ASSERT(response->payload().type() == PayloadType::COMPRESSABLE); + GPR_ASSERT(response->payload().type() == request->response_type()); GPR_ASSERT(response->payload().body() == grpc::string(kLargeResponseSize, '\0')); } @@ -124,6 +120,7 @@ void InteropClient::DoComputeEngineCreds( SimpleResponse response; request.set_fill_username(true); request.set_fill_oauth_scope(true); + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); gpr_log(GPR_INFO, "Got username %s", response.username().c_str()); gpr_log(GPR_INFO, "Got oauth_scope %s", response.oauth_scope().c_str()); @@ -143,6 +140,7 @@ void InteropClient::DoServiceAccountCreds(const grpc::string& username, SimpleResponse response; request.set_fill_username(true); request.set_fill_oauth_scope(true); + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(!response.oauth_scope().empty()); @@ -180,6 +178,7 @@ void InteropClient::DoJwtTokenCreds(const grpc::string& username) { SimpleRequest request; SimpleResponse response; request.set_fill_username(true); + request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(username.find(response.username()) != grpc::string::npos); @@ -187,12 +186,19 @@ void InteropClient::DoJwtTokenCreds(const grpc::string& username) { } void InteropClient::DoLargeUnary() { - gpr_log(GPR_INFO, "Sending a large unary rpc..."); - SimpleRequest request; - request.set_response_compression(grpc::testing::GZIP); - SimpleResponse response; - PerformLargeUnary(&request, &response); - gpr_log(GPR_INFO, "Large unary done."); + const CompressionType compression_types[] = {NONE, GZIP, DEFLATE}; + const PayloadType payload_types[] = {COMPRESSABLE, UNCOMPRESSABLE, RANDOM}; + for (const auto payload_type : payload_types) { + for (const auto compression_type : compression_types) { + gpr_log(GPR_INFO, "Sending a large unary rpc..."); + SimpleRequest request; + SimpleResponse response; + request.set_response_type(payload_type); + request.set_response_compression(compression_type); + PerformLargeUnary(&request, &response); + gpr_log(GPR_INFO, "Large unary done."); + } + } } void InteropClient::DoRequestStreaming() { @@ -227,11 +233,15 @@ void InteropClient::DoResponseStreaming() { ClientContext context; StreamingOutputCallRequest request; + request.set_response_type(PayloadType::COMPRESSABLE); + request.set_response_compression(CompressionType::GZIP); + for (unsigned int i = 0; i < response_stream_sizes.size(); ++i) { ResponseParameters* response_parameter = request.add_response_parameters(); response_parameter->set_size(response_stream_sizes[i]); } StreamingOutputCallResponse response; + std::unique_ptr<ClientReader<StreamingOutputCallResponse>> stream( stub->StreamingOutputCall(&context, request)); |