|
|
@ -43,6 +43,8 @@ |
|
|
|
#include <grpc++/client_context.h> |
|
|
|
#include <grpc++/client_context.h> |
|
|
|
#include <grpc++/status.h> |
|
|
|
#include <grpc++/status.h> |
|
|
|
#include <grpc++/stream.h> |
|
|
|
#include <grpc++/stream.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "test/cpp/interop/client_helper.h" |
|
|
|
#include "test/proto/test.grpc.pb.h" |
|
|
|
#include "test/proto/test.grpc.pb.h" |
|
|
|
#include "test/proto/empty.grpc.pb.h" |
|
|
|
#include "test/proto/empty.grpc.pb.h" |
|
|
|
#include "test/proto/messages.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_)); |
|
|
|
std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_)); |
|
|
|
|
|
|
|
|
|
|
|
ClientContext context; |
|
|
|
ClientContext context; |
|
|
|
// XXX: add UNCOMPRESSABLE to the mix
|
|
|
|
InteropClientContextInspector inspector(context); |
|
|
|
//
|
|
|
|
|
|
|
|
// 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); |
|
|
|
request->set_response_size(kLargeResponseSize); |
|
|
|
grpc::string payload(kLargeRequestSize, '\0'); |
|
|
|
grpc::string payload(kLargeRequestSize, '\0'); |
|
|
|
request->mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); |
|
|
|
request->mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); |
|
|
|
|
|
|
|
|
|
|
|
Status s = stub->UnaryCall(&context, *request, response); |
|
|
|
Status s = stub->UnaryCall(&context, *request, response); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GPR_ASSERT(request->response_compression() == |
|
|
|
|
|
|
|
GetInteropCompressionTypeFromCompressionAlgorithm( |
|
|
|
|
|
|
|
inspector.GetCallCompressionAlgorithm())); |
|
|
|
AssertOkOrPrintErrorStatus(s); |
|
|
|
AssertOkOrPrintErrorStatus(s); |
|
|
|
GPR_ASSERT(response->payload().type() == PayloadType::COMPRESSABLE); |
|
|
|
GPR_ASSERT(response->payload().type() == request->response_type()); |
|
|
|
GPR_ASSERT(response->payload().body() == |
|
|
|
GPR_ASSERT(response->payload().body() == |
|
|
|
grpc::string(kLargeResponseSize, '\0')); |
|
|
|
grpc::string(kLargeResponseSize, '\0')); |
|
|
|
} |
|
|
|
} |
|
|
@ -124,6 +120,7 @@ void InteropClient::DoComputeEngineCreds( |
|
|
|
SimpleResponse response; |
|
|
|
SimpleResponse response; |
|
|
|
request.set_fill_username(true); |
|
|
|
request.set_fill_username(true); |
|
|
|
request.set_fill_oauth_scope(true); |
|
|
|
request.set_fill_oauth_scope(true); |
|
|
|
|
|
|
|
request.set_response_type(PayloadType::COMPRESSABLE); |
|
|
|
PerformLargeUnary(&request, &response); |
|
|
|
PerformLargeUnary(&request, &response); |
|
|
|
gpr_log(GPR_INFO, "Got username %s", response.username().c_str()); |
|
|
|
gpr_log(GPR_INFO, "Got username %s", response.username().c_str()); |
|
|
|
gpr_log(GPR_INFO, "Got oauth_scope %s", response.oauth_scope().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; |
|
|
|
SimpleResponse response; |
|
|
|
request.set_fill_username(true); |
|
|
|
request.set_fill_username(true); |
|
|
|
request.set_fill_oauth_scope(true); |
|
|
|
request.set_fill_oauth_scope(true); |
|
|
|
|
|
|
|
request.set_response_type(PayloadType::COMPRESSABLE); |
|
|
|
PerformLargeUnary(&request, &response); |
|
|
|
PerformLargeUnary(&request, &response); |
|
|
|
GPR_ASSERT(!response.username().empty()); |
|
|
|
GPR_ASSERT(!response.username().empty()); |
|
|
|
GPR_ASSERT(!response.oauth_scope().empty()); |
|
|
|
GPR_ASSERT(!response.oauth_scope().empty()); |
|
|
@ -180,6 +178,7 @@ void InteropClient::DoJwtTokenCreds(const grpc::string& username) { |
|
|
|
SimpleRequest request; |
|
|
|
SimpleRequest request; |
|
|
|
SimpleResponse response; |
|
|
|
SimpleResponse response; |
|
|
|
request.set_fill_username(true); |
|
|
|
request.set_fill_username(true); |
|
|
|
|
|
|
|
request.set_response_type(PayloadType::COMPRESSABLE); |
|
|
|
PerformLargeUnary(&request, &response); |
|
|
|
PerformLargeUnary(&request, &response); |
|
|
|
GPR_ASSERT(!response.username().empty()); |
|
|
|
GPR_ASSERT(!response.username().empty()); |
|
|
|
GPR_ASSERT(username.find(response.username()) != grpc::string::npos); |
|
|
|
GPR_ASSERT(username.find(response.username()) != grpc::string::npos); |
|
|
@ -187,12 +186,19 @@ void InteropClient::DoJwtTokenCreds(const grpc::string& username) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void InteropClient::DoLargeUnary() { |
|
|
|
void InteropClient::DoLargeUnary() { |
|
|
|
gpr_log(GPR_INFO, "Sending a large unary rpc..."); |
|
|
|
const CompressionType compression_types[] = {NONE, GZIP, DEFLATE}; |
|
|
|
SimpleRequest request; |
|
|
|
const PayloadType payload_types[] = {COMPRESSABLE, UNCOMPRESSABLE, RANDOM}; |
|
|
|
request.set_response_compression(grpc::testing::GZIP); |
|
|
|
for (const auto payload_type : payload_types) { |
|
|
|
SimpleResponse response; |
|
|
|
for (const auto compression_type : compression_types) { |
|
|
|
PerformLargeUnary(&request, &response); |
|
|
|
gpr_log(GPR_INFO, "Sending a large unary rpc..."); |
|
|
|
gpr_log(GPR_INFO, "Large unary done."); |
|
|
|
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() { |
|
|
|
void InteropClient::DoRequestStreaming() { |
|
|
@ -227,11 +233,15 @@ void InteropClient::DoResponseStreaming() { |
|
|
|
|
|
|
|
|
|
|
|
ClientContext context; |
|
|
|
ClientContext context; |
|
|
|
StreamingOutputCallRequest request; |
|
|
|
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) { |
|
|
|
for (unsigned int i = 0; i < response_stream_sizes.size(); ++i) { |
|
|
|
ResponseParameters* response_parameter = request.add_response_parameters(); |
|
|
|
ResponseParameters* response_parameter = request.add_response_parameters(); |
|
|
|
response_parameter->set_size(response_stream_sizes[i]); |
|
|
|
response_parameter->set_size(response_stream_sizes[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
StreamingOutputCallResponse response; |
|
|
|
StreamingOutputCallResponse response; |
|
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<ClientReader<StreamingOutputCallResponse>> stream( |
|
|
|
std::unique_ptr<ClientReader<StreamingOutputCallResponse>> stream( |
|
|
|
stub->StreamingOutputCall(&context, request)); |
|
|
|
stub->StreamingOutputCall(&context, request)); |
|
|
|
|
|
|
|
|
|
|
|