aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2015-08-26 10:16:31 -0700
committerGravatar yang-g <yangg@google.com>2015-08-26 10:16:31 -0700
commit5e700f3d1fe24e7eed6d1b0414f5c083734df21d (patch)
treed8ff7c7db5cafe9501b9e48744d6801473ee6f15 /test/cpp
parentd090fe1379932d7d785fa805339110e70b96bd87 (diff)
parent60e0e743bed05b248c485949c6cd9e05fa02b607 (diff)
Merge remote-tracking branch 'upstream/master' into string_ref_auth
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/end2end/generic_end2end_test.cc4
-rw-r--r--test/cpp/interop/interop_client.cc31
-rw-r--r--test/cpp/interop/server.cc8
3 files changed, 31 insertions, 12 deletions
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
index de7eab8dc2..809eef058c 100644
--- a/test/cpp/end2end/generic_end2end_test.cc
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -160,7 +160,7 @@ class GenericEnd2endTest : public ::testing::Test {
srv_cq_.get(), tag(4));
verify_ok(srv_cq_.get(), 4, true);
- EXPECT_EQ(server_host_, srv_ctx.host());
+ EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length()));
EXPECT_EQ(kMethodName, srv_ctx.method());
ByteBuffer recv_buffer;
stream.Read(&recv_buffer, tag(5));
@@ -233,7 +233,7 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
srv_cq_.get(), tag(2));
verify_ok(srv_cq_.get(), 2, true);
- EXPECT_EQ(server_host_, srv_ctx.host());
+ EXPECT_EQ(server_host_, srv_ctx.host().substr(0, server_host_.length()));
EXPECT_EQ(kMethodName, srv_ctx.method());
std::unique_ptr<ByteBuffer> send_buffer =
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index fa358585d4..ca13cdc53d 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -362,20 +362,37 @@ void InteropClient::DoResponseCompressedStreaming() {
request.set_response_type(payload_types[i]);
request.set_response_compression(compression_types[j]);
- for (unsigned int i = 0; i < response_stream_sizes.size(); ++i) {
+ for (size_t k = 0; k < response_stream_sizes.size(); ++k) {
ResponseParameters* response_parameter =
request.add_response_parameters();
- response_parameter->set_size(response_stream_sizes[i]);
+ response_parameter->set_size(response_stream_sizes[k]);
}
StreamingOutputCallResponse response;
std::unique_ptr<ClientReader<StreamingOutputCallResponse>> stream(
stub->StreamingOutputCall(&context, request));
- unsigned int i = 0;
+ size_t k = 0;
while (stream->Read(&response)) {
- GPR_ASSERT(response.payload().body() ==
- grpc::string(response_stream_sizes[i], '\0'));
+ // Payload related checks.
+ if (request.response_type() != PayloadType::RANDOM) {
+ GPR_ASSERT(response.payload().type() == request.response_type());
+ }
+ switch (response.payload().type()) {
+ case PayloadType::COMPRESSABLE:
+ GPR_ASSERT(response.payload().body() ==
+ grpc::string(response_stream_sizes[k], '\0'));
+ break;
+ case PayloadType::UNCOMPRESSABLE: {
+ std::ifstream rnd_file(kRandomFile);
+ GPR_ASSERT(rnd_file.good());
+ for (int n = 0; n < response_stream_sizes[k]; n++) {
+ GPR_ASSERT(response.payload().body()[n] == (char)rnd_file.get());
+ }
+ } break;
+ default:
+ GPR_ASSERT(false);
+ }
// Compression related checks.
GPR_ASSERT(request.response_compression() ==
@@ -391,10 +408,10 @@ void InteropClient::DoResponseCompressedStreaming() {
GRPC_WRITE_INTERNAL_COMPRESS);
}
- ++i;
+ ++k;
}
- GPR_ASSERT(response_stream_sizes.size() == i);
+ GPR_ASSERT(response_stream_sizes.size() == k);
Status s = stream->Finish();
AssertOkOrPrintErrorStatus(s);
diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc
index 35ec890aa0..4921fde9fa 100644
--- a/test/cpp/interop/server.cc
+++ b/test/cpp/interop/server.cc
@@ -158,11 +158,13 @@ class TestServiceImpl : public TestService::Service {
SetResponseCompression(context, *request);
StreamingOutputCallResponse response;
bool write_success = true;
- response.mutable_payload()->set_type(request->response_type());
for (int i = 0; write_success && i < request->response_parameters_size();
i++) {
- response.mutable_payload()->set_body(
- grpc::string(request->response_parameters(i).size(), '\0'));
+ if (!SetPayload(request->response_type(),
+ request->response_parameters(i).size(),
+ response.mutable_payload())) {
+ return Status(grpc::StatusCode::INTERNAL, "Error creating payload.");
+ }
write_success = writer->Write(response);
}
if (write_success) {