diff options
author | Muxi Yan <mxyan@google.com> | 2017-09-14 09:42:56 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-09-25 11:42:46 -0700 |
commit | e6d888d0a086e0d208cad1849def4326f28670f0 (patch) | |
tree | 3eb7ce0db111ad850144ee34f4b34e8656b12cd8 /test/core | |
parent | e29d497fa90506e9e09f2d66536052454acf3a6e (diff) |
Change C core surface API
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/channel/channel_args_test.c | 25 | ||||
-rw-r--r-- | test/core/compression/BUILD | 12 | ||||
-rw-r--r-- | test/core/compression/algorithm_test.c | 18 | ||||
-rw-r--r-- | test/core/compression/compression_test.c | 178 | ||||
-rw-r--r-- | test/core/compression/message_compress_test.c | 34 | ||||
-rw-r--r-- | test/core/end2end/fixtures/h2_compress.c | 4 | ||||
-rw-r--r-- | test/core/end2end/fuzzers/hpack.dictionary | 3 | ||||
-rw-r--r-- | test/core/end2end/tests/compressed_payload.c | 37 | ||||
-rw-r--r-- | test/core/end2end/tests/stream_compression_compressed_payload.c | 104 | ||||
-rw-r--r-- | test/core/end2end/tests/stream_compression_payload.c | 10 | ||||
-rw-r--r-- | test/core/end2end/tests/stream_compression_ping_pong_streaming.c | 10 | ||||
-rw-r--r-- | test/core/end2end/tests/workaround_cronet_compression.c | 13 | ||||
-rw-r--r-- | test/core/surface/byte_buffer_reader_test.c | 8 |
13 files changed, 297 insertions, 159 deletions
diff --git a/test/core/channel/channel_args_test.c b/test/core/channel/channel_args_test.c index deaf2933ec..35b0c3e5e7 100644 --- a/test/core/channel/channel_args_test.c +++ b/test/core/channel/channel_args_test.c @@ -64,7 +64,7 @@ static void test_set_compression_algorithm(void) { grpc_channel_args *ch_args; ch_args = - grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_GZIP); + grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_MESSAGE_GZIP); GPR_ASSERT(ch_args->num_args == 1); GPR_ASSERT(strcmp(ch_args->args[0].key, GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM) == 0); @@ -76,7 +76,7 @@ static void test_set_compression_algorithm(void) { static void test_compression_algorithm_states(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate; + grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate, *ch_args_wo_gzip_deflate_gzip; unsigned states_bitset; size_t i; @@ -89,33 +89,38 @@ static void test_compression_algorithm_states(void) { GPR_ASSERT(GPR_BITGET(states_bitset, i)); } - /* disable gzip and deflate */ + /* disable message/gzip and message/deflate and stream/gzip */ ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state( - &exec_ctx, &ch_args, GRPC_COMPRESS_GZIP, 0); + &exec_ctx, &ch_args, GRPC_COMPRESS_MESSAGE_GZIP, 0); GPR_ASSERT(ch_args == ch_args_wo_gzip); ch_args_wo_gzip_deflate = grpc_channel_args_compression_algorithm_set_state( - &exec_ctx, &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0); + &exec_ctx, &ch_args_wo_gzip, GRPC_COMPRESS_MESSAGE_DEFLATE, 0); GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate); + ch_args_wo_gzip_deflate_gzip = grpc_channel_args_compression_algorithm_set_state( + &exec_ctx, &ch_args_wo_gzip_deflate, GRPC_COMPRESS_STREAM_GZIP, 0); + GPR_ASSERT(ch_args_wo_gzip_deflate == ch_args_wo_gzip_deflate_gzip); states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states( ch_args_wo_gzip_deflate); for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { - if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE) { + if (i == GRPC_COMPRESS_MESSAGE_GZIP || i == GRPC_COMPRESS_MESSAGE_DEFLATE || i == GRPC_COMPRESS_STREAM_GZIP) { GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0); } else { GPR_ASSERT(GPR_BITGET(states_bitset, i) != 0); } } - /* re-enabled gzip only */ + /* re-enabled message/gzip and stream/gzip only */ ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state( - &exec_ctx, &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1); - GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate); + &exec_ctx, &ch_args_wo_gzip_deflate_gzip, GRPC_COMPRESS_MESSAGE_GZIP, 1); + ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state( + &exec_ctx, &ch_args_wo_gzip, GRPC_COMPRESS_STREAM_GZIP, 1); + GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate_gzip); states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states( ch_args_wo_gzip); for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { - if (i == GRPC_COMPRESS_DEFLATE) { + if (i == GRPC_COMPRESS_MESSAGE_DEFLATE) { GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0); } else { GPR_ASSERT(GPR_BITGET(states_bitset, i) != 0); diff --git a/test/core/compression/BUILD b/test/core/compression/BUILD index 1ab6e35f0d..bbbd4c2e88 100644 --- a/test/core/compression/BUILD +++ b/test/core/compression/BUILD @@ -53,3 +53,15 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +grpc_cc_test( + name = "stream_compress_test", + srcs = ["stream_compress_test.c"], + language = "C", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:gpr_test_util", + "//test/core/util:grpc_test_util", + ], +) diff --git a/test/core/compression/algorithm_test.c b/test/core/compression/algorithm_test.c index e37c8c3010..51f7d09984 100644 --- a/test/core/compression/algorithm_test.c +++ b/test/core/compression/algorithm_test.c @@ -29,6 +29,8 @@ #include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" +const uint32_t message_prefix_length = 8; +const uint32_t stream_prefix_length = 7; static void test_algorithm_mesh(void) { int i; @@ -48,9 +50,19 @@ static void test_algorithm_mesh(void) { mdstr = grpc_slice_from_copied_string(name); GPR_ASSERT(grpc_slice_eq(mdstr, grpc_compression_algorithm_slice(parsed))); GPR_ASSERT(parsed == grpc_compression_algorithm_from_slice(mdstr)); - mdelem = grpc_compression_encoding_mdelem(parsed); - GPR_ASSERT(grpc_slice_eq(GRPC_MDVALUE(mdelem), mdstr)); - GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING)); + if (parsed == 0) { + continue; + } else if (grpc_compression_algorithm_is_message(parsed)) { + mdelem = grpc_message_compression_encoding_mdelem(grpc_compression_algorithm_to_message_compression_algorithm(parsed)); + grpc_slice value = GRPC_MDVALUE(mdelem); + GPR_ASSERT(0 == memcmp(&name[message_prefix_length], GRPC_SLICE_START_PTR(value), GRPC_SLICE_LENGTH(value))); + GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING)); + } else { + mdelem = grpc_stream_compression_encoding_mdelem(grpc_compression_algorithm_to_stream_compression_algorithm(parsed)); + grpc_slice value = GRPC_MDVALUE(mdelem); + GPR_ASSERT(0 == memcmp(&name[stream_prefix_length], GRPC_SLICE_START_PTR(value), GRPC_SLICE_LENGTH(value))); + GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_CONTENT_ENCODING)); + } grpc_slice_unref_internal(&exec_ctx, mdstr); GRPC_MDELEM_UNREF(&exec_ctx, mdelem); grpc_exec_ctx_finish(&exec_ctx); diff --git a/test/core/compression/compression_test.c b/test/core/compression/compression_test.c index 4b6026ec77..4b300e18d3 100644 --- a/test/core/compression/compression_test.c +++ b/test/core/compression/compression_test.c @@ -28,9 +28,9 @@ static void test_compression_algorithm_parse(void) { size_t i; - const char *valid_names[] = {"identity", "gzip", "deflate"}; + const char *valid_names[] = {"identity", "message/gzip", "message/deflate", "stream/gzip"}; const grpc_compression_algorithm valid_algorithms[] = { - GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE}; + GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP}; const char *invalid_names[] = {"gzip2", "foo", "", "2gzip"}; gpr_log(GPR_DEBUG, "test_compression_algorithm_parse"); @@ -59,9 +59,9 @@ static void test_compression_algorithm_name(void) { int success; char *name; size_t i; - const char *valid_names[] = {"identity", "gzip", "deflate"}; + const char *valid_names[] = {"identity", "message/gzip", "message/deflate", "stream/gzip"}; const grpc_compression_algorithm valid_algorithms[] = { - GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE}; + GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP}; gpr_log(GPR_DEBUG, "test_compression_algorithm_name"); @@ -90,15 +90,27 @@ static void test_compression_algorithm_for_level(void) { accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW, + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED, + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, accepted_encodings)); GPR_ASSERT(GRPC_COMPRESS_NONE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH, + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } @@ -106,22 +118,34 @@ static void test_compression_algorithm_for_level(void) { /* accept only gzip */ uint32_t accepted_encodings = 0; GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */ - GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP); + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_GZIP); GPR_ASSERT(GRPC_COMPRESS_NONE == grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE, accepted_encodings)); - GPR_ASSERT(GRPC_COMPRESS_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW, + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, accepted_encodings)); - GPR_ASSERT(GRPC_COMPRESS_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED, + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, accepted_encodings)); - GPR_ASSERT(GRPC_COMPRESS_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH, + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } @@ -129,22 +153,34 @@ static void test_compression_algorithm_for_level(void) { /* accept only deflate */ uint32_t accepted_encodings = 0; GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */ - GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE); + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE); GPR_ASSERT(GRPC_COMPRESS_NONE == grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE, accepted_encodings)); - GPR_ASSERT(GRPC_COMPRESS_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW, + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, accepted_encodings)); - GPR_ASSERT(GRPC_COMPRESS_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED, + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, accepted_encodings)); - GPR_ASSERT(GRPC_COMPRESS_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH, + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } @@ -152,23 +188,107 @@ static void test_compression_algorithm_for_level(void) { /* accept gzip and deflate */ uint32_t accepted_encodings = 0; GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */ - GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP); - GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE); + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_GZIP); + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE); GPR_ASSERT(GRPC_COMPRESS_NONE == grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE, accepted_encodings)); - GPR_ASSERT(GRPC_COMPRESS_GZIP == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW, + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, + accepted_encodings)); + } + + { + /* accept stream gzip */ + uint32_t accepted_encodings = 0; + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */ + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_STREAM_GZIP); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, + accepted_encodings)); + } + + { + /* accept all algorithms */ + uint32_t accepted_encodings = 0; + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */ + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_GZIP); + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE); + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_STREAM_GZIP); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_LOW, accepted_encodings)); - GPR_ASSERT(GRPC_COMPRESS_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED, + GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_MED, accepted_encodings)); - GPR_ASSERT(GRPC_COMPRESS_DEFLATE == - grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH, + GPR_ASSERT(GRPC_COMPRESS_STREAM_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_STREAM_HIGH, accepted_encodings)); } } diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index fd692fe5a5..4444b65802 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -39,7 +39,7 @@ typedef enum { } compressability; static void assert_passthrough(grpc_slice value, - grpc_compression_algorithm algorithm, + grpc_message_compression_algorithm algorithm, grpc_slice_split_mode uncompressed_split_mode, grpc_slice_split_mode compressed_split_mode, compressability compress_result_check) { @@ -51,7 +51,7 @@ static void assert_passthrough(grpc_slice value, int was_compressed; char *algorithm_name; - GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algorithm_name) != 0); + GPR_ASSERT(grpc_message_compression_algorithm_name(algorithm, &algorithm_name) != 0); gpr_log( GPR_INFO, "assert_passthrough: value_length=%" PRIuPTR " value_hash=0x%08x " @@ -93,7 +93,7 @@ static void assert_passthrough(grpc_slice value, { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(grpc_msg_decompress( - &exec_ctx, was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed, + &exec_ctx, was_compressed ? algorithm : GRPC_MESSAGE_COMPRESS_NONE, &compressed, &output)); grpc_exec_ctx_finish(&exec_ctx); } @@ -115,8 +115,8 @@ static grpc_slice repeated(char c, size_t length) { } static compressability get_compressability( - test_value id, grpc_compression_algorithm algorithm) { - if (algorithm == GRPC_COMPRESS_NONE) return SHOULD_NOT_COMPRESS; + test_value id, grpc_message_compression_algorithm algorithm) { + if (algorithm == GRPC_MESSAGE_COMPRESS_NONE) return SHOULD_NOT_COMPRESS; switch (id) { case ONE_A: return SHOULD_NOT_COMPRESS; @@ -148,14 +148,14 @@ static grpc_slice create_test_value(test_value id) { static void test_tiny_data_compress(void) { grpc_slice_buffer input; grpc_slice_buffer output; - grpc_compression_algorithm i; + grpc_message_compression_algorithm i; grpc_slice_buffer_init(&input); grpc_slice_buffer_init(&output); grpc_slice_buffer_add(&input, create_test_value(ONE_A)); - for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { - if (i == GRPC_COMPRESS_NONE) continue; + for (i = 0; i < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; i++) { + if (i == GRPC_MESSAGE_COMPRESS_NONE) continue; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(0 == grpc_msg_compress(&exec_ctx, i, &input, &output)); grpc_exec_ctx_finish(&exec_ctx); @@ -180,7 +180,7 @@ static void test_bad_decompression_data_crc(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; /* compress it */ - grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_GZIP, &input, &corrupted); + grpc_msg_compress(&exec_ctx, GRPC_MESSAGE_COMPRESS_GZIP, &input, &corrupted); /* corrupt the output by smashing the CRC */ GPR_ASSERT(corrupted.count > 1); GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[1]) > 8); @@ -188,7 +188,7 @@ static void test_bad_decompression_data_crc(void) { memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4); /* try (and fail) to decompress the corrupted compresed buffer */ - GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_GZIP, &corrupted, + GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_GZIP, &corrupted, &output)); grpc_exec_ctx_finish(&exec_ctx); @@ -210,7 +210,7 @@ static void test_bad_decompression_data_trailing_garbage(void) { /* try (and fail) to decompress the invalid compresed buffer */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input, + GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output)); grpc_exec_ctx_finish(&exec_ctx); @@ -229,7 +229,7 @@ static void test_bad_decompression_data_stream(void) { /* try (and fail) to decompress the invalid compresed buffer */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input, + GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output)); grpc_exec_ctx_finish(&exec_ctx); @@ -248,12 +248,12 @@ static void test_bad_compression_algorithm(void) { &input, grpc_slice_from_copied_string("Never gonna give you up")); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - was_compressed = grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT, + was_compressed = grpc_msg_compress(&exec_ctx, GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT, &input, &output); GPR_ASSERT(0 == was_compressed); was_compressed = grpc_msg_compress( - &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output); + &exec_ctx, GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output); GPR_ASSERT(0 == was_compressed); grpc_exec_ctx_finish(&exec_ctx); @@ -273,11 +273,11 @@ static void test_bad_decompression_algorithm(void) { "I'm not really compressed but it doesn't matter")); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; was_decompressed = grpc_msg_decompress( - &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output); + &exec_ctx, GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT, &input, &output); GPR_ASSERT(0 == was_decompressed); was_decompressed = grpc_msg_decompress( - &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output); + &exec_ctx, GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output); GPR_ASSERT(0 == was_decompressed); grpc_exec_ctx_finish(&exec_ctx); @@ -296,7 +296,7 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); - for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { + for (i = 0; i < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; i++) { for (j = 0; j < GPR_ARRAY_SIZE(uncompressed_split_modes); j++) { for (k = 0; k < GPR_ARRAY_SIZE(compressed_split_modes); k++) { for (m = 0; m < TEST_VALUE_COUNT; m++) { diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index 9866dea7eb..0f4621ae34 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -69,7 +69,7 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } ffd->client_args_compression = grpc_channel_args_set_compression_algorithm( - client_args, GRPC_COMPRESS_GZIP); + client_args, GRPC_COMPRESS_MESSAGE_GZIP); f->client = grpc_insecure_channel_create(ffd->localaddr, ffd->client_args_compression, NULL); } @@ -83,7 +83,7 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f, grpc_exec_ctx_finish(&exec_ctx); } ffd->server_args_compression = grpc_channel_args_set_compression_algorithm( - server_args, GRPC_COMPRESS_GZIP); + server_args, GRPC_COMPRESS_MESSAGE_GZIP); if (f->server) { grpc_server_destroy(f->server); } diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index 7c77512aa9..a87e49ee52 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -28,6 +28,9 @@ "\x1Egrpc.max_request_message_bytes" "\x1Fgrpc.max_response_message_bytes" "$/grpc.lb.v1.LoadBalancer/BalanceLoad" +"\x0Fmessage/deflate" +"\x0Cmessage/gzip" +"\x0Bstream/gzip" "\x010" "\x011" "\x012" diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 429717a7be..e07199ac28 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -384,9 +384,9 @@ static void request_with_payload_template( GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), GRPC_COMPRESS_NONE) != 0); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), - GRPC_COMPRESS_DEFLATE) != 0); + GRPC_COMPRESS_MESSAGE_DEFLATE) != 0); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), - GRPC_COMPRESS_GZIP) != 0); + GRPC_COMPRESS_MESSAGE_GZIP) != 0); memset(ops, 0, sizeof(ops)); op = ops; @@ -549,8 +549,9 @@ static void test_invoke_request_with_exceptionally_uncompressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_exceptionally_uncompressed_payload", - GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, - GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, NULL, false, + GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_MESSAGE_GZIP, + GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_MESSAGE_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE, false); } @@ -567,18 +568,18 @@ static void test_invoke_request_with_compressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_compressed_payload", 0, - GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, - GRPC_COMPRESS_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE, - false); + GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, + GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, NULL, false, + /* ignored */ GRPC_COMPRESS_LEVEL_NONE, false); } static void test_invoke_request_with_send_message_before_initial_metadata( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_compressed_payload", 0, - GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, - GRPC_COMPRESS_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE, - true); + GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, + GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, NULL, false, + /* ignored */ GRPC_COMPRESS_LEVEL_NONE, true); } static void test_invoke_request_with_server_level( @@ -586,7 +587,7 @@ static void test_invoke_request_with_server_level( request_with_payload_template( config, "test_invoke_request_with_server_level", 0, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE /* ignored */, - NULL, true, GRPC_COMPRESS_LEVEL_HIGH, false); + NULL, true, GRPC_COMPRESS_LEVEL_MESSAGE_HIGH, false); } static void test_invoke_request_with_compressed_payload_md_override( @@ -595,7 +596,7 @@ static void test_invoke_request_with_compressed_payload_md_override( grpc_metadata identity_compression_override; gzip_compression_override.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST; - gzip_compression_override.value = grpc_slice_from_static_string("gzip"); + gzip_compression_override.value = grpc_slice_from_static_string("message/gzip"); memset(&gzip_compression_override.internal_data, 0, sizeof(gzip_compression_override.internal_data)); @@ -608,21 +609,22 @@ static void test_invoke_request_with_compressed_payload_md_override( /* Channel default NONE (aka IDENTITY), call override to GZIP */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_1", 0, - GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_NONE, &gzip_compression_override, false, /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false); /* Channel default DEFLATE, call override to GZIP */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_2", 0, - GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, - GRPC_COMPRESS_NONE, &gzip_compression_override, false, + GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_NONE, + &gzip_compression_override, false, /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false); /* Channel default DEFLATE, call override to NONE (aka IDENTITY) */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_3", 0, - GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, &identity_compression_override, false, /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false); } @@ -631,7 +633,8 @@ static void test_invoke_request_with_disabled_algorithm( grpc_end2end_test_config config) { request_for_disabled_algorithm( config, "test_invoke_request_with_disabled_algorithm", 0, - GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_STATUS_UNIMPLEMENTED, NULL); + GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, + GRPC_STATUS_UNIMPLEMENTED, NULL); } void compressed_payload(grpc_end2end_test_config config) { diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.c b/test/core/end2end/tests/stream_compression_compressed_payload.c index 11e7999a1c..87c3183534 100644 --- a/test/core/end2end/tests/stream_compression_compressed_payload.c +++ b/test/core/end2end/tests/stream_compression_compressed_payload.c @@ -95,8 +95,8 @@ static void end_test(grpc_end2end_test_fixture *f) { static void request_for_disabled_algorithm( grpc_end2end_test_config config, const char *test_name, uint32_t send_flags_bitmask, - grpc_stream_compression_algorithm algorithm_to_disable, - grpc_stream_compression_algorithm requested_client_compression_algorithm, + grpc_compression_algorithm algorithm_to_disable, + grpc_compression_algorithm requested_client_compression_algorithm, grpc_status_code expected_error, grpc_metadata *client_metadata) { grpc_call *c; grpc_call *s; @@ -124,13 +124,13 @@ static void request_for_disabled_algorithm( request_payload_slice = grpc_slice_from_copied_string(str); request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - client_args = grpc_channel_args_set_stream_compression_algorithm( + client_args = grpc_channel_args_set_compression_algorithm( NULL, requested_client_compression_algorithm); - server_args = grpc_channel_args_set_stream_compression_algorithm( - NULL, GRPC_STREAM_COMPRESS_NONE); + server_args = + grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_NONE); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - server_args = grpc_channel_args_stream_compression_algorithm_set_state( + server_args = grpc_channel_args_compression_algorithm_set_state( &exec_ctx, &server_args, algorithm_to_disable, false); grpc_exec_ctx_finish(&exec_ctx); } @@ -229,11 +229,10 @@ static void request_for_disabled_algorithm( GPR_ASSERT(status == expected_error); char *algo_name = NULL; - GPR_ASSERT( - grpc_stream_compression_algorithm_name(algorithm_to_disable, &algo_name)); + GPR_ASSERT(grpc_compression_algorithm_name(algorithm_to_disable, &algo_name)); char *expected_details = NULL; gpr_asprintf(&expected_details, - "Stream compression algorithm '%s' is disabled.", algo_name); + "Compression algorithm '%s' is disabled.", algo_name); /* and we expect a specific reason for it */ GPR_ASSERT(0 == grpc_slice_str_cmp(details, expected_details)); gpr_free(expected_details); @@ -270,14 +269,12 @@ static void request_for_disabled_algorithm( static void request_with_payload_template( grpc_end2end_test_config config, const char *test_name, uint32_t client_send_flags_bitmask, - grpc_stream_compression_algorithm - default_client_channel_compression_algorithm, - grpc_stream_compression_algorithm - default_server_channel_compression_algorithm, - grpc_stream_compression_algorithm expected_client_compression_algorithm, - grpc_stream_compression_algorithm expected_server_compression_algorithm, + grpc_compression_algorithm default_client_channel_compression_algorithm, + grpc_compression_algorithm default_server_channel_compression_algorithm, + grpc_compression_algorithm expected_client_compression_algorithm, + grpc_compression_algorithm expected_server_compression_algorithm, grpc_metadata *client_init_metadata, bool set_server_level, - grpc_stream_compression_level server_compression_level, + grpc_compression_level server_compression_level, bool send_message_before_initial_metadata, bool set_default_server_message_compression_algorithm, grpc_compression_algorithm default_server_message_compression_algorithm) { @@ -315,13 +312,13 @@ static void request_with_payload_template( grpc_slice response_payload_slice = grpc_slice_from_copied_string(response_str); - client_args = grpc_channel_args_set_stream_compression_algorithm( + client_args = grpc_channel_args_set_compression_algorithm( NULL, default_client_channel_compression_algorithm); if (set_default_server_message_compression_algorithm) { server_args = grpc_channel_args_set_compression_algorithm( NULL, default_server_message_compression_algorithm); } else { - server_args = grpc_channel_args_set_stream_compression_algorithm( + server_args = grpc_channel_args_set_compression_algorithm( NULL, default_server_channel_compression_algorithm); } @@ -394,26 +391,21 @@ static void request_with_payload_template( GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), GRPC_COMPRESS_NONE) != 0); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), - GRPC_COMPRESS_DEFLATE) != 0); + GRPC_COMPRESS_MESSAGE_DEFLATE) != 0); + GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), + GRPC_COMPRESS_MESSAGE_GZIP) != 0); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), - GRPC_COMPRESS_GZIP) != 0); - GPR_ASSERT( - GPR_BITCOUNT(grpc_call_test_only_get_stream_encodings_accepted_by_peer( - s)) == GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT); - GPR_ASSERT( - GPR_BITGET(grpc_call_test_only_get_stream_encodings_accepted_by_peer(s), - GRPC_STREAM_COMPRESS_NONE) != 0); - GPR_ASSERT( - GPR_BITGET(grpc_call_test_only_get_stream_encodings_accepted_by_peer(s), - GRPC_STREAM_COMPRESS_GZIP) != 0); + GRPC_COMPRESS_STREAM_GZIP) != 0); + GPR_ASSERT(GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer( + s)) == GRPC_COMPRESS_ALGORITHMS_COUNT); memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; if (set_server_level) { - op->data.send_initial_metadata.maybe_stream_compression_level.is_set = true; - op->data.send_initial_metadata.maybe_stream_compression_level.level = + op->data.send_initial_metadata.maybe_compression_level.is_set = true; + op->data.send_initial_metadata.maybe_compression_level.level = server_compression_level; } op->flags = 0; @@ -557,29 +549,28 @@ static void test_invoke_request_with_compressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_compressed_payload", 0, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, NULL, + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, NULL, false, /* ignored */ - GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE); + GRPC_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE); } static void test_invoke_request_with_send_message_before_initial_metadata( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_send_message_before_initial_metadata", - 0, GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, NULL, + 0, GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, NULL, false, /* ignored */ - GRPC_STREAM_COMPRESS_LEVEL_NONE, true, false, GRPC_COMPRESS_NONE); + GRPC_COMPRESS_LEVEL_NONE, true, false, GRPC_COMPRESS_NONE); } static void test_invoke_request_with_server_level( grpc_end2end_test_config config) { request_with_payload_template( - config, "test_invoke_request_with_server_level", 0, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_GZIP, - /* ignored */ NULL, true, GRPC_STREAM_COMPRESS_LEVEL_HIGH, false, false, + config, "test_invoke_request_with_server_level", 0, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_STREAM_GZIP, + /* ignored */ NULL, true, GRPC_COMPRESS_LEVEL_STREAM_HIGH, false, false, GRPC_COMPRESS_NONE); } @@ -590,7 +581,7 @@ static void test_invoke_request_with_compressed_payload_md_override( gzip_compression_override.key = GRPC_MDSTR_GRPC_INTERNAL_STREAM_ENCODING_REQUEST; - gzip_compression_override.value = grpc_slice_from_static_string("gzip"); + gzip_compression_override.value = grpc_slice_from_static_string("stream/gzip"); memset(&gzip_compression_override.internal_data, 0, sizeof(gzip_compression_override.internal_data)); @@ -604,40 +595,35 @@ static void test_invoke_request_with_compressed_payload_md_override( /* Channel default NONE (aka IDENTITY), call override to stream GZIP */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_1", 0, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_NONE, - &gzip_compression_override, false, - /*ignored*/ GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false, - GRPC_COMPRESS_NONE); + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_STREAM_GZIP, + GRPC_COMPRESS_NONE, &gzip_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE); /* Channel default stream GZIP, call override to NONE (aka IDENTITY) */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_3", 0, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_NONE, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE, - &identity_compression_override, false, - /*ignored*/ GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false, - GRPC_COMPRESS_NONE); + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_NONE, &identity_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE); } static void test_invoke_request_with_disabled_algorithm( grpc_end2end_test_config config) { request_for_disabled_algorithm( config, "test_invoke_request_with_disabled_algorithm", 0, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, GRPC_STATUS_UNIMPLEMENTED, NULL); } static void test_stream_compression_override_message_compression( grpc_end2end_test_config config) { - grpc_stream_compression_level level = GRPC_STREAM_COMPRESS_LEVEL_MED; + grpc_compression_level level = GRPC_COMPRESS_LEVEL_STREAM_MED; request_with_payload_template( config, "test_stream_compression_override_message_compression", 0, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE, - GRPC_STREAM_COMPRESS_NONE, - grpc_stream_compression_algorithm_for_level( - level, (1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) - 1), - /* ignored */ NULL, true, level, false, true, GRPC_COMPRESS_GZIP); + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, + grpc_compression_algorithm_for_level( + level, (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1), + /* ignored */ NULL, true, level, false, true, GRPC_COMPRESS_MESSAGE_GZIP); } void stream_compression_compressed_payload(grpc_end2end_test_config config) { diff --git a/test/core/end2end/tests/stream_compression_payload.c b/test/core/end2end/tests/stream_compression_payload.c index e47d2aa93c..6b5b6d4fb5 100644 --- a/test/core/end2end/tests/stream_compression_payload.c +++ b/test/core/end2end/tests/stream_compression_payload.c @@ -265,12 +265,10 @@ static void request_response_with_payload(grpc_end2end_test_config config, payload and status. */ static void test_invoke_request_response_with_payload( grpc_end2end_test_config config) { - grpc_channel_args *client_args = - grpc_channel_args_set_stream_compression_algorithm( - NULL, GRPC_STREAM_COMPRESS_GZIP); - grpc_channel_args *server_args = - grpc_channel_args_set_stream_compression_algorithm( - NULL, GRPC_STREAM_COMPRESS_GZIP); + grpc_channel_args *client_args = grpc_channel_args_set_compression_algorithm( + NULL, GRPC_COMPRESS_STREAM_GZIP); + grpc_channel_args *server_args = grpc_channel_args_set_compression_algorithm( + NULL, GRPC_COMPRESS_STREAM_GZIP); grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_response_with_payload", client_args, server_args); diff --git a/test/core/end2end/tests/stream_compression_ping_pong_streaming.c b/test/core/end2end/tests/stream_compression_ping_pong_streaming.c index 4c1a34cc64..4dd35680d7 100644 --- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.c +++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.c @@ -90,12 +90,10 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Client pings and server pongs. Repeat messages rounds before finishing. */ static void test_pingpong_streaming(grpc_end2end_test_config config, int messages) { - grpc_channel_args *client_args = - grpc_channel_args_set_stream_compression_algorithm( - NULL, GRPC_STREAM_COMPRESS_GZIP); - grpc_channel_args *server_args = - grpc_channel_args_set_stream_compression_algorithm( - NULL, GRPC_STREAM_COMPRESS_GZIP); + grpc_channel_args *client_args = grpc_channel_args_set_compression_algorithm( + NULL, GRPC_COMPRESS_STREAM_GZIP); + grpc_channel_args *server_args = grpc_channel_args_set_compression_algorithm( + NULL, GRPC_COMPRESS_STREAM_GZIP); grpc_end2end_test_fixture f = begin_test(config, "test_pingpong_streaming", client_args, server_args); grpc_call *c; diff --git a/test/core/end2end/tests/workaround_cronet_compression.c b/test/core/end2end/tests/workaround_cronet_compression.c index 44e8e04643..4ca018cf50 100644 --- a/test/core/end2end/tests/workaround_cronet_compression.c +++ b/test/core/end2end/tests/workaround_cronet_compression.c @@ -208,9 +208,9 @@ static void request_with_payload_template( GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), GRPC_COMPRESS_NONE) != 0); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), - GRPC_COMPRESS_DEFLATE) != 0); + GRPC_COMPRESS_MESSAGE_DEFLATE) != 0); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), - GRPC_COMPRESS_GZIP) != 0); + GRPC_COMPRESS_MESSAGE_GZIP) != 0); memset(ops, 0, sizeof(ops)); op = ops; @@ -365,13 +365,13 @@ typedef struct workaround_cronet_compression_config { } workaround_cronet_compression_config; static workaround_cronet_compression_config workaround_configs[] = { - {NULL, GRPC_COMPRESS_GZIP}, + {NULL, GRPC_COMPRESS_MESSAGE_GZIP}, {"grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; cronet_http; gentle)", GRPC_COMPRESS_NONE}, {"grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; chttp2; gentle)", - GRPC_COMPRESS_GZIP}, + GRPC_COMPRESS_MESSAGE_GZIP}, {"grpc-objc/1.4.0 grpc-c/3.0.0-dev (ios; cronet_http; gentle)", - GRPC_COMPRESS_GZIP}}; + GRPC_COMPRESS_MESSAGE_GZIP}}; static const size_t workaround_configs_num = sizeof(workaround_configs) / sizeof(*workaround_configs); @@ -380,7 +380,8 @@ static void test_workaround_cronet_compression( for (uint32_t i = 0; i < workaround_configs_num; i++) { request_with_payload_template( config, "test_invoke_request_with_compressed_payload", 0, - GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, + GRPC_COMPRESS_MESSAGE_GZIP, workaround_configs[i].expected_algorithm_from_server, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE, workaround_configs[i].user_agent_override); diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.c index a6b4c86abc..c4c59ff6e1 100644 --- a/test/core/surface/byte_buffer_reader_test.c +++ b/test/core/surface/byte_buffer_reader_test.c @@ -109,7 +109,7 @@ static void test_read_corrupted_slice(void) { LOG_TEST("test_read_corrupted_slice"); slice = grpc_slice_from_copied_string("test"); buffer = grpc_raw_byte_buffer_create(&slice, 1); - buffer->data.raw.compression = GRPC_COMPRESS_GZIP; /* lies! */ + buffer->data.raw.compression = GRPC_COMPRESS_MESSAGE_GZIP; /* lies! */ grpc_slice_unref(slice); GPR_ASSERT(!grpc_byte_buffer_reader_init(&reader, buffer)); grpc_byte_buffer_destroy(buffer); @@ -134,7 +134,7 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm, { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT( - grpc_msg_compress(&exec_ctx, algorithm, &sliceb_in, &sliceb_out)); + grpc_msg_compress(&exec_ctx, grpc_compression_algorithm_to_message_compression_algorithm(algorithm), &sliceb_in, &sliceb_out)); grpc_exec_ctx_finish(&exec_ctx); } @@ -160,13 +160,13 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm, static void test_read_gzip_compressed_slice(void) { const size_t INPUT_SIZE = 2048; LOG_TEST("test_read_gzip_compressed_slice"); - read_compressed_slice(GRPC_COMPRESS_GZIP, INPUT_SIZE); + read_compressed_slice(GRPC_COMPRESS_MESSAGE_GZIP, INPUT_SIZE); } static void test_read_deflate_compressed_slice(void) { const size_t INPUT_SIZE = 2048; LOG_TEST("test_read_deflate_compressed_slice"); - read_compressed_slice(GRPC_COMPRESS_DEFLATE, INPUT_SIZE); + read_compressed_slice(GRPC_COMPRESS_MESSAGE_DEFLATE, INPUT_SIZE); } static void test_byte_buffer_from_reader(void) { |