diff options
author | David Garcia Quintas <dgq@google.com> | 2015-07-20 23:43:53 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2015-07-20 23:43:53 -0700 |
commit | 9c512bdf98fe66b45532b6c2ead242e45ec07651 (patch) | |
tree | 1a732289c425958aa56055f238d280bbf4d9e2a8 /test/cpp/interop | |
parent | 588a86dc0a0ac556f87788696a03e8331d3a6983 (diff) |
wip
Diffstat (limited to 'test/cpp/interop')
-rw-r--r-- | test/cpp/interop/interop_client.cc | 10 | ||||
-rw-r--r-- | test/cpp/interop/server.cc | 27 | ||||
-rw-r--r-- | test/cpp/interop/server_helper.cc | 8 | ||||
-rw-r--r-- | test/cpp/interop/server_helper.h | 2 |
4 files changed, 42 insertions, 5 deletions
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index f08f90b139..9803102da2 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -93,6 +93,15 @@ 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); request->set_response_size(kLargeResponseSize); grpc::string payload(kLargeRequestSize, '\0'); @@ -157,6 +166,7 @@ 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."); diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc index 22b8910a24..91954aa9de 100644 --- a/test/cpp/interop/server.cc +++ b/test/cpp/interop/server.cc @@ -80,16 +80,32 @@ static bool got_sigint = false; bool SetPayload(PayloadType type, int size, Payload* payload) { PayloadType response_type = type; - // TODO(yangg): Support UNCOMPRESSABLE payload. - if (type != PayloadType::COMPRESSABLE) { - return false; - } payload->set_type(response_type); std::unique_ptr<char[]> body(new char[size]()); payload->set_body(body.get(), size); return true; } +template <typename RequestType> +void SetResponseCompression(ServerContext* context, + const RequestType& request) { + if (request.has_response_compression()) { + switch (request.response_compression()) { + case grpc::testing::NONE: + context->set_compression_algorithm(GRPC_COMPRESS_NONE); + break; + case grpc::testing::GZIP: + context->set_compression_algorithm(GRPC_COMPRESS_GZIP); + break; + case grpc::testing::DEFLATE: + context->set_compression_algorithm(GRPC_COMPRESS_DEFLATE); + break; + } + } else { + context->set_compression_algorithm(GRPC_COMPRESS_NONE); + } +} + class TestServiceImpl : public TestService::Service { public: Status EmptyCall(ServerContext* context, const grpc::testing::Empty* request, @@ -99,6 +115,7 @@ class TestServiceImpl : public TestService::Service { Status UnaryCall(ServerContext* context, const SimpleRequest* request, SimpleResponse* response) { + SetResponseCompression(context, *request); if (request->has_response_size() && request->response_size() > 0) { if (!SetPayload(request->response_type(), request->response_size(), response->mutable_payload())) { @@ -111,6 +128,7 @@ class TestServiceImpl : public TestService::Service { Status StreamingOutputCall( ServerContext* context, const StreamingOutputCallRequest* request, ServerWriter<StreamingOutputCallResponse>* writer) { + SetResponseCompression(context, *request); StreamingOutputCallResponse response; bool write_success = true; response.mutable_payload()->set_type(request->response_type()); @@ -149,6 +167,7 @@ class TestServiceImpl : public TestService::Service { StreamingOutputCallResponse response; bool write_success = true; while (write_success && stream->Read(&request)) { + SetResponseCompression(context, request); response.mutable_payload()->set_type(request.payload().type()); if (request.response_parameters_size() == 0) { return Status(grpc::StatusCode::INTERNAL, diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc index 0f8b89ced2..58017ba9b8 100644 --- a/test/cpp/interop/server_helper.cc +++ b/test/cpp/interop/server_helper.cc @@ -36,10 +36,12 @@ #include <memory> #include <gflags/gflags.h> -#include "test/core/end2end/data/ssl_test_data.h" #include <grpc++/config.h> #include <grpc++/server_credentials.h> +#include "src/core/surface/call.h" +#include "test/core/end2end/data/ssl_test_data.h" + DECLARE_bool(enable_ssl); namespace grpc { @@ -62,5 +64,9 @@ InteropContextInspector::InteropContextInspector( const ::grpc::ServerContext& context) : context_(context) {} +grpc_compression_algorithm +InteropContextInspector::GetCallCompressionAlgorithm() const { + return grpc_call_get_compression_algorithm(context_.call_); +} } // namespace testing } // namespace grpc diff --git a/test/cpp/interop/server_helper.h b/test/cpp/interop/server_helper.h index d738d05038..006a0e31ea 100644 --- a/test/cpp/interop/server_helper.h +++ b/test/cpp/interop/server_helper.h @@ -36,6 +36,7 @@ #include <memory> +#include <grpc/compression.h> #include <grpc++/server_context.h> #include <grpc++/server_credentials.h> @@ -49,6 +50,7 @@ class InteropContextInspector { InteropContextInspector(const ::grpc::ServerContext& context); // Inspector methods, able to peek inside ServerContext go here. + grpc_compression_algorithm GetCallCompressionAlgorithm() const; private: const ::grpc::ServerContext& context_; |