Merge pull request #6463 from dgquintas/fix_compression_interop

Fixed compression interop and re-enable for C++.
pull/6254/head
Jan Tattermusch 9 years ago
commit aa51f63da3
  1. 6
      src/core/lib/channel/compress_filter.c
  2. 19
      src/core/lib/surface/byte_buffer_reader.c
  3. 9
      src/core/lib/surface/call.c
  4. 2
      test/cpp/interop/interop_client.cc
  5. 4
      tools/run_tests/run_interop_tests.py

@ -189,8 +189,10 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx,
char *algo_name; char *algo_name;
GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm,
&algo_name)); &algo_name));
gpr_log(GPR_DEBUG, "Algorithm '%s' enabled but decided not to compress.", gpr_log(
algo_name); GPR_DEBUG,
"Algorithm '%s' enabled but decided not to compress. Input size: %d",
algo_name, calld->slices.length);
} }
} }

@ -62,12 +62,19 @@ void grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader,
case GRPC_BB_RAW: case GRPC_BB_RAW:
gpr_slice_buffer_init(&decompressed_slices_buffer); gpr_slice_buffer_init(&decompressed_slices_buffer);
if (is_compressed(reader->buffer_in)) { if (is_compressed(reader->buffer_in)) {
grpc_msg_decompress(reader->buffer_in->data.raw.compression, if (grpc_msg_decompress(reader->buffer_in->data.raw.compression,
&reader->buffer_in->data.raw.slice_buffer, &reader->buffer_in->data.raw.slice_buffer,
&decompressed_slices_buffer); &decompressed_slices_buffer) == 0) {
reader->buffer_out = gpr_log(GPR_ERROR,
grpc_raw_byte_buffer_create(decompressed_slices_buffer.slices, "Unexpected error decompressing data for algorithm with enum "
decompressed_slices_buffer.count); "value '%d'. Reading data as if it were uncompressed.",
reader->buffer_in->data.raw.compression);
reader->buffer_out = reader->buffer_in;
} else { /* all fine */
reader->buffer_out =
grpc_raw_byte_buffer_create(decompressed_slices_buffer.slices,
decompressed_slices_buffer.count);
}
gpr_slice_buffer_destroy(&decompressed_slices_buffer); gpr_slice_buffer_destroy(&decompressed_slices_buffer);
} else { /* not compressed, use the input buffer as output */ } else { /* not compressed, use the input buffer as output */
reader->buffer_out = reader->buffer_in; reader->buffer_out = reader->buffer_in;

@ -410,6 +410,7 @@ static void set_status_code(grpc_call *call, status_source source,
static void set_compression_algorithm(grpc_call *call, static void set_compression_algorithm(grpc_call *call,
grpc_compression_algorithm algo) { grpc_compression_algorithm algo) {
GPR_ASSERT(algo < GRPC_COMPRESS_ALGORITHMS_COUNT);
call->compression_algorithm = algo; call->compression_algorithm = algo;
} }
@ -830,12 +831,16 @@ static uint32_t decode_status(grpc_mdelem *md) {
return status; return status;
} }
static uint32_t decode_compression(grpc_mdelem *md) { static grpc_compression_algorithm decode_compression(grpc_mdelem *md) {
grpc_compression_algorithm algorithm = grpc_compression_algorithm algorithm =
grpc_compression_algorithm_from_mdstr(md->value); grpc_compression_algorithm_from_mdstr(md->value);
if (algorithm == GRPC_COMPRESS_ALGORITHMS_COUNT) { if (algorithm == GRPC_COMPRESS_ALGORITHMS_COUNT) {
const char *md_c_str = grpc_mdstr_as_c_string(md->value); const char *md_c_str = grpc_mdstr_as_c_string(md->value);
gpr_log(GPR_ERROR, "Invalid compression algorithm: '%s'", md_c_str); gpr_log(GPR_ERROR,
"Invalid incoming compression algorithm: '%s'. Interpreting "
"incoming data as uncompressed.",
md_c_str);
return GRPC_COMPRESS_NONE;
} }
return algorithm; return algorithm;
} }

@ -60,7 +60,7 @@ static const char* kRandomFile = "test/cpp/interop/rnd.dat";
namespace { namespace {
// The same value is defined by the Java client. // The same value is defined by the Java client.
const std::vector<int> request_stream_sizes = {27182, 8, 1828, 45904}; const std::vector<int> request_stream_sizes = {27182, 8, 1828, 45904};
const std::vector<int> response_stream_sizes = {31415, 9, 2653, 58979}; const std::vector<int> response_stream_sizes = {31415, 59, 2653, 58979};
const int kNumResponseMessages = 2000; const int kNumResponseMessages = 2000;
const int kResponseMessageSize = 1030; const int kResponseMessageSize = 1030;
const int kReceiveDelayMilliSeconds = 20; const int kReceiveDelayMilliSeconds = 20;

@ -82,10 +82,10 @@ class CXXLanguage:
return {} return {}
def unimplemented_test_cases(self): def unimplemented_test_cases(self):
return _SKIP_ADVANCED + _SKIP_COMPRESSION return _SKIP_ADVANCED
def unimplemented_test_cases_server(self): def unimplemented_test_cases_server(self):
return _SKIP_ADVANCED + _SKIP_COMPRESSION return _SKIP_ADVANCED
def __str__(self): def __str__(self):
return 'c++' return 'c++'

Loading…
Cancel
Save