pull/2533/head
David Garcia Quintas 9 years ago
parent 588a86dc0a
commit 9c512bdf98
  1. 11
      src/core/surface/call.h
  2. 10
      test/cpp/interop/interop_client.cc
  3. 27
      test/cpp/interop/server.cc
  4. 8
      test/cpp/interop/server_helper.cc
  5. 2
      test/cpp/interop/server_helper.h
  6. 2
      test/proto/messages.proto

@ -38,6 +38,10 @@
#include "src/core/channel/context.h"
#include <grpc/grpc.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Primitive operation types - grpc_op's get rewritten into these */
typedef enum {
GRPC_IOREQ_RECV_INITIAL_METADATA,
@ -153,4 +157,11 @@ void *grpc_call_context_get(grpc_call *call, grpc_context_index elem);
gpr_uint8 grpc_call_is_client(grpc_call *call);
grpc_compression_algorithm grpc_call_get_compression_algorithm(
const grpc_call *call);
#ifdef __cplusplus
}
#endif
#endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_H */

@ -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.");

@ -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,

@ -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

@ -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_;

@ -64,7 +64,7 @@ message Payload {
// A protobuf representation for grpc status. This is used by test
// clients to specify a status that the server should attempt to return.
message EchoStatus {
message EchoStatus {
optional int32 code = 1;
optional string message = 2;
}

Loading…
Cancel
Save