aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2018-02-08 10:06:23 -0800
committerGravatar Vijay Pai <vpai@google.com>2018-02-08 10:06:23 -0800
commit32748c1b2aff43af72b643219fc843f501cb626f (patch)
tree6bd6c185dffb7ba02b83ff7754c7a3e046aff9f6 /test/core
parent08ce35de61e4397bf79e68b3203163a320e48461 (diff)
parentf37d33a21ad5775883f516011cbdd141119a571f (diff)
Merge branch 'master' into gpr_review3
Diffstat (limited to 'test/core')
-rwxr-xr-xtest/core/bad_client/gen_build_yaml.py1
-rwxr-xr-xtest/core/bad_client/generate_tests.bzl6
-rw-r--r--test/core/bad_client/tests/duplicate_header.cc134
-rwxr-xr-xtest/core/bad_ssl/generate_tests.bzl14
-rw-r--r--test/core/channel/BUILD12
-rw-r--r--test/core/channel/channel_args_test.cc18
-rw-r--r--test/core/client_channel/BUILD23
-rw-r--r--test/core/client_channel/resolvers/fake_resolver_test.cc194
-rw-r--r--test/core/compression/algorithm_test.cc2
-rw-r--r--test/core/compression/compression_test.cc50
-rw-r--r--test/core/end2end/fixtures/h2_compress.cc4
-rw-r--r--test/core/end2end/fuzzers/hpack.dictionary6
-rw-r--r--test/core/end2end/tests/compressed_payload.cc37
-rw-r--r--test/core/end2end/tests/stream_compression_compressed_payload.cc4
-rw-r--r--test/core/end2end/tests/workaround_cronet_compression.cc13
-rw-r--r--test/core/gprpp/orphanable_test.cc20
-rw-r--r--test/core/gprpp/ref_counted_ptr_test.cc7
-rw-r--r--test/core/gprpp/ref_counted_test.cc13
-rw-r--r--test/core/http/BUILD13
-rw-r--r--test/core/surface/byte_buffer_reader_test.cc6
-rw-r--r--test/core/surface/public_headers_must_be_c89.c3
21 files changed, 428 insertions, 152 deletions
diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py
index a8fd777216..32afba5b1f 100755
--- a/test/core/bad_client/gen_build_yaml.py
+++ b/test/core/bad_client/gen_build_yaml.py
@@ -27,6 +27,7 @@ default_test_options = TestOptions(False, 1.0)
BAD_CLIENT_TESTS = {
'badreq': default_test_options,
'connection_prefix': default_test_options._replace(cpu_cost=0.2),
+ 'duplicate_header': default_test_options,
'headers': default_test_options._replace(cpu_cost=0.2),
'initial_settings_frame': default_test_options._replace(cpu_cost=0.2),
'head_of_line_blocking': default_test_options,
diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl
index b595defb8c..2769d5c3bb 100755
--- a/test/core/bad_client/generate_tests.bzl
+++ b/test/core/bad_client/generate_tests.bzl
@@ -16,6 +16,7 @@
"""Generates the appropriate build.json data for all the bad_client tests."""
+load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_cc_library")
def test_options():
return struct()
@@ -25,6 +26,7 @@ def test_options():
BAD_CLIENT_TESTS = {
'badreq': test_options(),
'connection_prefix': test_options(),
+ 'duplicate_header': test_options(),
'headers': test_options(),
'initial_settings_frame': test_options(),
'head_of_line_blocking': test_options(),
@@ -36,14 +38,14 @@ BAD_CLIENT_TESTS = {
}
def grpc_bad_client_tests():
- native.cc_library(
+ grpc_cc_library(
name = 'bad_client_test',
srcs = ['bad_client.cc'],
hdrs = ['bad_client.h'],
deps = ['//test/core/util:grpc_test_util', '//:grpc', '//:gpr', '//test/core/end2end:cq_verifier']
)
for t, topt in BAD_CLIENT_TESTS.items():
- native.cc_test(
+ grpc_cc_test(
name = '%s_bad_client_test' % t,
srcs = ['tests/%s.cc' % t],
deps = [':bad_client_test'],
diff --git a/test/core/bad_client/tests/duplicate_header.cc b/test/core/bad_client/tests/duplicate_header.cc
new file mode 100644
index 0000000000..0d689bbb7e
--- /dev/null
+++ b/test/core/bad_client/tests/duplicate_header.cc
@@ -0,0 +1,134 @@
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "test/core/bad_client/bad_client.h"
+
+#include <string.h>
+
+#include <grpc/grpc.h>
+
+#include "src/core/lib/surface/server.h"
+#include "test/core/end2end/cq_verifier.h"
+
+#define PFX_STR \
+ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \
+ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */
+
+#define HEADER_STR \
+ "\x00\x00\xc9\x01\x04\x00\x00\x00\x01" /* headers: generated from \
+ simple_request.headers in this \
+ directory */ \
+ "\x10\x05:path\x08/foo/bar" \
+ "\x10\x07:scheme\x04http" \
+ "\x10\x07:method\x04POST" \
+ "\x10\x0a:authority\x09localhost" \
+ "\x10\x0c" \
+ "content-type\x10" \
+ "application/grpc" \
+ "\x10\x14grpc-accept-encoding\x15" \
+ "deflate,identity,gzip" \
+ "\x10\x02te\x08trailers" \
+ "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)"
+
+#define PAYLOAD_STR \
+ "\x00\x00\x20\x00\x00\x00\x00\x00\x01" \
+ "\x00\x00\x00\x00"
+
+static void* tag(intptr_t t) { return (void*)t; }
+
+static void verifier(grpc_server* server, grpc_completion_queue* cq,
+ void* registered_method) {
+ grpc_call_error error;
+ grpc_call* s;
+ grpc_call_details call_details;
+ grpc_byte_buffer* request_payload_recv = nullptr;
+ grpc_op* op;
+ grpc_op ops[6];
+ cq_verifier* cqv = cq_verifier_create(cq);
+ grpc_metadata_array request_metadata_recv;
+ int was_cancelled = 2;
+
+ grpc_call_details_init(&call_details);
+ grpc_metadata_array_init(&request_metadata_recv);
+
+ error = grpc_server_request_call(server, &s, &call_details,
+ &request_metadata_recv, cq, cq, tag(101));
+ GPR_ASSERT(GRPC_CALL_OK == error);
+ CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar"));
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message.recv_message = &request_payload_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
+ cq_verify(cqv);
+
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
+ grpc_slice status_details = grpc_slice_from_static_string("xyz");
+ op->data.send_status_from_server.status_details = &status_details;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
+
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+ grpc_call_unref(s);
+ cq_verifier_destroy(cqv);
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+
+ /* Verify that sending multiple headers doesn't segfault */
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR HEADER_STR HEADER_STR PAYLOAD_STR, 0);
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
+ PFX_STR HEADER_STR HEADER_STR HEADER_STR PAYLOAD_STR,
+ 0);
+ grpc_shutdown();
+ return 0;
+}
diff --git a/test/core/bad_ssl/generate_tests.bzl b/test/core/bad_ssl/generate_tests.bzl
index b7cb8f86e6..f2eab54904 100755
--- a/test/core/bad_ssl/generate_tests.bzl
+++ b/test/core/bad_ssl/generate_tests.bzl
@@ -26,12 +26,22 @@ def grpc_bad_ssl_tests():
name = 'bad_ssl_test_server',
srcs = ['server_common.cc'],
hdrs = ['server_common.h'],
- deps = ['//test/core/util:grpc_test_util', '//:grpc', '//test/core/end2end:ssl_test_data']
+ deps = ['//test/core/util:grpc_test_util',
+ '//:grpc',
+ '//test/core/end2end:ssl_test_data']
)
for t in BAD_SSL_TESTS:
- native.cc_test(
+ native.cc_binary(
name = 'bad_ssl_%s_server' % t,
srcs = ['servers/%s.cc' % t],
deps = [':bad_ssl_test_server'],
)
+ native.cc_test(
+ name = 'bad_ssl_%s_test' % t,
+ srcs = ['bad_ssl_test.cc'],
+ data = [':bad_ssl_%s_server' % t],
+ deps = ['//test/core/util:grpc_test_util',
+ '//:gpr',
+ '//test/core/end2end:cq_verifier'],
+ )
diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD
index 92f5907aac..c5dfd8ef37 100644
--- a/test/core/channel/BUILD
+++ b/test/core/channel/BUILD
@@ -53,3 +53,15 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
],
)
+
+grpc_cc_test(
+ name = "minimal_stack_is_minimal_test",
+ srcs = ["minimal_stack_is_minimal_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc
index 5b0a770c84..24319baae6 100644
--- a/test/core/channel/channel_args_test.cc
+++ b/test/core/channel/channel_args_test.cc
@@ -62,8 +62,8 @@ static void test_set_compression_algorithm(void) {
grpc_core::ExecCtx exec_ctx;
grpc_channel_args* ch_args;
- ch_args = grpc_channel_args_set_compression_algorithm(
- nullptr, GRPC_COMPRESS_MESSAGE_GZIP);
+ ch_args =
+ grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_GZIP);
GPR_ASSERT(ch_args->num_args == 1);
GPR_ASSERT(strcmp(ch_args->args[0].key,
GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM) == 0);
@@ -88,12 +88,12 @@ static void test_compression_algorithm_states(void) {
GPR_ASSERT(GPR_BITGET(states_bitset, i));
}
- /* disable message/gzip and message/deflate and stream/gzip */
+ /* disable gzip and deflate and stream/gzip */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &ch_args, GRPC_COMPRESS_MESSAGE_GZIP, 0);
+ &ch_args, GRPC_COMPRESS_GZIP, 0);
GPR_ASSERT(ch_args == ch_args_wo_gzip);
ch_args_wo_gzip_deflate = grpc_channel_args_compression_algorithm_set_state(
- &ch_args_wo_gzip, GRPC_COMPRESS_MESSAGE_DEFLATE, 0);
+ &ch_args_wo_gzip, GRPC_COMPRESS_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(
@@ -103,7 +103,7 @@ static void test_compression_algorithm_states(void) {
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_MESSAGE_GZIP || i == GRPC_COMPRESS_MESSAGE_DEFLATE ||
+ if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE ||
i == GRPC_COMPRESS_STREAM_GZIP) {
GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0);
} else {
@@ -111,9 +111,9 @@ static void test_compression_algorithm_states(void) {
}
}
- /* re-enabled message/gzip and stream/gzip only */
+ /* re-enabled gzip and stream/gzip only */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &ch_args_wo_gzip_deflate_gzip, GRPC_COMPRESS_MESSAGE_GZIP, 1);
+ &ch_args_wo_gzip_deflate_gzip, GRPC_COMPRESS_GZIP, 1);
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
&ch_args_wo_gzip, GRPC_COMPRESS_STREAM_GZIP, 1);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate_gzip);
@@ -121,7 +121,7 @@ static void test_compression_algorithm_states(void) {
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_MESSAGE_DEFLATE) {
+ if (i == GRPC_COMPRESS_DEFLATE) {
GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0);
} else {
GPR_ASSERT(GPR_BITGET(states_bitset, i) != 0);
diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD
index 890e03fec1..c4d12fe3a1 100644
--- a/test/core/client_channel/BUILD
+++ b/test/core/client_channel/BUILD
@@ -31,3 +31,26 @@ grpc_fuzzer(
"//test/core/util:grpc_test_util",
],
)
+
+grpc_cc_test(
+ name = "parse_address_test",
+ srcs = ["parse_address_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "uri_parser_test",
+ srcs = ["uri_parser_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc
index d85cbb1d03..9c11c01021 100644
--- a/test/core/client_channel/resolvers/fake_resolver_test.cc
+++ b/test/core/client_channel/resolvers/fake_resolver_test.cc
@@ -55,6 +55,7 @@ typedef struct on_resolution_arg {
gpr_event ev;
} on_resolution_arg;
+// Callback to check the resolution result is as expected.
void on_resolution_cb(void* arg, grpc_error* error) {
on_resolution_arg* res = static_cast<on_resolution_arg*>(arg);
// We only check the addresses channel arg because that's the only one
@@ -71,85 +72,167 @@ void on_resolution_cb(void* arg, grpc_error* error) {
gpr_event_set(&res->ev, (void*)1);
}
-static void test_fake_resolver() {
- grpc_core::ExecCtx exec_ctx;
- grpc_combiner* combiner = grpc_combiner_create();
- // Create resolver.
- grpc_fake_resolver_response_generator* response_generator =
- grpc_fake_resolver_response_generator_create();
- grpc_resolver* resolver = build_fake_resolver(combiner, response_generator);
- GPR_ASSERT(resolver != nullptr);
-
- // Setup expectations.
- grpc_uri* uris[] = {grpc_uri_parse("ipv4:10.2.1.1:1234", true),
- grpc_uri_parse("ipv4:127.0.0.1:4321", true)};
- const char* balancer_names[] = {"name1", "name2"};
- const bool is_balancer[] = {true, false};
- grpc_lb_addresses* addresses = grpc_lb_addresses_create(3, nullptr);
- for (size_t i = 0; i < GPR_ARRAY_SIZE(uris); ++i) {
+// Create a new resolution containing 2 addresses.
+static grpc_channel_args* create_new_resolver_result() {
+ static size_t test_counter = 0;
+ const size_t num_addresses = 2;
+ char* uri_string;
+ char* balancer_name;
+ // Create grpc_lb_addresses.
+ grpc_lb_addresses* addresses =
+ grpc_lb_addresses_create(num_addresses, nullptr);
+ for (size_t i = 0; i < num_addresses; ++i) {
+ gpr_asprintf(&uri_string, "ipv4:127.0.0.1:100%" PRIuPTR,
+ test_counter * num_addresses + i);
+ grpc_uri* uri = grpc_uri_parse(uri_string, true);
+ gpr_asprintf(&balancer_name, "balancer%" PRIuPTR,
+ test_counter * num_addresses + i);
grpc_lb_addresses_set_address_from_uri(
- addresses, i, uris[i], is_balancer[i], balancer_names[i], nullptr);
- grpc_uri_destroy(uris[i]);
+ addresses, i, uri, bool(num_addresses % 2), balancer_name, nullptr);
+ gpr_free(balancer_name);
+ grpc_uri_destroy(uri);
+ gpr_free(uri_string);
}
+ // Convert grpc_lb_addresses to grpc_channel_args.
const grpc_arg addresses_arg =
grpc_lb_addresses_create_channel_arg(addresses);
grpc_channel_args* results =
grpc_channel_args_copy_and_add(nullptr, &addresses_arg, 1);
grpc_lb_addresses_destroy(addresses);
+ ++test_counter;
+ return results;
+}
+
+static on_resolution_arg create_on_resolution_arg(grpc_channel_args* results) {
on_resolution_arg on_res_arg;
memset(&on_res_arg, 0, sizeof(on_res_arg));
on_res_arg.expected_resolver_result = results;
gpr_event_init(&on_res_arg.ev);
+ return on_res_arg;
+}
+
+static void test_fake_resolver() {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_combiner* combiner = grpc_combiner_create();
+ // Create resolver.
+ grpc_fake_resolver_response_generator* response_generator =
+ grpc_fake_resolver_response_generator_create();
+ grpc_resolver* resolver = build_fake_resolver(combiner, response_generator);
+ GPR_ASSERT(resolver != nullptr);
+ // Test 1: normal resolution.
+ // next_results != NULL, results_upon_error == NULL, last_used_results ==
+ // NULL. Expected response is next_results.
+ grpc_channel_args* results = create_new_resolver_result();
+ on_resolution_arg on_res_arg = create_on_resolution_arg(results);
grpc_closure* on_resolution = GRPC_CLOSURE_CREATE(
on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner));
-
- // Set resolver results and trigger first resolution. on_resolution_cb
- // performs the checks.
+ // Resolution won't be triggered until next_results is set.
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
+ on_resolution);
grpc_fake_resolver_response_generator_set_response(response_generator,
results);
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
+ // Test 2: update resolution.
+ // next_results != NULL, results_upon_error == NULL, last_used_results !=
+ // NULL. Expected response is next_results.
+ results = create_new_resolver_result();
+ grpc_channel_args* last_used_results = grpc_channel_args_copy(results);
+ on_res_arg = create_on_resolution_arg(results);
+ on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg,
+ grpc_combiner_scheduler(combiner));
+ // Resolution won't be triggered until next_results is set.
grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ results);
grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
-
- // Setup update.
- grpc_uri* uris_update[] = {grpc_uri_parse("ipv4:192.168.1.0:31416", true)};
- const char* balancer_names_update[] = {"name3"};
- const bool is_balancer_update[] = {false};
- grpc_lb_addresses* addresses_update = grpc_lb_addresses_create(1, nullptr);
- for (size_t i = 0; i < GPR_ARRAY_SIZE(uris_update); ++i) {
- grpc_lb_addresses_set_address_from_uri(addresses_update, i, uris_update[i],
- is_balancer_update[i],
- balancer_names_update[i], nullptr);
- grpc_uri_destroy(uris_update[i]);
- }
-
- grpc_arg addresses_update_arg =
- grpc_lb_addresses_create_channel_arg(addresses_update);
- grpc_channel_args* results_update =
- grpc_channel_args_copy_and_add(nullptr, &addresses_update_arg, 1);
- grpc_lb_addresses_destroy(addresses_update);
-
- // Setup expectations for the update.
- on_resolution_arg on_res_arg_update;
- memset(&on_res_arg_update, 0, sizeof(on_res_arg_update));
- on_res_arg_update.expected_resolver_result = results_update;
- gpr_event_init(&on_res_arg_update.ev);
- on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg_update,
+ // Test 3: fallback re-resolution.
+ // next_results == NULL, results_upon_error == NULL, last_used_results !=
+ // NULL. Expected response is last_used_results.
+ on_res_arg = create_on_resolution_arg(last_used_results);
+ on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg,
grpc_combiner_scheduler(combiner));
-
- // Set updated resolver results and trigger a second resolution.
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
+ on_resolution);
+ // Trigger a re-resolution.
+ grpc_resolver_channel_saw_error_locked(resolver);
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
+ // Test 4: normal re-resolution.
+ // next_results == NULL, results_upon_error != NULL, last_used_results !=
+ // NULL. Expected response is results_upon_error.
+ grpc_channel_args* results_upon_error = create_new_resolver_result();
+ on_res_arg =
+ create_on_resolution_arg(grpc_channel_args_copy(results_upon_error));
+ on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg,
+ grpc_combiner_scheduler(combiner));
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
+ on_resolution);
+ // Set results_upon_error.
+ grpc_fake_resolver_response_generator_set_response_upon_error(
+ response_generator, results_upon_error);
+ // Flush here to guarantee that the response has been set.
+ grpc_core::ExecCtx::Get()->Flush();
+ // Trigger a re-resolution.
+ grpc_resolver_channel_saw_error_locked(resolver);
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
+ // Test 5: repeat re-resolution.
+ // next_results == NULL, results_upon_error != NULL, last_used_results !=
+ // NULL. Expected response is results_upon_error.
+ on_res_arg = create_on_resolution_arg(results_upon_error);
+ on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg,
+ grpc_combiner_scheduler(combiner));
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
+ on_resolution);
+ // Trigger a re-resolution.
+ grpc_resolver_channel_saw_error_locked(resolver);
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
+ // Test 6: normal resolution.
+ // next_results != NULL, results_upon_error != NULL, last_used_results !=
+ // NULL. Expected response is next_results.
+ results = create_new_resolver_result();
+ last_used_results = grpc_channel_args_copy(results);
+ on_res_arg = create_on_resolution_arg(results);
+ on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg,
+ grpc_combiner_scheduler(combiner));
+ // Resolution won't be triggered until next_results is set.
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
+ on_resolution);
grpc_fake_resolver_response_generator_set_response(response_generator,
- results_update);
- grpc_resolver_next_locked(resolver, &on_res_arg_update.resolver_result,
+ results);
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
+ // Test 7: fallback re-resolution.
+ // next_results == NULL, results_upon_error == NULL, last_used_results !=
+ // NULL. Expected response is last_used_results.
+ on_res_arg = create_on_resolution_arg(last_used_results);
+ on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg,
+ grpc_combiner_scheduler(combiner));
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
+ // Reset results_upon_error.
+ grpc_fake_resolver_response_generator_set_response_upon_error(
+ response_generator, nullptr);
+ // Flush here to guarantee that results_upon_error has been reset.
+ grpc_core::ExecCtx::Get()->Flush();
+ // Trigger a re-resolution.
+ grpc_resolver_channel_saw_error_locked(resolver);
grpc_core::ExecCtx::Get()->Flush();
- GPR_ASSERT(gpr_event_wait(&on_res_arg_update.ev,
+ GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
-
- // Requesting a new resolution without re-senting the response shouldn't
- // trigger the resolution callback.
+ // Test 8: no-op.
+ // Requesting a new resolution without setting the response shouldn't trigger
+ // the resolution callback.
memset(&on_res_arg, 0, sizeof(on_res_arg));
grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
@@ -157,10 +240,9 @@ static void test_fake_resolver() {
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
-
+ // Clean up.
GRPC_COMBINER_UNREF(combiner, "test_fake_resolver");
GRPC_RESOLVER_UNREF(resolver, "test_fake_resolver");
-
grpc_fake_resolver_response_generator_unref(response_generator);
}
diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc
index 1699d27142..b053c399a1 100644
--- a/test/core/compression/algorithm_test.cc
+++ b/test/core/compression/algorithm_test.cc
@@ -29,7 +29,7 @@
#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 message_prefix_length = 0;
const uint32_t stream_prefix_length = 7;
static void test_algorithm_mesh(void) {
int i;
diff --git a/test/core/compression/compression_test.cc b/test/core/compression/compression_test.cc
index e49a93a4b6..589d91bbba 100644
--- a/test/core/compression/compression_test.cc
+++ b/test/core/compression/compression_test.cc
@@ -28,11 +28,10 @@
static void test_compression_algorithm_parse(void) {
size_t i;
- const char* valid_names[] = {"identity", "message/gzip", "message/deflate",
- "stream/gzip"};
+ const char* valid_names[] = {"identity", "gzip", "deflate", "stream/gzip"};
const grpc_compression_algorithm valid_algorithms[] = {
- GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP,
- GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP};
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE,
+ GRPC_COMPRESS_STREAM_GZIP};
const char* invalid_names[] = {"gzip2", "foo", "", "2gzip"};
gpr_log(GPR_DEBUG, "test_compression_algorithm_parse");
@@ -61,11 +60,10 @@ static void test_compression_algorithm_name(void) {
int success;
const char* name;
size_t i;
- const char* valid_names[] = {"identity", "message/gzip", "message/deflate",
- "stream/gzip"};
+ const char* valid_names[] = {"identity", "gzip", "deflate", "stream/gzip"};
const grpc_compression_algorithm valid_algorithms[] = {
- GRPC_COMPRESS_NONE, GRPC_COMPRESS_MESSAGE_GZIP,
- GRPC_COMPRESS_MESSAGE_DEFLATE, GRPC_COMPRESS_STREAM_GZIP};
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE,
+ GRPC_COMPRESS_STREAM_GZIP};
gpr_log(GPR_DEBUG, "test_compression_algorithm_name");
@@ -110,21 +108,21 @@ 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_MESSAGE_GZIP);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ GPR_ASSERT(GRPC_COMPRESS_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ GPR_ASSERT(GRPC_COMPRESS_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ GPR_ASSERT(GRPC_COMPRESS_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
@@ -133,21 +131,21 @@ 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_MESSAGE_DEFLATE);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
@@ -156,22 +154,22 @@ 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_MESSAGE_GZIP);
- GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_MESSAGE_DEFLATE);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_GZIP ==
+ GPR_ASSERT(GRPC_COMPRESS_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
@@ -203,23 +201,23 @@ static void test_compression_algorithm_for_level(void) {
/* 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_GZIP);
+ GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_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 ==
+ GPR_ASSERT(GRPC_COMPRESS_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
- GPR_ASSERT(GRPC_COMPRESS_MESSAGE_DEFLATE ==
+ GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc
index 3625afefcd..5b9181586c 100644
--- a/test/core/end2end/fixtures/h2_compress.cc
+++ b/test/core/end2end/fixtures/h2_compress.cc
@@ -70,7 +70,7 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f,
grpc_channel_args_destroy(ffd->client_args_compression);
}
ffd->client_args_compression = grpc_channel_args_set_compression_algorithm(
- client_args, GRPC_COMPRESS_MESSAGE_GZIP);
+ client_args, GRPC_COMPRESS_GZIP);
f->client = grpc_insecure_channel_create(
ffd->localaddr, ffd->client_args_compression, nullptr);
}
@@ -84,7 +84,7 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f,
grpc_channel_args_destroy(ffd->server_args_compression);
}
ffd->server_args_compression = grpc_channel_args_set_compression_algorithm(
- server_args, GRPC_COMPRESS_MESSAGE_GZIP);
+ server_args, GRPC_COMPRESS_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 a87e49ee52..3ed82e19bd 100644
--- a/test/core/end2end/fuzzers/hpack.dictionary
+++ b/test/core/end2end/fuzzers/hpack.dictionary
@@ -28,15 +28,13 @@
"\x1Egrpc.max_request_message_bytes"
"\x1Fgrpc.max_response_message_bytes"
"$/grpc.lb.v1.LoadBalancer/BalanceLoad"
-"\x0Fmessage/deflate"
-"\x0Cmessage/gzip"
+"\x07deflate"
+"\x04gzip"
"\x0Bstream/gzip"
"\x010"
"\x011"
"\x012"
"\x08identity"
-"\x04gzip"
-"\x07deflate"
"\x08trailers"
"\x10application/grpc"
"\x04POST"
diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc
index c08653b1c8..944edc7a70 100644
--- a/test/core/end2end/tests/compressed_payload.cc
+++ b/test/core/end2end/tests/compressed_payload.cc
@@ -383,9 +383,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_MESSAGE_DEFLATE) != 0);
+ GRPC_COMPRESS_DEFLATE) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
- GRPC_COMPRESS_MESSAGE_GZIP) != 0);
+ GRPC_COMPRESS_GZIP) != 0);
memset(ops, 0, sizeof(ops));
op = ops;
@@ -550,9 +550,8 @@ 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_MESSAGE_GZIP,
- GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_NONE,
- GRPC_COMPRESS_MESSAGE_GZIP, nullptr, false,
+ GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, nullptr, false,
/* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
}
@@ -569,8 +568,8 @@ 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_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP,
- GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, nullptr, false,
+ GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
+ GRPC_COMPRESS_GZIP, nullptr, false,
/* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
}
@@ -578,8 +577,8 @@ 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_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP,
- GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP, nullptr, false,
+ GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
+ GRPC_COMPRESS_GZIP, nullptr, false,
/* ignored */ GRPC_COMPRESS_LEVEL_NONE, true);
}
@@ -597,8 +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("message/gzip");
+ gzip_compression_override.value = grpc_slice_from_static_string("gzip");
memset(&gzip_compression_override.internal_data, 0,
sizeof(gzip_compression_override.internal_data));
@@ -611,32 +609,31 @@ 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_MESSAGE_GZIP,
+ GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_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_MESSAGE_DEFLATE, GRPC_COMPRESS_NONE,
- GRPC_COMPRESS_MESSAGE_GZIP, GRPC_COMPRESS_NONE,
- &gzip_compression_override, false,
+ GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_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_MESSAGE_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
+ GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
GRPC_COMPRESS_NONE, &identity_compression_override, false,
/*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false);
}
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_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP,
- GRPC_STATUS_UNIMPLEMENTED, nullptr);
+ request_for_disabled_algorithm(config,
+ "test_invoke_request_with_disabled_algorithm",
+ 0, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
+ GRPC_STATUS_UNIMPLEMENTED, nullptr);
}
void compressed_payload(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc
index 9a384441f0..7fdea529f2 100644
--- a/test/core/end2end/tests/stream_compression_compressed_payload.cc
+++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc
@@ -390,9 +390,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_MESSAGE_DEFLATE) != 0);
+ GRPC_COMPRESS_DEFLATE) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
- GRPC_COMPRESS_MESSAGE_GZIP) != 0);
+ GRPC_COMPRESS_GZIP) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
GRPC_COMPRESS_STREAM_GZIP) != 0);
GPR_ASSERT(GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer(
diff --git a/test/core/end2end/tests/workaround_cronet_compression.cc b/test/core/end2end/tests/workaround_cronet_compression.cc
index 97ab814d27..d4decce0aa 100644
--- a/test/core/end2end/tests/workaround_cronet_compression.cc
+++ b/test/core/end2end/tests/workaround_cronet_compression.cc
@@ -207,9 +207,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_MESSAGE_DEFLATE) != 0);
+ GRPC_COMPRESS_DEFLATE) != 0);
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
- GRPC_COMPRESS_MESSAGE_GZIP) != 0);
+ GRPC_COMPRESS_GZIP) != 0);
memset(ops, 0, sizeof(ops));
op = ops;
@@ -365,16 +365,16 @@ typedef struct workaround_cronet_compression_config {
} workaround_cronet_compression_config;
static workaround_cronet_compression_config workaround_configs[] = {
- {nullptr, GRPC_COMPRESS_MESSAGE_GZIP},
+ {nullptr, GRPC_COMPRESS_GZIP},
{const_cast<char*>(
"grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; cronet_http; gentle)"),
GRPC_COMPRESS_NONE},
{const_cast<char*>(
"grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; chttp2; gentle)"),
- GRPC_COMPRESS_MESSAGE_GZIP},
+ GRPC_COMPRESS_GZIP},
{const_cast<char*>(
"grpc-objc/1.4.0 grpc-c/3.0.0-dev (ios; cronet_http; gentle)"),
- GRPC_COMPRESS_MESSAGE_GZIP}};
+ GRPC_COMPRESS_GZIP}};
static const size_t workaround_configs_num =
sizeof(workaround_configs) / sizeof(*workaround_configs);
@@ -383,8 +383,7 @@ 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_MESSAGE_GZIP, GRPC_COMPRESS_MESSAGE_GZIP,
- GRPC_COMPRESS_MESSAGE_GZIP,
+ GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
workaround_configs[i].expected_algorithm_from_server, nullptr, false,
/* ignored */ GRPC_COMPRESS_LEVEL_NONE,
workaround_configs[i].user_agent_override);
diff --git a/test/core/gprpp/orphanable_test.cc b/test/core/gprpp/orphanable_test.cc
index ff2f6d8bc2..ad6b9ac867 100644
--- a/test/core/gprpp/orphanable_test.cc
+++ b/test/core/gprpp/orphanable_test.cc
@@ -58,18 +58,19 @@ TEST(MakeOrphanable, WithParameters) {
EXPECT_EQ(5, foo->value());
}
-class Bar : public InternallyRefCounted {
+class Bar : public InternallyRefCounted<Bar> {
public:
Bar() : Bar(0) {}
explicit Bar(int value) : value_(value) {}
void Orphan() override { Unref(); }
int value() const { return value_; }
- void StartWork() { Ref(); }
- void FinishWork() { Unref(); }
+ void StartWork() { self_ref_ = Ref(); }
+ void FinishWork() { self_ref_.reset(); }
private:
int value_;
+ RefCountedPtr<Bar> self_ref_;
};
TEST(OrphanablePtr, InternallyRefCounted) {
@@ -82,19 +83,24 @@ TEST(OrphanablePtr, InternallyRefCounted) {
// things build properly in both debug and non-debug cases.
DebugOnlyTraceFlag baz_tracer(true, "baz");
-class Baz : public InternallyRefCountedWithTracing {
+class Baz : public InternallyRefCountedWithTracing<Baz> {
public:
Baz() : Baz(0) {}
explicit Baz(int value)
- : InternallyRefCountedWithTracing(&baz_tracer), value_(value) {}
+ : InternallyRefCountedWithTracing<Baz>(&baz_tracer), value_(value) {}
void Orphan() override { Unref(); }
int value() const { return value_; }
- void StartWork() { Ref(DEBUG_LOCATION, "work"); }
- void FinishWork() { Unref(DEBUG_LOCATION, "work"); }
+ void StartWork() { self_ref_ = Ref(DEBUG_LOCATION, "work"); }
+ void FinishWork() {
+ // This is a little ugly, but it makes the logged ref and unref match up.
+ self_ref_.release();
+ Unref(DEBUG_LOCATION, "work");
+ }
private:
int value_;
+ RefCountedPtr<Baz> self_ref_;
};
TEST(OrphanablePtr, InternallyRefCountedWithTracing) {
diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc
index f1f13f3183..2e398a7722 100644
--- a/test/core/gprpp/ref_counted_ptr_test.cc
+++ b/test/core/gprpp/ref_counted_ptr_test.cc
@@ -30,7 +30,7 @@ namespace grpc_core {
namespace testing {
namespace {
-class Foo : public RefCounted {
+class Foo : public RefCounted<Foo> {
public:
Foo() : value_(0) {}
@@ -163,14 +163,15 @@ TEST(MakeRefCounted, Args) {
TraceFlag foo_tracer(true, "foo");
-class FooWithTracing : public RefCountedWithTracing {
+class FooWithTracing : public RefCountedWithTracing<FooWithTracing> {
public:
FooWithTracing() : RefCountedWithTracing(&foo_tracer) {}
};
TEST(RefCountedPtr, RefCountedWithTracing) {
RefCountedPtr<FooWithTracing> foo(New<FooWithTracing>());
- foo->Ref(DEBUG_LOCATION, "foo");
+ RefCountedPtr<FooWithTracing> foo2 = foo->Ref(DEBUG_LOCATION, "foo");
+ foo2.release();
foo->Unref(DEBUG_LOCATION, "foo");
}
diff --git a/test/core/gprpp/ref_counted_test.cc b/test/core/gprpp/ref_counted_test.cc
index b1b0fee5c0..f85a2e4675 100644
--- a/test/core/gprpp/ref_counted_test.cc
+++ b/test/core/gprpp/ref_counted_test.cc
@@ -27,7 +27,7 @@ namespace grpc_core {
namespace testing {
namespace {
-class Foo : public RefCounted {
+class Foo : public RefCounted<Foo> {
public:
Foo() {}
};
@@ -39,7 +39,8 @@ TEST(RefCounted, Basic) {
TEST(RefCounted, ExtraRef) {
Foo* foo = New<Foo>();
- foo->Ref();
+ RefCountedPtr<Foo> foop = foo->Ref();
+ foop.release();
foo->Unref();
foo->Unref();
}
@@ -48,17 +49,19 @@ TEST(RefCounted, ExtraRef) {
// things build properly in both debug and non-debug cases.
DebugOnlyTraceFlag foo_tracer(true, "foo");
-class FooWithTracing : public RefCountedWithTracing {
+class FooWithTracing : public RefCountedWithTracing<FooWithTracing> {
public:
FooWithTracing() : RefCountedWithTracing(&foo_tracer) {}
};
TEST(RefCountedWithTracing, Basic) {
FooWithTracing* foo = New<FooWithTracing>();
- foo->Ref(DEBUG_LOCATION, "extra_ref");
+ RefCountedPtr<FooWithTracing> foop = foo->Ref(DEBUG_LOCATION, "extra_ref");
+ foop.release();
foo->Unref(DEBUG_LOCATION, "extra_ref");
// Can use the no-argument methods, too.
- foo->Ref();
+ foop = foo->Ref();
+ foop.release();
foo->Unref();
foo->Unref(DEBUG_LOCATION, "original_ref");
}
diff --git a/test/core/http/BUILD b/test/core/http/BUILD
index 03b8f4edfe..be51ea0737 100644
--- a/test/core/http/BUILD
+++ b/test/core/http/BUILD
@@ -113,3 +113,16 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
],
)
+
+grpc_cc_test(
+ name = "format_request_test",
+ srcs = ["format_request_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/end2end:ssl_test_data",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
diff --git a/test/core/surface/byte_buffer_reader_test.cc b/test/core/surface/byte_buffer_reader_test.cc
index 91662b027a..648a9d6986 100644
--- a/test/core/surface/byte_buffer_reader_test.cc
+++ b/test/core/surface/byte_buffer_reader_test.cc
@@ -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_MESSAGE_GZIP; /* lies! */
+ buffer->data.raw.compression = GRPC_COMPRESS_GZIP; /* lies! */
grpc_slice_unref(slice);
GPR_ASSERT(!grpc_byte_buffer_reader_init(&reader, buffer));
grpc_byte_buffer_destroy(buffer);
@@ -161,13 +161,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_MESSAGE_GZIP, INPUT_SIZE);
+ read_compressed_slice(GRPC_COMPRESS_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_MESSAGE_DEFLATE, INPUT_SIZE);
+ read_compressed_slice(GRPC_COMPRESS_DEFLATE, INPUT_SIZE);
}
static void test_byte_buffer_from_reader(void) {
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index 91554fe2a3..d6e4afda57 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -20,7 +20,6 @@
#include <grpc/byte_buffer_reader.h>
#include <grpc/census.h>
#include <grpc/compression.h>
-#include <grpc/compression_ruby.h>
#include <grpc/fork.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
@@ -74,8 +73,6 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) grpc_compression_options_enable_algorithm);
printf("%lx", (unsigned long) grpc_compression_options_disable_algorithm);
printf("%lx", (unsigned long) grpc_compression_options_is_algorithm_enabled);
- printf("%lx", (unsigned long) grpc_compression_algorithm_parse_ruby);
- printf("%lx", (unsigned long) grpc_compression_algorithm_name_ruby);
printf("%lx", (unsigned long) grpc_metadata_array_init);
printf("%lx", (unsigned long) grpc_metadata_array_destroy);
printf("%lx", (unsigned long) grpc_call_details_init);