Skip to content

Commit

Permalink
Fixed wrong spec and reworked streaming compressed case
Browse files Browse the repository at this point in the history
  • Loading branch information
dgquintas committed Jun 8, 2016
1 parent 20d802d commit 485cf40
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
36 changes: 13 additions & 23 deletions doc/interop-test-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Procedure:
size: 31415
}
response_parameters:{
size: 59
size: 9
}
response_parameters:{
size: 2653
Expand Down Expand Up @@ -261,20 +261,19 @@ Procedure:
request_compressed_response: bool
response_type:COMPRESSABLE
response_parameters:{
size: 31415
}
response_parameters:{
size: 59
}
response_parameters:{
size: 2653
size: 31424
}
response_parameters:{
size: 58979
size: 61632
}
}
```
Note that the `response_parameters` sizes are the sum of the usual streaming
response sizes (31415, 9, 2653, 58979) taken in successive pairs. This way,
we only keep a single list of sizes while making sure the individual message
sizes are large enough to trigger compression in all implementations.
Client asserts:
* call was successful
* exactly four responses
Expand All @@ -283,7 +282,7 @@ Procedure:
NOT have the compressed message flag set.
* if `request_compressed_response` is true, the response's messages MUST
have the compressed message flag set.
* response payload bodies are sized (in order): 31415, 59, 2653, 58979
* response payload bodies are sized (in order): 31424, 61632
* clients are free to assert that the response payload body contents are
zero and comparing the entire response messages against golden responses
Expand All @@ -295,16 +294,10 @@ Procedure:
request_compressed_response: bool
response_type:UNCOMPRESSABLE
response_parameters:{
size: 31415
}
response_parameters:{
size: 59
}
response_parameters:{
size: 2653
size: 31424
}
response_parameters:{
size: 58979
size: 61632
}
}
```
Expand All @@ -316,10 +309,7 @@ Procedure:
* the response MAY have the compressed message flag set. Some
implementations will choose to compress the payload even when the output
size if larger than the input.
* response payload bodies are sized (in order): 31415, 59, 2653, 58979
* clients are free to assert that the body of the responses are identical to
the golden uncompressable data at `test/cpp/interop/rnd.dat`.
* response payload bodies are sized (in order): 31424, 61632
### ping_pong
Expand Down Expand Up @@ -350,7 +340,7 @@ Procedure:
{
response_type: COMPRESSABLE
response_parameters:{
size: 59
size: 9
}
payload:{
body: 8 bytes of zeros
Expand Down
17 changes: 10 additions & 7 deletions test/cpp/interop/interop_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace testing {
namespace {
// The same value is defined by the Java client.
const std::vector<int> request_stream_sizes = {27182, 8, 1828, 45904};
const std::vector<int> response_stream_sizes = {31415, 59, 2653, 58979};
const std::vector<int> response_stream_sizes = {31415, 9, 2653, 58979};
const int kNumResponseMessages = 2000;
const int kResponseMessageSize = 1030;
const int kReceiveDelayMilliSeconds = 20;
Expand Down Expand Up @@ -466,10 +466,11 @@ bool InteropClient::DoResponseCompressedStreaming() {
request.set_response_type(payload_types[i]);
request.set_request_compressed_response(request_compression[j]);

for (size_t k = 0; k < response_stream_sizes.size(); ++k) {
for (size_t k = 0; k < response_stream_sizes.size() / 2; ++k) {
ResponseParameters* response_parameter =
request.add_response_parameters();
response_parameter->set_size(response_stream_sizes[k]);
response_parameter->set_size(response_stream_sizes[k] +
response_stream_sizes[k + 1]);
}
StreamingOutputCallResponse response;

Expand All @@ -483,7 +484,9 @@ bool InteropClient::DoResponseCompressedStreaming() {
switch (response.payload().type()) {
case PayloadType::COMPRESSABLE:
GPR_ASSERT(response.payload().body() ==
grpc::string(response_stream_sizes[k], '\0'));
grpc::string(response_stream_sizes[k] +
response_stream_sizes[k + 1],
'\0'));
break;
case PayloadType::UNCOMPRESSABLE:
break;
Expand Down Expand Up @@ -513,14 +516,14 @@ bool InteropClient::DoResponseCompressedStreaming() {
gpr_log(GPR_DEBUG, "Response streaming done %s.", log_suffix);
gpr_free(log_suffix);

if (k < response_stream_sizes.size()) {
if (k < response_stream_sizes.size() / 2) {
// stream->Read() failed before reading all the expected messages. This
// is most likely due to a connection failure.
gpr_log(GPR_ERROR,
"DoResponseCompressedStreaming(): Responses read (k=%d) is "
"less than the expected messages (i.e "
"response_stream_sizes.size() (%d)). (i=%d, j=%d)",
k, response_stream_sizes.size(), i, j);
"response_stream_sizes.size()/2 (%d)). (i=%d, j=%d)",
k, response_stream_sizes.size() / 2, i, j);
return TransientFailureOrAbort();
}

Expand Down

0 comments on commit 485cf40

Please sign in to comment.