aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/.clang-tidy6
-rw-r--r--test/build/no-c++14-compat.cc (renamed from test/core/statistics/small_log_test.cc)14
-rw-r--r--test/build/no-maybe-uninitialized.c (renamed from test/core/statistics/performance_test.cc)14
-rw-r--r--test/build/no-unused-but-set-variable.c (renamed from test/core/statistics/multiple_writers_test.cc)14
-rw-r--r--test/build/openssl-npn.c30
-rw-r--r--test/core/avl/avl_test.cc3361
-rw-r--r--test/core/bad_client/bad_client.cc2
-rw-r--r--test/core/bad_ssl/bad_ssl_test.cc2
-rw-r--r--test/core/channel/BUILD34
-rw-r--r--test/core/channel/channel_args_test.cc84
-rw-r--r--test/core/channel/channel_stack_test.cc2
-rw-r--r--test/core/channel/channel_trace_test.cc224
-rw-r--r--test/core/channel/channelz_registry_test.cc109
-rw-r--r--test/core/channel/channelz_test.cc379
-rw-r--r--test/core/client_channel/parse_address_test.cc14
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc8
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc133
-rw-r--r--test/core/client_channel/resolvers/fake_resolver_test.cc58
-rw-r--r--test/core/debug/stats_test.cc5
-rw-r--r--test/core/end2end/BUILD13
-rw-r--r--test/core/end2end/bad_server_response_test.cc2
-rw-r--r--test/core/end2end/end2end_nosec_tests.cc24
-rwxr-xr-xtest/core/end2end/end2end_test.sh2
-rw-r--r--test/core/end2end/end2end_tests.cc24
-rw-r--r--test/core/end2end/fixtures/h2_load_reporting.cc120
-rw-r--r--test/core/end2end/fixtures/h2_local.cc154
-rw-r--r--test/core/end2end/fixtures/h2_oauth2.cc2
-rw-r--r--test/core/end2end/fixtures/h2_ssl.cc2
-rw-r--r--test/core/end2end/fixtures/h2_ssl_proxy.cc4
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc28
-rw-r--r--test/core/end2end/fixtures/proxy.cc17
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.cc17
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.cc26
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py14
-rwxr-xr-xtest/core/end2end/generate_tests.bzl566
-rw-r--r--test/core/end2end/goaway_server_test.cc20
-rw-r--r--test/core/end2end/h2_ssl_cert_test.cc4
-rw-r--r--test/core/end2end/h2_ssl_session_reuse_test.cc2
-rw-r--r--test/core/end2end/inproc_callback_test.cc507
-rw-r--r--test/core/end2end/tests/channelz.cc326
-rw-r--r--test/core/end2end/tests/filter_status_code.cc26
-rw-r--r--test/core/end2end/tests/no_error_on_hotpath.cc246
-rw-r--r--test/core/end2end/tests/retry_server_pushback_delay.cc2
-rw-r--r--test/core/end2end/tests/simple_request.cc2
-rw-r--r--test/core/gpr/BUILD1
-rw-r--r--test/core/gpr/arena_test.cc2
-rw-r--r--test/core/gprpp/BUILD10
-rw-r--r--test/core/gprpp/fork_test.cc139
-rw-r--r--test/core/gprpp/inlined_vector_test.cc194
-rw-r--r--test/core/gprpp/ref_counted_ptr_test.cc67
-rw-r--r--test/core/handshake/BUILD18
-rw-r--r--test/core/handshake/client_ssl.cc4
-rw-r--r--test/core/handshake/verify_peer_options.cc275
-rw-r--r--test/core/http/httpcli_test.cc3
-rw-r--r--test/core/http/httpscli_test.cc3
-rw-r--r--test/core/iomgr/BUILD53
-rw-r--r--test/core/iomgr/buffer_list_test.cc111
-rw-r--r--test/core/iomgr/endpoint_tests.cc7
-rw-r--r--test/core/iomgr/error_test.cc11
-rw-r--r--test/core/iomgr/ev_epollex_linux_test.cc115
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.cc323
-rw-r--r--test/core/iomgr/fd_posix_test.cc16
-rw-r--r--test/core/iomgr/grpc_ipv6_loopback_available_test.cc (renamed from test/core/statistics/quick_test.cc)35
-rw-r--r--test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm201
-rw-r--r--test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm344
-rw-r--r--test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj338
-rw-r--r--test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests.xcscheme56
-rw-r--r--test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Asan.xcscheme61
-rw-r--r--test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Msan.xcscheme78
-rw-r--r--test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Tsan.xcscheme60
-rw-r--r--test/core/iomgr/ios/CFStreamTests/Info.plist22
-rw-r--r--test/core/iomgr/ios/CFStreamTests/Podfile51
-rwxr-xr-xtest/core/iomgr/ios/CFStreamTests/build_tests.sh39
-rwxr-xr-xtest/core/iomgr/ios/CFStreamTests/run_tests.sh67
-rw-r--r--test/core/iomgr/pollset_set_test.cc448
-rw-r--r--test/core/iomgr/resolve_address_posix_test.cc2
-rw-r--r--test/core/iomgr/resolve_address_test.cc42
-rw-r--r--test/core/iomgr/resource_quota_test.cc97
-rw-r--r--test/core/iomgr/tcp_posix_test.cc125
-rw-r--r--test/core/iomgr/timer_heap_test.cc2
-rw-r--r--test/core/iomgr/timer_list_test.cc111
-rw-r--r--test/core/security/BUILD29
-rw-r--r--test/core/security/check_gcp_environment_linux_test.cc3
-rw-r--r--test/core/security/check_gcp_environment_windows_test.cc2
-rw-r--r--test/core/security/credentials_test.cc66
-rw-r--r--[-rwxr-xr-x]test/core/security/etc/BUILD (renamed from test/cpp/naming/create_private_dns_zone.sh)21
-rw-r--r--test/core/security/etc/README2
-rw-r--r--test/core/security/etc/bundle.pem63
-rw-r--r--test/core/security/etc/test_roots/cert1.pem21
-rw-r--r--test/core/security/etc/test_roots/cert2.pem21
-rw-r--r--test/core/security/etc/test_roots/cert3.pem21
-rw-r--r--test/core/security/linux_system_roots_test.cc98
-rw-r--r--test/core/security/security_connector_test.cc13
-rw-r--r--test/core/statistics/census_log_tests.h36
-rw-r--r--test/core/statistics/census_stub_test.cc62
-rw-r--r--test/core/statistics/rpc_stats_test.cc183
-rw-r--r--test/core/surface/completion_queue_test.cc87
-rw-r--r--test/core/surface/num_external_connectivity_watchers_test.cc2
-rw-r--r--test/core/surface/public_headers_must_be_c89.c28
-rw-r--r--test/core/surface/sequential_connectivity_test.cc2
-rw-r--r--test/core/transport/BUILD1
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.cc25
-rw-r--r--test/core/transport/metadata_test.cc5
-rw-r--r--test/core/transport/status_conversion_test.cc25
-rw-r--r--test/core/transport/timeout_encoding_test.cc2
-rw-r--r--test/core/tsi/alts/crypt/BUILD1
-rw-r--r--test/core/tsi/alts/fake_handshaker/BUILD5
-rw-r--r--test/core/tsi/alts/fake_handshaker/fake_handshaker_server.cc31
-rw-r--r--test/core/tsi/alts/fake_handshaker/fake_handshaker_server.h (renamed from test/core/statistics/multiple_writers_circular_buffer_test.cc)20
-rw-r--r--test/core/tsi/alts/fake_handshaker/fake_handshaker_server_main.cc53
-rw-r--r--test/core/tsi/alts/frame_protector/BUILD4
-rw-r--r--test/core/tsi/alts/handshaker/BUILD5
-rw-r--r--test/core/tsi/alts/zero_copy_frame_protector/BUILD3
-rw-r--r--test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc26
-rw-r--r--test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc41
-rw-r--r--test/core/tsi/ssl_transport_security_test.cc6
-rw-r--r--test/core/util/BUILD5
-rw-r--r--test/core/util/lsan_suppressions.txt6
-rw-r--r--test/core/util/mock_endpoint.cc2
-rw-r--r--test/core/util/passthru_endpoint.cc2
-rw-r--r--test/core/util/port_isolated_runtime_environment.cc31
-rw-r--r--test/core/util/trickle_endpoint.cc5
-rw-r--r--test/core/util/tsan_suppressions.txt13
-rw-r--r--test/core/util/ubsan_suppressions.txt17
-rw-r--r--test/cpp/client/BUILD1
-rw-r--r--test/cpp/codegen/compiler_test_golden177
-rw-r--r--test/cpp/codegen/golden_file_test.cc4
-rw-r--r--test/cpp/common/alarm_test.cc106
-rw-r--r--test/cpp/end2end/BUILD76
-rw-r--r--test/cpp/end2end/async_end2end_test.cc41
-rw-r--r--test/cpp/end2end/channelz_service_test.cc458
-rw-r--r--test/cpp/end2end/client_callback_end2end_test.cc241
-rw-r--r--test/cpp/end2end/client_lb_end2end_test.cc283
-rw-r--r--test/cpp/end2end/end2end_test.cc14
-rw-r--r--test/cpp/end2end/grpclb_end2end_test.cc21
-rw-r--r--test/cpp/end2end/hybrid_end2end_test.cc100
-rw-r--r--test/cpp/end2end/mock_test.cc2
-rw-r--r--test/cpp/end2end/raw_end2end_test.cc370
-rw-r--r--test/cpp/end2end/round_robin_end2end_test.cc226
-rw-r--r--test/cpp/end2end/server_load_reporting_end2end_test.cc191
-rw-r--r--test/cpp/end2end/thread_stress_test.cc118
-rw-r--r--test/cpp/ext/filters/census/BUILD42
-rw-r--r--test/cpp/ext/filters/census/stats_plugin_end2end_test.cc376
-rw-r--r--test/cpp/interop/client.cc22
-rw-r--r--test/cpp/interop/client_helper.cc20
-rw-r--r--test/cpp/interop/http2_client.cc11
-rw-r--r--test/cpp/interop/http2_client.h6
-rw-r--r--test/cpp/interop/interop_client.cc94
-rw-r--r--test/cpp/interop/interop_client.h27
-rw-r--r--test/cpp/interop/interop_server.cc8
-rw-r--r--test/cpp/interop/server_helper.h8
-rw-r--r--test/cpp/interop/stress_interop_client.cc9
-rw-r--r--test/cpp/interop/stress_interop_client.h6
-rw-r--r--test/cpp/interop/stress_test.cc11
-rw-r--r--test/cpp/microbenchmarks/BUILD27
-rw-r--r--test/cpp/microbenchmarks/bm_call_create.cc35
-rw-r--r--test/cpp/microbenchmarks/bm_channel.cc90
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc76
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_transport.cc2
-rw-r--r--test/cpp/microbenchmarks/bm_closure.cc2
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc83
-rw-r--r--test/cpp/microbenchmarks/bm_opencensus_plugin.cc118
-rw-r--r--test/cpp/microbenchmarks/bm_pollset.cc8
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h1
-rw-r--r--test/cpp/microbenchmarks/helpers.cc2
-rw-r--r--test/cpp/microbenchmarks/helpers.h1
-rw-r--r--test/cpp/naming/BUILD18
-rw-r--r--test/cpp/naming/README.md43
-rw-r--r--test/cpp/naming/address_sorting_test.cc208
-rw-r--r--test/cpp/naming/cancel_ares_query_test.cc360
-rwxr-xr-xtest/cpp/naming/gen_build_yaml.py114
-rw-r--r--test/cpp/naming/manual_run_resolver_component_test.py36
-rwxr-xr-xtest/cpp/naming/private_dns_zone_init.sh215
-rw-r--r--test/cpp/naming/resolver_component_test.cc194
-rwxr-xr-xtest/cpp/naming/resolver_component_tests_runner.py31
-rw-r--r--test/cpp/naming/resolver_component_tests_runner_invoker.cc26
-rwxr-xr-xtest/cpp/naming/resolver_gce_integration_tests_runner.sh359
-rw-r--r--test/cpp/naming/resolver_test_record_groups.yaml8
-rw-r--r--test/cpp/qps/BUILD60
-rw-r--r--test/cpp/qps/benchmark_config.cc15
-rw-r--r--test/cpp/qps/client.h71
-rw-r--r--test/cpp/qps/client_async.cc43
-rw-r--r--test/cpp/qps/client_sync.cc4
-rw-r--r--test/cpp/qps/driver.cc35
-rw-r--r--test/cpp/qps/driver.h3
-rwxr-xr-xtest/cpp/qps/gen_build_yaml.py123
-rw-r--r--test/cpp/qps/histogram.h5
-rw-r--r--test/cpp/qps/inproc_sync_unary_ping_pong_test.cc2
-rwxr-xr-xtest/cpp/qps/json_run_localhost_scenario_gen.py39
-rw-r--r--test/cpp/qps/json_run_localhost_scenarios.bzl3
-rw-r--r--test/cpp/qps/qps_benchmark_script.bzl80
-rw-r--r--test/cpp/qps/qps_interarrival_test.cc3
-rw-r--r--test/cpp/qps/qps_json_driver.cc19
-rwxr-xr-xtest/cpp/qps/qps_json_driver_scenario_gen.py39
-rw-r--r--test/cpp/qps/qps_json_driver_scenarios.bzl3
-rw-r--r--test/cpp/qps/qps_openloop_test.cc2
-rw-r--r--test/cpp/qps/qps_server_builder.cc45
-rw-r--r--test/cpp/qps/qps_server_builder.h46
-rw-r--r--test/cpp/qps/qps_worker.cc9
-rw-r--r--test/cpp/qps/report.h2
-rw-r--r--test/cpp/qps/secure_sync_unary_ping_pong_test.cc2
-rw-r--r--test/cpp/qps/server_async.cc15
-rw-r--r--test/cpp/qps/server_sync.cc15
-rw-r--r--test/cpp/server/load_reporter/BUILD35
-rw-r--r--test/cpp/server/load_reporter/get_cpu_stats_test.cc61
-rw-r--r--test/cpp/server/load_reporter/load_data_store_test.cc14
-rw-r--r--test/cpp/server/load_reporter/load_reporter_test.cc507
-rw-r--r--test/cpp/thread_manager/thread_manager_test.cc153
-rw-r--r--test/cpp/util/BUILD21
-rw-r--r--test/cpp/util/byte_buffer_proto_helper.cc13
-rw-r--r--test/cpp/util/byte_buffer_proto_helper.h3
-rw-r--r--test/cpp/util/byte_buffer_test.cc7
-rw-r--r--test/cpp/util/channel_trace_proto_helper.cc63
-rw-r--r--test/cpp/util/channel_trace_proto_helper.h8
-rw-r--r--test/cpp/util/cli_call.cc5
-rw-r--r--test/cpp/util/cli_call.h3
-rw-r--r--test/cpp/util/cli_credentials.cc202
-rw-r--r--test/cpp/util/cli_credentials.h19
-rw-r--r--test/cpp/util/grpc_tool.cc45
-rw-r--r--test/cpp/util/grpc_tool_test.cc55
-rw-r--r--test/cpp/util/proto_file_parser.cc2
-rw-r--r--test/cpp/util/proto_file_parser.h2
-rw-r--r--test/cpp/util/proto_reflection_descriptor_database.cc14
-rw-r--r--test/cpp/util/proto_reflection_descriptor_database.h2
-rw-r--r--test/cpp/util/string_ref_test.cc2
-rw-r--r--test/cpp/util/test_credentials_provider.cc2
-rw-r--r--test/cpp/util/test_credentials_provider.h1
-rw-r--r--test/distrib/cpp/run_distrib_test_cmake.bat2
-rwxr-xr-xtest/distrib/cpp/run_distrib_test_routeguide.sh2
-rw-r--r--test/distrib/csharp/DistribTest/packages.config1
-rwxr-xr-xtest/distrib/csharp/run_distrib_test.sh6
-rwxr-xr-xtest/distrib/csharp/test_codegen/test_codegen.sh38
-rw-r--r--test/distrib/csharp/test_codegen/testcodegen.proto29
-rwxr-xr-xtest/distrib/csharp/update_version.sh2
-rwxr-xr-xtest/distrib/python/test_packages.sh16
235 files changed, 11419 insertions, 6993 deletions
diff --git a/test/.clang-tidy b/test/.clang-tidy
new file mode 100644
index 0000000000..f951ee5fea
--- /dev/null
+++ b/test/.clang-tidy
@@ -0,0 +1,6 @@
+---
+Checks: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size,performance-*,-performance-unnecessary-copy-initialization'
+WarningsAsErrors: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size,performance-*,-performance-unnecessary-copy-initialization'
+CheckOptions:
+ - key: readability-function-size.StatementThreshold
+ value: '450'
diff --git a/test/core/statistics/small_log_test.cc b/test/build/no-c++14-compat.cc
index fb8dfc9988..0c1771c7bb 100644
--- a/test/core/statistics/small_log_test.cc
+++ b/test/build/no-c++14-compat.cc
@@ -16,16 +16,4 @@
*
*/
-#include "test/core/statistics/census_log_tests.h"
-
-#include <stdlib.h>
-
-#include <grpc/support/time.h>
-#include "test/core/util/test_config.h"
-
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
- test_small_log();
- return 0;
-}
+int main(void) {}
diff --git a/test/core/statistics/performance_test.cc b/test/build/no-maybe-uninitialized.c
index 9d4fd6ef90..0c1771c7bb 100644
--- a/test/core/statistics/performance_test.cc
+++ b/test/build/no-maybe-uninitialized.c
@@ -16,16 +16,4 @@
*
*/
-#include "test/core/statistics/census_log_tests.h"
-
-#include <stdlib.h>
-
-#include <grpc/support/time.h>
-#include "test/core/util/test_config.h"
-
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
- test_performance();
- return 0;
-}
+int main(void) {}
diff --git a/test/core/statistics/multiple_writers_test.cc b/test/build/no-unused-but-set-variable.c
index 47410ab105..0c1771c7bb 100644
--- a/test/core/statistics/multiple_writers_test.cc
+++ b/test/build/no-unused-but-set-variable.c
@@ -16,16 +16,4 @@
*
*/
-#include "test/core/statistics/census_log_tests.h"
-
-#include <stdlib.h>
-
-#include <grpc/support/time.h>
-#include "test/core/util/test_config.h"
-
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
- test_multiple_writers();
- return 0;
-}
+int main(void) {}
diff --git a/test/build/openssl-npn.c b/test/build/openssl-npn.c
deleted file mode 100644
index 9c71382720..0000000000
--- a/test/build/openssl-npn.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *
- * Copyright 2015 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.
- *
- */
-
-/* This is just a compilation test, to see if we have a version of OpenSSL with
- NPN support installed. It's not meant to be run, and all of the values and
- function calls there are non-sensical. The code is only meant to test the
- presence of symbols, and we're expecting a compilation failure otherwise. */
-
-#include <stdlib.h>
-#include <openssl/ssl.h>
-
-int main() {
- SSL_get0_next_proto_negotiated(NULL, NULL, NULL);
- return OPENSSL_NPN_UNSUPPORTED;
-}
diff --git a/test/core/avl/avl_test.cc b/test/core/avl/avl_test.cc
index ecebe833b3..01002fec72 100644
--- a/test/core/avl/avl_test.cc
+++ b/test/core/avl/avl_test.cc
@@ -241,3365 +241,6 @@ static void test_badcase1(void) {
grpc_avl_unref(avl, nullptr);
}
-static void test_badcase2(void) {
- grpc_avl avl;
-
- gpr_log(GPR_DEBUG, "test_badcase2");
-
- avl = grpc_avl_create(&int_int_vtable);
- avl = grpc_avl_add(avl, box(288), box(1), nullptr);
- avl = remove_int(avl, 415);
- avl = grpc_avl_add(avl, box(953), box(3), nullptr);
- avl = grpc_avl_add(avl, box(101), box(4), nullptr);
- avl = grpc_avl_add(avl, box(516), box(5), nullptr);
- avl = grpc_avl_add(avl, box(547), box(6), nullptr);
- avl = grpc_avl_add(avl, box(467), box(7), nullptr);
- avl = grpc_avl_add(avl, box(793), box(8), nullptr);
- avl = remove_int(avl, 190);
- avl = grpc_avl_add(avl, box(687), box(10), nullptr);
- avl = grpc_avl_add(avl, box(242), box(11), nullptr);
- avl = grpc_avl_add(avl, box(142), box(12), nullptr);
- avl = remove_int(avl, 705);
- avl = remove_int(avl, 578);
- avl = remove_int(avl, 767);
- avl = remove_int(avl, 183);
- avl = grpc_avl_add(avl, box(950), box(17), nullptr);
- avl = grpc_avl_add(avl, box(622), box(18), nullptr);
- avl = remove_int(avl, 513);
- avl = remove_int(avl, 429);
- avl = grpc_avl_add(avl, box(205), box(21), nullptr);
- avl = remove_int(avl, 663);
- avl = remove_int(avl, 953);
- avl = remove_int(avl, 892);
- avl = grpc_avl_add(avl, box(236), box(25), nullptr);
- avl = remove_int(avl, 982);
- avl = remove_int(avl, 201);
- avl = remove_int(avl, 684);
- avl = grpc_avl_add(avl, box(572), box(29), nullptr);
- avl = remove_int(avl, 817);
- avl = grpc_avl_add(avl, box(970), box(31), nullptr);
- avl = remove_int(avl, 347);
- avl = remove_int(avl, 574);
- avl = grpc_avl_add(avl, box(752), box(34), nullptr);
- avl = grpc_avl_add(avl, box(670), box(35), nullptr);
- avl = grpc_avl_add(avl, box(69), box(36), nullptr);
- avl = remove_int(avl, 111);
- avl = remove_int(avl, 523);
- avl = grpc_avl_add(avl, box(141), box(39), nullptr);
- avl = remove_int(avl, 159);
- avl = grpc_avl_add(avl, box(947), box(41), nullptr);
- avl = grpc_avl_add(avl, box(855), box(42), nullptr);
- avl = remove_int(avl, 218);
- avl = remove_int(avl, 6);
- avl = grpc_avl_add(avl, box(753), box(45), nullptr);
- avl = remove_int(avl, 82);
- avl = remove_int(avl, 799);
- avl = grpc_avl_add(avl, box(572), box(48), nullptr);
- avl = remove_int(avl, 376);
- avl = remove_int(avl, 413);
- avl = grpc_avl_add(avl, box(458), box(51), nullptr);
- avl = remove_int(avl, 897);
- avl = grpc_avl_add(avl, box(191), box(53), nullptr);
- avl = grpc_avl_add(avl, box(609), box(54), nullptr);
- avl = remove_int(avl, 787);
- avl = remove_int(avl, 710);
- avl = remove_int(avl, 886);
- avl = remove_int(avl, 835);
- avl = remove_int(avl, 33);
- avl = grpc_avl_add(avl, box(871), box(60), nullptr);
- avl = remove_int(avl, 641);
- avl = grpc_avl_add(avl, box(462), box(62), nullptr);
- avl = remove_int(avl, 359);
- avl = remove_int(avl, 767);
- avl = grpc_avl_add(avl, box(310), box(65), nullptr);
- avl = remove_int(avl, 757);
- avl = remove_int(avl, 639);
- avl = remove_int(avl, 314);
- avl = grpc_avl_add(avl, box(2), box(69), nullptr);
- avl = remove_int(avl, 138);
- avl = grpc_avl_add(avl, box(669), box(71), nullptr);
- avl = remove_int(avl, 477);
- avl = grpc_avl_add(avl, box(366), box(73), nullptr);
- avl = grpc_avl_add(avl, box(612), box(74), nullptr);
- avl = grpc_avl_add(avl, box(106), box(75), nullptr);
- avl = remove_int(avl, 161);
- avl = grpc_avl_add(avl, box(388), box(77), nullptr);
- avl = grpc_avl_add(avl, box(141), box(78), nullptr);
- avl = remove_int(avl, 633);
- avl = remove_int(avl, 459);
- avl = grpc_avl_add(avl, box(40), box(81), nullptr);
- avl = remove_int(avl, 689);
- avl = grpc_avl_add(avl, box(823), box(83), nullptr);
- avl = remove_int(avl, 485);
- avl = grpc_avl_add(avl, box(903), box(85), nullptr);
- avl = grpc_avl_add(avl, box(592), box(86), nullptr);
- avl = remove_int(avl, 448);
- avl = grpc_avl_add(avl, box(56), box(88), nullptr);
- avl = remove_int(avl, 333);
- avl = grpc_avl_add(avl, box(189), box(90), nullptr);
- avl = grpc_avl_add(avl, box(103), box(91), nullptr);
- avl = remove_int(avl, 164);
- avl = remove_int(avl, 974);
- avl = grpc_avl_add(avl, box(215), box(94), nullptr);
- avl = remove_int(avl, 189);
- avl = remove_int(avl, 504);
- avl = grpc_avl_add(avl, box(868), box(97), nullptr);
- avl = remove_int(avl, 909);
- avl = remove_int(avl, 148);
- avl = remove_int(avl, 469);
- avl = grpc_avl_add(avl, box(994), box(101), nullptr);
- avl = grpc_avl_add(avl, box(576), box(102), nullptr);
- avl = remove_int(avl, 82);
- avl = remove_int(avl, 209);
- avl = grpc_avl_add(avl, box(276), box(105), nullptr);
- avl = remove_int(avl, 856);
- avl = grpc_avl_add(avl, box(750), box(107), nullptr);
- avl = remove_int(avl, 871);
- avl = grpc_avl_add(avl, box(301), box(109), nullptr);
- avl = remove_int(avl, 260);
- avl = remove_int(avl, 737);
- avl = remove_int(avl, 719);
- avl = grpc_avl_add(avl, box(933), box(113), nullptr);
- avl = grpc_avl_add(avl, box(225), box(114), nullptr);
- avl = grpc_avl_add(avl, box(975), box(115), nullptr);
- avl = grpc_avl_add(avl, box(86), box(116), nullptr);
- avl = remove_int(avl, 732);
- avl = grpc_avl_add(avl, box(340), box(118), nullptr);
- avl = grpc_avl_add(avl, box(271), box(119), nullptr);
- avl = remove_int(avl, 206);
- avl = grpc_avl_add(avl, box(949), box(121), nullptr);
- avl = grpc_avl_add(avl, box(927), box(122), nullptr);
- avl = grpc_avl_add(avl, box(34), box(123), nullptr);
- avl = grpc_avl_add(avl, box(351), box(124), nullptr);
- avl = remove_int(avl, 836);
- avl = grpc_avl_add(avl, box(825), box(126), nullptr);
- avl = grpc_avl_add(avl, box(352), box(127), nullptr);
- avl = remove_int(avl, 107);
- avl = remove_int(avl, 101);
- avl = grpc_avl_add(avl, box(320), box(130), nullptr);
- avl = grpc_avl_add(avl, box(3), box(131), nullptr);
- avl = remove_int(avl, 998);
- avl = remove_int(avl, 44);
- avl = grpc_avl_add(avl, box(525), box(134), nullptr);
- avl = grpc_avl_add(avl, box(864), box(135), nullptr);
- avl = grpc_avl_add(avl, box(863), box(136), nullptr);
- avl = remove_int(avl, 770);
- avl = grpc_avl_add(avl, box(440), box(138), nullptr);
- avl = remove_int(avl, 516);
- avl = grpc_avl_add(avl, box(116), box(140), nullptr);
- avl = remove_int(avl, 380);
- avl = grpc_avl_add(avl, box(878), box(142), nullptr);
- avl = remove_int(avl, 439);
- avl = grpc_avl_add(avl, box(994), box(144), nullptr);
- avl = remove_int(avl, 294);
- avl = remove_int(avl, 593);
- avl = grpc_avl_add(avl, box(696), box(147), nullptr);
- avl = remove_int(avl, 8);
- avl = grpc_avl_add(avl, box(881), box(149), nullptr);
- avl = remove_int(avl, 32);
- avl = remove_int(avl, 242);
- avl = grpc_avl_add(avl, box(487), box(152), nullptr);
- avl = grpc_avl_add(avl, box(637), box(153), nullptr);
- avl = grpc_avl_add(avl, box(793), box(154), nullptr);
- avl = grpc_avl_add(avl, box(696), box(155), nullptr);
- avl = remove_int(avl, 458);
- avl = grpc_avl_add(avl, box(828), box(157), nullptr);
- avl = remove_int(avl, 784);
- avl = remove_int(avl, 274);
- avl = grpc_avl_add(avl, box(783), box(160), nullptr);
- avl = remove_int(avl, 21);
- avl = grpc_avl_add(avl, box(866), box(162), nullptr);
- avl = remove_int(avl, 919);
- avl = grpc_avl_add(avl, box(435), box(164), nullptr);
- avl = remove_int(avl, 385);
- avl = grpc_avl_add(avl, box(475), box(166), nullptr);
- avl = remove_int(avl, 339);
- avl = grpc_avl_add(avl, box(615), box(168), nullptr);
- avl = remove_int(avl, 866);
- avl = remove_int(avl, 82);
- avl = remove_int(avl, 271);
- avl = grpc_avl_add(avl, box(590), box(172), nullptr);
- avl = grpc_avl_add(avl, box(852), box(173), nullptr);
- avl = remove_int(avl, 318);
- avl = remove_int(avl, 82);
- avl = grpc_avl_add(avl, box(672), box(176), nullptr);
- avl = remove_int(avl, 430);
- avl = grpc_avl_add(avl, box(821), box(178), nullptr);
- avl = grpc_avl_add(avl, box(365), box(179), nullptr);
- avl = remove_int(avl, 78);
- avl = grpc_avl_add(avl, box(700), box(181), nullptr);
- avl = grpc_avl_add(avl, box(353), box(182), nullptr);
- avl = remove_int(avl, 492);
- avl = grpc_avl_add(avl, box(991), box(184), nullptr);
- avl = remove_int(avl, 330);
- avl = grpc_avl_add(avl, box(873), box(186), nullptr);
- avl = remove_int(avl, 589);
- avl = grpc_avl_add(avl, box(676), box(188), nullptr);
- avl = grpc_avl_add(avl, box(790), box(189), nullptr);
- avl = remove_int(avl, 521);
- avl = remove_int(avl, 47);
- avl = grpc_avl_add(avl, box(976), box(192), nullptr);
- avl = grpc_avl_add(avl, box(683), box(193), nullptr);
- avl = remove_int(avl, 803);
- avl = remove_int(avl, 1006);
- avl = grpc_avl_add(avl, box(775), box(196), nullptr);
- avl = grpc_avl_add(avl, box(411), box(197), nullptr);
- avl = grpc_avl_add(avl, box(697), box(198), nullptr);
- avl = remove_int(avl, 50);
- avl = grpc_avl_add(avl, box(213), box(200), nullptr);
- avl = remove_int(avl, 714);
- avl = grpc_avl_add(avl, box(981), box(202), nullptr);
- avl = grpc_avl_add(avl, box(502), box(203), nullptr);
- avl = grpc_avl_add(avl, box(697), box(204), nullptr);
- avl = grpc_avl_add(avl, box(603), box(205), nullptr);
- avl = grpc_avl_add(avl, box(117), box(206), nullptr);
- avl = remove_int(avl, 363);
- avl = grpc_avl_add(avl, box(104), box(208), nullptr);
- avl = remove_int(avl, 842);
- avl = grpc_avl_add(avl, box(48), box(210), nullptr);
- avl = remove_int(avl, 764);
- avl = grpc_avl_add(avl, box(482), box(212), nullptr);
- avl = grpc_avl_add(avl, box(928), box(213), nullptr);
- avl = grpc_avl_add(avl, box(30), box(214), nullptr);
- avl = grpc_avl_add(avl, box(820), box(215), nullptr);
- avl = grpc_avl_add(avl, box(334), box(216), nullptr);
- avl = remove_int(avl, 306);
- avl = grpc_avl_add(avl, box(789), box(218), nullptr);
- avl = remove_int(avl, 924);
- avl = grpc_avl_add(avl, box(53), box(220), nullptr);
- avl = remove_int(avl, 657);
- avl = grpc_avl_add(avl, box(130), box(222), nullptr);
- avl = grpc_avl_add(avl, box(239), box(223), nullptr);
- avl = remove_int(avl, 20);
- avl = grpc_avl_add(avl, box(117), box(225), nullptr);
- avl = remove_int(avl, 882);
- avl = remove_int(avl, 891);
- avl = grpc_avl_add(avl, box(9), box(228), nullptr);
- avl = grpc_avl_add(avl, box(496), box(229), nullptr);
- avl = grpc_avl_add(avl, box(750), box(230), nullptr);
- avl = grpc_avl_add(avl, box(283), box(231), nullptr);
- avl = grpc_avl_add(avl, box(802), box(232), nullptr);
- avl = remove_int(avl, 352);
- avl = grpc_avl_add(avl, box(374), box(234), nullptr);
- avl = grpc_avl_add(avl, box(6), box(235), nullptr);
- avl = grpc_avl_add(avl, box(756), box(236), nullptr);
- avl = grpc_avl_add(avl, box(597), box(237), nullptr);
- avl = grpc_avl_add(avl, box(661), box(238), nullptr);
- avl = remove_int(avl, 96);
- avl = grpc_avl_add(avl, box(894), box(240), nullptr);
- avl = remove_int(avl, 749);
- avl = grpc_avl_add(avl, box(71), box(242), nullptr);
- avl = remove_int(avl, 68);
- avl = grpc_avl_add(avl, box(388), box(244), nullptr);
- avl = remove_int(avl, 119);
- avl = remove_int(avl, 856);
- avl = grpc_avl_add(avl, box(176), box(247), nullptr);
- avl = grpc_avl_add(avl, box(993), box(248), nullptr);
- avl = remove_int(avl, 178);
- avl = remove_int(avl, 781);
- avl = remove_int(avl, 771);
- avl = remove_int(avl, 848);
- avl = remove_int(avl, 376);
- avl = remove_int(avl, 157);
- avl = remove_int(avl, 142);
- avl = remove_int(avl, 686);
- avl = grpc_avl_add(avl, box(779), box(257), nullptr);
- avl = grpc_avl_add(avl, box(484), box(258), nullptr);
- avl = remove_int(avl, 837);
- avl = grpc_avl_add(avl, box(388), box(260), nullptr);
- avl = remove_int(avl, 987);
- avl = grpc_avl_add(avl, box(336), box(262), nullptr);
- avl = remove_int(avl, 855);
- avl = grpc_avl_add(avl, box(668), box(264), nullptr);
- avl = remove_int(avl, 648);
- avl = grpc_avl_add(avl, box(193), box(266), nullptr);
- avl = remove_int(avl, 939);
- avl = grpc_avl_add(avl, box(740), box(268), nullptr);
- avl = grpc_avl_add(avl, box(503), box(269), nullptr);
- avl = grpc_avl_add(avl, box(765), box(270), nullptr);
- avl = remove_int(avl, 924);
- avl = remove_int(avl, 513);
- avl = grpc_avl_add(avl, box(161), box(273), nullptr);
- avl = grpc_avl_add(avl, box(502), box(274), nullptr);
- avl = grpc_avl_add(avl, box(846), box(275), nullptr);
- avl = remove_int(avl, 931);
- avl = grpc_avl_add(avl, box(87), box(277), nullptr);
- avl = grpc_avl_add(avl, box(949), box(278), nullptr);
- avl = grpc_avl_add(avl, box(548), box(279), nullptr);
- avl = grpc_avl_add(avl, box(951), box(280), nullptr);
- avl = remove_int(avl, 1018);
- avl = remove_int(avl, 568);
- avl = grpc_avl_add(avl, box(138), box(283), nullptr);
- avl = grpc_avl_add(avl, box(202), box(284), nullptr);
- avl = grpc_avl_add(avl, box(157), box(285), nullptr);
- avl = grpc_avl_add(avl, box(264), box(286), nullptr);
- avl = grpc_avl_add(avl, box(370), box(287), nullptr);
- avl = remove_int(avl, 736);
- avl = remove_int(avl, 751);
- avl = remove_int(avl, 506);
- avl = remove_int(avl, 81);
- avl = remove_int(avl, 358);
- avl = remove_int(avl, 657);
- avl = remove_int(avl, 86);
- avl = grpc_avl_add(avl, box(876), box(295), nullptr);
- avl = remove_int(avl, 354);
- avl = grpc_avl_add(avl, box(134), box(297), nullptr);
- avl = remove_int(avl, 781);
- avl = remove_int(avl, 183);
- avl = grpc_avl_add(avl, box(914), box(300), nullptr);
- avl = remove_int(avl, 926);
- avl = remove_int(avl, 398);
- avl = remove_int(avl, 932);
- avl = remove_int(avl, 804);
- avl = remove_int(avl, 326);
- avl = grpc_avl_add(avl, box(208), box(306), nullptr);
- avl = grpc_avl_add(avl, box(699), box(307), nullptr);
- avl = remove_int(avl, 576);
- avl = remove_int(avl, 850);
- avl = remove_int(avl, 514);
- avl = remove_int(avl, 676);
- avl = remove_int(avl, 549);
- avl = remove_int(avl, 767);
- avl = grpc_avl_add(avl, box(58), box(314), nullptr);
- avl = grpc_avl_add(avl, box(265), box(315), nullptr);
- avl = grpc_avl_add(avl, box(268), box(316), nullptr);
- avl = grpc_avl_add(avl, box(103), box(317), nullptr);
- avl = grpc_avl_add(avl, box(440), box(318), nullptr);
- avl = remove_int(avl, 777);
- avl = grpc_avl_add(avl, box(670), box(320), nullptr);
- avl = remove_int(avl, 506);
- avl = remove_int(avl, 487);
- avl = grpc_avl_add(avl, box(421), box(323), nullptr);
- avl = remove_int(avl, 514);
- avl = grpc_avl_add(avl, box(701), box(325), nullptr);
- avl = remove_int(avl, 949);
- avl = remove_int(avl, 872);
- avl = remove_int(avl, 139);
- avl = grpc_avl_add(avl, box(781), box(329), nullptr);
- avl = grpc_avl_add(avl, box(543), box(330), nullptr);
- avl = grpc_avl_add(avl, box(147), box(331), nullptr);
- avl = remove_int(avl, 190);
- avl = grpc_avl_add(avl, box(453), box(333), nullptr);
- avl = remove_int(avl, 262);
- avl = remove_int(avl, 850);
- avl = remove_int(avl, 286);
- avl = remove_int(avl, 787);
- avl = grpc_avl_add(avl, box(514), box(338), nullptr);
- avl = remove_int(avl, 812);
- avl = grpc_avl_add(avl, box(431), box(340), nullptr);
- avl = grpc_avl_add(avl, box(8), box(341), nullptr);
- avl = remove_int(avl, 843);
- avl = grpc_avl_add(avl, box(831), box(343), nullptr);
- avl = remove_int(avl, 472);
- avl = remove_int(avl, 157);
- avl = grpc_avl_add(avl, box(612), box(346), nullptr);
- avl = grpc_avl_add(avl, box(802), box(347), nullptr);
- avl = remove_int(avl, 554);
- avl = grpc_avl_add(avl, box(409), box(349), nullptr);
- avl = grpc_avl_add(avl, box(439), box(350), nullptr);
- avl = grpc_avl_add(avl, box(725), box(351), nullptr);
- avl = grpc_avl_add(avl, box(568), box(352), nullptr);
- avl = remove_int(avl, 475);
- avl = remove_int(avl, 672);
- avl = remove_int(avl, 62);
- avl = remove_int(avl, 753);
- avl = grpc_avl_add(avl, box(435), box(357), nullptr);
- avl = grpc_avl_add(avl, box(950), box(358), nullptr);
- avl = grpc_avl_add(avl, box(532), box(359), nullptr);
- avl = grpc_avl_add(avl, box(832), box(360), nullptr);
- avl = remove_int(avl, 390);
- avl = grpc_avl_add(avl, box(993), box(362), nullptr);
- avl = remove_int(avl, 198);
- avl = remove_int(avl, 401);
- avl = grpc_avl_add(avl, box(316), box(365), nullptr);
- avl = remove_int(avl, 843);
- avl = grpc_avl_add(avl, box(541), box(367), nullptr);
- avl = grpc_avl_add(avl, box(505), box(368), nullptr);
- avl = remove_int(avl, 445);
- avl = remove_int(avl, 256);
- avl = grpc_avl_add(avl, box(232), box(371), nullptr);
- avl = remove_int(avl, 577);
- avl = remove_int(avl, 558);
- avl = grpc_avl_add(avl, box(910), box(374), nullptr);
- avl = remove_int(avl, 902);
- avl = remove_int(avl, 755);
- avl = remove_int(avl, 114);
- avl = remove_int(avl, 438);
- avl = remove_int(avl, 224);
- avl = grpc_avl_add(avl, box(920), box(380), nullptr);
- avl = grpc_avl_add(avl, box(655), box(381), nullptr);
- avl = remove_int(avl, 557);
- avl = remove_int(avl, 102);
- avl = remove_int(avl, 165);
- avl = grpc_avl_add(avl, box(191), box(385), nullptr);
- avl = remove_int(avl, 30);
- avl = grpc_avl_add(avl, box(406), box(387), nullptr);
- avl = grpc_avl_add(avl, box(66), box(388), nullptr);
- avl = grpc_avl_add(avl, box(87), box(389), nullptr);
- avl = remove_int(avl, 7);
- avl = remove_int(avl, 671);
- avl = grpc_avl_add(avl, box(234), box(392), nullptr);
- avl = remove_int(avl, 463);
- avl = grpc_avl_add(avl, box(75), box(394), nullptr);
- avl = grpc_avl_add(avl, box(487), box(395), nullptr);
- avl = remove_int(avl, 203);
- avl = grpc_avl_add(avl, box(711), box(397), nullptr);
- avl = remove_int(avl, 291);
- avl = remove_int(avl, 798);
- avl = remove_int(avl, 337);
- avl = grpc_avl_add(avl, box(877), box(401), nullptr);
- avl = grpc_avl_add(avl, box(388), box(402), nullptr);
- avl = remove_int(avl, 975);
- avl = grpc_avl_add(avl, box(200), box(404), nullptr);
- avl = grpc_avl_add(avl, box(408), box(405), nullptr);
- avl = grpc_avl_add(avl, box(3), box(406), nullptr);
- avl = grpc_avl_add(avl, box(971), box(407), nullptr);
- avl = remove_int(avl, 841);
- avl = remove_int(avl, 910);
- avl = remove_int(avl, 74);
- avl = remove_int(avl, 888);
- avl = grpc_avl_add(avl, box(492), box(412), nullptr);
- avl = remove_int(avl, 14);
- avl = remove_int(avl, 364);
- avl = grpc_avl_add(avl, box(215), box(415), nullptr);
- avl = remove_int(avl, 778);
- avl = remove_int(avl, 45);
- avl = grpc_avl_add(avl, box(328), box(418), nullptr);
- avl = grpc_avl_add(avl, box(597), box(419), nullptr);
- avl = remove_int(avl, 34);
- avl = grpc_avl_add(avl, box(736), box(421), nullptr);
- avl = remove_int(avl, 37);
- avl = grpc_avl_add(avl, box(275), box(423), nullptr);
- avl = grpc_avl_add(avl, box(70), box(424), nullptr);
- avl = grpc_avl_add(avl, box(771), box(425), nullptr);
- avl = remove_int(avl, 536);
- avl = remove_int(avl, 421);
- avl = grpc_avl_add(avl, box(186), box(428), nullptr);
- avl = grpc_avl_add(avl, box(788), box(429), nullptr);
- avl = grpc_avl_add(avl, box(224), box(430), nullptr);
- avl = remove_int(avl, 228);
- avl = grpc_avl_add(avl, box(48), box(432), nullptr);
- avl = grpc_avl_add(avl, box(120), box(433), nullptr);
- avl = grpc_avl_add(avl, box(269), box(434), nullptr);
- avl = grpc_avl_add(avl, box(904), box(435), nullptr);
- avl = remove_int(avl, 699);
- avl = grpc_avl_add(avl, box(340), box(437), nullptr);
- avl = remove_int(avl, 276);
- avl = grpc_avl_add(avl, box(591), box(439), nullptr);
- avl = grpc_avl_add(avl, box(778), box(440), nullptr);
- avl = remove_int(avl, 490);
- avl = remove_int(avl, 973);
- avl = grpc_avl_add(avl, box(294), box(443), nullptr);
- avl = grpc_avl_add(avl, box(323), box(444), nullptr);
- avl = remove_int(avl, 685);
- avl = grpc_avl_add(avl, box(38), box(446), nullptr);
- avl = grpc_avl_add(avl, box(525), box(447), nullptr);
- avl = remove_int(avl, 162);
- avl = grpc_avl_add(avl, box(462), box(449), nullptr);
- avl = grpc_avl_add(avl, box(340), box(450), nullptr);
- avl = remove_int(avl, 734);
- avl = remove_int(avl, 959);
- avl = grpc_avl_add(avl, box(752), box(453), nullptr);
- avl = grpc_avl_add(avl, box(667), box(454), nullptr);
- avl = remove_int(avl, 558);
- avl = remove_int(avl, 657);
- avl = grpc_avl_add(avl, box(711), box(457), nullptr);
- avl = remove_int(avl, 937);
- avl = grpc_avl_add(avl, box(741), box(459), nullptr);
- avl = grpc_avl_add(avl, box(40), box(460), nullptr);
- avl = remove_int(avl, 784);
- avl = grpc_avl_add(avl, box(292), box(462), nullptr);
- avl = remove_int(avl, 164);
- avl = remove_int(avl, 931);
- avl = remove_int(avl, 886);
- avl = grpc_avl_add(avl, box(968), box(466), nullptr);
- avl = remove_int(avl, 263);
- avl = grpc_avl_add(avl, box(647), box(468), nullptr);
- avl = grpc_avl_add(avl, box(92), box(469), nullptr);
- avl = remove_int(avl, 310);
- avl = grpc_avl_add(avl, box(711), box(471), nullptr);
- avl = grpc_avl_add(avl, box(675), box(472), nullptr);
- avl = remove_int(avl, 549);
- avl = grpc_avl_add(avl, box(380), box(474), nullptr);
- avl = remove_int(avl, 825);
- avl = grpc_avl_add(avl, box(668), box(476), nullptr);
- avl = remove_int(avl, 498);
- avl = grpc_avl_add(avl, box(870), box(478), nullptr);
- avl = grpc_avl_add(avl, box(391), box(479), nullptr);
- avl = grpc_avl_add(avl, box(264), box(480), nullptr);
- avl = remove_int(avl, 1);
- avl = remove_int(avl, 849);
- avl = remove_int(avl, 88);
- avl = remove_int(avl, 255);
- avl = remove_int(avl, 763);
- avl = remove_int(avl, 831);
- avl = grpc_avl_add(avl, box(508), box(487), nullptr);
- avl = remove_int(avl, 849);
- avl = remove_int(avl, 47);
- avl = grpc_avl_add(avl, box(299), box(490), nullptr);
- avl = remove_int(avl, 625);
- avl = remove_int(avl, 433);
- avl = remove_int(avl, 904);
- avl = remove_int(avl, 761);
- avl = grpc_avl_add(avl, box(33), box(495), nullptr);
- avl = grpc_avl_add(avl, box(524), box(496), nullptr);
- avl = remove_int(avl, 210);
- avl = remove_int(avl, 299);
- avl = grpc_avl_add(avl, box(823), box(499), nullptr);
- avl = remove_int(avl, 479);
- avl = remove_int(avl, 96);
- avl = remove_int(avl, 1013);
- avl = grpc_avl_add(avl, box(768), box(503), nullptr);
- avl = remove_int(avl, 638);
- avl = remove_int(avl, 20);
- avl = grpc_avl_add(avl, box(663), box(506), nullptr);
- avl = remove_int(avl, 882);
- avl = grpc_avl_add(avl, box(745), box(508), nullptr);
- avl = remove_int(avl, 352);
- avl = grpc_avl_add(avl, box(10), box(510), nullptr);
- avl = remove_int(avl, 484);
- avl = grpc_avl_add(avl, box(420), box(512), nullptr);
- avl = grpc_avl_add(avl, box(884), box(513), nullptr);
- avl = grpc_avl_add(avl, box(993), box(514), nullptr);
- avl = grpc_avl_add(avl, box(251), box(515), nullptr);
- avl = remove_int(avl, 222);
- avl = grpc_avl_add(avl, box(734), box(517), nullptr);
- avl = grpc_avl_add(avl, box(952), box(518), nullptr);
- avl = remove_int(avl, 26);
- avl = remove_int(avl, 270);
- avl = remove_int(avl, 481);
- avl = remove_int(avl, 693);
- avl = remove_int(avl, 1006);
- avl = grpc_avl_add(avl, box(77), box(524), nullptr);
- avl = remove_int(avl, 897);
- avl = grpc_avl_add(avl, box(719), box(526), nullptr);
- avl = grpc_avl_add(avl, box(622), box(527), nullptr);
- avl = remove_int(avl, 28);
- avl = remove_int(avl, 836);
- avl = remove_int(avl, 142);
- avl = grpc_avl_add(avl, box(445), box(531), nullptr);
- avl = grpc_avl_add(avl, box(410), box(532), nullptr);
- avl = remove_int(avl, 575);
- avl = grpc_avl_add(avl, box(634), box(534), nullptr);
- avl = grpc_avl_add(avl, box(906), box(535), nullptr);
- avl = remove_int(avl, 649);
- avl = grpc_avl_add(avl, box(813), box(537), nullptr);
- avl = remove_int(avl, 702);
- avl = remove_int(avl, 732);
- avl = grpc_avl_add(avl, box(105), box(540), nullptr);
- avl = grpc_avl_add(avl, box(867), box(541), nullptr);
- avl = remove_int(avl, 964);
- avl = remove_int(avl, 941);
- avl = grpc_avl_add(avl, box(947), box(544), nullptr);
- avl = remove_int(avl, 990);
- avl = grpc_avl_add(avl, box(816), box(546), nullptr);
- avl = remove_int(avl, 429);
- avl = remove_int(avl, 567);
- avl = remove_int(avl, 541);
- avl = remove_int(avl, 583);
- avl = grpc_avl_add(avl, box(57), box(551), nullptr);
- avl = grpc_avl_add(avl, box(786), box(552), nullptr);
- avl = grpc_avl_add(avl, box(526), box(553), nullptr);
- avl = remove_int(avl, 642);
- avl = remove_int(avl, 220);
- avl = remove_int(avl, 840);
- avl = remove_int(avl, 548);
- avl = grpc_avl_add(avl, box(528), box(558), nullptr);
- avl = grpc_avl_add(avl, box(749), box(559), nullptr);
- avl = grpc_avl_add(avl, box(194), box(560), nullptr);
- avl = remove_int(avl, 517);
- avl = grpc_avl_add(avl, box(102), box(562), nullptr);
- avl = remove_int(avl, 189);
- avl = grpc_avl_add(avl, box(927), box(564), nullptr);
- avl = remove_int(avl, 846);
- avl = remove_int(avl, 130);
- avl = grpc_avl_add(avl, box(694), box(567), nullptr);
- avl = remove_int(avl, 750);
- avl = grpc_avl_add(avl, box(357), box(569), nullptr);
- avl = remove_int(avl, 431);
- avl = remove_int(avl, 91);
- avl = grpc_avl_add(avl, box(640), box(572), nullptr);
- avl = remove_int(avl, 4);
- avl = grpc_avl_add(avl, box(81), box(574), nullptr);
- avl = grpc_avl_add(avl, box(595), box(575), nullptr);
- avl = remove_int(avl, 444);
- avl = remove_int(avl, 262);
- avl = remove_int(avl, 11);
- avl = grpc_avl_add(avl, box(192), box(579), nullptr);
- avl = grpc_avl_add(avl, box(158), box(580), nullptr);
- avl = remove_int(avl, 401);
- avl = remove_int(avl, 918);
- avl = grpc_avl_add(avl, box(180), box(583), nullptr);
- avl = remove_int(avl, 268);
- avl = grpc_avl_add(avl, box(1012), box(585), nullptr);
- avl = grpc_avl_add(avl, box(90), box(586), nullptr);
- avl = grpc_avl_add(avl, box(946), box(587), nullptr);
- avl = remove_int(avl, 719);
- avl = grpc_avl_add(avl, box(874), box(589), nullptr);
- avl = grpc_avl_add(avl, box(679), box(590), nullptr);
- avl = remove_int(avl, 53);
- avl = remove_int(avl, 534);
- avl = grpc_avl_add(avl, box(646), box(593), nullptr);
- avl = grpc_avl_add(avl, box(767), box(594), nullptr);
- avl = grpc_avl_add(avl, box(460), box(595), nullptr);
- avl = grpc_avl_add(avl, box(852), box(596), nullptr);
- avl = grpc_avl_add(avl, box(189), box(597), nullptr);
- avl = remove_int(avl, 932);
- avl = remove_int(avl, 366);
- avl = remove_int(avl, 907);
- avl = grpc_avl_add(avl, box(875), box(601), nullptr);
- avl = grpc_avl_add(avl, box(434), box(602), nullptr);
- avl = grpc_avl_add(avl, box(704), box(603), nullptr);
- avl = grpc_avl_add(avl, box(724), box(604), nullptr);
- avl = grpc_avl_add(avl, box(930), box(605), nullptr);
- avl = grpc_avl_add(avl, box(1000), box(606), nullptr);
- avl = remove_int(avl, 479);
- avl = grpc_avl_add(avl, box(275), box(608), nullptr);
- avl = remove_int(avl, 32);
- avl = grpc_avl_add(avl, box(939), box(610), nullptr);
- avl = remove_int(avl, 943);
- avl = remove_int(avl, 329);
- avl = grpc_avl_add(avl, box(490), box(613), nullptr);
- avl = remove_int(avl, 477);
- avl = remove_int(avl, 414);
- avl = remove_int(avl, 187);
- avl = remove_int(avl, 334);
- avl = grpc_avl_add(avl, box(40), box(618), nullptr);
- avl = remove_int(avl, 751);
- avl = grpc_avl_add(avl, box(568), box(620), nullptr);
- avl = grpc_avl_add(avl, box(120), box(621), nullptr);
- avl = grpc_avl_add(avl, box(617), box(622), nullptr);
- avl = grpc_avl_add(avl, box(32), box(623), nullptr);
- avl = remove_int(avl, 701);
- avl = grpc_avl_add(avl, box(910), box(625), nullptr);
- avl = remove_int(avl, 557);
- avl = remove_int(avl, 361);
- avl = remove_int(avl, 937);
- avl = remove_int(avl, 100);
- avl = remove_int(avl, 684);
- avl = grpc_avl_add(avl, box(751), box(631), nullptr);
- avl = remove_int(avl, 781);
- avl = remove_int(avl, 469);
- avl = remove_int(avl, 75);
- avl = remove_int(avl, 561);
- avl = grpc_avl_add(avl, box(854), box(636), nullptr);
- avl = remove_int(avl, 164);
- avl = remove_int(avl, 258);
- avl = remove_int(avl, 315);
- avl = remove_int(avl, 261);
- avl = grpc_avl_add(avl, box(552), box(641), nullptr);
- avl = grpc_avl_add(avl, box(6), box(642), nullptr);
- avl = grpc_avl_add(avl, box(680), box(643), nullptr);
- avl = remove_int(avl, 741);
- avl = remove_int(avl, 309);
- avl = remove_int(avl, 272);
- avl = grpc_avl_add(avl, box(249), box(647), nullptr);
- avl = remove_int(avl, 97);
- avl = remove_int(avl, 850);
- avl = grpc_avl_add(avl, box(915), box(650), nullptr);
- avl = grpc_avl_add(avl, box(816), box(651), nullptr);
- avl = grpc_avl_add(avl, box(45), box(652), nullptr);
- avl = grpc_avl_add(avl, box(168), box(653), nullptr);
- avl = remove_int(avl, 153);
- avl = remove_int(avl, 239);
- avl = grpc_avl_add(avl, box(684), box(656), nullptr);
- avl = grpc_avl_add(avl, box(208), box(657), nullptr);
- avl = grpc_avl_add(avl, box(681), box(658), nullptr);
- avl = grpc_avl_add(avl, box(609), box(659), nullptr);
- avl = grpc_avl_add(avl, box(645), box(660), nullptr);
- avl = remove_int(avl, 799);
- avl = grpc_avl_add(avl, box(955), box(662), nullptr);
- avl = grpc_avl_add(avl, box(946), box(663), nullptr);
- avl = grpc_avl_add(avl, box(744), box(664), nullptr);
- avl = grpc_avl_add(avl, box(201), box(665), nullptr);
- avl = grpc_avl_add(avl, box(136), box(666), nullptr);
- avl = remove_int(avl, 357);
- avl = grpc_avl_add(avl, box(974), box(668), nullptr);
- avl = remove_int(avl, 485);
- avl = grpc_avl_add(avl, box(1009), box(670), nullptr);
- avl = grpc_avl_add(avl, box(517), box(671), nullptr);
- avl = remove_int(avl, 491);
- avl = grpc_avl_add(avl, box(336), box(673), nullptr);
- avl = grpc_avl_add(avl, box(589), box(674), nullptr);
- avl = remove_int(avl, 546);
- avl = remove_int(avl, 840);
- avl = remove_int(avl, 104);
- avl = remove_int(avl, 347);
- avl = grpc_avl_add(avl, box(801), box(679), nullptr);
- avl = remove_int(avl, 799);
- avl = remove_int(avl, 702);
- avl = remove_int(avl, 996);
- avl = remove_int(avl, 93);
- avl = grpc_avl_add(avl, box(561), box(684), nullptr);
- avl = grpc_avl_add(avl, box(25), box(685), nullptr);
- avl = remove_int(avl, 278);
- avl = grpc_avl_add(avl, box(191), box(687), nullptr);
- avl = remove_int(avl, 243);
- avl = remove_int(avl, 918);
- avl = remove_int(avl, 449);
- avl = grpc_avl_add(avl, box(19), box(691), nullptr);
- avl = grpc_avl_add(avl, box(762), box(692), nullptr);
- avl = grpc_avl_add(avl, box(13), box(693), nullptr);
- avl = grpc_avl_add(avl, box(151), box(694), nullptr);
- avl = grpc_avl_add(avl, box(152), box(695), nullptr);
- avl = grpc_avl_add(avl, box(793), box(696), nullptr);
- avl = remove_int(avl, 862);
- avl = remove_int(avl, 890);
- avl = grpc_avl_add(avl, box(687), box(699), nullptr);
- avl = grpc_avl_add(avl, box(509), box(700), nullptr);
- avl = grpc_avl_add(avl, box(973), box(701), nullptr);
- avl = remove_int(avl, 230);
- avl = grpc_avl_add(avl, box(532), box(703), nullptr);
- avl = remove_int(avl, 668);
- avl = grpc_avl_add(avl, box(281), box(705), nullptr);
- avl = grpc_avl_add(avl, box(867), box(706), nullptr);
- avl = grpc_avl_add(avl, box(359), box(707), nullptr);
- avl = remove_int(avl, 425);
- avl = grpc_avl_add(avl, box(691), box(709), nullptr);
- avl = grpc_avl_add(avl, box(163), box(710), nullptr);
- avl = grpc_avl_add(avl, box(502), box(711), nullptr);
- avl = remove_int(avl, 674);
- avl = grpc_avl_add(avl, box(697), box(713), nullptr);
- avl = remove_int(avl, 271);
- avl = grpc_avl_add(avl, box(968), box(715), nullptr);
- avl = grpc_avl_add(avl, box(48), box(716), nullptr);
- avl = remove_int(avl, 543);
- avl = grpc_avl_add(avl, box(35), box(718), nullptr);
- avl = grpc_avl_add(avl, box(751), box(719), nullptr);
- avl = grpc_avl_add(avl, box(478), box(720), nullptr);
- avl = remove_int(avl, 797);
- avl = remove_int(avl, 309);
- avl = grpc_avl_add(avl, box(927), box(723), nullptr);
- avl = remove_int(avl, 504);
- avl = grpc_avl_add(avl, box(286), box(725), nullptr);
- avl = grpc_avl_add(avl, box(413), box(726), nullptr);
- avl = grpc_avl_add(avl, box(599), box(727), nullptr);
- avl = remove_int(avl, 105);
- avl = remove_int(avl, 605);
- avl = grpc_avl_add(avl, box(632), box(730), nullptr);
- avl = grpc_avl_add(avl, box(133), box(731), nullptr);
- avl = remove_int(avl, 443);
- avl = grpc_avl_add(avl, box(958), box(733), nullptr);
- avl = grpc_avl_add(avl, box(729), box(734), nullptr);
- avl = remove_int(avl, 158);
- avl = grpc_avl_add(avl, box(694), box(736), nullptr);
- avl = grpc_avl_add(avl, box(505), box(737), nullptr);
- avl = remove_int(avl, 63);
- avl = remove_int(avl, 714);
- avl = grpc_avl_add(avl, box(1002), box(740), nullptr);
- avl = remove_int(avl, 211);
- avl = grpc_avl_add(avl, box(765), box(742), nullptr);
- avl = grpc_avl_add(avl, box(455), box(743), nullptr);
- avl = remove_int(avl, 59);
- avl = remove_int(avl, 224);
- avl = grpc_avl_add(avl, box(586), box(746), nullptr);
- avl = grpc_avl_add(avl, box(348), box(747), nullptr);
- avl = remove_int(avl, 10);
- avl = remove_int(avl, 484);
- avl = grpc_avl_add(avl, box(968), box(750), nullptr);
- avl = grpc_avl_add(avl, box(923), box(751), nullptr);
- avl = remove_int(avl, 573);
- avl = remove_int(avl, 617);
- avl = grpc_avl_add(avl, box(812), box(754), nullptr);
- avl = grpc_avl_add(avl, box(179), box(755), nullptr);
- avl = remove_int(avl, 284);
- avl = remove_int(avl, 157);
- avl = remove_int(avl, 177);
- avl = remove_int(avl, 896);
- avl = grpc_avl_add(avl, box(649), box(760), nullptr);
- avl = grpc_avl_add(avl, box(927), box(761), nullptr);
- avl = grpc_avl_add(avl, box(454), box(762), nullptr);
- avl = grpc_avl_add(avl, box(217), box(763), nullptr);
- avl = remove_int(avl, 534);
- avl = grpc_avl_add(avl, box(180), box(765), nullptr);
- avl = grpc_avl_add(avl, box(319), box(766), nullptr);
- avl = remove_int(avl, 92);
- avl = grpc_avl_add(avl, box(483), box(768), nullptr);
- avl = remove_int(avl, 504);
- avl = remove_int(avl, 1017);
- avl = remove_int(avl, 37);
- avl = remove_int(avl, 50);
- avl = grpc_avl_add(avl, box(302), box(773), nullptr);
- avl = remove_int(avl, 807);
- avl = grpc_avl_add(avl, box(463), box(775), nullptr);
- avl = grpc_avl_add(avl, box(271), box(776), nullptr);
- avl = grpc_avl_add(avl, box(644), box(777), nullptr);
- avl = remove_int(avl, 618);
- avl = grpc_avl_add(avl, box(166), box(779), nullptr);
- avl = grpc_avl_add(avl, box(538), box(780), nullptr);
- avl = remove_int(avl, 606);
- avl = grpc_avl_add(avl, box(425), box(782), nullptr);
- avl = remove_int(avl, 725);
- avl = remove_int(avl, 383);
- avl = grpc_avl_add(avl, box(155), box(785), nullptr);
- avl = remove_int(avl, 889);
- avl = grpc_avl_add(avl, box(653), box(787), nullptr);
- avl = remove_int(avl, 386);
- avl = grpc_avl_add(avl, box(142), box(789), nullptr);
- avl = remove_int(avl, 107);
- avl = remove_int(avl, 603);
- avl = remove_int(avl, 971);
- avl = grpc_avl_add(avl, box(80), box(793), nullptr);
- avl = grpc_avl_add(avl, box(61), box(794), nullptr);
- avl = grpc_avl_add(avl, box(693), box(795), nullptr);
- avl = grpc_avl_add(avl, box(592), box(796), nullptr);
- avl = grpc_avl_add(avl, box(433), box(797), nullptr);
- avl = grpc_avl_add(avl, box(973), box(798), nullptr);
- avl = remove_int(avl, 901);
- avl = remove_int(avl, 340);
- avl = remove_int(avl, 709);
- avl = grpc_avl_add(avl, box(224), box(802), nullptr);
- avl = remove_int(avl, 120);
- avl = remove_int(avl, 271);
- avl = grpc_avl_add(avl, box(780), box(805), nullptr);
- avl = grpc_avl_add(avl, box(867), box(806), nullptr);
- avl = grpc_avl_add(avl, box(756), box(807), nullptr);
- avl = grpc_avl_add(avl, box(583), box(808), nullptr);
- avl = grpc_avl_add(avl, box(356), box(809), nullptr);
- avl = grpc_avl_add(avl, box(58), box(810), nullptr);
- avl = remove_int(avl, 219);
- avl = grpc_avl_add(avl, box(301), box(812), nullptr);
- avl = remove_int(avl, 643);
- avl = remove_int(avl, 787);
- avl = remove_int(avl, 583);
- avl = remove_int(avl, 552);
- avl = remove_int(avl, 308);
- avl = remove_int(avl, 608);
- avl = remove_int(avl, 363);
- avl = remove_int(avl, 690);
- avl = grpc_avl_add(avl, box(233), box(821), nullptr);
- avl = grpc_avl_add(avl, box(479), box(822), nullptr);
- avl = grpc_avl_add(avl, box(323), box(823), nullptr);
- avl = grpc_avl_add(avl, box(802), box(824), nullptr);
- avl = remove_int(avl, 682);
- avl = remove_int(avl, 705);
- avl = remove_int(avl, 487);
- avl = grpc_avl_add(avl, box(530), box(828), nullptr);
- avl = grpc_avl_add(avl, box(232), box(829), nullptr);
- avl = remove_int(avl, 627);
- avl = grpc_avl_add(avl, box(396), box(831), nullptr);
- avl = grpc_avl_add(avl, box(61), box(832), nullptr);
- avl = grpc_avl_add(avl, box(932), box(833), nullptr);
- avl = grpc_avl_add(avl, box(108), box(834), nullptr);
- avl = grpc_avl_add(avl, box(524), box(835), nullptr);
- avl = remove_int(avl, 390);
- avl = remove_int(avl, 307);
- avl = grpc_avl_add(avl, box(722), box(838), nullptr);
- avl = grpc_avl_add(avl, box(907), box(839), nullptr);
- avl = remove_int(avl, 286);
- avl = remove_int(avl, 337);
- avl = remove_int(avl, 443);
- avl = grpc_avl_add(avl, box(973), box(843), nullptr);
- avl = remove_int(avl, 930);
- avl = remove_int(avl, 242);
- avl = grpc_avl_add(avl, box(997), box(846), nullptr);
- avl = grpc_avl_add(avl, box(689), box(847), nullptr);
- avl = remove_int(avl, 318);
- avl = grpc_avl_add(avl, box(703), box(849), nullptr);
- avl = grpc_avl_add(avl, box(868), box(850), nullptr);
- avl = grpc_avl_add(avl, box(200), box(851), nullptr);
- avl = grpc_avl_add(avl, box(960), box(852), nullptr);
- avl = grpc_avl_add(avl, box(80), box(853), nullptr);
- avl = remove_int(avl, 113);
- avl = grpc_avl_add(avl, box(135), box(855), nullptr);
- avl = remove_int(avl, 529);
- avl = grpc_avl_add(avl, box(366), box(857), nullptr);
- avl = remove_int(avl, 272);
- avl = grpc_avl_add(avl, box(921), box(859), nullptr);
- avl = remove_int(avl, 497);
- avl = grpc_avl_add(avl, box(712), box(861), nullptr);
- avl = remove_int(avl, 777);
- avl = remove_int(avl, 505);
- avl = remove_int(avl, 974);
- avl = remove_int(avl, 497);
- avl = grpc_avl_add(avl, box(388), box(866), nullptr);
- avl = grpc_avl_add(avl, box(29), box(867), nullptr);
- avl = grpc_avl_add(avl, box(180), box(868), nullptr);
- avl = grpc_avl_add(avl, box(983), box(869), nullptr);
- avl = grpc_avl_add(avl, box(72), box(870), nullptr);
- avl = grpc_avl_add(avl, box(693), box(871), nullptr);
- avl = grpc_avl_add(avl, box(567), box(872), nullptr);
- avl = remove_int(avl, 549);
- avl = remove_int(avl, 351);
- avl = grpc_avl_add(avl, box(1019), box(875), nullptr);
- avl = remove_int(avl, 585);
- avl = remove_int(avl, 294);
- avl = remove_int(avl, 61);
- avl = grpc_avl_add(avl, box(409), box(879), nullptr);
- avl = grpc_avl_add(avl, box(984), box(880), nullptr);
- avl = grpc_avl_add(avl, box(830), box(881), nullptr);
- avl = remove_int(avl, 579);
- avl = grpc_avl_add(avl, box(672), box(883), nullptr);
- avl = remove_int(avl, 968);
-
- grpc_avl_unref(avl, nullptr);
-}
-
-static void test_badcase3(void) {
- grpc_avl avl;
-
- gpr_log(GPR_DEBUG, "test_badcase3");
-
- avl = grpc_avl_create(&int_int_vtable);
- avl = remove_int(avl, 624);
- avl = grpc_avl_add(avl, box(59), box(2), nullptr);
- avl = grpc_avl_add(avl, box(494), box(3), nullptr);
- avl = grpc_avl_add(avl, box(226), box(4), nullptr);
- avl = remove_int(avl, 524);
- avl = grpc_avl_add(avl, box(540), box(6), nullptr);
- avl = remove_int(avl, 1008);
- avl = grpc_avl_add(avl, box(502), box(8), nullptr);
- avl = remove_int(avl, 267);
- avl = remove_int(avl, 764);
- avl = remove_int(avl, 443);
- avl = grpc_avl_add(avl, box(8), box(12), nullptr);
- avl = remove_int(avl, 291);
- avl = remove_int(avl, 796);
- avl = remove_int(avl, 1002);
- avl = grpc_avl_add(avl, box(778), box(16), nullptr);
- avl = remove_int(avl, 621);
- avl = remove_int(avl, 891);
- avl = remove_int(avl, 880);
- avl = grpc_avl_add(avl, box(197), box(20), nullptr);
- avl = grpc_avl_add(avl, box(441), box(21), nullptr);
- avl = grpc_avl_add(avl, box(719), box(22), nullptr);
- avl = remove_int(avl, 109);
- avl = grpc_avl_add(avl, box(458), box(24), nullptr);
- avl = remove_int(avl, 86);
- avl = grpc_avl_add(avl, box(897), box(26), nullptr);
- avl = grpc_avl_add(avl, box(997), box(27), nullptr);
- avl = remove_int(avl, 235);
- avl = remove_int(avl, 425);
- avl = remove_int(avl, 186);
- avl = grpc_avl_add(avl, box(887), box(31), nullptr);
- avl = grpc_avl_add(avl, box(1005), box(32), nullptr);
- avl = grpc_avl_add(avl, box(778), box(33), nullptr);
- avl = grpc_avl_add(avl, box(575), box(34), nullptr);
- avl = remove_int(avl, 966);
- avl = remove_int(avl, 1015);
- avl = grpc_avl_add(avl, box(486), box(37), nullptr);
- avl = grpc_avl_add(avl, box(809), box(38), nullptr);
- avl = grpc_avl_add(avl, box(907), box(39), nullptr);
- avl = grpc_avl_add(avl, box(971), box(40), nullptr);
- avl = remove_int(avl, 441);
- avl = remove_int(avl, 498);
- avl = grpc_avl_add(avl, box(727), box(43), nullptr);
- avl = remove_int(avl, 679);
- avl = remove_int(avl, 740);
- avl = remove_int(avl, 532);
- avl = grpc_avl_add(avl, box(805), box(47), nullptr);
- avl = remove_int(avl, 64);
- avl = grpc_avl_add(avl, box(362), box(49), nullptr);
- avl = grpc_avl_add(avl, box(170), box(50), nullptr);
- avl = grpc_avl_add(avl, box(389), box(51), nullptr);
- avl = grpc_avl_add(avl, box(689), box(52), nullptr);
- avl = remove_int(avl, 871);
- avl = grpc_avl_add(avl, box(447), box(54), nullptr);
- avl = remove_int(avl, 718);
- avl = grpc_avl_add(avl, box(724), box(56), nullptr);
- avl = remove_int(avl, 215);
- avl = grpc_avl_add(avl, box(550), box(58), nullptr);
- avl = remove_int(avl, 932);
- avl = grpc_avl_add(avl, box(47), box(60), nullptr);
- avl = remove_int(avl, 46);
- avl = remove_int(avl, 229);
- avl = grpc_avl_add(avl, box(68), box(63), nullptr);
- avl = grpc_avl_add(avl, box(387), box(64), nullptr);
- avl = remove_int(avl, 933);
- avl = remove_int(avl, 736);
- avl = remove_int(avl, 719);
- avl = grpc_avl_add(avl, box(150), box(68), nullptr);
- avl = remove_int(avl, 875);
- avl = remove_int(avl, 298);
- avl = grpc_avl_add(avl, box(991), box(71), nullptr);
- avl = remove_int(avl, 705);
- avl = grpc_avl_add(avl, box(197), box(73), nullptr);
- avl = grpc_avl_add(avl, box(101), box(74), nullptr);
- avl = remove_int(avl, 436);
- avl = grpc_avl_add(avl, box(755), box(76), nullptr);
- avl = grpc_avl_add(avl, box(727), box(77), nullptr);
- avl = remove_int(avl, 309);
- avl = remove_int(avl, 253);
- avl = grpc_avl_add(avl, box(203), box(80), nullptr);
- avl = remove_int(avl, 231);
- avl = grpc_avl_add(avl, box(461), box(82), nullptr);
- avl = remove_int(avl, 316);
- avl = remove_int(avl, 493);
- avl = grpc_avl_add(avl, box(184), box(85), nullptr);
- avl = remove_int(avl, 737);
- avl = grpc_avl_add(avl, box(790), box(87), nullptr);
- avl = grpc_avl_add(avl, box(335), box(88), nullptr);
- avl = remove_int(avl, 649);
- avl = grpc_avl_add(avl, box(69), box(90), nullptr);
- avl = remove_int(avl, 585);
- avl = remove_int(avl, 543);
- avl = grpc_avl_add(avl, box(784), box(93), nullptr);
- avl = grpc_avl_add(avl, box(60), box(94), nullptr);
- avl = grpc_avl_add(avl, box(525), box(95), nullptr);
- avl = grpc_avl_add(avl, box(177), box(96), nullptr);
- avl = grpc_avl_add(avl, box(178), box(97), nullptr);
- avl = grpc_avl_add(avl, box(683), box(98), nullptr);
- avl = grpc_avl_add(avl, box(226), box(99), nullptr);
- avl = grpc_avl_add(avl, box(662), box(100), nullptr);
- avl = remove_int(avl, 944);
- avl = grpc_avl_add(avl, box(562), box(102), nullptr);
- avl = grpc_avl_add(avl, box(793), box(103), nullptr);
- avl = remove_int(avl, 673);
- avl = grpc_avl_add(avl, box(310), box(105), nullptr);
- avl = remove_int(avl, 479);
- avl = remove_int(avl, 543);
- avl = remove_int(avl, 159);
- avl = remove_int(avl, 850);
- avl = grpc_avl_add(avl, box(318), box(110), nullptr);
- avl = grpc_avl_add(avl, box(483), box(111), nullptr);
- avl = grpc_avl_add(avl, box(84), box(112), nullptr);
- avl = remove_int(avl, 109);
- avl = grpc_avl_add(avl, box(132), box(114), nullptr);
- avl = grpc_avl_add(avl, box(920), box(115), nullptr);
- avl = remove_int(avl, 746);
- avl = grpc_avl_add(avl, box(145), box(117), nullptr);
- avl = grpc_avl_add(avl, box(526), box(118), nullptr);
- avl = remove_int(avl, 158);
- avl = grpc_avl_add(avl, box(332), box(120), nullptr);
- avl = grpc_avl_add(avl, box(918), box(121), nullptr);
- avl = remove_int(avl, 339);
- avl = grpc_avl_add(avl, box(809), box(123), nullptr);
- avl = grpc_avl_add(avl, box(742), box(124), nullptr);
- avl = grpc_avl_add(avl, box(718), box(125), nullptr);
- avl = remove_int(avl, 988);
- avl = remove_int(avl, 531);
- avl = remove_int(avl, 840);
- avl = grpc_avl_add(avl, box(816), box(129), nullptr);
- avl = grpc_avl_add(avl, box(976), box(130), nullptr);
- avl = remove_int(avl, 743);
- avl = remove_int(avl, 528);
- avl = remove_int(avl, 982);
- avl = grpc_avl_add(avl, box(803), box(134), nullptr);
- avl = grpc_avl_add(avl, box(205), box(135), nullptr);
- avl = grpc_avl_add(avl, box(584), box(136), nullptr);
- avl = remove_int(avl, 923);
- avl = remove_int(avl, 538);
- avl = remove_int(avl, 398);
- avl = remove_int(avl, 320);
- avl = remove_int(avl, 292);
- avl = grpc_avl_add(avl, box(270), box(142), nullptr);
- avl = grpc_avl_add(avl, box(333), box(143), nullptr);
- avl = remove_int(avl, 439);
- avl = grpc_avl_add(avl, box(35), box(145), nullptr);
- avl = grpc_avl_add(avl, box(837), box(146), nullptr);
- avl = remove_int(avl, 65);
- avl = remove_int(avl, 642);
- avl = remove_int(avl, 371);
- avl = remove_int(avl, 140);
- avl = remove_int(avl, 533);
- avl = remove_int(avl, 676);
- avl = grpc_avl_add(avl, box(624), box(153), nullptr);
- avl = grpc_avl_add(avl, box(116), box(154), nullptr);
- avl = grpc_avl_add(avl, box(446), box(155), nullptr);
- avl = remove_int(avl, 91);
- avl = remove_int(avl, 721);
- avl = remove_int(avl, 537);
- avl = grpc_avl_add(avl, box(448), box(159), nullptr);
- avl = remove_int(avl, 155);
- avl = remove_int(avl, 344);
- avl = remove_int(avl, 237);
- avl = grpc_avl_add(avl, box(309), box(163), nullptr);
- avl = grpc_avl_add(avl, box(434), box(164), nullptr);
- avl = grpc_avl_add(avl, box(277), box(165), nullptr);
- avl = remove_int(avl, 233);
- avl = grpc_avl_add(avl, box(275), box(167), nullptr);
- avl = grpc_avl_add(avl, box(218), box(168), nullptr);
- avl = grpc_avl_add(avl, box(76), box(169), nullptr);
- avl = grpc_avl_add(avl, box(898), box(170), nullptr);
- avl = remove_int(avl, 771);
- avl = grpc_avl_add(avl, box(237), box(172), nullptr);
- avl = remove_int(avl, 327);
- avl = grpc_avl_add(avl, box(499), box(174), nullptr);
- avl = remove_int(avl, 727);
- avl = remove_int(avl, 234);
- avl = remove_int(avl, 623);
- avl = remove_int(avl, 458);
- avl = remove_int(avl, 326);
- avl = remove_int(avl, 589);
- avl = grpc_avl_add(avl, box(442), box(181), nullptr);
- avl = remove_int(avl, 389);
- avl = grpc_avl_add(avl, box(708), box(183), nullptr);
- avl = grpc_avl_add(avl, box(594), box(184), nullptr);
- avl = grpc_avl_add(avl, box(942), box(185), nullptr);
- avl = grpc_avl_add(avl, box(282), box(186), nullptr);
- avl = remove_int(avl, 434);
- avl = remove_int(avl, 134);
- avl = remove_int(avl, 270);
- avl = remove_int(avl, 512);
- avl = remove_int(avl, 265);
- avl = remove_int(avl, 21);
- avl = remove_int(avl, 193);
- avl = remove_int(avl, 797);
- avl = remove_int(avl, 347);
- avl = grpc_avl_add(avl, box(99), box(196), nullptr);
- avl = grpc_avl_add(avl, box(161), box(197), nullptr);
- avl = remove_int(avl, 484);
- avl = grpc_avl_add(avl, box(72), box(199), nullptr);
- avl = remove_int(avl, 629);
- avl = grpc_avl_add(avl, box(522), box(201), nullptr);
- avl = remove_int(avl, 679);
- avl = grpc_avl_add(avl, box(407), box(203), nullptr);
- avl = remove_int(avl, 693);
- avl = grpc_avl_add(avl, box(424), box(205), nullptr);
- avl = grpc_avl_add(avl, box(651), box(206), nullptr);
- avl = grpc_avl_add(avl, box(927), box(207), nullptr);
- avl = remove_int(avl, 553);
- avl = grpc_avl_add(avl, box(128), box(209), nullptr);
- avl = grpc_avl_add(avl, box(616), box(210), nullptr);
- avl = grpc_avl_add(avl, box(690), box(211), nullptr);
- avl = remove_int(avl, 241);
- avl = remove_int(avl, 179);
- avl = grpc_avl_add(avl, box(697), box(214), nullptr);
- avl = remove_int(avl, 779);
- avl = grpc_avl_add(avl, box(241), box(216), nullptr);
- avl = remove_int(avl, 190);
- avl = remove_int(avl, 210);
- avl = grpc_avl_add(avl, box(711), box(219), nullptr);
- avl = remove_int(avl, 251);
- avl = remove_int(avl, 61);
- avl = grpc_avl_add(avl, box(800), box(222), nullptr);
- avl = remove_int(avl, 551);
- avl = grpc_avl_add(avl, box(61), box(224), nullptr);
- avl = grpc_avl_add(avl, box(656), box(225), nullptr);
- avl = remove_int(avl, 130);
- avl = remove_int(avl, 368);
- avl = remove_int(avl, 150);
- avl = remove_int(avl, 73);
- avl = grpc_avl_add(avl, box(799), box(230), nullptr);
- avl = grpc_avl_add(avl, box(125), box(231), nullptr);
- avl = remove_int(avl, 107);
- avl = grpc_avl_add(avl, box(938), box(233), nullptr);
- avl = grpc_avl_add(avl, box(914), box(234), nullptr);
- avl = grpc_avl_add(avl, box(197), box(235), nullptr);
- avl = remove_int(avl, 736);
- avl = grpc_avl_add(avl, box(20), box(237), nullptr);
- avl = remove_int(avl, 224);
- avl = remove_int(avl, 841);
- avl = grpc_avl_add(avl, box(226), box(240), nullptr);
- avl = remove_int(avl, 963);
- avl = remove_int(avl, 796);
- avl = remove_int(avl, 728);
- avl = grpc_avl_add(avl, box(855), box(244), nullptr);
- avl = grpc_avl_add(avl, box(769), box(245), nullptr);
- avl = grpc_avl_add(avl, box(631), box(246), nullptr);
- avl = remove_int(avl, 648);
- avl = grpc_avl_add(avl, box(187), box(248), nullptr);
- avl = grpc_avl_add(avl, box(31), box(249), nullptr);
- avl = remove_int(avl, 163);
- avl = grpc_avl_add(avl, box(218), box(251), nullptr);
- avl = grpc_avl_add(avl, box(488), box(252), nullptr);
- avl = grpc_avl_add(avl, box(387), box(253), nullptr);
- avl = grpc_avl_add(avl, box(809), box(254), nullptr);
- avl = grpc_avl_add(avl, box(997), box(255), nullptr);
- avl = remove_int(avl, 678);
- avl = grpc_avl_add(avl, box(368), box(257), nullptr);
- avl = grpc_avl_add(avl, box(220), box(258), nullptr);
- avl = grpc_avl_add(avl, box(373), box(259), nullptr);
- avl = remove_int(avl, 874);
- avl = remove_int(avl, 682);
- avl = remove_int(avl, 1014);
- avl = remove_int(avl, 195);
- avl = grpc_avl_add(avl, box(868), box(264), nullptr);
- avl = remove_int(avl, 254);
- avl = remove_int(avl, 456);
- avl = grpc_avl_add(avl, box(906), box(267), nullptr);
- avl = remove_int(avl, 711);
- avl = grpc_avl_add(avl, box(632), box(269), nullptr);
- avl = remove_int(avl, 474);
- avl = grpc_avl_add(avl, box(508), box(271), nullptr);
- avl = grpc_avl_add(avl, box(518), box(272), nullptr);
- avl = remove_int(avl, 579);
- avl = remove_int(avl, 948);
- avl = grpc_avl_add(avl, box(789), box(275), nullptr);
- avl = grpc_avl_add(avl, box(48), box(276), nullptr);
- avl = grpc_avl_add(avl, box(256), box(277), nullptr);
- avl = grpc_avl_add(avl, box(754), box(278), nullptr);
- avl = remove_int(avl, 215);
- avl = grpc_avl_add(avl, box(679), box(280), nullptr);
- avl = grpc_avl_add(avl, box(606), box(281), nullptr);
- avl = remove_int(avl, 941);
- avl = remove_int(avl, 31);
- avl = grpc_avl_add(avl, box(758), box(284), nullptr);
- avl = remove_int(avl, 101);
- avl = grpc_avl_add(avl, box(244), box(286), nullptr);
- avl = grpc_avl_add(avl, box(337), box(287), nullptr);
- avl = grpc_avl_add(avl, box(461), box(288), nullptr);
- avl = remove_int(avl, 476);
- avl = grpc_avl_add(avl, box(845), box(290), nullptr);
- avl = remove_int(avl, 160);
- avl = grpc_avl_add(avl, box(690), box(292), nullptr);
- avl = remove_int(avl, 931);
- avl = grpc_avl_add(avl, box(869), box(294), nullptr);
- avl = grpc_avl_add(avl, box(1019), box(295), nullptr);
- avl = remove_int(avl, 591);
- avl = remove_int(avl, 635);
- avl = remove_int(avl, 67);
- avl = grpc_avl_add(avl, box(113), box(299), nullptr);
- avl = remove_int(avl, 305);
- avl = grpc_avl_add(avl, box(10), box(301), nullptr);
- avl = remove_int(avl, 823);
- avl = remove_int(avl, 288);
- avl = remove_int(avl, 239);
- avl = grpc_avl_add(avl, box(646), box(305), nullptr);
- avl = grpc_avl_add(avl, box(1006), box(306), nullptr);
- avl = grpc_avl_add(avl, box(954), box(307), nullptr);
- avl = grpc_avl_add(avl, box(199), box(308), nullptr);
- avl = grpc_avl_add(avl, box(69), box(309), nullptr);
- avl = grpc_avl_add(avl, box(984), box(310), nullptr);
- avl = remove_int(avl, 568);
- avl = remove_int(avl, 666);
- avl = remove_int(avl, 37);
- avl = grpc_avl_add(avl, box(845), box(314), nullptr);
- avl = remove_int(avl, 535);
- avl = remove_int(avl, 365);
- avl = remove_int(avl, 676);
- avl = remove_int(avl, 892);
- avl = remove_int(avl, 425);
- avl = remove_int(avl, 704);
- avl = remove_int(avl, 168);
- avl = grpc_avl_add(avl, box(853), box(322), nullptr);
- avl = grpc_avl_add(avl, box(335), box(323), nullptr);
- avl = grpc_avl_add(avl, box(961), box(324), nullptr);
- avl = grpc_avl_add(avl, box(73), box(325), nullptr);
- avl = remove_int(avl, 469);
- avl = grpc_avl_add(avl, box(449), box(327), nullptr);
- avl = remove_int(avl, 821);
- avl = grpc_avl_add(avl, box(845), box(329), nullptr);
- avl = remove_int(avl, 637);
- avl = grpc_avl_add(avl, box(769), box(331), nullptr);
- avl = grpc_avl_add(avl, box(901), box(332), nullptr);
- avl = remove_int(avl, 142);
- avl = remove_int(avl, 361);
- avl = remove_int(avl, 876);
- avl = grpc_avl_add(avl, box(614), box(336), nullptr);
- avl = grpc_avl_add(avl, box(729), box(337), nullptr);
- avl = remove_int(avl, 120);
- avl = remove_int(avl, 473);
- avl = remove_int(avl, 445);
- avl = grpc_avl_add(avl, box(978), box(341), nullptr);
- avl = grpc_avl_add(avl, box(164), box(342), nullptr);
- avl = grpc_avl_add(avl, box(1), box(343), nullptr);
- avl = remove_int(avl, 890);
- avl = grpc_avl_add(avl, box(605), box(345), nullptr);
- avl = grpc_avl_add(avl, box(178), box(346), nullptr);
- avl = grpc_avl_add(avl, box(481), box(347), nullptr);
- avl = grpc_avl_add(avl, box(772), box(348), nullptr);
- avl = remove_int(avl, 824);
- avl = remove_int(avl, 167);
- avl = remove_int(avl, 151);
- avl = grpc_avl_add(avl, box(698), box(352), nullptr);
- avl = grpc_avl_add(avl, box(202), box(353), nullptr);
- avl = grpc_avl_add(avl, box(921), box(354), nullptr);
- avl = grpc_avl_add(avl, box(875), box(355), nullptr);
- avl = remove_int(avl, 197);
- avl = remove_int(avl, 232);
- avl = grpc_avl_add(avl, box(209), box(358), nullptr);
- avl = remove_int(avl, 324);
- avl = remove_int(avl, 56);
- avl = remove_int(avl, 579);
- avl = remove_int(avl, 255);
- avl = remove_int(avl, 290);
- avl = grpc_avl_add(avl, box(661), box(364), nullptr);
- avl = grpc_avl_add(avl, box(113), box(365), nullptr);
- avl = remove_int(avl, 767);
- avl = grpc_avl_add(avl, box(586), box(367), nullptr);
- avl = grpc_avl_add(avl, box(121), box(368), nullptr);
- avl = remove_int(avl, 235);
- avl = remove_int(avl, 439);
- avl = remove_int(avl, 360);
- avl = grpc_avl_add(avl, box(916), box(372), nullptr);
- avl = remove_int(avl, 999);
- avl = grpc_avl_add(avl, box(825), box(374), nullptr);
- avl = grpc_avl_add(avl, box(177), box(375), nullptr);
- avl = remove_int(avl, 204);
- avl = remove_int(avl, 92);
- avl = grpc_avl_add(avl, box(794), box(378), nullptr);
- avl = grpc_avl_add(avl, box(463), box(379), nullptr);
- avl = grpc_avl_add(avl, box(472), box(380), nullptr);
- avl = remove_int(avl, 235);
- avl = grpc_avl_add(avl, box(840), box(382), nullptr);
- avl = remove_int(avl, 657);
- avl = grpc_avl_add(avl, box(586), box(384), nullptr);
- avl = grpc_avl_add(avl, box(979), box(385), nullptr);
- avl = remove_int(avl, 979);
- avl = grpc_avl_add(avl, box(639), box(387), nullptr);
- avl = remove_int(avl, 907);
- avl = remove_int(avl, 973);
- avl = grpc_avl_add(avl, box(913), box(390), nullptr);
- avl = grpc_avl_add(avl, box(566), box(391), nullptr);
- avl = grpc_avl_add(avl, box(883), box(392), nullptr);
- avl = grpc_avl_add(avl, box(552), box(393), nullptr);
- avl = grpc_avl_add(avl, box(16), box(394), nullptr);
- avl = remove_int(avl, 60);
- avl = grpc_avl_add(avl, box(567), box(396), nullptr);
- avl = grpc_avl_add(avl, box(705), box(397), nullptr);
- avl = grpc_avl_add(avl, box(94), box(398), nullptr);
- avl = remove_int(avl, 321);
- avl = grpc_avl_add(avl, box(207), box(400), nullptr);
- avl = grpc_avl_add(avl, box(682), box(401), nullptr);
- avl = grpc_avl_add(avl, box(592), box(402), nullptr);
- avl = grpc_avl_add(avl, box(10), box(403), nullptr);
- avl = remove_int(avl, 911);
- avl = remove_int(avl, 161);
- avl = grpc_avl_add(avl, box(86), box(406), nullptr);
- avl = remove_int(avl, 893);
- avl = remove_int(avl, 362);
- avl = grpc_avl_add(avl, box(599), box(409), nullptr);
- avl = remove_int(avl, 413);
- avl = grpc_avl_add(avl, box(867), box(411), nullptr);
- avl = remove_int(avl, 955);
- avl = grpc_avl_add(avl, box(341), box(413), nullptr);
- avl = grpc_avl_add(avl, box(887), box(414), nullptr);
- avl = remove_int(avl, 706);
- avl = grpc_avl_add(avl, box(939), box(416), nullptr);
- avl = remove_int(avl, 233);
- avl = remove_int(avl, 662);
- avl = remove_int(avl, 984);
- avl = remove_int(avl, 203);
- avl = grpc_avl_add(avl, box(326), box(421), nullptr);
- avl = remove_int(avl, 848);
- avl = grpc_avl_add(avl, box(235), box(423), nullptr);
- avl = remove_int(avl, 617);
- avl = grpc_avl_add(avl, box(565), box(425), nullptr);
- avl = remove_int(avl, 469);
- avl = grpc_avl_add(avl, box(988), box(427), nullptr);
- avl = remove_int(avl, 957);
- avl = grpc_avl_add(avl, box(426), box(429), nullptr);
- avl = remove_int(avl, 967);
- avl = grpc_avl_add(avl, box(890), box(431), nullptr);
- avl = grpc_avl_add(avl, box(473), box(432), nullptr);
- avl = remove_int(avl, 367);
- avl = remove_int(avl, 344);
- avl = remove_int(avl, 660);
- avl = remove_int(avl, 448);
- avl = remove_int(avl, 837);
- avl = remove_int(avl, 158);
- avl = grpc_avl_add(avl, box(459), box(439), nullptr);
- avl = remove_int(avl, 882);
- avl = remove_int(avl, 782);
- avl = grpc_avl_add(avl, box(408), box(442), nullptr);
- avl = grpc_avl_add(avl, box(728), box(443), nullptr);
- avl = remove_int(avl, 27);
- avl = grpc_avl_add(avl, box(137), box(445), nullptr);
- avl = grpc_avl_add(avl, box(239), box(446), nullptr);
- avl = remove_int(avl, 854);
- avl = grpc_avl_add(avl, box(104), box(448), nullptr);
- avl = grpc_avl_add(avl, box(823), box(449), nullptr);
- avl = grpc_avl_add(avl, box(524), box(450), nullptr);
- avl = grpc_avl_add(avl, box(995), box(451), nullptr);
- avl = remove_int(avl, 422);
- avl = remove_int(avl, 220);
- avl = grpc_avl_add(avl, box(856), box(454), nullptr);
- avl = remove_int(avl, 332);
- avl = grpc_avl_add(avl, box(679), box(456), nullptr);
- avl = remove_int(avl, 18);
- avl = grpc_avl_add(avl, box(837), box(458), nullptr);
- avl = remove_int(avl, 405);
- avl = remove_int(avl, 877);
- avl = remove_int(avl, 835);
- avl = grpc_avl_add(avl, box(547), box(462), nullptr);
- avl = remove_int(avl, 805);
- avl = remove_int(avl, 862);
- avl = grpc_avl_add(avl, box(75), box(465), nullptr);
- avl = remove_int(avl, 41);
- avl = grpc_avl_add(avl, box(310), box(467), nullptr);
- avl = remove_int(avl, 855);
- avl = grpc_avl_add(avl, box(20), box(469), nullptr);
- avl = remove_int(avl, 186);
- avl = remove_int(avl, 378);
- avl = remove_int(avl, 442);
- avl = remove_int(avl, 930);
- avl = grpc_avl_add(avl, box(118), box(474), nullptr);
- avl = grpc_avl_add(avl, box(96), box(475), nullptr);
- avl = remove_int(avl, 854);
- avl = grpc_avl_add(avl, box(65), box(477), nullptr);
- avl = grpc_avl_add(avl, box(573), box(478), nullptr);
- avl = grpc_avl_add(avl, box(4), box(479), nullptr);
- avl = grpc_avl_add(avl, box(451), box(480), nullptr);
- avl = grpc_avl_add(avl, box(774), box(481), nullptr);
- avl = grpc_avl_add(avl, box(126), box(482), nullptr);
- avl = remove_int(avl, 956);
- avl = remove_int(avl, 591);
- avl = remove_int(avl, 644);
- avl = grpc_avl_add(avl, box(304), box(486), nullptr);
- avl = remove_int(avl, 620);
- avl = remove_int(avl, 394);
- avl = grpc_avl_add(avl, box(1002), box(489), nullptr);
- avl = grpc_avl_add(avl, box(837), box(490), nullptr);
- avl = remove_int(avl, 485);
- avl = grpc_avl_add(avl, box(1005), box(492), nullptr);
- avl = remove_int(avl, 21);
- avl = grpc_avl_add(avl, box(396), box(494), nullptr);
- avl = remove_int(avl, 966);
- avl = grpc_avl_add(avl, box(105), box(496), nullptr);
- avl = grpc_avl_add(avl, box(316), box(497), nullptr);
- avl = remove_int(avl, 776);
- avl = grpc_avl_add(avl, box(188), box(499), nullptr);
- avl = remove_int(avl, 200);
- avl = grpc_avl_add(avl, box(98), box(501), nullptr);
- avl = grpc_avl_add(avl, box(831), box(502), nullptr);
- avl = grpc_avl_add(avl, box(227), box(503), nullptr);
- avl = grpc_avl_add(avl, box(220), box(504), nullptr);
- avl = remove_int(avl, 715);
- avl = remove_int(avl, 279);
- avl = grpc_avl_add(avl, box(701), box(507), nullptr);
- avl = grpc_avl_add(avl, box(726), box(508), nullptr);
- avl = grpc_avl_add(avl, box(815), box(509), nullptr);
- avl = grpc_avl_add(avl, box(749), box(510), nullptr);
- avl = remove_int(avl, 946);
- avl = remove_int(avl, 449);
- avl = remove_int(avl, 62);
- avl = remove_int(avl, 487);
- avl = grpc_avl_add(avl, box(545), box(515), nullptr);
- avl = remove_int(avl, 59);
- avl = grpc_avl_add(avl, box(168), box(517), nullptr);
- avl = remove_int(avl, 337);
- avl = grpc_avl_add(avl, box(69), box(519), nullptr);
- avl = remove_int(avl, 600);
- avl = grpc_avl_add(avl, box(591), box(521), nullptr);
- avl = grpc_avl_add(avl, box(960), box(522), nullptr);
- avl = grpc_avl_add(avl, box(116), box(523), nullptr);
- avl = remove_int(avl, 991);
- avl = grpc_avl_add(avl, box(760), box(525), nullptr);
- avl = grpc_avl_add(avl, box(664), box(526), nullptr);
- avl = grpc_avl_add(avl, box(547), box(527), nullptr);
- avl = remove_int(avl, 922);
- avl = grpc_avl_add(avl, box(290), box(529), nullptr);
- avl = grpc_avl_add(avl, box(859), box(530), nullptr);
- avl = grpc_avl_add(avl, box(49), box(531), nullptr);
- avl = remove_int(avl, 455);
- avl = remove_int(avl, 786);
- avl = grpc_avl_add(avl, box(613), box(534), nullptr);
- avl = grpc_avl_add(avl, box(326), box(535), nullptr);
- avl = remove_int(avl, 615);
- avl = grpc_avl_add(avl, box(45), box(537), nullptr);
- avl = grpc_avl_add(avl, box(162), box(538), nullptr);
- avl = grpc_avl_add(avl, box(189), box(539), nullptr);
- avl = remove_int(avl, 68);
- avl = remove_int(avl, 846);
- avl = grpc_avl_add(avl, box(608), box(542), nullptr);
- avl = remove_int(avl, 821);
- avl = grpc_avl_add(avl, box(978), box(544), nullptr);
- avl = grpc_avl_add(avl, box(892), box(545), nullptr);
- avl = remove_int(avl, 924);
- avl = grpc_avl_add(avl, box(708), box(547), nullptr);
- avl = remove_int(avl, 135);
- avl = remove_int(avl, 124);
- avl = grpc_avl_add(avl, box(301), box(550), nullptr);
- avl = grpc_avl_add(avl, box(939), box(551), nullptr);
- avl = grpc_avl_add(avl, box(344), box(552), nullptr);
- avl = remove_int(avl, 443);
- avl = remove_int(avl, 122);
- avl = grpc_avl_add(avl, box(636), box(555), nullptr);
- avl = remove_int(avl, 558);
- avl = grpc_avl_add(avl, box(923), box(557), nullptr);
- avl = remove_int(avl, 827);
- avl = grpc_avl_add(avl, box(649), box(559), nullptr);
- avl = grpc_avl_add(avl, box(808), box(560), nullptr);
- avl = remove_int(avl, 570);
- avl = remove_int(avl, 434);
- avl = grpc_avl_add(avl, box(40), box(563), nullptr);
- avl = grpc_avl_add(avl, box(725), box(564), nullptr);
- avl = remove_int(avl, 295);
- avl = remove_int(avl, 615);
- avl = remove_int(avl, 919);
- avl = remove_int(avl, 170);
- avl = remove_int(avl, 442);
- avl = remove_int(avl, 971);
- avl = grpc_avl_add(avl, box(483), box(571), nullptr);
- avl = grpc_avl_add(avl, box(512), box(572), nullptr);
- avl = remove_int(avl, 648);
- avl = remove_int(avl, 78);
- avl = remove_int(avl, 72);
- avl = remove_int(avl, 790);
- avl = remove_int(avl, 571);
- avl = grpc_avl_add(avl, box(898), box(578), nullptr);
- avl = remove_int(avl, 770);
- avl = remove_int(avl, 776);
- avl = grpc_avl_add(avl, box(602), box(581), nullptr);
- avl = remove_int(avl, 251);
- avl = grpc_avl_add(avl, box(303), box(583), nullptr);
- avl = remove_int(avl, 837);
- avl = grpc_avl_add(avl, box(714), box(585), nullptr);
- avl = remove_int(avl, 800);
- avl = grpc_avl_add(avl, box(266), box(587), nullptr);
- avl = grpc_avl_add(avl, box(555), box(588), nullptr);
- avl = remove_int(avl, 604);
- avl = remove_int(avl, 163);
- avl = remove_int(avl, 497);
- avl = grpc_avl_add(avl, box(296), box(592), nullptr);
- avl = remove_int(avl, 129);
- avl = grpc_avl_add(avl, box(656), box(594), nullptr);
- avl = remove_int(avl, 769);
- avl = remove_int(avl, 941);
- avl = grpc_avl_add(avl, box(775), box(597), nullptr);
- avl = grpc_avl_add(avl, box(846), box(598), nullptr);
- avl = remove_int(avl, 591);
- avl = remove_int(avl, 801);
- avl = remove_int(avl, 419);
- avl = remove_int(avl, 455);
- avl = grpc_avl_add(avl, box(866), box(603), nullptr);
- avl = grpc_avl_add(avl, box(575), box(604), nullptr);
- avl = grpc_avl_add(avl, box(620), box(605), nullptr);
- avl = remove_int(avl, 100);
- avl = remove_int(avl, 667);
- avl = grpc_avl_add(avl, box(138), box(608), nullptr);
- avl = grpc_avl_add(avl, box(566), box(609), nullptr);
- avl = grpc_avl_add(avl, box(673), box(610), nullptr);
- avl = grpc_avl_add(avl, box(178), box(611), nullptr);
- avl = remove_int(avl, 659);
- avl = grpc_avl_add(avl, box(759), box(613), nullptr);
- avl = grpc_avl_add(avl, box(1008), box(614), nullptr);
- avl = remove_int(avl, 116);
- avl = grpc_avl_add(avl, box(608), box(616), nullptr);
- avl = grpc_avl_add(avl, box(339), box(617), nullptr);
- avl = grpc_avl_add(avl, box(197), box(618), nullptr);
- avl = remove_int(avl, 25);
- avl = remove_int(avl, 628);
- avl = grpc_avl_add(avl, box(487), box(621), nullptr);
- avl = remove_int(avl, 739);
- avl = remove_int(avl, 100);
- avl = remove_int(avl, 928);
- avl = grpc_avl_add(avl, box(647), box(625), nullptr);
- avl = remove_int(avl, 978);
- avl = remove_int(avl, 143);
- avl = remove_int(avl, 755);
- avl = grpc_avl_add(avl, box(71), box(629), nullptr);
- avl = remove_int(avl, 205);
- avl = grpc_avl_add(avl, box(501), box(631), nullptr);
- avl = remove_int(avl, 723);
- avl = remove_int(avl, 852);
- avl = remove_int(avl, 1021);
- avl = remove_int(avl, 670);
- avl = remove_int(avl, 500);
- avl = grpc_avl_add(avl, box(330), box(637), nullptr);
- avl = remove_int(avl, 264);
- avl = grpc_avl_add(avl, box(69), box(639), nullptr);
- avl = remove_int(avl, 73);
- avl = grpc_avl_add(avl, box(745), box(641), nullptr);
- avl = remove_int(avl, 518);
- avl = remove_int(avl, 641);
- avl = remove_int(avl, 768);
- avl = grpc_avl_add(avl, box(988), box(645), nullptr);
- avl = grpc_avl_add(avl, box(899), box(646), nullptr);
- avl = remove_int(avl, 763);
- avl = remove_int(avl, 281);
- avl = remove_int(avl, 496);
- avl = grpc_avl_add(avl, box(445), box(650), nullptr);
- avl = remove_int(avl, 905);
- avl = grpc_avl_add(avl, box(275), box(652), nullptr);
- avl = grpc_avl_add(avl, box(137), box(653), nullptr);
- avl = remove_int(avl, 642);
- avl = grpc_avl_add(avl, box(708), box(655), nullptr);
- avl = remove_int(avl, 922);
- avl = grpc_avl_add(avl, box(743), box(657), nullptr);
- avl = remove_int(avl, 295);
- avl = remove_int(avl, 665);
- avl = remove_int(avl, 48);
- avl = grpc_avl_add(avl, box(1012), box(661), nullptr);
- avl = remove_int(avl, 71);
- avl = remove_int(avl, 523);
- avl = grpc_avl_add(avl, box(319), box(664), nullptr);
- avl = remove_int(avl, 632);
- avl = grpc_avl_add(avl, box(137), box(666), nullptr);
- avl = grpc_avl_add(avl, box(686), box(667), nullptr);
- avl = grpc_avl_add(avl, box(724), box(668), nullptr);
- avl = grpc_avl_add(avl, box(952), box(669), nullptr);
- avl = grpc_avl_add(avl, box(5), box(670), nullptr);
- avl = remove_int(avl, 35);
- avl = grpc_avl_add(avl, box(43), box(672), nullptr);
- avl = grpc_avl_add(avl, box(320), box(673), nullptr);
- avl = grpc_avl_add(avl, box(115), box(674), nullptr);
- avl = remove_int(avl, 377);
- avl = remove_int(avl, 591);
- avl = remove_int(avl, 87);
- avl = remove_int(avl, 93);
- avl = grpc_avl_add(avl, box(1016), box(679), nullptr);
- avl = grpc_avl_add(avl, box(605), box(680), nullptr);
- avl = grpc_avl_add(avl, box(152), box(681), nullptr);
- avl = grpc_avl_add(avl, box(113), box(682), nullptr);
- avl = remove_int(avl, 131);
- avl = remove_int(avl, 637);
- avl = grpc_avl_add(avl, box(156), box(685), nullptr);
- avl = remove_int(avl, 696);
- avl = grpc_avl_add(avl, box(546), box(687), nullptr);
- avl = remove_int(avl, 970);
- avl = remove_int(avl, 53);
- avl = remove_int(avl, 827);
- avl = remove_int(avl, 224);
- avl = remove_int(avl, 796);
- avl = remove_int(avl, 34);
- avl = remove_int(avl, 922);
- avl = remove_int(avl, 277);
- avl = remove_int(avl, 650);
- avl = remove_int(avl, 222);
- avl = remove_int(avl, 244);
- avl = remove_int(avl, 576);
- avl = remove_int(avl, 413);
- avl = grpc_avl_add(avl, box(500), box(701), nullptr);
- avl = remove_int(avl, 924);
- avl = grpc_avl_add(avl, box(825), box(703), nullptr);
- avl = remove_int(avl, 888);
- avl = remove_int(avl, 931);
- avl = grpc_avl_add(avl, box(285), box(706), nullptr);
- avl = remove_int(avl, 62);
- avl = remove_int(avl, 444);
- avl = remove_int(avl, 946);
- avl = grpc_avl_add(avl, box(122), box(710), nullptr);
- avl = grpc_avl_add(avl, box(846), box(711), nullptr);
- avl = remove_int(avl, 628);
- avl = grpc_avl_add(avl, box(511), box(713), nullptr);
- avl = grpc_avl_add(avl, box(398), box(714), nullptr);
- avl = remove_int(avl, 730);
- avl = grpc_avl_add(avl, box(797), box(716), nullptr);
- avl = remove_int(avl, 897);
- avl = remove_int(avl, 228);
- avl = remove_int(avl, 544);
- avl = remove_int(avl, 552);
- avl = remove_int(avl, 783);
- avl = remove_int(avl, 583);
- avl = remove_int(avl, 894);
- avl = remove_int(avl, 942);
- avl = grpc_avl_add(avl, box(346), box(725), nullptr);
- avl = grpc_avl_add(avl, box(1015), box(726), nullptr);
- avl = remove_int(avl, 813);
- avl = grpc_avl_add(avl, box(213), box(728), nullptr);
- avl = remove_int(avl, 468);
- avl = remove_int(avl, 365);
- avl = remove_int(avl, 399);
- avl = grpc_avl_add(avl, box(380), box(732), nullptr);
- avl = remove_int(avl, 835);
- avl = remove_int(avl, 970);
- avl = grpc_avl_add(avl, box(700), box(735), nullptr);
- avl = grpc_avl_add(avl, box(807), box(736), nullptr);
- avl = remove_int(avl, 312);
- avl = remove_int(avl, 282);
- avl = remove_int(avl, 370);
- avl = remove_int(avl, 999);
- avl = remove_int(avl, 241);
- avl = remove_int(avl, 884);
- avl = grpc_avl_add(avl, box(587), box(743), nullptr);
- avl = grpc_avl_add(avl, box(332), box(744), nullptr);
- avl = remove_int(avl, 686);
- avl = remove_int(avl, 206);
- avl = remove_int(avl, 835);
- avl = grpc_avl_add(avl, box(334), box(748), nullptr);
- avl = remove_int(avl, 171);
- avl = grpc_avl_add(avl, box(1002), box(750), nullptr);
- avl = grpc_avl_add(avl, box(779), box(751), nullptr);
- avl = grpc_avl_add(avl, box(307), box(752), nullptr);
- avl = grpc_avl_add(avl, box(127), box(753), nullptr);
- avl = grpc_avl_add(avl, box(251), box(754), nullptr);
- avl = remove_int(avl, 790);
- avl = remove_int(avl, 189);
- avl = remove_int(avl, 193);
- avl = remove_int(avl, 38);
- avl = remove_int(avl, 124);
- avl = grpc_avl_add(avl, box(812), box(760), nullptr);
- avl = remove_int(avl, 43);
- avl = grpc_avl_add(avl, box(871), box(762), nullptr);
- avl = grpc_avl_add(avl, box(580), box(763), nullptr);
- avl = remove_int(avl, 501);
- avl = remove_int(avl, 462);
- avl = remove_int(avl, 599);
- avl = grpc_avl_add(avl, box(240), box(767), nullptr);
- avl = grpc_avl_add(avl, box(285), box(768), nullptr);
- avl = grpc_avl_add(avl, box(472), box(769), nullptr);
- avl = remove_int(avl, 865);
- avl = remove_int(avl, 763);
- avl = remove_int(avl, 245);
- avl = remove_int(avl, 80);
- avl = remove_int(avl, 713);
- avl = remove_int(avl, 654);
- avl = remove_int(avl, 1014);
- avl = grpc_avl_add(avl, box(495), box(777), nullptr);
- avl = grpc_avl_add(avl, box(552), box(778), nullptr);
- avl = remove_int(avl, 19);
- avl = remove_int(avl, 803);
- avl = grpc_avl_add(avl, box(508), box(781), nullptr);
- avl = remove_int(avl, 699);
- avl = remove_int(avl, 260);
- avl = remove_int(avl, 92);
- avl = remove_int(avl, 497);
- avl = grpc_avl_add(avl, box(970), box(786), nullptr);
- avl = remove_int(avl, 987);
- avl = remove_int(avl, 168);
- avl = remove_int(avl, 476);
- avl = remove_int(avl, 248);
- avl = grpc_avl_add(avl, box(358), box(791), nullptr);
- avl = remove_int(avl, 804);
- avl = remove_int(avl, 77);
- avl = remove_int(avl, 905);
- avl = remove_int(avl, 362);
- avl = grpc_avl_add(avl, box(578), box(796), nullptr);
- avl = remove_int(avl, 38);
- avl = remove_int(avl, 595);
- avl = grpc_avl_add(avl, box(213), box(799), nullptr);
- avl = remove_int(avl, 7);
- avl = remove_int(avl, 620);
- avl = grpc_avl_add(avl, box(946), box(802), nullptr);
- avl = remove_int(avl, 145);
- avl = grpc_avl_add(avl, box(628), box(804), nullptr);
- avl = remove_int(avl, 972);
- avl = grpc_avl_add(avl, box(728), box(806), nullptr);
- avl = remove_int(avl, 91);
- avl = grpc_avl_add(avl, box(136), box(808), nullptr);
- avl = grpc_avl_add(avl, box(841), box(809), nullptr);
- avl = grpc_avl_add(avl, box(265), box(810), nullptr);
- avl = grpc_avl_add(avl, box(701), box(811), nullptr);
- avl = grpc_avl_add(avl, box(27), box(812), nullptr);
- avl = remove_int(avl, 72);
- avl = remove_int(avl, 14);
- avl = grpc_avl_add(avl, box(286), box(815), nullptr);
- avl = remove_int(avl, 996);
- avl = remove_int(avl, 998);
- avl = grpc_avl_add(avl, box(466), box(818), nullptr);
- avl = remove_int(avl, 1009);
- avl = remove_int(avl, 741);
- avl = remove_int(avl, 947);
- avl = remove_int(avl, 241);
- avl = remove_int(avl, 954);
- avl = remove_int(avl, 183);
- avl = remove_int(avl, 395);
- avl = remove_int(avl, 951);
- avl = grpc_avl_add(avl, box(267), box(827), nullptr);
- avl = remove_int(avl, 812);
- avl = grpc_avl_add(avl, box(577), box(829), nullptr);
- avl = remove_int(avl, 624);
- avl = remove_int(avl, 847);
- avl = remove_int(avl, 745);
- avl = grpc_avl_add(avl, box(491), box(833), nullptr);
- avl = grpc_avl_add(avl, box(941), box(834), nullptr);
- avl = remove_int(avl, 258);
- avl = grpc_avl_add(avl, box(410), box(836), nullptr);
- avl = grpc_avl_add(avl, box(80), box(837), nullptr);
- avl = grpc_avl_add(avl, box(196), box(838), nullptr);
- avl = grpc_avl_add(avl, box(5), box(839), nullptr);
- avl = remove_int(avl, 782);
- avl = grpc_avl_add(avl, box(827), box(841), nullptr);
- avl = remove_int(avl, 472);
- avl = remove_int(avl, 664);
- avl = grpc_avl_add(avl, box(409), box(844), nullptr);
- avl = grpc_avl_add(avl, box(62), box(845), nullptr);
- avl = remove_int(avl, 56);
- avl = remove_int(avl, 606);
- avl = remove_int(avl, 707);
- avl = remove_int(avl, 989);
- avl = remove_int(avl, 549);
- avl = remove_int(avl, 259);
- avl = grpc_avl_add(avl, box(405), box(852), nullptr);
- avl = remove_int(avl, 587);
- avl = remove_int(avl, 350);
- avl = grpc_avl_add(avl, box(980), box(855), nullptr);
- avl = grpc_avl_add(avl, box(992), box(856), nullptr);
- avl = grpc_avl_add(avl, box(818), box(857), nullptr);
- avl = remove_int(avl, 853);
- avl = remove_int(avl, 701);
- avl = grpc_avl_add(avl, box(675), box(860), nullptr);
- avl = remove_int(avl, 248);
- avl = remove_int(avl, 649);
- avl = grpc_avl_add(avl, box(508), box(863), nullptr);
- avl = remove_int(avl, 927);
- avl = grpc_avl_add(avl, box(957), box(865), nullptr);
- avl = grpc_avl_add(avl, box(698), box(866), nullptr);
- avl = grpc_avl_add(avl, box(388), box(867), nullptr);
- avl = grpc_avl_add(avl, box(532), box(868), nullptr);
- avl = grpc_avl_add(avl, box(681), box(869), nullptr);
- avl = remove_int(avl, 544);
- avl = remove_int(avl, 991);
- avl = remove_int(avl, 397);
- avl = grpc_avl_add(avl, box(954), box(873), nullptr);
- avl = grpc_avl_add(avl, box(219), box(874), nullptr);
- avl = grpc_avl_add(avl, box(465), box(875), nullptr);
- avl = remove_int(avl, 371);
- avl = grpc_avl_add(avl, box(601), box(877), nullptr);
- avl = grpc_avl_add(avl, box(543), box(878), nullptr);
- avl = remove_int(avl, 329);
- avl = grpc_avl_add(avl, box(560), box(880), nullptr);
- avl = remove_int(avl, 898);
- avl = grpc_avl_add(avl, box(455), box(882), nullptr);
- avl = remove_int(avl, 313);
- avl = grpc_avl_add(avl, box(215), box(884), nullptr);
- avl = remove_int(avl, 846);
- avl = grpc_avl_add(avl, box(608), box(886), nullptr);
- avl = remove_int(avl, 248);
- avl = grpc_avl_add(avl, box(575), box(888), nullptr);
- avl = remove_int(avl, 207);
- avl = remove_int(avl, 810);
- avl = remove_int(avl, 665);
- avl = remove_int(avl, 361);
- avl = grpc_avl_add(avl, box(154), box(893), nullptr);
- avl = grpc_avl_add(avl, box(329), box(894), nullptr);
- avl = grpc_avl_add(avl, box(326), box(895), nullptr);
- avl = remove_int(avl, 746);
- avl = remove_int(avl, 99);
- avl = grpc_avl_add(avl, box(464), box(898), nullptr);
- avl = grpc_avl_add(avl, box(141), box(899), nullptr);
- avl = remove_int(avl, 383);
- avl = grpc_avl_add(avl, box(414), box(901), nullptr);
- avl = grpc_avl_add(avl, box(777), box(902), nullptr);
- avl = remove_int(avl, 972);
- avl = remove_int(avl, 841);
- avl = remove_int(avl, 100);
- avl = grpc_avl_add(avl, box(828), box(906), nullptr);
- avl = remove_int(avl, 785);
- avl = grpc_avl_add(avl, box(1008), box(908), nullptr);
- avl = grpc_avl_add(avl, box(46), box(909), nullptr);
- avl = remove_int(avl, 399);
- avl = grpc_avl_add(avl, box(178), box(911), nullptr);
- avl = grpc_avl_add(avl, box(573), box(912), nullptr);
- avl = remove_int(avl, 299);
- avl = grpc_avl_add(avl, box(690), box(914), nullptr);
- avl = grpc_avl_add(avl, box(692), box(915), nullptr);
- avl = remove_int(avl, 404);
- avl = remove_int(avl, 16);
- avl = remove_int(avl, 746);
- avl = remove_int(avl, 486);
- avl = remove_int(avl, 119);
- avl = grpc_avl_add(avl, box(167), box(921), nullptr);
- avl = remove_int(avl, 328);
- avl = grpc_avl_add(avl, box(89), box(923), nullptr);
- avl = remove_int(avl, 867);
- avl = remove_int(avl, 626);
- avl = remove_int(avl, 507);
- avl = grpc_avl_add(avl, box(365), box(927), nullptr);
- avl = grpc_avl_add(avl, box(58), box(928), nullptr);
- avl = grpc_avl_add(avl, box(70), box(929), nullptr);
- avl = remove_int(avl, 81);
- avl = remove_int(avl, 797);
- avl = grpc_avl_add(avl, box(846), box(932), nullptr);
- avl = remove_int(avl, 642);
- avl = grpc_avl_add(avl, box(777), box(934), nullptr);
- avl = remove_int(avl, 107);
- avl = grpc_avl_add(avl, box(691), box(936), nullptr);
- avl = grpc_avl_add(avl, box(820), box(937), nullptr);
- avl = grpc_avl_add(avl, box(202), box(938), nullptr);
- avl = grpc_avl_add(avl, box(308), box(939), nullptr);
- avl = grpc_avl_add(avl, box(20), box(940), nullptr);
- avl = remove_int(avl, 289);
- avl = grpc_avl_add(avl, box(714), box(942), nullptr);
- avl = grpc_avl_add(avl, box(584), box(943), nullptr);
- avl = remove_int(avl, 294);
- avl = grpc_avl_add(avl, box(496), box(945), nullptr);
- avl = grpc_avl_add(avl, box(394), box(946), nullptr);
- avl = grpc_avl_add(avl, box(860), box(947), nullptr);
- avl = grpc_avl_add(avl, box(58), box(948), nullptr);
- avl = remove_int(avl, 784);
- avl = remove_int(avl, 584);
- avl = remove_int(avl, 708);
- avl = grpc_avl_add(avl, box(142), box(952), nullptr);
- avl = grpc_avl_add(avl, box(247), box(953), nullptr);
- avl = grpc_avl_add(avl, box(389), box(954), nullptr);
- avl = remove_int(avl, 390);
- avl = grpc_avl_add(avl, box(465), box(956), nullptr);
- avl = grpc_avl_add(avl, box(936), box(957), nullptr);
- avl = grpc_avl_add(avl, box(309), box(958), nullptr);
- avl = remove_int(avl, 928);
- avl = remove_int(avl, 128);
- avl = remove_int(avl, 979);
- avl = remove_int(avl, 670);
- avl = remove_int(avl, 738);
- avl = remove_int(avl, 271);
- avl = remove_int(avl, 540);
- avl = grpc_avl_add(avl, box(365), box(966), nullptr);
- avl = remove_int(avl, 82);
- avl = grpc_avl_add(avl, box(728), box(968), nullptr);
- avl = remove_int(avl, 852);
- avl = grpc_avl_add(avl, box(884), box(970), nullptr);
- avl = grpc_avl_add(avl, box(502), box(971), nullptr);
- avl = remove_int(avl, 898);
- avl = remove_int(avl, 481);
- avl = grpc_avl_add(avl, box(911), box(974), nullptr);
- avl = remove_int(avl, 787);
- avl = remove_int(avl, 785);
- avl = remove_int(avl, 537);
- avl = remove_int(avl, 535);
- avl = remove_int(avl, 136);
- avl = remove_int(avl, 749);
- avl = remove_int(avl, 637);
- avl = remove_int(avl, 900);
- avl = grpc_avl_add(avl, box(598), box(983), nullptr);
- avl = remove_int(avl, 25);
- avl = remove_int(avl, 697);
- avl = grpc_avl_add(avl, box(645), box(986), nullptr);
- avl = grpc_avl_add(avl, box(211), box(987), nullptr);
- avl = grpc_avl_add(avl, box(589), box(988), nullptr);
- avl = remove_int(avl, 702);
- avl = grpc_avl_add(avl, box(53), box(990), nullptr);
- avl = remove_int(avl, 492);
- avl = remove_int(avl, 185);
- avl = remove_int(avl, 246);
- avl = remove_int(avl, 257);
- avl = remove_int(avl, 502);
- avl = remove_int(avl, 34);
- avl = grpc_avl_add(avl, box(74), box(997), nullptr);
- avl = grpc_avl_add(avl, box(834), box(998), nullptr);
- avl = grpc_avl_add(avl, box(514), box(999), nullptr);
- avl = grpc_avl_add(avl, box(75), box(1000), nullptr);
- avl = remove_int(avl, 745);
- avl = grpc_avl_add(avl, box(362), box(1002), nullptr);
- avl = remove_int(avl, 215);
- avl = grpc_avl_add(avl, box(624), box(1004), nullptr);
- avl = remove_int(avl, 404);
- avl = remove_int(avl, 359);
- avl = remove_int(avl, 491);
- avl = grpc_avl_add(avl, box(903), box(1008), nullptr);
- avl = grpc_avl_add(avl, box(240), box(1009), nullptr);
- avl = remove_int(avl, 95);
- avl = grpc_avl_add(avl, box(119), box(1011), nullptr);
- avl = grpc_avl_add(avl, box(857), box(1012), nullptr);
- avl = remove_int(avl, 39);
- avl = remove_int(avl, 866);
- avl = grpc_avl_add(avl, box(503), box(1015), nullptr);
- avl = grpc_avl_add(avl, box(740), box(1016), nullptr);
- avl = remove_int(avl, 637);
- avl = remove_int(avl, 156);
- avl = remove_int(avl, 6);
- avl = remove_int(avl, 745);
- avl = remove_int(avl, 433);
- avl = remove_int(avl, 283);
- avl = grpc_avl_add(avl, box(625), box(1023), nullptr);
- avl = remove_int(avl, 638);
- avl = grpc_avl_add(avl, box(299), box(1025), nullptr);
- avl = grpc_avl_add(avl, box(584), box(1026), nullptr);
- avl = remove_int(avl, 863);
- avl = grpc_avl_add(avl, box(612), box(1028), nullptr);
- avl = grpc_avl_add(avl, box(62), box(1029), nullptr);
- avl = grpc_avl_add(avl, box(432), box(1030), nullptr);
- avl = remove_int(avl, 371);
- avl = remove_int(avl, 790);
- avl = remove_int(avl, 227);
- avl = remove_int(avl, 836);
- avl = grpc_avl_add(avl, box(703), box(1035), nullptr);
- avl = grpc_avl_add(avl, box(644), box(1036), nullptr);
- avl = remove_int(avl, 638);
- avl = grpc_avl_add(avl, box(13), box(1038), nullptr);
- avl = remove_int(avl, 66);
- avl = remove_int(avl, 82);
- avl = grpc_avl_add(avl, box(362), box(1041), nullptr);
- avl = grpc_avl_add(avl, box(783), box(1042), nullptr);
- avl = remove_int(avl, 60);
- avl = grpc_avl_add(avl, box(80), box(1044), nullptr);
- avl = grpc_avl_add(avl, box(825), box(1045), nullptr);
- avl = grpc_avl_add(avl, box(688), box(1046), nullptr);
- avl = grpc_avl_add(avl, box(662), box(1047), nullptr);
- avl = remove_int(avl, 156);
- avl = remove_int(avl, 376);
- avl = remove_int(avl, 99);
- avl = grpc_avl_add(avl, box(526), box(1051), nullptr);
- avl = grpc_avl_add(avl, box(168), box(1052), nullptr);
- avl = remove_int(avl, 646);
- avl = remove_int(avl, 380);
- avl = remove_int(avl, 833);
- avl = grpc_avl_add(avl, box(53), box(1056), nullptr);
- avl = remove_int(avl, 105);
- avl = grpc_avl_add(avl, box(373), box(1058), nullptr);
- avl = grpc_avl_add(avl, box(184), box(1059), nullptr);
- avl = remove_int(avl, 288);
- avl = grpc_avl_add(avl, box(966), box(1061), nullptr);
- avl = remove_int(avl, 158);
- avl = grpc_avl_add(avl, box(406), box(1063), nullptr);
- avl = remove_int(avl, 470);
- avl = grpc_avl_add(avl, box(283), box(1065), nullptr);
- avl = grpc_avl_add(avl, box(838), box(1066), nullptr);
- avl = grpc_avl_add(avl, box(288), box(1067), nullptr);
- avl = grpc_avl_add(avl, box(950), box(1068), nullptr);
- avl = grpc_avl_add(avl, box(163), box(1069), nullptr);
- avl = remove_int(avl, 623);
- avl = remove_int(avl, 769);
- avl = grpc_avl_add(avl, box(144), box(1072), nullptr);
- avl = grpc_avl_add(avl, box(489), box(1073), nullptr);
- avl = remove_int(avl, 15);
- avl = grpc_avl_add(avl, box(971), box(1075), nullptr);
- avl = remove_int(avl, 660);
- avl = grpc_avl_add(avl, box(255), box(1077), nullptr);
- avl = remove_int(avl, 494);
- avl = grpc_avl_add(avl, box(109), box(1079), nullptr);
- avl = grpc_avl_add(avl, box(420), box(1080), nullptr);
- avl = grpc_avl_add(avl, box(509), box(1081), nullptr);
- avl = remove_int(avl, 178);
- avl = grpc_avl_add(avl, box(216), box(1083), nullptr);
- avl = grpc_avl_add(avl, box(707), box(1084), nullptr);
- avl = grpc_avl_add(avl, box(411), box(1085), nullptr);
- avl = grpc_avl_add(avl, box(352), box(1086), nullptr);
- avl = remove_int(avl, 983);
- avl = grpc_avl_add(avl, box(6), box(1088), nullptr);
- avl = grpc_avl_add(avl, box(1014), box(1089), nullptr);
- avl = remove_int(avl, 98);
- avl = remove_int(avl, 325);
- avl = grpc_avl_add(avl, box(851), box(1092), nullptr);
- avl = remove_int(avl, 553);
- avl = grpc_avl_add(avl, box(218), box(1094), nullptr);
- avl = grpc_avl_add(avl, box(261), box(1095), nullptr);
- avl = remove_int(avl, 31);
- avl = grpc_avl_add(avl, box(872), box(1097), nullptr);
- avl = remove_int(avl, 543);
- avl = remove_int(avl, 314);
- avl = remove_int(avl, 443);
- avl = grpc_avl_add(avl, box(533), box(1101), nullptr);
- avl = remove_int(avl, 881);
- avl = remove_int(avl, 269);
- avl = remove_int(avl, 940);
- avl = remove_int(avl, 909);
- avl = remove_int(avl, 197);
- avl = remove_int(avl, 773);
- avl = remove_int(avl, 790);
- avl = remove_int(avl, 345);
- avl = grpc_avl_add(avl, box(965), box(1110), nullptr);
- avl = remove_int(avl, 622);
- avl = grpc_avl_add(avl, box(352), box(1112), nullptr);
- avl = remove_int(avl, 182);
- avl = grpc_avl_add(avl, box(534), box(1114), nullptr);
- avl = grpc_avl_add(avl, box(97), box(1115), nullptr);
- avl = grpc_avl_add(avl, box(198), box(1116), nullptr);
- avl = remove_int(avl, 750);
- avl = grpc_avl_add(avl, box(98), box(1118), nullptr);
- avl = remove_int(avl, 943);
- avl = grpc_avl_add(avl, box(254), box(1120), nullptr);
- avl = grpc_avl_add(avl, box(30), box(1121), nullptr);
- avl = remove_int(avl, 14);
- avl = remove_int(avl, 475);
- avl = remove_int(avl, 82);
- avl = grpc_avl_add(avl, box(789), box(1125), nullptr);
- avl = grpc_avl_add(avl, box(402), box(1126), nullptr);
- avl = remove_int(avl, 1019);
- avl = grpc_avl_add(avl, box(858), box(1128), nullptr);
- avl = grpc_avl_add(avl, box(625), box(1129), nullptr);
- avl = remove_int(avl, 675);
- avl = remove_int(avl, 323);
- avl = grpc_avl_add(avl, box(329), box(1132), nullptr);
- avl = remove_int(avl, 929);
- avl = remove_int(avl, 44);
- avl = grpc_avl_add(avl, box(443), box(1135), nullptr);
- avl = grpc_avl_add(avl, box(653), box(1136), nullptr);
- avl = grpc_avl_add(avl, box(750), box(1137), nullptr);
- avl = grpc_avl_add(avl, box(252), box(1138), nullptr);
- avl = grpc_avl_add(avl, box(449), box(1139), nullptr);
- avl = remove_int(avl, 1022);
- avl = remove_int(avl, 357);
- avl = remove_int(avl, 602);
- avl = remove_int(avl, 131);
- avl = grpc_avl_add(avl, box(531), box(1144), nullptr);
- avl = remove_int(avl, 806);
- avl = grpc_avl_add(avl, box(455), box(1146), nullptr);
- avl = remove_int(avl, 31);
- avl = grpc_avl_add(avl, box(154), box(1148), nullptr);
- avl = grpc_avl_add(avl, box(189), box(1149), nullptr);
- avl = remove_int(avl, 786);
- avl = grpc_avl_add(avl, box(496), box(1151), nullptr);
- avl = grpc_avl_add(avl, box(81), box(1152), nullptr);
- avl = grpc_avl_add(avl, box(59), box(1153), nullptr);
- avl = remove_int(avl, 424);
- avl = remove_int(avl, 668);
- avl = grpc_avl_add(avl, box(723), box(1156), nullptr);
- avl = grpc_avl_add(avl, box(822), box(1157), nullptr);
- avl = grpc_avl_add(avl, box(354), box(1158), nullptr);
- avl = remove_int(avl, 738);
- avl = grpc_avl_add(avl, box(686), box(1160), nullptr);
- avl = grpc_avl_add(avl, box(43), box(1161), nullptr);
- avl = grpc_avl_add(avl, box(625), box(1162), nullptr);
- avl = grpc_avl_add(avl, box(902), box(1163), nullptr);
- avl = grpc_avl_add(avl, box(12), box(1164), nullptr);
- avl = grpc_avl_add(avl, box(977), box(1165), nullptr);
- avl = grpc_avl_add(avl, box(699), box(1166), nullptr);
- avl = grpc_avl_add(avl, box(189), box(1167), nullptr);
- avl = remove_int(avl, 672);
- avl = remove_int(avl, 90);
- avl = remove_int(avl, 757);
- avl = remove_int(avl, 494);
- avl = grpc_avl_add(avl, box(759), box(1172), nullptr);
- avl = remove_int(avl, 758);
- avl = remove_int(avl, 222);
- avl = grpc_avl_add(avl, box(975), box(1175), nullptr);
- avl = remove_int(avl, 993);
- avl = grpc_avl_add(avl, box(2), box(1177), nullptr);
- avl = grpc_avl_add(avl, box(70), box(1178), nullptr);
- avl = remove_int(avl, 350);
- avl = remove_int(avl, 972);
- avl = remove_int(avl, 880);
- avl = grpc_avl_add(avl, box(753), box(1182), nullptr);
- avl = remove_int(avl, 404);
- avl = grpc_avl_add(avl, box(294), box(1184), nullptr);
- avl = remove_int(avl, 474);
- avl = grpc_avl_add(avl, box(228), box(1186), nullptr);
- avl = grpc_avl_add(avl, box(484), box(1187), nullptr);
- avl = remove_int(avl, 238);
- avl = remove_int(avl, 53);
- avl = remove_int(avl, 691);
- avl = grpc_avl_add(avl, box(345), box(1191), nullptr);
- avl = remove_int(avl, 0);
- avl = grpc_avl_add(avl, box(230), box(1193), nullptr);
- avl = remove_int(avl, 227);
- avl = remove_int(avl, 152);
- avl = grpc_avl_add(avl, box(884), box(1196), nullptr);
- avl = remove_int(avl, 823);
- avl = remove_int(avl, 53);
- avl = grpc_avl_add(avl, box(1015), box(1199), nullptr);
- avl = grpc_avl_add(avl, box(697), box(1200), nullptr);
- avl = grpc_avl_add(avl, box(376), box(1201), nullptr);
- avl = remove_int(avl, 411);
- avl = grpc_avl_add(avl, box(888), box(1203), nullptr);
- avl = remove_int(avl, 55);
- avl = grpc_avl_add(avl, box(85), box(1205), nullptr);
- avl = remove_int(avl, 947);
- avl = remove_int(avl, 382);
- avl = remove_int(avl, 777);
- avl = grpc_avl_add(avl, box(1017), box(1209), nullptr);
- avl = grpc_avl_add(avl, box(169), box(1210), nullptr);
- avl = grpc_avl_add(avl, box(156), box(1211), nullptr);
- avl = remove_int(avl, 153);
- avl = remove_int(avl, 642);
- avl = remove_int(avl, 158);
- avl = grpc_avl_add(avl, box(554), box(1215), nullptr);
- avl = grpc_avl_add(avl, box(76), box(1216), nullptr);
- avl = grpc_avl_add(avl, box(756), box(1217), nullptr);
- avl = remove_int(avl, 767);
- avl = remove_int(avl, 112);
- avl = remove_int(avl, 539);
- avl = remove_int(avl, 544);
- avl = remove_int(avl, 628);
- avl = remove_int(avl, 385);
- avl = remove_int(avl, 514);
- avl = remove_int(avl, 362);
- avl = grpc_avl_add(avl, box(523), box(1226), nullptr);
- avl = grpc_avl_add(avl, box(712), box(1227), nullptr);
- avl = grpc_avl_add(avl, box(474), box(1228), nullptr);
- avl = grpc_avl_add(avl, box(882), box(1229), nullptr);
- avl = grpc_avl_add(avl, box(965), box(1230), nullptr);
- avl = remove_int(avl, 464);
- avl = grpc_avl_add(avl, box(319), box(1232), nullptr);
- avl = grpc_avl_add(avl, box(504), box(1233), nullptr);
- avl = remove_int(avl, 818);
- avl = grpc_avl_add(avl, box(884), box(1235), nullptr);
- avl = grpc_avl_add(avl, box(813), box(1236), nullptr);
- avl = grpc_avl_add(avl, box(795), box(1237), nullptr);
- avl = remove_int(avl, 306);
- avl = grpc_avl_add(avl, box(799), box(1239), nullptr);
- avl = remove_int(avl, 534);
- avl = grpc_avl_add(avl, box(480), box(1241), nullptr);
- avl = grpc_avl_add(avl, box(656), box(1242), nullptr);
- avl = grpc_avl_add(avl, box(709), box(1243), nullptr);
- avl = grpc_avl_add(avl, box(500), box(1244), nullptr);
- avl = remove_int(avl, 740);
- avl = grpc_avl_add(avl, box(980), box(1246), nullptr);
- avl = grpc_avl_add(avl, box(458), box(1247), nullptr);
- avl = remove_int(avl, 377);
- avl = remove_int(avl, 338);
- avl = grpc_avl_add(avl, box(554), box(1250), nullptr);
- avl = grpc_avl_add(avl, box(504), box(1251), nullptr);
- avl = grpc_avl_add(avl, box(603), box(1252), nullptr);
- avl = grpc_avl_add(avl, box(761), box(1253), nullptr);
- avl = remove_int(avl, 431);
- avl = grpc_avl_add(avl, box(707), box(1255), nullptr);
- avl = grpc_avl_add(avl, box(673), box(1256), nullptr);
- avl = remove_int(avl, 998);
- avl = remove_int(avl, 332);
- avl = remove_int(avl, 413);
- avl = remove_int(avl, 227);
- avl = remove_int(avl, 249);
- avl = remove_int(avl, 309);
- avl = remove_int(avl, 459);
- avl = grpc_avl_add(avl, box(645), box(1264), nullptr);
- avl = remove_int(avl, 858);
- avl = remove_int(avl, 997);
- avl = grpc_avl_add(avl, box(519), box(1267), nullptr);
- avl = remove_int(avl, 614);
- avl = remove_int(avl, 462);
- avl = remove_int(avl, 792);
- avl = grpc_avl_add(avl, box(987), box(1271), nullptr);
- avl = grpc_avl_add(avl, box(309), box(1272), nullptr);
- avl = remove_int(avl, 747);
- avl = grpc_avl_add(avl, box(621), box(1274), nullptr);
- avl = grpc_avl_add(avl, box(450), box(1275), nullptr);
- avl = remove_int(avl, 265);
- avl = remove_int(avl, 8);
- avl = remove_int(avl, 383);
- avl = grpc_avl_add(avl, box(238), box(1279), nullptr);
- avl = remove_int(avl, 241);
- avl = grpc_avl_add(avl, box(180), box(1281), nullptr);
- avl = grpc_avl_add(avl, box(411), box(1282), nullptr);
- avl = grpc_avl_add(avl, box(791), box(1283), nullptr);
- avl = grpc_avl_add(avl, box(955), box(1284), nullptr);
- avl = remove_int(avl, 24);
- avl = remove_int(avl, 375);
- avl = grpc_avl_add(avl, box(140), box(1287), nullptr);
- avl = remove_int(avl, 949);
- avl = grpc_avl_add(avl, box(301), box(1289), nullptr);
- avl = grpc_avl_add(avl, box(0), box(1290), nullptr);
- avl = remove_int(avl, 371);
- avl = remove_int(avl, 427);
- avl = remove_int(avl, 841);
- avl = remove_int(avl, 847);
- avl = grpc_avl_add(avl, box(814), box(1295), nullptr);
- avl = grpc_avl_add(avl, box(127), box(1296), nullptr);
- avl = grpc_avl_add(avl, box(279), box(1297), nullptr);
- avl = remove_int(avl, 669);
- avl = remove_int(avl, 541);
- avl = remove_int(avl, 275);
- avl = remove_int(avl, 299);
- avl = remove_int(avl, 552);
- avl = grpc_avl_add(avl, box(310), box(1303), nullptr);
- avl = grpc_avl_add(avl, box(304), box(1304), nullptr);
- avl = grpc_avl_add(avl, box(1), box(1305), nullptr);
- avl = grpc_avl_add(avl, box(339), box(1306), nullptr);
- avl = remove_int(avl, 570);
- avl = remove_int(avl, 752);
- avl = remove_int(avl, 552);
- avl = remove_int(avl, 442);
- avl = remove_int(avl, 639);
- avl = grpc_avl_add(avl, box(313), box(1312), nullptr);
- avl = remove_int(avl, 85);
- avl = grpc_avl_add(avl, box(964), box(1314), nullptr);
- avl = grpc_avl_add(avl, box(559), box(1315), nullptr);
- avl = remove_int(avl, 167);
- avl = grpc_avl_add(avl, box(866), box(1317), nullptr);
- avl = remove_int(avl, 275);
- avl = grpc_avl_add(avl, box(173), box(1319), nullptr);
- avl = grpc_avl_add(avl, box(765), box(1320), nullptr);
- avl = remove_int(avl, 883);
- avl = grpc_avl_add(avl, box(547), box(1322), nullptr);
- avl = grpc_avl_add(avl, box(847), box(1323), nullptr);
- avl = remove_int(avl, 817);
- avl = remove_int(avl, 850);
- avl = remove_int(avl, 718);
- avl = grpc_avl_add(avl, box(806), box(1327), nullptr);
- avl = grpc_avl_add(avl, box(360), box(1328), nullptr);
- avl = remove_int(avl, 991);
- avl = grpc_avl_add(avl, box(493), box(1330), nullptr);
- avl = remove_int(avl, 516);
- avl = grpc_avl_add(avl, box(361), box(1332), nullptr);
- avl = remove_int(avl, 355);
- avl = grpc_avl_add(avl, box(512), box(1334), nullptr);
- avl = grpc_avl_add(avl, box(191), box(1335), nullptr);
- avl = remove_int(avl, 703);
- avl = grpc_avl_add(avl, box(333), box(1337), nullptr);
- avl = remove_int(avl, 481);
- avl = grpc_avl_add(avl, box(501), box(1339), nullptr);
- avl = remove_int(avl, 532);
- avl = remove_int(avl, 510);
- avl = grpc_avl_add(avl, box(793), box(1342), nullptr);
- avl = grpc_avl_add(avl, box(234), box(1343), nullptr);
- avl = remove_int(avl, 159);
- avl = remove_int(avl, 429);
- avl = remove_int(avl, 728);
- avl = remove_int(avl, 288);
- avl = grpc_avl_add(avl, box(281), box(1348), nullptr);
- avl = grpc_avl_add(avl, box(702), box(1349), nullptr);
- avl = grpc_avl_add(avl, box(149), box(1350), nullptr);
- avl = remove_int(avl, 22);
- avl = remove_int(avl, 944);
- avl = remove_int(avl, 55);
- avl = remove_int(avl, 512);
- avl = remove_int(avl, 676);
- avl = remove_int(avl, 884);
- avl = grpc_avl_add(avl, box(246), box(1357), nullptr);
- avl = grpc_avl_add(avl, box(455), box(1358), nullptr);
- avl = remove_int(avl, 782);
- avl = remove_int(avl, 682);
- avl = grpc_avl_add(avl, box(243), box(1361), nullptr);
- avl = grpc_avl_add(avl, box(109), box(1362), nullptr);
- avl = grpc_avl_add(avl, box(452), box(1363), nullptr);
- avl = remove_int(avl, 151);
- avl = grpc_avl_add(avl, box(159), box(1365), nullptr);
- avl = remove_int(avl, 1023);
- avl = grpc_avl_add(avl, box(129), box(1367), nullptr);
- avl = grpc_avl_add(avl, box(537), box(1368), nullptr);
- avl = remove_int(avl, 321);
- avl = grpc_avl_add(avl, box(740), box(1370), nullptr);
- avl = remove_int(avl, 45);
- avl = remove_int(avl, 136);
- avl = grpc_avl_add(avl, box(229), box(1373), nullptr);
- avl = remove_int(avl, 772);
- avl = grpc_avl_add(avl, box(181), box(1375), nullptr);
- avl = remove_int(avl, 175);
- avl = grpc_avl_add(avl, box(817), box(1377), nullptr);
- avl = remove_int(avl, 956);
- avl = grpc_avl_add(avl, box(675), box(1379), nullptr);
- avl = grpc_avl_add(avl, box(375), box(1380), nullptr);
- avl = remove_int(avl, 384);
- avl = grpc_avl_add(avl, box(1016), box(1382), nullptr);
- avl = remove_int(avl, 295);
- avl = remove_int(avl, 697);
- avl = remove_int(avl, 554);
- avl = remove_int(avl, 590);
- avl = remove_int(avl, 1014);
- avl = grpc_avl_add(avl, box(890), box(1388), nullptr);
- avl = grpc_avl_add(avl, box(293), box(1389), nullptr);
- avl = remove_int(avl, 207);
- avl = remove_int(avl, 46);
- avl = grpc_avl_add(avl, box(899), box(1392), nullptr);
- avl = grpc_avl_add(avl, box(666), box(1393), nullptr);
- avl = grpc_avl_add(avl, box(85), box(1394), nullptr);
- avl = grpc_avl_add(avl, box(914), box(1395), nullptr);
- avl = grpc_avl_add(avl, box(128), box(1396), nullptr);
- avl = grpc_avl_add(avl, box(835), box(1397), nullptr);
- avl = grpc_avl_add(avl, box(787), box(1398), nullptr);
- avl = grpc_avl_add(avl, box(649), box(1399), nullptr);
- avl = grpc_avl_add(avl, box(723), box(1400), nullptr);
- avl = remove_int(avl, 874);
- avl = grpc_avl_add(avl, box(778), box(1402), nullptr);
- avl = grpc_avl_add(avl, box(1015), box(1403), nullptr);
- avl = grpc_avl_add(avl, box(59), box(1404), nullptr);
- avl = grpc_avl_add(avl, box(259), box(1405), nullptr);
- avl = grpc_avl_add(avl, box(758), box(1406), nullptr);
- avl = remove_int(avl, 648);
- avl = grpc_avl_add(avl, box(145), box(1408), nullptr);
- avl = grpc_avl_add(avl, box(440), box(1409), nullptr);
- avl = remove_int(avl, 608);
- avl = remove_int(avl, 690);
- avl = grpc_avl_add(avl, box(605), box(1412), nullptr);
- avl = remove_int(avl, 856);
- avl = remove_int(avl, 608);
- avl = grpc_avl_add(avl, box(829), box(1415), nullptr);
- avl = grpc_avl_add(avl, box(660), box(1416), nullptr);
- avl = remove_int(avl, 596);
- avl = grpc_avl_add(avl, box(519), box(1418), nullptr);
- avl = grpc_avl_add(avl, box(35), box(1419), nullptr);
- avl = grpc_avl_add(avl, box(871), box(1420), nullptr);
- avl = remove_int(avl, 845);
- avl = grpc_avl_add(avl, box(600), box(1422), nullptr);
- avl = grpc_avl_add(avl, box(215), box(1423), nullptr);
- avl = remove_int(avl, 761);
- avl = grpc_avl_add(avl, box(975), box(1425), nullptr);
- avl = remove_int(avl, 987);
- avl = grpc_avl_add(avl, box(58), box(1427), nullptr);
- avl = remove_int(avl, 119);
- avl = grpc_avl_add(avl, box(937), box(1429), nullptr);
- avl = grpc_avl_add(avl, box(372), box(1430), nullptr);
- avl = grpc_avl_add(avl, box(11), box(1431), nullptr);
- avl = grpc_avl_add(avl, box(398), box(1432), nullptr);
- avl = grpc_avl_add(avl, box(423), box(1433), nullptr);
- avl = remove_int(avl, 171);
- avl = grpc_avl_add(avl, box(473), box(1435), nullptr);
- avl = remove_int(avl, 752);
- avl = remove_int(avl, 625);
- avl = remove_int(avl, 764);
- avl = remove_int(avl, 49);
- avl = grpc_avl_add(avl, box(472), box(1440), nullptr);
- avl = remove_int(avl, 847);
- avl = remove_int(avl, 642);
- avl = remove_int(avl, 1004);
- avl = remove_int(avl, 795);
- avl = remove_int(avl, 465);
- avl = grpc_avl_add(avl, box(636), box(1446), nullptr);
- avl = remove_int(avl, 152);
- avl = grpc_avl_add(avl, box(61), box(1448), nullptr);
- avl = remove_int(avl, 929);
- avl = remove_int(avl, 9);
- avl = grpc_avl_add(avl, box(251), box(1451), nullptr);
- avl = grpc_avl_add(avl, box(672), box(1452), nullptr);
- avl = grpc_avl_add(avl, box(66), box(1453), nullptr);
- avl = remove_int(avl, 693);
- avl = remove_int(avl, 914);
- avl = remove_int(avl, 116);
- avl = remove_int(avl, 577);
- avl = grpc_avl_add(avl, box(618), box(1458), nullptr);
- avl = grpc_avl_add(avl, box(495), box(1459), nullptr);
- avl = remove_int(avl, 450);
- avl = grpc_avl_add(avl, box(533), box(1461), nullptr);
- avl = grpc_avl_add(avl, box(414), box(1462), nullptr);
- avl = remove_int(avl, 74);
- avl = remove_int(avl, 236);
- avl = grpc_avl_add(avl, box(707), box(1465), nullptr);
- avl = grpc_avl_add(avl, box(357), box(1466), nullptr);
- avl = grpc_avl_add(avl, box(1007), box(1467), nullptr);
- avl = grpc_avl_add(avl, box(811), box(1468), nullptr);
- avl = grpc_avl_add(avl, box(418), box(1469), nullptr);
- avl = grpc_avl_add(avl, box(164), box(1470), nullptr);
- avl = grpc_avl_add(avl, box(622), box(1471), nullptr);
- avl = remove_int(avl, 22);
- avl = remove_int(avl, 14);
- avl = remove_int(avl, 732);
- avl = remove_int(avl, 7);
- avl = remove_int(avl, 447);
- avl = grpc_avl_add(avl, box(221), box(1477), nullptr);
- avl = grpc_avl_add(avl, box(202), box(1478), nullptr);
- avl = grpc_avl_add(avl, box(312), box(1479), nullptr);
- avl = remove_int(avl, 274);
- avl = grpc_avl_add(avl, box(684), box(1481), nullptr);
- avl = grpc_avl_add(avl, box(954), box(1482), nullptr);
- avl = grpc_avl_add(avl, box(637), box(1483), nullptr);
- avl = remove_int(avl, 716);
- avl = grpc_avl_add(avl, box(198), box(1485), nullptr);
- avl = remove_int(avl, 340);
- avl = remove_int(avl, 137);
- avl = remove_int(avl, 995);
- avl = remove_int(avl, 1004);
- avl = grpc_avl_add(avl, box(661), box(1490), nullptr);
- avl = grpc_avl_add(avl, box(862), box(1491), nullptr);
- avl = remove_int(avl, 527);
- avl = grpc_avl_add(avl, box(945), box(1493), nullptr);
- avl = remove_int(avl, 355);
- avl = remove_int(avl, 144);
- avl = grpc_avl_add(avl, box(229), box(1496), nullptr);
- avl = grpc_avl_add(avl, box(237), box(1497), nullptr);
- avl = remove_int(avl, 471);
- avl = remove_int(avl, 901);
- avl = grpc_avl_add(avl, box(905), box(1500), nullptr);
- avl = remove_int(avl, 19);
- avl = remove_int(avl, 896);
- avl = remove_int(avl, 585);
- avl = remove_int(avl, 308);
- avl = grpc_avl_add(avl, box(547), box(1505), nullptr);
- avl = grpc_avl_add(avl, box(552), box(1506), nullptr);
- avl = grpc_avl_add(avl, box(30), box(1507), nullptr);
- avl = grpc_avl_add(avl, box(445), box(1508), nullptr);
- avl = remove_int(avl, 785);
- avl = remove_int(avl, 185);
- avl = grpc_avl_add(avl, box(405), box(1511), nullptr);
- avl = grpc_avl_add(avl, box(733), box(1512), nullptr);
- avl = grpc_avl_add(avl, box(573), box(1513), nullptr);
- avl = grpc_avl_add(avl, box(492), box(1514), nullptr);
- avl = grpc_avl_add(avl, box(343), box(1515), nullptr);
- avl = grpc_avl_add(avl, box(527), box(1516), nullptr);
- avl = grpc_avl_add(avl, box(596), box(1517), nullptr);
- avl = grpc_avl_add(avl, box(519), box(1518), nullptr);
- avl = remove_int(avl, 243);
- avl = remove_int(avl, 722);
- avl = grpc_avl_add(avl, box(772), box(1521), nullptr);
- avl = remove_int(avl, 152);
- avl = remove_int(avl, 305);
- avl = grpc_avl_add(avl, box(754), box(1524), nullptr);
- avl = grpc_avl_add(avl, box(373), box(1525), nullptr);
- avl = remove_int(avl, 995);
- avl = grpc_avl_add(avl, box(329), box(1527), nullptr);
- avl = remove_int(avl, 397);
- avl = grpc_avl_add(avl, box(884), box(1529), nullptr);
- avl = remove_int(avl, 329);
- avl = remove_int(avl, 240);
- avl = grpc_avl_add(avl, box(566), box(1532), nullptr);
- avl = grpc_avl_add(avl, box(232), box(1533), nullptr);
- avl = remove_int(avl, 993);
- avl = grpc_avl_add(avl, box(888), box(1535), nullptr);
- avl = remove_int(avl, 242);
- avl = grpc_avl_add(avl, box(941), box(1537), nullptr);
- avl = remove_int(avl, 415);
- avl = grpc_avl_add(avl, box(992), box(1539), nullptr);
- avl = remove_int(avl, 289);
- avl = grpc_avl_add(avl, box(60), box(1541), nullptr);
- avl = grpc_avl_add(avl, box(97), box(1542), nullptr);
- avl = remove_int(avl, 965);
- avl = remove_int(avl, 267);
- avl = remove_int(avl, 360);
- avl = grpc_avl_add(avl, box(5), box(1546), nullptr);
- avl = remove_int(avl, 429);
- avl = grpc_avl_add(avl, box(412), box(1548), nullptr);
- avl = remove_int(avl, 632);
- avl = remove_int(avl, 113);
- avl = grpc_avl_add(avl, box(48), box(1551), nullptr);
- avl = grpc_avl_add(avl, box(108), box(1552), nullptr);
- avl = grpc_avl_add(avl, box(750), box(1553), nullptr);
- avl = remove_int(avl, 188);
- avl = grpc_avl_add(avl, box(668), box(1555), nullptr);
- avl = remove_int(avl, 37);
- avl = remove_int(avl, 737);
- avl = grpc_avl_add(avl, box(93), box(1558), nullptr);
- avl = grpc_avl_add(avl, box(628), box(1559), nullptr);
- avl = grpc_avl_add(avl, box(480), box(1560), nullptr);
- avl = remove_int(avl, 958);
- avl = remove_int(avl, 565);
- avl = remove_int(avl, 32);
- avl = remove_int(avl, 1);
- avl = remove_int(avl, 335);
- avl = grpc_avl_add(avl, box(136), box(1566), nullptr);
- avl = grpc_avl_add(avl, box(469), box(1567), nullptr);
- avl = remove_int(avl, 349);
- avl = grpc_avl_add(avl, box(768), box(1569), nullptr);
- avl = grpc_avl_add(avl, box(915), box(1570), nullptr);
- avl = remove_int(avl, 1014);
- avl = grpc_avl_add(avl, box(117), box(1572), nullptr);
- avl = remove_int(avl, 62);
- avl = grpc_avl_add(avl, box(382), box(1574), nullptr);
- avl = remove_int(avl, 571);
- avl = grpc_avl_add(avl, box(655), box(1576), nullptr);
- avl = grpc_avl_add(avl, box(323), box(1577), nullptr);
- avl = remove_int(avl, 869);
- avl = remove_int(avl, 151);
- avl = grpc_avl_add(avl, box(1019), box(1580), nullptr);
- avl = grpc_avl_add(avl, box(984), box(1581), nullptr);
- avl = grpc_avl_add(avl, box(870), box(1582), nullptr);
- avl = grpc_avl_add(avl, box(376), box(1583), nullptr);
- avl = remove_int(avl, 625);
- avl = grpc_avl_add(avl, box(733), box(1585), nullptr);
- avl = remove_int(avl, 532);
- avl = remove_int(avl, 444);
- avl = grpc_avl_add(avl, box(428), box(1588), nullptr);
- avl = grpc_avl_add(avl, box(860), box(1589), nullptr);
- avl = grpc_avl_add(avl, box(173), box(1590), nullptr);
- avl = remove_int(avl, 649);
- avl = remove_int(avl, 913);
- avl = remove_int(avl, 1);
- avl = remove_int(avl, 304);
- avl = grpc_avl_add(avl, box(604), box(1595), nullptr);
- avl = grpc_avl_add(avl, box(639), box(1596), nullptr);
- avl = remove_int(avl, 431);
- avl = grpc_avl_add(avl, box(993), box(1598), nullptr);
- avl = remove_int(avl, 681);
- avl = remove_int(avl, 927);
- avl = grpc_avl_add(avl, box(87), box(1601), nullptr);
- avl = grpc_avl_add(avl, box(91), box(1602), nullptr);
- avl = remove_int(avl, 61);
- avl = remove_int(avl, 14);
- avl = remove_int(avl, 305);
- avl = remove_int(avl, 304);
- avl = remove_int(avl, 1016);
- avl = grpc_avl_add(avl, box(903), box(1608), nullptr);
- avl = grpc_avl_add(avl, box(951), box(1609), nullptr);
- avl = grpc_avl_add(avl, box(146), box(1610), nullptr);
- avl = grpc_avl_add(avl, box(482), box(1611), nullptr);
- avl = grpc_avl_add(avl, box(71), box(1612), nullptr);
- avl = remove_int(avl, 246);
- avl = remove_int(avl, 696);
- avl = grpc_avl_add(avl, box(636), box(1615), nullptr);
- avl = grpc_avl_add(avl, box(295), box(1616), nullptr);
- avl = remove_int(avl, 11);
- avl = remove_int(avl, 231);
- avl = grpc_avl_add(avl, box(905), box(1619), nullptr);
- avl = grpc_avl_add(avl, box(993), box(1620), nullptr);
- avl = grpc_avl_add(avl, box(433), box(1621), nullptr);
- avl = grpc_avl_add(avl, box(117), box(1622), nullptr);
- avl = grpc_avl_add(avl, box(467), box(1623), nullptr);
- avl = remove_int(avl, 419);
- avl = grpc_avl_add(avl, box(179), box(1625), nullptr);
- avl = remove_int(avl, 926);
- avl = remove_int(avl, 326);
- avl = grpc_avl_add(avl, box(551), box(1628), nullptr);
- avl = remove_int(avl, 14);
- avl = remove_int(avl, 476);
- avl = remove_int(avl, 823);
- avl = grpc_avl_add(avl, box(350), box(1632), nullptr);
- avl = grpc_avl_add(avl, box(133), box(1633), nullptr);
- avl = remove_int(avl, 906);
- avl = grpc_avl_add(avl, box(827), box(1635), nullptr);
- avl = grpc_avl_add(avl, box(201), box(1636), nullptr);
- avl = remove_int(avl, 124);
- avl = remove_int(avl, 662);
- avl = grpc_avl_add(avl, box(314), box(1639), nullptr);
- avl = grpc_avl_add(avl, box(986), box(1640), nullptr);
- avl = grpc_avl_add(avl, box(622), box(1641), nullptr);
- avl = remove_int(avl, 130);
- avl = grpc_avl_add(avl, box(861), box(1643), nullptr);
- avl = remove_int(avl, 497);
- avl = remove_int(avl, 905);
- avl = grpc_avl_add(avl, box(502), box(1646), nullptr);
- avl = remove_int(avl, 721);
- avl = grpc_avl_add(avl, box(514), box(1648), nullptr);
- avl = grpc_avl_add(avl, box(410), box(1649), nullptr);
- avl = remove_int(avl, 869);
- avl = remove_int(avl, 247);
- avl = grpc_avl_add(avl, box(450), box(1652), nullptr);
- avl = remove_int(avl, 364);
- avl = grpc_avl_add(avl, box(963), box(1654), nullptr);
- avl = grpc_avl_add(avl, box(146), box(1655), nullptr);
- avl = remove_int(avl, 147);
- avl = remove_int(avl, 789);
- avl = grpc_avl_add(avl, box(693), box(1658), nullptr);
- avl = grpc_avl_add(avl, box(959), box(1659), nullptr);
- avl = remove_int(avl, 478);
- avl = grpc_avl_add(avl, box(116), box(1661), nullptr);
- avl = grpc_avl_add(avl, box(520), box(1662), nullptr);
- avl = grpc_avl_add(avl, box(809), box(1663), nullptr);
- avl = grpc_avl_add(avl, box(667), box(1664), nullptr);
- avl = grpc_avl_add(avl, box(406), box(1665), nullptr);
- avl = remove_int(avl, 409);
- avl = grpc_avl_add(avl, box(558), box(1667), nullptr);
- avl = grpc_avl_add(avl, box(0), box(1668), nullptr);
- avl = grpc_avl_add(avl, box(948), box(1669), nullptr);
- avl = grpc_avl_add(avl, box(576), box(1670), nullptr);
- avl = remove_int(avl, 864);
- avl = remove_int(avl, 840);
- avl = remove_int(avl, 1001);
- avl = grpc_avl_add(avl, box(232), box(1674), nullptr);
- avl = remove_int(avl, 676);
- avl = remove_int(avl, 752);
- avl = remove_int(avl, 667);
- avl = remove_int(avl, 605);
- avl = grpc_avl_add(avl, box(258), box(1679), nullptr);
- avl = grpc_avl_add(avl, box(648), box(1680), nullptr);
- avl = grpc_avl_add(avl, box(761), box(1681), nullptr);
- avl = remove_int(avl, 293);
- avl = remove_int(avl, 893);
- avl = grpc_avl_add(avl, box(194), box(1684), nullptr);
- avl = remove_int(avl, 233);
- avl = grpc_avl_add(avl, box(888), box(1686), nullptr);
- avl = remove_int(avl, 470);
- avl = remove_int(avl, 703);
- avl = remove_int(avl, 190);
- avl = remove_int(avl, 359);
- avl = grpc_avl_add(avl, box(621), box(1691), nullptr);
- avl = remove_int(avl, 634);
- avl = remove_int(avl, 335);
- avl = grpc_avl_add(avl, box(718), box(1694), nullptr);
- avl = grpc_avl_add(avl, box(463), box(1695), nullptr);
- avl = grpc_avl_add(avl, box(233), box(1696), nullptr);
- avl = remove_int(avl, 376);
- avl = remove_int(avl, 496);
- avl = remove_int(avl, 819);
- avl = remove_int(avl, 38);
- avl = remove_int(avl, 436);
- avl = remove_int(avl, 102);
- avl = grpc_avl_add(avl, box(607), box(1703), nullptr);
- avl = remove_int(avl, 329);
- avl = grpc_avl_add(avl, box(716), box(1705), nullptr);
- avl = remove_int(avl, 639);
- avl = remove_int(avl, 775);
- avl = remove_int(avl, 578);
- avl = remove_int(avl, 464);
- avl = remove_int(avl, 679);
- avl = remove_int(avl, 615);
- avl = remove_int(avl, 104);
- avl = grpc_avl_add(avl, box(414), box(1713), nullptr);
- avl = grpc_avl_add(avl, box(212), box(1714), nullptr);
- avl = grpc_avl_add(avl, box(266), box(1715), nullptr);
- avl = grpc_avl_add(avl, box(238), box(1716), nullptr);
- avl = remove_int(avl, 153);
- avl = grpc_avl_add(avl, box(585), box(1718), nullptr);
- avl = remove_int(avl, 121);
- avl = grpc_avl_add(avl, box(534), box(1720), nullptr);
- avl = remove_int(avl, 579);
- avl = grpc_avl_add(avl, box(127), box(1722), nullptr);
- avl = grpc_avl_add(avl, box(399), box(1723), nullptr);
- avl = remove_int(avl, 417);
- avl = grpc_avl_add(avl, box(978), box(1725), nullptr);
- avl = grpc_avl_add(avl, box(768), box(1726), nullptr);
- avl = remove_int(avl, 985);
- avl = grpc_avl_add(avl, box(536), box(1728), nullptr);
- avl = grpc_avl_add(avl, box(449), box(1729), nullptr);
- avl = grpc_avl_add(avl, box(586), box(1730), nullptr);
- avl = remove_int(avl, 998);
- avl = remove_int(avl, 394);
- avl = remove_int(avl, 141);
- avl = grpc_avl_add(avl, box(889), box(1734), nullptr);
- avl = grpc_avl_add(avl, box(871), box(1735), nullptr);
- avl = grpc_avl_add(avl, box(76), box(1736), nullptr);
- avl = grpc_avl_add(avl, box(549), box(1737), nullptr);
- avl = grpc_avl_add(avl, box(757), box(1738), nullptr);
- avl = remove_int(avl, 908);
- avl = grpc_avl_add(avl, box(789), box(1740), nullptr);
- avl = remove_int(avl, 224);
- avl = grpc_avl_add(avl, box(407), box(1742), nullptr);
- avl = grpc_avl_add(avl, box(381), box(1743), nullptr);
- avl = grpc_avl_add(avl, box(561), box(1744), nullptr);
- avl = grpc_avl_add(avl, box(667), box(1745), nullptr);
- avl = grpc_avl_add(avl, box(522), box(1746), nullptr);
- avl = grpc_avl_add(avl, box(948), box(1747), nullptr);
- avl = remove_int(avl, 770);
- avl = grpc_avl_add(avl, box(872), box(1749), nullptr);
- avl = grpc_avl_add(avl, box(327), box(1750), nullptr);
- avl = remove_int(avl, 10);
- avl = grpc_avl_add(avl, box(122), box(1752), nullptr);
- avl = remove_int(avl, 606);
- avl = grpc_avl_add(avl, box(485), box(1754), nullptr);
- avl = remove_int(avl, 6);
- avl = grpc_avl_add(avl, box(329), box(1756), nullptr);
- avl = grpc_avl_add(avl, box(783), box(1757), nullptr);
- avl = remove_int(avl, 416);
- avl = grpc_avl_add(avl, box(656), box(1759), nullptr);
- avl = grpc_avl_add(avl, box(971), box(1760), nullptr);
- avl = grpc_avl_add(avl, box(77), box(1761), nullptr);
- avl = grpc_avl_add(avl, box(942), box(1762), nullptr);
- avl = remove_int(avl, 361);
- avl = grpc_avl_add(avl, box(66), box(1764), nullptr);
- avl = grpc_avl_add(avl, box(299), box(1765), nullptr);
- avl = grpc_avl_add(avl, box(929), box(1766), nullptr);
- avl = grpc_avl_add(avl, box(797), box(1767), nullptr);
- avl = remove_int(avl, 869);
- avl = remove_int(avl, 907);
- avl = grpc_avl_add(avl, box(870), box(1770), nullptr);
- avl = remove_int(avl, 580);
- avl = remove_int(avl, 120);
- avl = grpc_avl_add(avl, box(913), box(1773), nullptr);
- avl = remove_int(avl, 480);
- avl = grpc_avl_add(avl, box(489), box(1775), nullptr);
- avl = remove_int(avl, 845);
- avl = grpc_avl_add(avl, box(896), box(1777), nullptr);
- avl = remove_int(avl, 567);
- avl = remove_int(avl, 427);
- avl = grpc_avl_add(avl, box(443), box(1780), nullptr);
- avl = grpc_avl_add(avl, box(3), box(1781), nullptr);
- avl = remove_int(avl, 12);
- avl = grpc_avl_add(avl, box(376), box(1783), nullptr);
- avl = grpc_avl_add(avl, box(155), box(1784), nullptr);
- avl = grpc_avl_add(avl, box(188), box(1785), nullptr);
- avl = grpc_avl_add(avl, box(149), box(1786), nullptr);
- avl = grpc_avl_add(avl, box(178), box(1787), nullptr);
- avl = remove_int(avl, 84);
- avl = grpc_avl_add(avl, box(805), box(1789), nullptr);
- avl = grpc_avl_add(avl, box(612), box(1790), nullptr);
- avl = remove_int(avl, 991);
- avl = grpc_avl_add(avl, box(837), box(1792), nullptr);
- avl = remove_int(avl, 173);
- avl = remove_int(avl, 72);
- avl = grpc_avl_add(avl, box(1014), box(1795), nullptr);
- avl = remove_int(avl, 303);
- avl = grpc_avl_add(avl, box(865), box(1797), nullptr);
- avl = grpc_avl_add(avl, box(793), box(1798), nullptr);
- avl = remove_int(avl, 173);
- avl = remove_int(avl, 477);
- avl = grpc_avl_add(avl, box(950), box(1801), nullptr);
- avl = grpc_avl_add(avl, box(105), box(1802), nullptr);
- avl = grpc_avl_add(avl, box(895), box(1803), nullptr);
- avl = grpc_avl_add(avl, box(171), box(1804), nullptr);
- avl = grpc_avl_add(avl, box(753), box(1805), nullptr);
- avl = grpc_avl_add(avl, box(946), box(1806), nullptr);
- avl = remove_int(avl, 194);
- avl = remove_int(avl, 559);
- avl = remove_int(avl, 116);
- avl = grpc_avl_add(avl, box(968), box(1810), nullptr);
- avl = remove_int(avl, 124);
- avl = remove_int(avl, 99);
- avl = grpc_avl_add(avl, box(563), box(1813), nullptr);
- avl = remove_int(avl, 182);
- avl = grpc_avl_add(avl, box(816), box(1815), nullptr);
- avl = remove_int(avl, 73);
- avl = remove_int(avl, 261);
- avl = grpc_avl_add(avl, box(847), box(1818), nullptr);
- avl = grpc_avl_add(avl, box(368), box(1819), nullptr);
- avl = grpc_avl_add(avl, box(808), box(1820), nullptr);
- avl = grpc_avl_add(avl, box(779), box(1821), nullptr);
- avl = remove_int(avl, 818);
- avl = grpc_avl_add(avl, box(466), box(1823), nullptr);
- avl = remove_int(avl, 316);
- avl = grpc_avl_add(avl, box(986), box(1825), nullptr);
- avl = grpc_avl_add(avl, box(688), box(1826), nullptr);
- avl = grpc_avl_add(avl, box(509), box(1827), nullptr);
- avl = grpc_avl_add(avl, box(51), box(1828), nullptr);
- avl = remove_int(avl, 655);
- avl = remove_int(avl, 785);
- avl = remove_int(avl, 893);
- avl = grpc_avl_add(avl, box(167), box(1832), nullptr);
- avl = remove_int(avl, 13);
- avl = remove_int(avl, 263);
- avl = grpc_avl_add(avl, box(1009), box(1835), nullptr);
- avl = remove_int(avl, 480);
- avl = remove_int(avl, 778);
- avl = remove_int(avl, 713);
- avl = remove_int(avl, 628);
- avl = grpc_avl_add(avl, box(803), box(1840), nullptr);
- avl = remove_int(avl, 267);
- avl = grpc_avl_add(avl, box(676), box(1842), nullptr);
- avl = grpc_avl_add(avl, box(231), box(1843), nullptr);
- avl = grpc_avl_add(avl, box(824), box(1844), nullptr);
- avl = remove_int(avl, 961);
- avl = grpc_avl_add(avl, box(311), box(1846), nullptr);
- avl = grpc_avl_add(avl, box(420), box(1847), nullptr);
- avl = grpc_avl_add(avl, box(960), box(1848), nullptr);
- avl = grpc_avl_add(avl, box(468), box(1849), nullptr);
- avl = grpc_avl_add(avl, box(815), box(1850), nullptr);
- avl = remove_int(avl, 247);
- avl = remove_int(avl, 194);
- avl = grpc_avl_add(avl, box(546), box(1853), nullptr);
- avl = remove_int(avl, 222);
- avl = remove_int(avl, 914);
- avl = remove_int(avl, 741);
- avl = grpc_avl_add(avl, box(470), box(1857), nullptr);
- avl = grpc_avl_add(avl, box(933), box(1858), nullptr);
- avl = grpc_avl_add(avl, box(97), box(1859), nullptr);
- avl = remove_int(avl, 564);
- avl = remove_int(avl, 295);
- avl = grpc_avl_add(avl, box(864), box(1862), nullptr);
- avl = remove_int(avl, 329);
- avl = grpc_avl_add(avl, box(124), box(1864), nullptr);
- avl = grpc_avl_add(avl, box(1000), box(1865), nullptr);
- avl = grpc_avl_add(avl, box(228), box(1866), nullptr);
- avl = grpc_avl_add(avl, box(187), box(1867), nullptr);
- avl = remove_int(avl, 224);
- avl = remove_int(avl, 306);
- avl = remove_int(avl, 884);
- avl = grpc_avl_add(avl, box(449), box(1871), nullptr);
- avl = grpc_avl_add(avl, box(353), box(1872), nullptr);
- avl = grpc_avl_add(avl, box(994), box(1873), nullptr);
- avl = grpc_avl_add(avl, box(596), box(1874), nullptr);
- avl = grpc_avl_add(avl, box(996), box(1875), nullptr);
- avl = grpc_avl_add(avl, box(101), box(1876), nullptr);
- avl = grpc_avl_add(avl, box(1012), box(1877), nullptr);
- avl = grpc_avl_add(avl, box(982), box(1878), nullptr);
- avl = grpc_avl_add(avl, box(742), box(1879), nullptr);
- avl = remove_int(avl, 92);
- avl = remove_int(avl, 1022);
- avl = grpc_avl_add(avl, box(941), box(1882), nullptr);
- avl = remove_int(avl, 742);
- avl = remove_int(avl, 919);
- avl = grpc_avl_add(avl, box(588), box(1885), nullptr);
- avl = remove_int(avl, 221);
- avl = grpc_avl_add(avl, box(356), box(1887), nullptr);
- avl = grpc_avl_add(avl, box(932), box(1888), nullptr);
- avl = remove_int(avl, 837);
- avl = grpc_avl_add(avl, box(394), box(1890), nullptr);
- avl = grpc_avl_add(avl, box(642), box(1891), nullptr);
- avl = grpc_avl_add(avl, box(52), box(1892), nullptr);
- avl = grpc_avl_add(avl, box(437), box(1893), nullptr);
- avl = grpc_avl_add(avl, box(948), box(1894), nullptr);
- avl = grpc_avl_add(avl, box(93), box(1895), nullptr);
- avl = remove_int(avl, 873);
- avl = remove_int(avl, 336);
- avl = remove_int(avl, 277);
- avl = remove_int(avl, 932);
- avl = grpc_avl_add(avl, box(80), box(1900), nullptr);
- avl = grpc_avl_add(avl, box(952), box(1901), nullptr);
- avl = grpc_avl_add(avl, box(510), box(1902), nullptr);
- avl = remove_int(avl, 876);
- avl = remove_int(avl, 612);
- avl = grpc_avl_add(avl, box(923), box(1905), nullptr);
- avl = grpc_avl_add(avl, box(475), box(1906), nullptr);
- avl = remove_int(avl, 478);
- avl = remove_int(avl, 148);
- avl = grpc_avl_add(avl, box(538), box(1909), nullptr);
- avl = remove_int(avl, 47);
- avl = grpc_avl_add(avl, box(89), box(1911), nullptr);
- avl = remove_int(avl, 723);
- avl = grpc_avl_add(avl, box(687), box(1913), nullptr);
- avl = grpc_avl_add(avl, box(480), box(1914), nullptr);
- avl = grpc_avl_add(avl, box(149), box(1915), nullptr);
- avl = remove_int(avl, 68);
- avl = remove_int(avl, 862);
- avl = remove_int(avl, 363);
- avl = grpc_avl_add(avl, box(996), box(1919), nullptr);
- avl = remove_int(avl, 380);
- avl = grpc_avl_add(avl, box(957), box(1921), nullptr);
- avl = remove_int(avl, 413);
- avl = grpc_avl_add(avl, box(360), box(1923), nullptr);
- avl = grpc_avl_add(avl, box(304), box(1924), nullptr);
- avl = grpc_avl_add(avl, box(634), box(1925), nullptr);
- avl = grpc_avl_add(avl, box(506), box(1926), nullptr);
- avl = remove_int(avl, 248);
- avl = grpc_avl_add(avl, box(124), box(1928), nullptr);
- avl = grpc_avl_add(avl, box(181), box(1929), nullptr);
- avl = remove_int(avl, 507);
- avl = grpc_avl_add(avl, box(141), box(1931), nullptr);
- avl = remove_int(avl, 409);
- avl = remove_int(avl, 129);
- avl = remove_int(avl, 694);
- avl = remove_int(avl, 723);
- avl = grpc_avl_add(avl, box(998), box(1936), nullptr);
- avl = grpc_avl_add(avl, box(906), box(1937), nullptr);
- avl = grpc_avl_add(avl, box(44), box(1938), nullptr);
- avl = remove_int(avl, 949);
- avl = remove_int(avl, 117);
- avl = grpc_avl_add(avl, box(700), box(1941), nullptr);
- avl = grpc_avl_add(avl, box(258), box(1942), nullptr);
- avl = remove_int(avl, 828);
- avl = grpc_avl_add(avl, box(860), box(1944), nullptr);
- avl = grpc_avl_add(avl, box(987), box(1945), nullptr);
- avl = grpc_avl_add(avl, box(316), box(1946), nullptr);
- avl = grpc_avl_add(avl, box(919), box(1947), nullptr);
- avl = remove_int(avl, 84);
- avl = grpc_avl_add(avl, box(473), box(1949), nullptr);
- avl = remove_int(avl, 127);
- avl = remove_int(avl, 829);
- avl = remove_int(avl, 829);
- avl = grpc_avl_add(avl, box(488), box(1953), nullptr);
- avl = grpc_avl_add(avl, box(954), box(1954), nullptr);
- avl = remove_int(avl, 198);
- avl = remove_int(avl, 972);
- avl = remove_int(avl, 670);
- avl = grpc_avl_add(avl, box(822), box(1958), nullptr);
- avl = remove_int(avl, 589);
- avl = remove_int(avl, 459);
- avl = grpc_avl_add(avl, box(1003), box(1961), nullptr);
- avl = grpc_avl_add(avl, box(657), box(1962), nullptr);
- avl = grpc_avl_add(avl, box(477), box(1963), nullptr);
- avl = grpc_avl_add(avl, box(923), box(1964), nullptr);
- avl = remove_int(avl, 496);
- avl = remove_int(avl, 99);
- avl = grpc_avl_add(avl, box(127), box(1967), nullptr);
- avl = grpc_avl_add(avl, box(1013), box(1968), nullptr);
- avl = grpc_avl_add(avl, box(778), box(1969), nullptr);
- avl = remove_int(avl, 5);
- avl = remove_int(avl, 990);
- avl = remove_int(avl, 850);
- avl = remove_int(avl, 160);
- avl = remove_int(avl, 86);
- avl = grpc_avl_add(avl, box(283), box(1975), nullptr);
- avl = remove_int(avl, 278);
- avl = remove_int(avl, 297);
- avl = remove_int(avl, 137);
- avl = remove_int(avl, 653);
- avl = grpc_avl_add(avl, box(702), box(1980), nullptr);
- avl = remove_int(avl, 63);
- avl = remove_int(avl, 427);
- avl = remove_int(avl, 706);
- avl = remove_int(avl, 806);
- avl = grpc_avl_add(avl, box(335), box(1985), nullptr);
- avl = grpc_avl_add(avl, box(412), box(1986), nullptr);
- avl = remove_int(avl, 766);
- avl = remove_int(avl, 937);
- avl = remove_int(avl, 886);
- avl = remove_int(avl, 652);
- avl = grpc_avl_add(avl, box(545), box(1991), nullptr);
- avl = grpc_avl_add(avl, box(408), box(1992), nullptr);
- avl = grpc_avl_add(avl, box(841), box(1993), nullptr);
- avl = remove_int(avl, 593);
- avl = grpc_avl_add(avl, box(582), box(1995), nullptr);
- avl = grpc_avl_add(avl, box(597), box(1996), nullptr);
- avl = remove_int(avl, 49);
- avl = remove_int(avl, 835);
- avl = grpc_avl_add(avl, box(417), box(1999), nullptr);
- avl = grpc_avl_add(avl, box(191), box(2000), nullptr);
- avl = remove_int(avl, 406);
- avl = grpc_avl_add(avl, box(30), box(2002), nullptr);
- avl = remove_int(avl, 841);
- avl = remove_int(avl, 50);
- avl = grpc_avl_add(avl, box(967), box(2005), nullptr);
- avl = grpc_avl_add(avl, box(849), box(2006), nullptr);
- avl = remove_int(avl, 608);
- avl = grpc_avl_add(avl, box(306), box(2008), nullptr);
- avl = remove_int(avl, 779);
- avl = grpc_avl_add(avl, box(897), box(2010), nullptr);
- avl = grpc_avl_add(avl, box(147), box(2011), nullptr);
- avl = remove_int(avl, 982);
- avl = grpc_avl_add(avl, box(470), box(2013), nullptr);
- avl = remove_int(avl, 951);
- avl = grpc_avl_add(avl, box(388), box(2015), nullptr);
- avl = remove_int(avl, 616);
- avl = remove_int(avl, 721);
- avl = remove_int(avl, 942);
- avl = remove_int(avl, 589);
- avl = grpc_avl_add(avl, box(218), box(2020), nullptr);
- avl = remove_int(avl, 671);
- avl = grpc_avl_add(avl, box(1020), box(2022), nullptr);
- avl = remove_int(avl, 277);
- avl = grpc_avl_add(avl, box(681), box(2024), nullptr);
- avl = grpc_avl_add(avl, box(179), box(2025), nullptr);
- avl = grpc_avl_add(avl, box(370), box(2026), nullptr);
- avl = grpc_avl_add(avl, box(0), box(2027), nullptr);
- avl = remove_int(avl, 523);
- avl = grpc_avl_add(avl, box(99), box(2029), nullptr);
- avl = grpc_avl_add(avl, box(334), box(2030), nullptr);
- avl = grpc_avl_add(avl, box(569), box(2031), nullptr);
- avl = grpc_avl_add(avl, box(257), box(2032), nullptr);
- avl = remove_int(avl, 572);
- avl = grpc_avl_add(avl, box(805), box(2034), nullptr);
- avl = grpc_avl_add(avl, box(143), box(2035), nullptr);
- avl = grpc_avl_add(avl, box(670), box(2036), nullptr);
- avl = remove_int(avl, 42);
- avl = grpc_avl_add(avl, box(46), box(2038), nullptr);
- avl = remove_int(avl, 970);
- avl = grpc_avl_add(avl, box(353), box(2040), nullptr);
- avl = remove_int(avl, 258);
- avl = grpc_avl_add(avl, box(451), box(2042), nullptr);
- avl = grpc_avl_add(avl, box(28), box(2043), nullptr);
- avl = grpc_avl_add(avl, box(729), box(2044), nullptr);
- avl = grpc_avl_add(avl, box(401), box(2045), nullptr);
- avl = grpc_avl_add(avl, box(614), box(2046), nullptr);
- avl = remove_int(avl, 990);
- avl = remove_int(avl, 212);
- avl = remove_int(avl, 22);
- avl = remove_int(avl, 677);
- avl = grpc_avl_add(avl, box(1016), box(2051), nullptr);
- avl = grpc_avl_add(avl, box(980), box(2052), nullptr);
- avl = grpc_avl_add(avl, box(990), box(2053), nullptr);
- avl = grpc_avl_add(avl, box(355), box(2054), nullptr);
- avl = remove_int(avl, 730);
- avl = remove_int(avl, 37);
- avl = grpc_avl_add(avl, box(407), box(2057), nullptr);
- avl = grpc_avl_add(avl, box(222), box(2058), nullptr);
- avl = grpc_avl_add(avl, box(439), box(2059), nullptr);
- avl = grpc_avl_add(avl, box(563), box(2060), nullptr);
- avl = remove_int(avl, 992);
- avl = remove_int(avl, 786);
- avl = grpc_avl_add(avl, box(1), box(2063), nullptr);
- avl = grpc_avl_add(avl, box(473), box(2064), nullptr);
- avl = grpc_avl_add(avl, box(992), box(2065), nullptr);
- avl = remove_int(avl, 190);
- avl = remove_int(avl, 450);
- avl = remove_int(avl, 1020);
- avl = remove_int(avl, 149);
- avl = grpc_avl_add(avl, box(329), box(2070), nullptr);
- avl = grpc_avl_add(avl, box(35), box(2071), nullptr);
- avl = remove_int(avl, 843);
- avl = grpc_avl_add(avl, box(855), box(2073), nullptr);
- avl = remove_int(avl, 878);
- avl = grpc_avl_add(avl, box(993), box(2075), nullptr);
- avl = grpc_avl_add(avl, box(87), box(2076), nullptr);
- avl = grpc_avl_add(avl, box(572), box(2077), nullptr);
- avl = remove_int(avl, 896);
- avl = grpc_avl_add(avl, box(849), box(2079), nullptr);
- avl = remove_int(avl, 597);
- avl = grpc_avl_add(avl, box(472), box(2081), nullptr);
- avl = remove_int(avl, 778);
- avl = remove_int(avl, 934);
- avl = remove_int(avl, 314);
- avl = grpc_avl_add(avl, box(101), box(2085), nullptr);
- avl = remove_int(avl, 938);
- avl = remove_int(avl, 1010);
- avl = grpc_avl_add(avl, box(579), box(2088), nullptr);
- avl = remove_int(avl, 798);
- avl = remove_int(avl, 88);
- avl = grpc_avl_add(avl, box(851), box(2091), nullptr);
- avl = remove_int(avl, 705);
- avl = grpc_avl_add(avl, box(26), box(2093), nullptr);
- avl = remove_int(avl, 973);
- avl = grpc_avl_add(avl, box(923), box(2095), nullptr);
- avl = remove_int(avl, 668);
- avl = grpc_avl_add(avl, box(310), box(2097), nullptr);
- avl = grpc_avl_add(avl, box(269), box(2098), nullptr);
- avl = remove_int(avl, 173);
- avl = grpc_avl_add(avl, box(279), box(2100), nullptr);
- avl = remove_int(avl, 203);
- avl = grpc_avl_add(avl, box(411), box(2102), nullptr);
- avl = remove_int(avl, 950);
- avl = grpc_avl_add(avl, box(6), box(2104), nullptr);
- avl = remove_int(avl, 400);
- avl = remove_int(avl, 468);
- avl = remove_int(avl, 271);
- avl = grpc_avl_add(avl, box(627), box(2108), nullptr);
- avl = remove_int(avl, 727);
- avl = remove_int(avl, 148);
- avl = remove_int(avl, 98);
- avl = remove_int(avl, 997);
- avl = remove_int(avl, 215);
- avl = remove_int(avl, 628);
- avl = remove_int(avl, 826);
- avl = remove_int(avl, 664);
- avl = grpc_avl_add(avl, box(76), box(2117), nullptr);
- avl = remove_int(avl, 194);
- avl = remove_int(avl, 18);
- avl = grpc_avl_add(avl, box(727), box(2120), nullptr);
- avl = remove_int(avl, 295);
- avl = grpc_avl_add(avl, box(645), box(2122), nullptr);
- avl = remove_int(avl, 321);
- avl = remove_int(avl, 863);
- avl = grpc_avl_add(avl, box(824), box(2125), nullptr);
- avl = grpc_avl_add(avl, box(651), box(2126), nullptr);
- avl = grpc_avl_add(avl, box(804), box(2127), nullptr);
- avl = remove_int(avl, 307);
- avl = grpc_avl_add(avl, box(867), box(2129), nullptr);
- avl = remove_int(avl, 384);
- avl = grpc_avl_add(avl, box(819), box(2131), nullptr);
- avl = remove_int(avl, 674);
- avl = grpc_avl_add(avl, box(76), box(2133), nullptr);
- avl = remove_int(avl, 898);
- avl = grpc_avl_add(avl, box(45), box(2135), nullptr);
- avl = grpc_avl_add(avl, box(512), box(2136), nullptr);
- avl = remove_int(avl, 773);
- avl = remove_int(avl, 907);
- avl = remove_int(avl, 382);
- avl = remove_int(avl, 95);
- avl = remove_int(avl, 734);
- avl = remove_int(avl, 81);
- avl = grpc_avl_add(avl, box(348), box(2143), nullptr);
- avl = remove_int(avl, 509);
- avl = remove_int(avl, 301);
- avl = grpc_avl_add(avl, box(861), box(2146), nullptr);
- avl = grpc_avl_add(avl, box(918), box(2147), nullptr);
- avl = remove_int(avl, 992);
- avl = grpc_avl_add(avl, box(356), box(2149), nullptr);
- avl = remove_int(avl, 64);
- avl = remove_int(avl, 444);
- avl = remove_int(avl, 741);
- avl = grpc_avl_add(avl, box(710), box(2153), nullptr);
- avl = grpc_avl_add(avl, box(264), box(2154), nullptr);
- avl = remove_int(avl, 347);
- avl = remove_int(avl, 250);
- avl = grpc_avl_add(avl, box(82), box(2157), nullptr);
- avl = grpc_avl_add(avl, box(571), box(2158), nullptr);
- avl = remove_int(avl, 721);
- avl = remove_int(avl, 622);
- avl = grpc_avl_add(avl, box(950), box(2161), nullptr);
- avl = grpc_avl_add(avl, box(94), box(2162), nullptr);
- avl = remove_int(avl, 970);
- avl = grpc_avl_add(avl, box(815), box(2164), nullptr);
- avl = remove_int(avl, 930);
- avl = remove_int(avl, 703);
- avl = grpc_avl_add(avl, box(432), box(2167), nullptr);
- avl = remove_int(avl, 544);
- avl = grpc_avl_add(avl, box(21), box(2169), nullptr);
- avl = grpc_avl_add(avl, box(186), box(2170), nullptr);
- avl = remove_int(avl, 143);
- avl = grpc_avl_add(avl, box(425), box(2172), nullptr);
- avl = remove_int(avl, 769);
- avl = grpc_avl_add(avl, box(656), box(2174), nullptr);
- avl = remove_int(avl, 29);
- avl = grpc_avl_add(avl, box(464), box(2176), nullptr);
- avl = remove_int(avl, 713);
- avl = grpc_avl_add(avl, box(800), box(2178), nullptr);
- avl = remove_int(avl, 621);
- avl = grpc_avl_add(avl, box(962), box(2180), nullptr);
- avl = remove_int(avl, 448);
- avl = grpc_avl_add(avl, box(878), box(2182), nullptr);
- avl = remove_int(avl, 39);
- avl = remove_int(avl, 999);
- avl = grpc_avl_add(avl, box(182), box(2185), nullptr);
- avl = grpc_avl_add(avl, box(429), box(2186), nullptr);
- avl = grpc_avl_add(avl, box(598), box(2187), nullptr);
- avl = remove_int(avl, 551);
- avl = grpc_avl_add(avl, box(827), box(2189), nullptr);
- avl = grpc_avl_add(avl, box(809), box(2190), nullptr);
- avl = remove_int(avl, 438);
- avl = remove_int(avl, 811);
- avl = grpc_avl_add(avl, box(808), box(2193), nullptr);
- avl = grpc_avl_add(avl, box(788), box(2194), nullptr);
- avl = remove_int(avl, 156);
- avl = grpc_avl_add(avl, box(933), box(2196), nullptr);
- avl = grpc_avl_add(avl, box(344), box(2197), nullptr);
- avl = remove_int(avl, 460);
- avl = grpc_avl_add(avl, box(161), box(2199), nullptr);
- avl = grpc_avl_add(avl, box(444), box(2200), nullptr);
- avl = remove_int(avl, 597);
- avl = remove_int(avl, 668);
- avl = grpc_avl_add(avl, box(703), box(2203), nullptr);
- avl = remove_int(avl, 515);
- avl = grpc_avl_add(avl, box(380), box(2205), nullptr);
- avl = grpc_avl_add(avl, box(338), box(2206), nullptr);
- avl = remove_int(avl, 550);
- avl = remove_int(avl, 946);
- avl = remove_int(avl, 714);
- avl = remove_int(avl, 739);
- avl = grpc_avl_add(avl, box(413), box(2211), nullptr);
- avl = remove_int(avl, 450);
- avl = grpc_avl_add(avl, box(411), box(2213), nullptr);
- avl = grpc_avl_add(avl, box(117), box(2214), nullptr);
- avl = grpc_avl_add(avl, box(322), box(2215), nullptr);
- avl = grpc_avl_add(avl, box(915), box(2216), nullptr);
- avl = grpc_avl_add(avl, box(410), box(2217), nullptr);
- avl = grpc_avl_add(avl, box(66), box(2218), nullptr);
- avl = remove_int(avl, 756);
- avl = remove_int(avl, 596);
- avl = grpc_avl_add(avl, box(882), box(2221), nullptr);
- avl = grpc_avl_add(avl, box(930), box(2222), nullptr);
- avl = grpc_avl_add(avl, box(36), box(2223), nullptr);
- avl = remove_int(avl, 742);
- avl = grpc_avl_add(avl, box(539), box(2225), nullptr);
- avl = grpc_avl_add(avl, box(596), box(2226), nullptr);
- avl = remove_int(avl, 82);
- avl = remove_int(avl, 686);
- avl = remove_int(avl, 933);
- avl = remove_int(avl, 42);
- avl = remove_int(avl, 340);
- avl = grpc_avl_add(avl, box(126), box(2232), nullptr);
- avl = grpc_avl_add(avl, box(493), box(2233), nullptr);
- avl = grpc_avl_add(avl, box(839), box(2234), nullptr);
- avl = remove_int(avl, 774);
- avl = grpc_avl_add(avl, box(337), box(2236), nullptr);
- avl = remove_int(avl, 322);
- avl = grpc_avl_add(avl, box(16), box(2238), nullptr);
- avl = remove_int(avl, 73);
- avl = remove_int(avl, 85);
- avl = remove_int(avl, 191);
- avl = remove_int(avl, 541);
- avl = grpc_avl_add(avl, box(704), box(2243), nullptr);
- avl = remove_int(avl, 767);
- avl = remove_int(avl, 1006);
- avl = remove_int(avl, 844);
- avl = remove_int(avl, 742);
- avl = grpc_avl_add(avl, box(48), box(2248), nullptr);
- avl = grpc_avl_add(avl, box(138), box(2249), nullptr);
- avl = grpc_avl_add(avl, box(437), box(2250), nullptr);
- avl = grpc_avl_add(avl, box(275), box(2251), nullptr);
- avl = remove_int(avl, 520);
- avl = grpc_avl_add(avl, box(1019), box(2253), nullptr);
- avl = remove_int(avl, 955);
- avl = grpc_avl_add(avl, box(270), box(2255), nullptr);
- avl = remove_int(avl, 680);
- avl = remove_int(avl, 698);
- avl = grpc_avl_add(avl, box(735), box(2258), nullptr);
- avl = grpc_avl_add(avl, box(400), box(2259), nullptr);
- avl = remove_int(avl, 991);
- avl = grpc_avl_add(avl, box(263), box(2261), nullptr);
- avl = remove_int(avl, 704);
- avl = grpc_avl_add(avl, box(757), box(2263), nullptr);
- avl = remove_int(avl, 194);
- avl = remove_int(avl, 616);
- avl = remove_int(avl, 784);
- avl = grpc_avl_add(avl, box(382), box(2267), nullptr);
- avl = grpc_avl_add(avl, box(464), box(2268), nullptr);
- avl = grpc_avl_add(avl, box(817), box(2269), nullptr);
- avl = remove_int(avl, 445);
- avl = grpc_avl_add(avl, box(412), box(2271), nullptr);
- avl = remove_int(avl, 525);
- avl = grpc_avl_add(avl, box(299), box(2273), nullptr);
- avl = grpc_avl_add(avl, box(464), box(2274), nullptr);
- avl = grpc_avl_add(avl, box(715), box(2275), nullptr);
- avl = remove_int(avl, 58);
- avl = remove_int(avl, 218);
- avl = grpc_avl_add(avl, box(961), box(2278), nullptr);
- avl = grpc_avl_add(avl, box(491), box(2279), nullptr);
- avl = remove_int(avl, 846);
- avl = grpc_avl_add(avl, box(762), box(2281), nullptr);
- avl = remove_int(avl, 974);
- avl = remove_int(avl, 887);
- avl = grpc_avl_add(avl, box(498), box(2284), nullptr);
- avl = remove_int(avl, 810);
- avl = remove_int(avl, 743);
- avl = remove_int(avl, 22);
- avl = remove_int(avl, 284);
- avl = grpc_avl_add(avl, box(482), box(2289), nullptr);
- avl = grpc_avl_add(avl, box(1021), box(2290), nullptr);
- avl = remove_int(avl, 155);
- avl = remove_int(avl, 128);
- avl = grpc_avl_add(avl, box(819), box(2293), nullptr);
- avl = grpc_avl_add(avl, box(324), box(2294), nullptr);
- avl = remove_int(avl, 196);
- avl = remove_int(avl, 370);
- avl = remove_int(avl, 753);
- avl = remove_int(avl, 56);
- avl = remove_int(avl, 735);
- avl = grpc_avl_add(avl, box(272), box(2300), nullptr);
- avl = grpc_avl_add(avl, box(474), box(2301), nullptr);
- avl = grpc_avl_add(avl, box(719), box(2302), nullptr);
- avl = grpc_avl_add(avl, box(236), box(2303), nullptr);
- avl = remove_int(avl, 818);
- avl = grpc_avl_add(avl, box(727), box(2305), nullptr);
- avl = remove_int(avl, 892);
- avl = remove_int(avl, 871);
- avl = remove_int(avl, 231);
- avl = grpc_avl_add(avl, box(62), box(2309), nullptr);
- avl = grpc_avl_add(avl, box(953), box(2310), nullptr);
- avl = remove_int(avl, 701);
- avl = grpc_avl_add(avl, box(193), box(2312), nullptr);
- avl = remove_int(avl, 619);
- avl = remove_int(avl, 22);
- avl = remove_int(avl, 804);
- avl = remove_int(avl, 851);
- avl = grpc_avl_add(avl, box(286), box(2317), nullptr);
- avl = grpc_avl_add(avl, box(751), box(2318), nullptr);
- avl = remove_int(avl, 525);
- avl = grpc_avl_add(avl, box(217), box(2320), nullptr);
- avl = remove_int(avl, 336);
- avl = grpc_avl_add(avl, box(86), box(2322), nullptr);
- avl = grpc_avl_add(avl, box(81), box(2323), nullptr);
- avl = grpc_avl_add(avl, box(850), box(2324), nullptr);
- avl = remove_int(avl, 872);
- avl = grpc_avl_add(avl, box(402), box(2326), nullptr);
- avl = grpc_avl_add(avl, box(54), box(2327), nullptr);
- avl = grpc_avl_add(avl, box(980), box(2328), nullptr);
- avl = grpc_avl_add(avl, box(845), box(2329), nullptr);
- avl = remove_int(avl, 1004);
- avl = remove_int(avl, 273);
- avl = remove_int(avl, 879);
- avl = grpc_avl_add(avl, box(354), box(2333), nullptr);
- avl = grpc_avl_add(avl, box(58), box(2334), nullptr);
- avl = grpc_avl_add(avl, box(127), box(2335), nullptr);
- avl = remove_int(avl, 84);
- avl = grpc_avl_add(avl, box(360), box(2337), nullptr);
- avl = remove_int(avl, 648);
- avl = remove_int(avl, 488);
- avl = remove_int(avl, 585);
- avl = remove_int(avl, 230);
- avl = grpc_avl_add(avl, box(887), box(2342), nullptr);
- avl = remove_int(avl, 558);
- avl = remove_int(avl, 958);
- avl = grpc_avl_add(avl, box(822), box(2345), nullptr);
- avl = remove_int(avl, 1004);
- avl = remove_int(avl, 747);
- avl = grpc_avl_add(avl, box(631), box(2348), nullptr);
- avl = grpc_avl_add(avl, box(442), box(2349), nullptr);
- avl = remove_int(avl, 957);
- avl = remove_int(avl, 964);
- avl = grpc_avl_add(avl, box(10), box(2352), nullptr);
- avl = remove_int(avl, 189);
- avl = grpc_avl_add(avl, box(742), box(2354), nullptr);
- avl = remove_int(avl, 108);
- avl = grpc_avl_add(avl, box(1014), box(2356), nullptr);
- avl = remove_int(avl, 266);
- avl = remove_int(avl, 623);
- avl = remove_int(avl, 697);
- avl = grpc_avl_add(avl, box(180), box(2360), nullptr);
- avl = remove_int(avl, 472);
- avl = grpc_avl_add(avl, box(567), box(2362), nullptr);
- avl = remove_int(avl, 1020);
- avl = remove_int(avl, 273);
- avl = grpc_avl_add(avl, box(864), box(2365), nullptr);
- avl = grpc_avl_add(avl, box(1009), box(2366), nullptr);
- avl = remove_int(avl, 224);
- avl = remove_int(avl, 81);
- avl = grpc_avl_add(avl, box(653), box(2369), nullptr);
- avl = remove_int(avl, 67);
- avl = remove_int(avl, 102);
- avl = remove_int(avl, 76);
- avl = remove_int(avl, 935);
- avl = remove_int(avl, 169);
- avl = remove_int(avl, 232);
- avl = remove_int(avl, 79);
- avl = grpc_avl_add(avl, box(509), box(2377), nullptr);
- avl = remove_int(avl, 900);
- avl = remove_int(avl, 822);
- avl = remove_int(avl, 945);
- avl = remove_int(avl, 356);
- avl = grpc_avl_add(avl, box(443), box(2382), nullptr);
- avl = grpc_avl_add(avl, box(925), box(2383), nullptr);
- avl = remove_int(avl, 994);
- avl = remove_int(avl, 324);
- avl = grpc_avl_add(avl, box(291), box(2386), nullptr);
- avl = remove_int(avl, 94);
- avl = remove_int(avl, 795);
- avl = remove_int(avl, 42);
- avl = grpc_avl_add(avl, box(613), box(2390), nullptr);
- avl = remove_int(avl, 289);
- avl = grpc_avl_add(avl, box(980), box(2392), nullptr);
- avl = remove_int(avl, 316);
- avl = grpc_avl_add(avl, box(281), box(2394), nullptr);
- avl = grpc_avl_add(avl, box(1006), box(2395), nullptr);
- avl = remove_int(avl, 776);
- avl = grpc_avl_add(avl, box(108), box(2397), nullptr);
- avl = grpc_avl_add(avl, box(918), box(2398), nullptr);
- avl = remove_int(avl, 721);
- avl = remove_int(avl, 563);
- avl = grpc_avl_add(avl, box(925), box(2401), nullptr);
- avl = remove_int(avl, 448);
- avl = remove_int(avl, 198);
- avl = remove_int(avl, 1);
- avl = grpc_avl_add(avl, box(160), box(2405), nullptr);
- avl = remove_int(avl, 515);
- avl = grpc_avl_add(avl, box(284), box(2407), nullptr);
- avl = grpc_avl_add(avl, box(225), box(2408), nullptr);
- avl = remove_int(avl, 304);
- avl = grpc_avl_add(avl, box(714), box(2410), nullptr);
- avl = grpc_avl_add(avl, box(708), box(2411), nullptr);
- avl = grpc_avl_add(avl, box(624), box(2412), nullptr);
- avl = remove_int(avl, 662);
- avl = remove_int(avl, 825);
- avl = remove_int(avl, 383);
- avl = remove_int(avl, 381);
- avl = grpc_avl_add(avl, box(194), box(2417), nullptr);
- avl = remove_int(avl, 280);
- avl = remove_int(avl, 25);
- avl = remove_int(avl, 633);
- avl = grpc_avl_add(avl, box(897), box(2421), nullptr);
- avl = remove_int(avl, 636);
- avl = remove_int(avl, 596);
- avl = remove_int(avl, 757);
- avl = remove_int(avl, 343);
- avl = remove_int(avl, 162);
- avl = remove_int(avl, 913);
- avl = remove_int(avl, 843);
- avl = remove_int(avl, 280);
- avl = remove_int(avl, 911);
- avl = grpc_avl_add(avl, box(1008), box(2431), nullptr);
- avl = remove_int(avl, 948);
- avl = remove_int(avl, 74);
- avl = remove_int(avl, 571);
- avl = grpc_avl_add(avl, box(486), box(2435), nullptr);
- avl = grpc_avl_add(avl, box(285), box(2436), nullptr);
- avl = remove_int(avl, 304);
- avl = remove_int(avl, 516);
- avl = grpc_avl_add(avl, box(758), box(2439), nullptr);
- avl = grpc_avl_add(avl, box(776), box(2440), nullptr);
- avl = remove_int(avl, 696);
- avl = grpc_avl_add(avl, box(104), box(2442), nullptr);
- avl = grpc_avl_add(avl, box(700), box(2443), nullptr);
- avl = grpc_avl_add(avl, box(114), box(2444), nullptr);
- avl = grpc_avl_add(avl, box(567), box(2445), nullptr);
- avl = remove_int(avl, 620);
- avl = grpc_avl_add(avl, box(270), box(2447), nullptr);
- avl = remove_int(avl, 730);
- avl = grpc_avl_add(avl, box(749), box(2449), nullptr);
- avl = grpc_avl_add(avl, box(443), box(2450), nullptr);
- avl = remove_int(avl, 457);
- avl = grpc_avl_add(avl, box(571), box(2452), nullptr);
- avl = grpc_avl_add(avl, box(626), box(2453), nullptr);
- avl = remove_int(avl, 638);
- avl = remove_int(avl, 313);
-
- grpc_avl_unref(avl, nullptr);
-}
-
static void test_stress(int amount_of_stress) {
int added[1024];
int i, j;
@@ -3653,8 +294,6 @@ int main(int argc, char* argv[]) {
test_replace();
test_remove();
test_badcase1();
- test_badcase2();
- test_badcase3();
test_stress(10);
return 0;
diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc
index c03ebcf409..ade23133c5 100644
--- a/test/core/bad_client/bad_client.cc
+++ b/test/core/bad_client/bad_client.cc
@@ -115,7 +115,7 @@ void grpc_run_client_side_validator(grpc_bad_client_arg* arg, uint32_t flags,
grpc_schedule_on_exec_ctx);
/* Write data */
- grpc_endpoint_write(sfd->client, &outgoing, &done_write_closure);
+ grpc_endpoint_write(sfd->client, &outgoing, &done_write_closure, nullptr);
grpc_core::ExecCtx::Get()->Flush();
/* Await completion, unless the request is large and write may not finish
diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc
index e2ea7540ef..73d251eff4 100644
--- a/test/core/bad_ssl/bad_ssl_test.cc
+++ b/test/core/bad_ssl/bad_ssl_test.cc
@@ -37,7 +37,7 @@ static void* tag(intptr_t t) { return (void*)t; }
static void run_test(const char* target, size_t nops) {
grpc_channel_credentials* ssl_creds =
- grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr);
grpc_channel* channel;
grpc_call* c;
diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD
index 6bf4fcdbb8..da419f00cf 100644
--- a/test/core/channel/BUILD
+++ b/test/core/channel/BUILD
@@ -84,11 +84,45 @@ grpc_cc_test(
)
grpc_cc_test(
+ name = "channelz_test",
+ srcs = ["channelz_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:channel_trace_proto_helper",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
+ name = "channelz_registry_test",
+ srcs = ["channelz_registry_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
+)
+
+grpc_cc_test(
name = "status_util_test",
srcs = ["status_util_test.cc"],
language = "C++",
deps = [
"//:grpc",
+ "//test/core/util:gpr_test_util",
],
external_deps = [
"gtest",
diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc
index 57ff7370ad..41c62a8f16 100644
--- a/test/core/channel/channel_args_test.cc
+++ b/test/core/channel/channel_args_test.cc
@@ -148,6 +148,88 @@ static void test_set_socket_mutator(void) {
}
}
+struct fake_class {
+ int foo;
+};
+
+static void* fake_pointer_arg_copy(void* arg) {
+ gpr_log(GPR_DEBUG, "fake_pointer_arg_copy");
+ fake_class* fc = static_cast<fake_class*>(arg);
+ fake_class* new_fc = static_cast<fake_class*>(gpr_malloc(sizeof(fake_class)));
+ new_fc->foo = fc->foo;
+ return new_fc;
+}
+
+static void fake_pointer_arg_destroy(void* arg) {
+ gpr_log(GPR_DEBUG, "fake_pointer_arg_destroy");
+ fake_class* fc = static_cast<fake_class*>(arg);
+ gpr_free(fc);
+}
+
+static int fake_pointer_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
+
+static const grpc_arg_pointer_vtable fake_pointer_arg_vtable = {
+ fake_pointer_arg_copy, fake_pointer_arg_destroy, fake_pointer_cmp};
+
+static void test_channel_create_with_args(void) {
+ grpc_arg client_a[3];
+
+ // adds integer arg
+ client_a[0].type = GRPC_ARG_INTEGER;
+ client_a[0].key = const_cast<char*>("arg_int");
+ client_a[0].value.integer = 0;
+
+ // adds const str arg
+ client_a[1].type = GRPC_ARG_STRING;
+ client_a[1].key = const_cast<char*>("arg_str");
+ client_a[1].value.string = const_cast<char*>("arg_str_val");
+
+ // allocated and adds custom pointer arg
+ fake_class* fc = static_cast<fake_class*>(gpr_malloc(sizeof(fake_class)));
+ fc->foo = 42;
+ client_a[2].type = GRPC_ARG_POINTER;
+ client_a[2].key = const_cast<char*>("arg_pointer");
+ client_a[2].value.pointer.vtable = &fake_pointer_arg_vtable;
+ client_a[2].value.pointer.p = fc;
+
+ // creates channel
+ grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a};
+ grpc_channel* c =
+ grpc_insecure_channel_create("fake_target", &client_args, nullptr);
+ // user is can free the memory they allocated here
+ gpr_free(fc);
+ grpc_channel_destroy(c);
+}
+
+static void test_server_create_with_args(void) {
+ grpc_arg server_a[3];
+
+ // adds integer arg
+ server_a[0].type = GRPC_ARG_INTEGER;
+ server_a[0].key = const_cast<char*>("arg_int");
+ server_a[0].value.integer = 0;
+
+ // adds const str arg
+ server_a[1].type = GRPC_ARG_STRING;
+ server_a[1].key = const_cast<char*>("arg_str");
+ server_a[1].value.string = const_cast<char*>("arg_str_val");
+
+ // allocated and adds custom pointer arg
+ fake_class* fc = static_cast<fake_class*>(gpr_malloc(sizeof(fake_class)));
+ fc->foo = 42;
+ server_a[2].type = GRPC_ARG_POINTER;
+ server_a[2].key = const_cast<char*>("arg_pointer");
+ server_a[2].value.pointer.vtable = &fake_pointer_arg_vtable;
+ server_a[2].value.pointer.p = fc;
+
+ // creates server
+ grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a};
+ grpc_server* s = grpc_server_create(&server_args, nullptr);
+ // user is can free the memory they allocated here
+ gpr_free(fc);
+ grpc_server_destroy(s);
+}
+
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
@@ -155,6 +237,8 @@ int main(int argc, char** argv) {
test_set_compression_algorithm();
test_compression_algorithm_states();
test_set_socket_mutator();
+ test_channel_create_with_args();
+ test_server_create_with_args();
grpc_shutdown();
return 0;
}
diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc
index 2f5329a96d..6f0bfa06d2 100644
--- a/test/core/channel/channel_stack_test.cc
+++ b/test/core/channel/channel_stack_test.cc
@@ -124,7 +124,7 @@ static void test_create_channel_stack(void) {
gpr_now(GPR_CLOCK_MONOTONIC), /* start_time */
GRPC_MILLIS_INF_FUTURE, /* deadline */
nullptr, /* arena */
- nullptr /* call_combiner */
+ nullptr, /* call_combiner */
};
grpc_error* error =
grpc_call_stack_init(channel_stack, 1, free_call, call_stack, &args);
diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc
index 3c73e33612..d594445bfb 100644
--- a/test/core/channel/channel_trace_test.cc
+++ b/test/core/channel/channel_trace_test.cc
@@ -25,7 +25,8 @@
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_trace.h"
-#include "src/core/lib/channel/channel_trace_registry.h"
+#include "src/core/lib/channel/channelz.h"
+#include "src/core/lib/channel/channelz_registry.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/json/json.h"
@@ -33,13 +34,23 @@
#include "test/core/util/test_config.h"
#include "test/cpp/util/channel_trace_proto_helper.h"
-// remove me
-#include <grpc/support/string_util.h>
#include <stdlib.h>
#include <string.h>
namespace grpc_core {
+namespace channelz {
namespace testing {
+
+// testing peer to access channel internals
+class ChannelNodePeer {
+ public:
+ explicit ChannelNodePeer(ChannelNode* node) : node_(node) {}
+ ChannelTrace* trace() const { return &node_->trace_; }
+
+ private:
+ ChannelNode* node_;
+};
+
namespace {
grpc_json* GetJsonChild(grpc_json* parent, const char* key) {
@@ -69,7 +80,7 @@ void ValidateChannelTraceData(grpc_json* json,
ASSERT_NE(json, nullptr);
grpc_json* num_events_logged_json = GetJsonChild(json, "numEventsLogged");
ASSERT_NE(num_events_logged_json, nullptr);
- grpc_json* start_time = GetJsonChild(json, "creationTime");
+ grpc_json* start_time = GetJsonChild(json, "creationTimestamp");
ASSERT_NE(start_time, nullptr);
size_t num_events_logged =
(size_t)strtol(num_events_logged_json->value, nullptr, 0);
@@ -77,35 +88,47 @@ void ValidateChannelTraceData(grpc_json* json,
ValidateJsonArraySize(json, "events", actual_num_events_expected);
}
-void AddSimpleTrace(RefCountedPtr<ChannelTrace> tracer) {
+void AddSimpleTrace(ChannelTrace* tracer) {
tracer->AddTraceEvent(ChannelTrace::Severity::Info,
grpc_slice_from_static_string("simple trace"));
}
// checks for the existence of all the required members of the tracer.
-void ValidateChannelTrace(RefCountedPtr<ChannelTrace> tracer,
+void ValidateChannelTrace(ChannelTrace* tracer,
size_t expected_num_event_logged, size_t max_nodes) {
if (!max_nodes) return;
- char* json_str = tracer->RenderTrace();
+ grpc_json* json = tracer->RenderJson();
+ EXPECT_NE(json, nullptr);
+ char* json_str = grpc_json_dump_to_string(json, 0);
+ grpc_json_destroy(json);
grpc::testing::ValidateChannelTraceProtoJsonTranslation(json_str);
- grpc_json* json = grpc_json_parse_string(json_str);
- ValidateChannelTraceData(json, expected_num_event_logged,
+ grpc_json* parsed_json = grpc_json_parse_string(json_str);
+ ValidateChannelTraceData(parsed_json, expected_num_event_logged,
GPR_MIN(expected_num_event_logged, max_nodes));
- grpc_json_destroy(json);
+ grpc_json_destroy(parsed_json);
gpr_free(json_str);
}
-void ValidateTraceDataMatchedUuidLookup(RefCountedPtr<ChannelTrace> tracer) {
- intptr_t uuid = tracer->GetUuid();
- if (uuid == -1) return; // Doesn't make sense to lookup if tracing disabled
- char* tracer_json_str = tracer->RenderTrace();
- ChannelTrace* uuid_lookup =
- grpc_channel_trace_registry_get_channel_trace(uuid);
- char* uuid_lookup_json_str = uuid_lookup->RenderTrace();
- EXPECT_EQ(strcmp(tracer_json_str, uuid_lookup_json_str), 0);
- gpr_free(tracer_json_str);
- gpr_free(uuid_lookup_json_str);
-}
+class ChannelFixture {
+ public:
+ ChannelFixture(int max_trace_nodes) {
+ grpc_arg client_a;
+ client_a.type = GRPC_ARG_INTEGER;
+ client_a.key =
+ const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE);
+ client_a.value.integer = max_trace_nodes;
+ grpc_channel_args client_args = {1, &client_a};
+ channel_ =
+ grpc_insecure_channel_create("fake_target", &client_args, nullptr);
+ }
+
+ ~ChannelFixture() { grpc_channel_destroy(channel_); }
+
+ grpc_channel* channel() { return channel_; }
+
+ private:
+ grpc_channel* channel_;
+};
} // anonymous namespace
@@ -115,25 +138,22 @@ class ChannelTracerTest : public ::testing::TestWithParam<size_t> {};
// lookups by uuid.
TEST_P(ChannelTracerTest, BasicTest) {
grpc_core::ExecCtx exec_ctx;
- RefCountedPtr<ChannelTrace> tracer = MakeRefCounted<ChannelTrace>(GetParam());
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- ValidateTraceDataMatchedUuidLookup(tracer);
- tracer->AddTraceEvent(ChannelTrace::Severity::Info,
- grpc_slice_from_static_string("trace three"));
- tracer->AddTraceEvent(ChannelTrace::Severity::Error,
- grpc_slice_from_static_string("trace four error"));
- ValidateChannelTrace(tracer, 4, GetParam());
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- ValidateChannelTrace(tracer, 6, GetParam());
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- ValidateChannelTrace(tracer, 10, GetParam());
- ValidateTraceDataMatchedUuidLookup(tracer);
- tracer.reset(nullptr);
+ ChannelTrace tracer(GetParam());
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ tracer.AddTraceEvent(ChannelTrace::Severity::Info,
+ grpc_slice_from_static_string("trace three"));
+ tracer.AddTraceEvent(ChannelTrace::Severity::Error,
+ grpc_slice_from_static_string("trace four error"));
+ ValidateChannelTrace(&tracer, 4, GetParam());
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ ValidateChannelTrace(&tracer, 6, GetParam());
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ ValidateChannelTrace(&tracer, 10, GetParam());
}
// Tests more complex functionality, like a parent channel tracking
@@ -141,44 +161,46 @@ TEST_P(ChannelTracerTest, BasicTest) {
// and this function will both hold refs to the subchannel.
TEST_P(ChannelTracerTest, ComplexTest) {
grpc_core::ExecCtx exec_ctx;
- RefCountedPtr<ChannelTrace> tracer = MakeRefCounted<ChannelTrace>(GetParam());
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- RefCountedPtr<ChannelTrace> sc1 = MakeRefCounted<ChannelTrace>(GetParam());
- tracer->AddTraceEventReferencingSubchannel(
+ ChannelTrace tracer(GetParam());
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ ChannelFixture channel1(GetParam());
+ RefCountedPtr<ChannelNode> sc1 =
+ MakeRefCounted<ChannelNode>(channel1.channel(), GetParam(), true);
+ ChannelNodePeer sc1_peer(sc1.get());
+ tracer.AddTraceEventWithReference(
ChannelTrace::Severity::Info,
grpc_slice_from_static_string("subchannel one created"), sc1);
- ValidateChannelTrace(tracer, 3, GetParam());
- AddSimpleTrace(sc1);
- AddSimpleTrace(sc1);
- AddSimpleTrace(sc1);
- ValidateChannelTrace(sc1, 3, GetParam());
- AddSimpleTrace(sc1);
- AddSimpleTrace(sc1);
- AddSimpleTrace(sc1);
- ValidateChannelTrace(sc1, 6, GetParam());
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- ValidateChannelTrace(tracer, 5, GetParam());
- ValidateTraceDataMatchedUuidLookup(tracer);
- RefCountedPtr<ChannelTrace> sc2 = MakeRefCounted<ChannelTrace>(GetParam());
- tracer->AddTraceEventReferencingChannel(
+ ValidateChannelTrace(&tracer, 3, GetParam());
+ AddSimpleTrace(sc1_peer.trace());
+ AddSimpleTrace(sc1_peer.trace());
+ AddSimpleTrace(sc1_peer.trace());
+ ValidateChannelTrace(sc1_peer.trace(), 3, GetParam());
+ AddSimpleTrace(sc1_peer.trace());
+ AddSimpleTrace(sc1_peer.trace());
+ AddSimpleTrace(sc1_peer.trace());
+ ValidateChannelTrace(sc1_peer.trace(), 6, GetParam());
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ ValidateChannelTrace(&tracer, 5, GetParam());
+ ChannelFixture channel2(GetParam());
+ RefCountedPtr<ChannelNode> sc2 =
+ MakeRefCounted<ChannelNode>(channel2.channel(), GetParam(), true);
+ tracer.AddTraceEventWithReference(
ChannelTrace::Severity::Info,
grpc_slice_from_static_string("LB channel two created"), sc2);
- tracer->AddTraceEventReferencingSubchannel(
+ tracer.AddTraceEventWithReference(
ChannelTrace::Severity::Warning,
grpc_slice_from_static_string("subchannel one inactive"), sc1);
- ValidateChannelTrace(tracer, 7, GetParam());
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- ValidateTraceDataMatchedUuidLookup(tracer);
- tracer.reset(nullptr);
- sc1.reset(nullptr);
- sc2.reset(nullptr);
+ ValidateChannelTrace(&tracer, 7, GetParam());
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ sc1.reset();
+ sc2.reset();
}
// Test a case in which the parent channel has subchannels and the subchannels
@@ -186,48 +208,56 @@ TEST_P(ChannelTracerTest, ComplexTest) {
// gets deleted.
TEST_P(ChannelTracerTest, TestNesting) {
grpc_core::ExecCtx exec_ctx;
- RefCountedPtr<ChannelTrace> tracer = MakeRefCounted<ChannelTrace>(GetParam());
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- ValidateChannelTrace(tracer, 2, GetParam());
- RefCountedPtr<ChannelTrace> sc1 = MakeRefCounted<ChannelTrace>(GetParam());
- tracer->AddTraceEventReferencingChannel(
+ ChannelTrace tracer(GetParam());
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ ValidateChannelTrace(&tracer, 2, GetParam());
+ ChannelFixture channel1(GetParam());
+ RefCountedPtr<ChannelNode> sc1 =
+ MakeRefCounted<ChannelNode>(channel1.channel(), GetParam(), true);
+ ChannelNodePeer sc1_peer(sc1.get());
+ tracer.AddTraceEventWithReference(
ChannelTrace::Severity::Info,
grpc_slice_from_static_string("subchannel one created"), sc1);
- ValidateChannelTrace(tracer, 3, GetParam());
- AddSimpleTrace(sc1);
- RefCountedPtr<ChannelTrace> conn1 = MakeRefCounted<ChannelTrace>(GetParam());
+ ValidateChannelTrace(&tracer, 3, GetParam());
+ AddSimpleTrace(sc1_peer.trace());
+ ChannelFixture channel2(GetParam());
+ RefCountedPtr<ChannelNode> conn1 =
+ MakeRefCounted<ChannelNode>(channel2.channel(), GetParam(), true);
+ ChannelNodePeer conn1_peer(conn1.get());
// nesting one level deeper.
- sc1->AddTraceEventReferencingSubchannel(
+ sc1_peer.trace()->AddTraceEventWithReference(
ChannelTrace::Severity::Info,
grpc_slice_from_static_string("connection one created"), conn1);
- ValidateChannelTrace(tracer, 3, GetParam());
- AddSimpleTrace(conn1);
- AddSimpleTrace(tracer);
- AddSimpleTrace(tracer);
- ValidateChannelTrace(tracer, 5, GetParam());
- ValidateChannelTrace(conn1, 1, GetParam());
- RefCountedPtr<ChannelTrace> sc2 = MakeRefCounted<ChannelTrace>(GetParam());
- tracer->AddTraceEventReferencingSubchannel(
+ ValidateChannelTrace(&tracer, 3, GetParam());
+ AddSimpleTrace(conn1_peer.trace());
+ AddSimpleTrace(&tracer);
+ AddSimpleTrace(&tracer);
+ ValidateChannelTrace(&tracer, 5, GetParam());
+ ValidateChannelTrace(conn1_peer.trace(), 1, GetParam());
+ ChannelFixture channel3(GetParam());
+ RefCountedPtr<ChannelNode> sc2 =
+ MakeRefCounted<ChannelNode>(channel3.channel(), GetParam(), true);
+ tracer.AddTraceEventWithReference(
ChannelTrace::Severity::Info,
grpc_slice_from_static_string("subchannel two created"), sc2);
// this trace should not get added to the parents children since it is already
// present in the tracer.
- tracer->AddTraceEventReferencingChannel(
+ tracer.AddTraceEventWithReference(
ChannelTrace::Severity::Warning,
grpc_slice_from_static_string("subchannel one inactive"), sc1);
- AddSimpleTrace(tracer);
- ValidateChannelTrace(tracer, 8, GetParam());
- tracer.reset(nullptr);
- sc1.reset(nullptr);
- sc2.reset(nullptr);
- conn1.reset(nullptr);
+ AddSimpleTrace(&tracer);
+ ValidateChannelTrace(&tracer, 8, GetParam());
+ sc1.reset();
+ sc2.reset();
+ conn1.reset();
}
INSTANTIATE_TEST_CASE_P(ChannelTracerTestSweep, ChannelTracerTest,
::testing::Values(0, 1, 2, 6, 10, 15));
} // namespace testing
+} // namespace channelz
} // namespace grpc_core
int main(int argc, char** argv) {
diff --git a/test/core/channel/channelz_registry_test.cc b/test/core/channel/channelz_registry_test.cc
new file mode 100644
index 0000000000..c02d525c81
--- /dev/null
+++ b/test/core/channel/channelz_registry_test.cc
@@ -0,0 +1,109 @@
+/*
+ *
+ * Copyright 2017 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 <stdlib.h>
+#include <string.h>
+
+#include <grpc/grpc.h>
+#include <gtest/gtest.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+
+#include "src/core/lib/channel/channel_trace.h"
+#include "src/core/lib/channel/channelz.h"
+#include "src/core/lib/channel/channelz_registry.h"
+#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/memory.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/json/json.h"
+#include "src/core/lib/surface/channel.h"
+
+#include "test/core/util/test_config.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+namespace grpc_core {
+namespace channelz {
+namespace testing {
+
+TEST(ChannelzRegistryTest, UuidStartsAboveZeroTest) {
+ BaseNode* channelz_channel = nullptr;
+ intptr_t uuid = ChannelzRegistry::Register(channelz_channel);
+ EXPECT_GT(uuid, 0) << "First uuid chose must be greater than zero. Zero if "
+ "reserved according to "
+ "https://github.com/grpc/proposal/blob/master/"
+ "A14-channelz.md";
+ ChannelzRegistry::Unregister(uuid);
+}
+
+TEST(ChannelzRegistryTest, UuidsAreIncreasing) {
+ BaseNode* channelz_channel = nullptr;
+ std::vector<intptr_t> uuids;
+ uuids.reserve(10);
+ for (int i = 0; i < 10; ++i) {
+ // reregister the same object. It's ok since we are just testing uuids
+ uuids.push_back(ChannelzRegistry::Register(channelz_channel));
+ }
+ for (size_t i = 1; i < uuids.size(); ++i) {
+ EXPECT_LT(uuids[i - 1], uuids[i]) << "Uuids must always be increasing";
+ }
+}
+
+TEST(ChannelzRegistryTest, RegisterGetTest) {
+ // we hackily jam an intptr_t into this pointer to check for equality later
+ BaseNode* channelz_channel = (BaseNode*)42;
+ intptr_t uuid = ChannelzRegistry::Register(channelz_channel);
+ BaseNode* retrieved = ChannelzRegistry::Get(uuid);
+ EXPECT_EQ(channelz_channel, retrieved);
+}
+
+TEST(ChannelzRegistryTest, RegisterManyItems) {
+ // we hackily jam an intptr_t into this pointer to check for equality later
+ BaseNode* channelz_channel = (BaseNode*)42;
+ for (int i = 0; i < 100; i++) {
+ intptr_t uuid = ChannelzRegistry::Register(channelz_channel);
+ BaseNode* retrieved = ChannelzRegistry::Get(uuid);
+ EXPECT_EQ(channelz_channel, retrieved);
+ }
+}
+
+TEST(ChannelzRegistryTest, NullIfNotPresentTest) {
+ // we hackily jam an intptr_t into this pointer to check for equality later
+ BaseNode* channelz_channel = (BaseNode*)42;
+ intptr_t uuid = ChannelzRegistry::Register(channelz_channel);
+ // try to pull out a uuid that does not exist.
+ BaseNode* nonexistant = ChannelzRegistry::Get(uuid + 1);
+ EXPECT_EQ(nonexistant, nullptr);
+ BaseNode* retrieved = ChannelzRegistry::Get(uuid);
+ EXPECT_EQ(channelz_channel, retrieved);
+}
+
+} // namespace testing
+} // namespace channelz
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+ ::testing::InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
+}
diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc
new file mode 100644
index 0000000000..bcda30d9f2
--- /dev/null
+++ b/test/core/channel/channelz_test.cc
@@ -0,0 +1,379 @@
+/*
+ *
+ * Copyright 2017 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 <stdlib.h>
+#include <string.h>
+
+#include <gtest/gtest.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+
+#include "src/core/lib/channel/channel_trace.h"
+#include "src/core/lib/channel/channelz.h"
+#include "src/core/lib/channel/channelz_registry.h"
+#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/json/json.h"
+#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/surface/server.h"
+
+#include "test/core/util/test_config.h"
+#include "test/cpp/util/channel_trace_proto_helper.h"
+
+#include <grpc/support/string_util.h>
+#include <stdlib.h>
+#include <string.h>
+
+namespace grpc_core {
+namespace channelz {
+namespace testing {
+
+// testing peer to access channel internals
+class CallCountingHelperPeer {
+ public:
+ explicit CallCountingHelperPeer(CallCountingHelper* node) : node_(node) {}
+ grpc_millis last_call_started_millis() const {
+ return (grpc_millis)gpr_atm_no_barrier_load(
+ &node_->last_call_started_millis_);
+ }
+
+ private:
+ CallCountingHelper* node_;
+};
+
+namespace {
+
+grpc_json* GetJsonChild(grpc_json* parent, const char* key) {
+ EXPECT_NE(parent, nullptr);
+ for (grpc_json* child = parent->child; child != nullptr;
+ child = child->next) {
+ if (child->key != nullptr && strcmp(child->key, key) == 0) return child;
+ }
+ return nullptr;
+}
+
+void ValidateJsonArraySize(grpc_json* json, const char* key,
+ size_t expected_size) {
+ grpc_json* arr = GetJsonChild(json, key);
+ if (expected_size == 0) {
+ ASSERT_EQ(arr, nullptr);
+ return;
+ }
+ ASSERT_NE(arr, nullptr);
+ ASSERT_EQ(arr->type, GRPC_JSON_ARRAY);
+ size_t count = 0;
+ for (grpc_json* child = arr->child; child != nullptr; child = child->next) {
+ ++count;
+ }
+ EXPECT_EQ(count, expected_size);
+}
+
+void ValidateGetTopChannels(size_t expected_channels) {
+ char* json_str = ChannelzRegistry::GetTopChannels(0);
+ grpc::testing::ValidateGetTopChannelsResponseProtoJsonTranslation(json_str);
+ grpc_json* parsed_json = grpc_json_parse_string(json_str);
+ // This check will naturally have to change when we support pagination.
+ // tracked: https://github.com/grpc/grpc/issues/16019.
+ ValidateJsonArraySize(parsed_json, "channel", expected_channels);
+ grpc_json* end = GetJsonChild(parsed_json, "end");
+ ASSERT_NE(end, nullptr);
+ EXPECT_EQ(end->type, GRPC_JSON_TRUE);
+ grpc_json_destroy(parsed_json);
+ gpr_free(json_str);
+ // also check that the core API formats this correctly
+ char* core_api_json_str = grpc_channelz_get_top_channels(0);
+ grpc::testing::ValidateGetTopChannelsResponseProtoJsonTranslation(
+ core_api_json_str);
+ gpr_free(core_api_json_str);
+}
+
+void ValidateGetServers(size_t expected_servers) {
+ char* json_str = ChannelzRegistry::GetServers(0);
+ grpc::testing::ValidateGetServersResponseProtoJsonTranslation(json_str);
+ grpc_json* parsed_json = grpc_json_parse_string(json_str);
+ // This check will naturally have to change when we support pagination.
+ // tracked: https://github.com/grpc/grpc/issues/16019.
+ ValidateJsonArraySize(parsed_json, "server", expected_servers);
+ grpc_json* end = GetJsonChild(parsed_json, "end");
+ ASSERT_NE(end, nullptr);
+ EXPECT_EQ(end->type, GRPC_JSON_TRUE);
+ grpc_json_destroy(parsed_json);
+ gpr_free(json_str);
+ // also check that the core API formats this correctly
+ char* core_api_json_str = grpc_channelz_get_servers(0);
+ grpc::testing::ValidateGetServersResponseProtoJsonTranslation(
+ core_api_json_str);
+ gpr_free(core_api_json_str);
+}
+
+class ChannelFixture {
+ public:
+ ChannelFixture(int max_trace_nodes = 0) {
+ grpc_arg client_a[2];
+ client_a[0] = grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE),
+ max_trace_nodes);
+ client_a[1] = grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true);
+ grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a};
+ channel_ =
+ grpc_insecure_channel_create("fake_target", &client_args, nullptr);
+ }
+
+ ~ChannelFixture() { grpc_channel_destroy(channel_); }
+
+ grpc_channel* channel() { return channel_; }
+
+ private:
+ grpc_channel* channel_;
+};
+
+class ServerFixture {
+ public:
+ explicit ServerFixture(int max_trace_nodes = 0) {
+ grpc_arg server_a[] = {
+ grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE),
+ max_trace_nodes),
+ grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true),
+ };
+ grpc_channel_args server_args = {GPR_ARRAY_SIZE(server_a), server_a};
+ server_ = grpc_server_create(&server_args, nullptr);
+ }
+
+ ~ServerFixture() { grpc_server_destroy(server_); }
+
+ grpc_server* server() const { return server_; }
+
+ private:
+ grpc_server* server_;
+};
+
+struct validate_channel_data_args {
+ int64_t calls_started;
+ int64_t calls_failed;
+ int64_t calls_succeeded;
+};
+
+void ValidateChildInteger(grpc_json* json, int64_t expect, const char* key) {
+ grpc_json* gotten_json = GetJsonChild(json, key);
+ if (expect == 0) {
+ ASSERT_EQ(gotten_json, nullptr);
+ return;
+ }
+ ASSERT_NE(gotten_json, nullptr);
+ int64_t gotten_number = (int64_t)strtol(gotten_json->value, nullptr, 0);
+ EXPECT_EQ(gotten_number, expect);
+}
+
+void ValidateCounters(char* json_str, validate_channel_data_args args) {
+ grpc_json* json = grpc_json_parse_string(json_str);
+ ASSERT_NE(json, nullptr);
+ grpc_json* data = GetJsonChild(json, "data");
+ ValidateChildInteger(data, args.calls_started, "callsStarted");
+ ValidateChildInteger(data, args.calls_failed, "callsFailed");
+ ValidateChildInteger(data, args.calls_succeeded, "callsSucceeded");
+ grpc_json_destroy(json);
+}
+
+void ValidateChannel(ChannelNode* channel, validate_channel_data_args args) {
+ char* json_str = channel->RenderJsonString();
+ grpc::testing::ValidateChannelProtoJsonTranslation(json_str);
+ ValidateCounters(json_str, args);
+ gpr_free(json_str);
+ // also check that the core API formats this the correct way
+ char* core_api_json_str = grpc_channelz_get_channel(channel->uuid());
+ grpc::testing::ValidateGetChannelResponseProtoJsonTranslation(
+ core_api_json_str);
+ gpr_free(core_api_json_str);
+}
+
+void ValidateServer(ServerNode* server, validate_channel_data_args args) {
+ char* json_str = server->RenderJsonString();
+ grpc::testing::ValidateServerProtoJsonTranslation(json_str);
+ ValidateCounters(json_str, args);
+ gpr_free(json_str);
+}
+
+grpc_millis GetLastCallStartedMillis(CallCountingHelper* channel) {
+ CallCountingHelperPeer peer(channel);
+ return peer.last_call_started_millis();
+}
+
+void ChannelzSleep(int64_t sleep_us) {
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_micros(sleep_us, GPR_TIMESPAN)));
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+}
+
+} // anonymous namespace
+
+class ChannelzChannelTest : public ::testing::TestWithParam<size_t> {};
+
+TEST_P(ChannelzChannelTest, BasicChannel) {
+ grpc_core::ExecCtx exec_ctx;
+ ChannelFixture channel(GetParam());
+ ChannelNode* channelz_channel =
+ grpc_channel_get_channelz_node(channel.channel());
+ ValidateChannel(channelz_channel, {0, 0, 0});
+}
+
+TEST(ChannelzChannelTest, ChannelzDisabled) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel* channel =
+ grpc_insecure_channel_create("fake_target", nullptr, nullptr);
+ ChannelNode* channelz_channel = grpc_channel_get_channelz_node(channel);
+ ASSERT_EQ(channelz_channel, nullptr);
+ grpc_channel_destroy(channel);
+}
+
+TEST_P(ChannelzChannelTest, BasicChannelAPIFunctionality) {
+ grpc_core::ExecCtx exec_ctx;
+ ChannelFixture channel(GetParam());
+ ChannelNode* channelz_channel =
+ grpc_channel_get_channelz_node(channel.channel());
+ channelz_channel->RecordCallStarted();
+ channelz_channel->RecordCallFailed();
+ channelz_channel->RecordCallSucceeded();
+ ValidateChannel(channelz_channel, {1, 1, 1});
+ channelz_channel->RecordCallStarted();
+ channelz_channel->RecordCallFailed();
+ channelz_channel->RecordCallSucceeded();
+ channelz_channel->RecordCallStarted();
+ channelz_channel->RecordCallFailed();
+ channelz_channel->RecordCallSucceeded();
+ ValidateChannel(channelz_channel, {3, 3, 3});
+}
+
+TEST_P(ChannelzChannelTest, LastCallStartedMillis) {
+ grpc_core::ExecCtx exec_ctx;
+ CallCountingHelper counter;
+ // start a call to set the last call started timestamp
+ counter.RecordCallStarted();
+ grpc_millis millis1 = GetLastCallStartedMillis(&counter);
+ // time gone by should not affect the timestamp
+ ChannelzSleep(100);
+ grpc_millis millis2 = GetLastCallStartedMillis(&counter);
+ EXPECT_EQ(millis1, millis2);
+ // calls succeeded or failed should not affect the timestamp
+ ChannelzSleep(100);
+ counter.RecordCallFailed();
+ counter.RecordCallSucceeded();
+ grpc_millis millis3 = GetLastCallStartedMillis(&counter);
+ EXPECT_EQ(millis1, millis3);
+ // another call started should affect the timestamp
+ // sleep for extra long to avoid flakes (since we cache Now())
+ ChannelzSleep(5000);
+ counter.RecordCallStarted();
+ grpc_millis millis4 = GetLastCallStartedMillis(&counter);
+ EXPECT_NE(millis1, millis4);
+}
+
+TEST(ChannelzGetTopChannelsTest, BasicGetTopChannelsTest) {
+ grpc_core::ExecCtx exec_ctx;
+ ChannelFixture channel;
+ ValidateGetTopChannels(1);
+}
+
+TEST(ChannelzGetTopChannelsTest, NoChannelsTest) {
+ grpc_core::ExecCtx exec_ctx;
+ ValidateGetTopChannels(0);
+}
+
+TEST(ChannelzGetTopChannelsTest, ManyChannelsTest) {
+ grpc_core::ExecCtx exec_ctx;
+ ChannelFixture channels[10];
+ (void)channels; // suppress unused variable error
+ ValidateGetTopChannels(10);
+}
+
+TEST(ChannelzGetTopChannelsTest, InternalChannelTest) {
+ grpc_core::ExecCtx exec_ctx;
+ ChannelFixture channels[10];
+ (void)channels; // suppress unused variable error
+ // create an internal channel
+ grpc_arg client_a[2];
+ client_a[0] = grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_CHANNELZ_CHANNEL_IS_INTERNAL_CHANNEL), true);
+ client_a[1] = grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true);
+ grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a};
+ grpc_channel* internal_channel =
+ grpc_insecure_channel_create("fake_target", &client_args, nullptr);
+ // The internal channel should not be returned from the request
+ ValidateGetTopChannels(10);
+ grpc_channel_destroy(internal_channel);
+}
+
+class ChannelzServerTest : public ::testing::TestWithParam<size_t> {};
+
+TEST_P(ChannelzServerTest, BasicServerAPIFunctionality) {
+ grpc_core::ExecCtx exec_ctx;
+ ServerFixture server(10);
+ ServerNode* channelz_server = grpc_server_get_channelz_node(server.server());
+ channelz_server->RecordCallStarted();
+ channelz_server->RecordCallFailed();
+ channelz_server->RecordCallSucceeded();
+ ValidateServer(channelz_server, {1, 1, 1});
+ channelz_server->RecordCallStarted();
+ channelz_server->RecordCallFailed();
+ channelz_server->RecordCallSucceeded();
+ channelz_server->RecordCallStarted();
+ channelz_server->RecordCallFailed();
+ channelz_server->RecordCallSucceeded();
+ ValidateServer(channelz_server, {3, 3, 3});
+}
+
+TEST(ChannelzGetServersTest, BasicGetServersTest) {
+ grpc_core::ExecCtx exec_ctx;
+ ServerFixture server;
+ ValidateGetServers(1);
+}
+
+TEST(ChannelzGetServersTest, NoServersTest) {
+ grpc_core::ExecCtx exec_ctx;
+ ValidateGetServers(0);
+}
+
+TEST(ChannelzGetServersTest, ManyServersTest) {
+ grpc_core::ExecCtx exec_ctx;
+ ServerFixture servers[10];
+ (void)servers; // suppress unused variable error
+ ValidateGetServers(10);
+}
+
+INSTANTIATE_TEST_CASE_P(ChannelzChannelTestSweep, ChannelzChannelTest,
+ ::testing::Values(0, 1, 2, 6, 10, 15));
+
+INSTANTIATE_TEST_CASE_P(ChannelzServerTestSweep, ChannelzServerTest,
+ ::testing::Values(0, 1, 2, 6, 10, 15));
+
+} // namespace testing
+} // namespace channelz
+} // namespace grpc_core
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+ ::testing::InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return ret;
+}
diff --git a/test/core/client_channel/parse_address_test.cc b/test/core/client_channel/parse_address_test.cc
index ae157fbb8b..004549fa62 100644
--- a/test/core/client_channel/parse_address_test.cc
+++ b/test/core/client_channel/parse_address_test.cc
@@ -91,6 +91,15 @@ static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
grpc_uri_destroy(uri);
}
+/* Test parsing invalid ipv6 addresses (valid uri_text but invalid ipv6 addr) */
+static void test_grpc_parse_ipv6_invalid(const char* uri_text) {
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
+ grpc_resolved_address addr;
+ GPR_ASSERT(!grpc_parse_ipv6(uri, &addr));
+ grpc_uri_destroy(uri);
+}
+
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
@@ -100,5 +109,10 @@ int main(int argc, char** argv) {
test_grpc_parse_ipv6("ipv6:[2001:db8::1]:12345", "2001:db8::1", 12345, 0);
test_grpc_parse_ipv6("ipv6:[2001:db8::1%252]:12345", "2001:db8::1", 12345, 2);
+ /* Address length greater than GRPC_INET6_ADDRSTRLEN */
+ test_grpc_parse_ipv6_invalid(
+ "ipv6:WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW45%"
+ "v6:45%x$1*");
+
grpc_shutdown();
}
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
index e34aa2e676..1c8d0775ab 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
@@ -60,11 +60,11 @@ static void my_resolve_address(const char* addr, const char* default_port,
static grpc_address_resolver_vtable test_resolver = {my_resolve_address,
nullptr};
-static grpc_ares_request* my_dns_lookup_ares(
+static grpc_ares_request* my_dns_lookup_ares_locked(
const char* dns_server, const char* addr, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
- grpc_lb_addresses** lb_addrs, bool check_grpclb,
- char** service_config_json) {
+ grpc_lb_addresses** lb_addrs, bool check_grpclb, char** service_config_json,
+ grpc_combiner* combiner) {
gpr_mu_lock(&g_mu);
GPR_ASSERT(0 == strcmp("test", addr));
grpc_error* error = GRPC_ERROR_NONE;
@@ -147,7 +147,7 @@ int main(int argc, char** argv) {
gpr_mu_init(&g_mu);
g_combiner = grpc_combiner_create();
grpc_set_resolver_impl(&test_resolver);
- grpc_dns_lookup_ares = my_dns_lookup_ares;
+ grpc_dns_lookup_ares_locked = my_dns_lookup_ares_locked;
grpc_channel_args* result = (grpc_channel_args*)1;
{
diff --git a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc
index 37e1d714ca..1a7db40f59 100644
--- a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc
@@ -28,21 +28,26 @@
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "test/core/util/test_config.h"
+constexpr int kMinResolutionPeriodMs = 1000;
+// Provide some slack when checking intervals, to allow for test timing issues.
+constexpr int kMinResolutionPeriodForCheckMs = 900;
+
extern grpc_address_resolver_vtable* grpc_resolve_address_impl;
static grpc_address_resolver_vtable* default_resolve_address;
static grpc_combiner* g_combiner;
-grpc_ares_request* (*g_default_dns_lookup_ares)(
+static grpc_ares_request* (*g_default_dns_lookup_ares_locked)(
const char* dns_server, const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
- grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json);
+ grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json,
+ grpc_combiner* combiner);
// Counter incremented by test_resolve_address_impl indicating the number of
// times a system-level resolution has happened.
static int g_resolution_count;
-struct iomgr_args {
+static struct iomgr_args {
gpr_event ev;
gpr_atm done_atm;
gpr_mu* mu;
@@ -60,6 +65,16 @@ static void test_resolve_address_impl(const char* name,
default_resolve_address->resolve_address(
name, default_port, g_iomgr_args.pollset_set, on_done, addrs);
++g_resolution_count;
+ static grpc_millis last_resolution_time = 0;
+ if (last_resolution_time == 0) {
+ last_resolution_time =
+ grpc_timespec_to_millis_round_up(gpr_now(GPR_CLOCK_MONOTONIC));
+ } else {
+ grpc_millis now =
+ grpc_timespec_to_millis_round_up(gpr_now(GPR_CLOCK_MONOTONIC));
+ GPR_ASSERT(now - last_resolution_time >= kMinResolutionPeriodForCheckMs);
+ last_resolution_time = now;
+ }
}
static grpc_error* test_blocking_resolve_address_impl(
@@ -72,14 +87,25 @@ static grpc_error* test_blocking_resolve_address_impl(
static grpc_address_resolver_vtable test_resolver = {
test_resolve_address_impl, test_blocking_resolve_address_impl};
-grpc_ares_request* test_dns_lookup_ares(
+static grpc_ares_request* test_dns_lookup_ares_locked(
const char* dns_server, const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
- grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json) {
- grpc_ares_request* result = g_default_dns_lookup_ares(
+ grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json,
+ grpc_combiner* combiner) {
+ grpc_ares_request* result = g_default_dns_lookup_ares_locked(
dns_server, name, default_port, g_iomgr_args.pollset_set, on_done, addrs,
- check_grpclb, service_config_json);
+ check_grpclb, service_config_json, combiner);
++g_resolution_count;
+ static grpc_millis last_resolution_time = 0;
+ if (last_resolution_time == 0) {
+ last_resolution_time =
+ grpc_timespec_to_millis_round_up(gpr_now(GPR_CLOCK_MONOTONIC));
+ } else {
+ grpc_millis now =
+ grpc_timespec_to_millis_round_up(gpr_now(GPR_CLOCK_MONOTONIC));
+ GPR_ASSERT(now - last_resolution_time >= kMinResolutionPeriodForCheckMs);
+ last_resolution_time = now;
+ }
return result;
}
@@ -89,7 +115,7 @@ static gpr_timespec test_deadline(void) {
static void do_nothing(void* arg, grpc_error* error) {}
-void iomgr_args_init(iomgr_args* args) {
+static void iomgr_args_init(iomgr_args* args) {
gpr_event_init(&args->ev);
args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(args->pollset, &args->mu);
@@ -98,7 +124,7 @@ void iomgr_args_init(iomgr_args* args) {
gpr_atm_rel_store(&args->done_atm, 0);
}
-void iomgr_args_finish(iomgr_args* args) {
+static void iomgr_args_finish(iomgr_args* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
grpc_pollset_set_destroy(args->pollset_set);
@@ -128,7 +154,7 @@ static void poll_pollset_until_request_done(iomgr_args* args) {
break;
}
grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now();
- gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
+ gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu);
@@ -144,29 +170,19 @@ struct OnResolutionCallbackArg {
const char* uri_str = nullptr;
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver;
grpc_channel_args* result = nullptr;
- grpc_millis delay_before_second_resolution = 0;
};
-// Counter for the number of times a resolution notification callback has been
-// invoked.
-static int g_on_resolution_invocations_count;
-
// Set to true by the last callback in the resolution chain.
-bool g_all_callbacks_invoked;
+static bool g_all_callbacks_invoked;
-void on_fourth_resolution(void* arg, grpc_error* error) {
+static void on_second_resolution(void* arg, grpc_error* error) {
OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg);
grpc_channel_args_destroy(cb_arg->result);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- ++g_on_resolution_invocations_count;
- gpr_log(GPR_INFO,
- "4th: g_on_resolution_invocations_count: %d, g_resolution_count: %d",
- g_on_resolution_invocations_count, g_resolution_count);
- // In this case we expect to have incurred in another system-level resolution
- // because on_third_resolution slept for longer than the min resolution
- // period.
- GPR_ASSERT(g_on_resolution_invocations_count == 4);
- GPR_ASSERT(g_resolution_count == 3);
+ gpr_log(GPR_INFO, "2nd: g_resolution_count: %d", g_resolution_count);
+ // The resolution callback was not invoked until new data was
+ // available, which was delayed until after the cooldown period.
+ GPR_ASSERT(g_resolution_count == 2);
cb_arg->resolver.reset();
gpr_atm_rel_store(&g_iomgr_args.done_atm, 1);
gpr_mu_lock(g_iomgr_args.mu);
@@ -177,67 +193,13 @@ void on_fourth_resolution(void* arg, grpc_error* error) {
g_all_callbacks_invoked = true;
}
-void on_third_resolution(void* arg, grpc_error* error) {
- OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg);
- grpc_channel_args_destroy(cb_arg->result);
- GPR_ASSERT(error == GRPC_ERROR_NONE);
- ++g_on_resolution_invocations_count;
- gpr_log(GPR_INFO,
- "3rd: g_on_resolution_invocations_count: %d, g_resolution_count: %d",
- g_on_resolution_invocations_count, g_resolution_count);
- // The timer set because of the previous re-resolution request fires, so a new
- // system-level resolution happened.
- GPR_ASSERT(g_on_resolution_invocations_count == 3);
- GPR_ASSERT(g_resolution_count == 2);
- grpc_core::ExecCtx::Get()->TestOnlySetNow(
- cb_arg->delay_before_second_resolution * 2);
- cb_arg->resolver->NextLocked(
- &cb_arg->result,
- GRPC_CLOSURE_CREATE(on_fourth_resolution, arg,
- grpc_combiner_scheduler(g_combiner)));
- cb_arg->resolver->RequestReresolutionLocked();
- gpr_mu_lock(g_iomgr_args.mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(g_iomgr_args.pollset, nullptr));
- gpr_mu_unlock(g_iomgr_args.mu);
-}
-
-void on_second_resolution(void* arg, grpc_error* error) {
- OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg);
- grpc_channel_args_destroy(cb_arg->result);
- GPR_ASSERT(error == GRPC_ERROR_NONE);
- ++g_on_resolution_invocations_count;
- gpr_log(GPR_INFO,
- "2nd: g_on_resolution_invocations_count: %d, g_resolution_count: %d",
- g_on_resolution_invocations_count, g_resolution_count);
- // The resolution request for which this function is the callback happened
- // before the min resolution period. Therefore, no new system-level
- // resolutions happened, as indicated by g_resolution_count. But a resolution
- // timer was set to fire when the cooldown finishes.
- GPR_ASSERT(g_on_resolution_invocations_count == 2);
- GPR_ASSERT(g_resolution_count == 1);
- // Register a new callback to capture the timer firing.
- cb_arg->resolver->NextLocked(
- &cb_arg->result,
- GRPC_CLOSURE_CREATE(on_third_resolution, arg,
- grpc_combiner_scheduler(g_combiner)));
- gpr_mu_lock(g_iomgr_args.mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(g_iomgr_args.pollset, nullptr));
- gpr_mu_unlock(g_iomgr_args.mu);
-}
-
-void on_first_resolution(void* arg, grpc_error* error) {
+static void on_first_resolution(void* arg, grpc_error* error) {
OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg);
grpc_channel_args_destroy(cb_arg->result);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- ++g_on_resolution_invocations_count;
- gpr_log(GPR_INFO,
- "1st: g_on_resolution_invocations_count: %d, g_resolution_count: %d",
- g_on_resolution_invocations_count, g_resolution_count);
+ gpr_log(GPR_INFO, "1st: g_resolution_count: %d", g_resolution_count);
// There's one initial system-level resolution and one invocation of a
// notification callback (the current function).
- GPR_ASSERT(g_on_resolution_invocations_count == 1);
GPR_ASSERT(g_resolution_count == 1);
cb_arg->resolver->NextLocked(
&cb_arg->result,
@@ -263,9 +225,7 @@ static void start_test_under_combiner(void* arg, grpc_error* error) {
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = g_combiner;
- g_on_resolution_invocations_count = 0;
g_resolution_count = 0;
- constexpr int kMinResolutionPeriodMs = 1000;
grpc_arg cooldown_arg;
cooldown_arg.key =
@@ -278,7 +238,6 @@ static void start_test_under_combiner(void* arg, grpc_error* error) {
res_cb_arg->resolver = factory->CreateResolver(args);
grpc_channel_args_destroy(cooldown_channel_args);
GPR_ASSERT(res_cb_arg->resolver != nullptr);
- res_cb_arg->delay_before_second_resolution = kMinResolutionPeriodMs;
// First resolution, would incur in system-level resolution.
res_cb_arg->resolver->NextLocked(
&res_cb_arg->result,
@@ -308,8 +267,8 @@ int main(int argc, char** argv) {
g_combiner = grpc_combiner_create();
- g_default_dns_lookup_ares = grpc_dns_lookup_ares;
- grpc_dns_lookup_ares = test_dns_lookup_ares;
+ g_default_dns_lookup_ares_locked = grpc_dns_lookup_ares_locked;
+ grpc_dns_lookup_ares_locked = test_dns_lookup_ares_locked;
default_resolve_address = grpc_resolve_address_impl;
grpc_set_resolver_impl(&test_resolver);
diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc
index 14caa3ea5d..f6696bf127 100644
--- a/test/core/client_channel/resolvers/fake_resolver_test.cc
+++ b/test/core/client_channel/resolvers/fake_resolver_test.cc
@@ -124,8 +124,8 @@ static void test_fake_resolver() {
build_fake_resolver(combiner, response_generator.get());
GPR_ASSERT(resolver.get() != nullptr);
// Test 1: normal resolution.
- // next_results != NULL, reresolution_results == NULL, last_used_results ==
- // NULL. Expected response is next_results.
+ // next_results != NULL, reresolution_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(
@@ -137,10 +137,9 @@ static void test_fake_resolver() {
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
// Test 2: update resolution.
- // next_results != NULL, reresolution_results == NULL, last_used_results !=
- // NULL. Expected response is next_results.
+ // next_results != NULL, reresolution_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));
@@ -150,21 +149,9 @@ static void test_fake_resolver() {
grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
- // Test 3: fallback re-resolution.
- // next_results == NULL, reresolution_results == 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));
- resolver->NextLocked(&on_res_arg.resolver_result, on_resolution);
- // Trigger a re-resolution.
- resolver->RequestReresolutionLocked();
- 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, reresolution_results != NULL, last_used_results !=
- // NULL. Expected response is reresolution_results.
+ // Test 3: normal re-resolution.
+ // next_results == NULL, reresolution_results != NULL.
+ // Expected response is reresolution_results.
grpc_channel_args* reresolution_results = create_new_resolver_result();
on_res_arg =
create_on_resolution_arg(grpc_channel_args_copy(reresolution_results));
@@ -180,9 +167,9 @@ static void test_fake_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, reresolution_results != NULL, last_used_results !=
- // NULL. Expected response is reresolution_results.
+ // Test 4: repeat re-resolution.
+ // next_results == NULL, reresolution_results != NULL.
+ // Expected response is reresolution_results.
on_res_arg = create_on_resolution_arg(reresolution_results);
on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg,
grpc_combiner_scheduler(combiner));
@@ -192,11 +179,10 @@ static void test_fake_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, reresolution_results != NULL, last_used_results !=
- // NULL. Expected response is next_results.
+ // Test 5: normal resolution.
+ // next_results != NULL, reresolution_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));
@@ -206,23 +192,7 @@ static void test_fake_resolver() {
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, reresolution_results == 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));
- resolver->NextLocked(&on_res_arg.resolver_result, on_resolution);
- // Reset reresolution_results.
- response_generator->SetReresolutionResponse(nullptr);
- // Flush here to guarantee that reresolution_results has been reset.
- grpc_core::ExecCtx::Get()->Flush();
- // Trigger a re-resolution.
- resolver->RequestReresolutionLocked();
- grpc_core::ExecCtx::Get()->Flush();
- GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
- grpc_timeout_seconds_to_deadline(5)) != nullptr);
- // Test 8: no-op.
+ // Test 6: 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));
diff --git a/test/core/debug/stats_test.cc b/test/core/debug/stats_test.cc
index 949a88f8f0..aeb13655bf 100644
--- a/test/core/debug/stats_test.cc
+++ b/test/core/debug/stats_test.cc
@@ -142,9 +142,14 @@ INSTANTIATE_TEST_CASE_P(HistogramTestCases, HistogramTest,
} // namespace grpc
int main(int argc, char** argv) {
+/* Only run this test if GRPC_COLLECT_STATS is defined or if it is a debug
+ * build.
+ */
+#if defined(GRPC_COLLECT_STATS) || !defined(NDEBUG)
::testing::InitGoogleTest(&argc, argv);
grpc_init();
int ret = RUN_ALL_TESTS();
grpc_shutdown();
return ret;
+#endif
}
diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD
index dd16694204..37999a98d1 100644
--- a/test/core/end2end/BUILD
+++ b/test/core/end2end/BUILD
@@ -124,6 +124,19 @@ grpc_cc_test(
)
grpc_cc_test(
+ name = "inproc_callback_test",
+ srcs = ["inproc_callback_test.cc"],
+ language = "C++",
+ deps = [
+ ':end2end_tests',
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
name = "invalid_call_argument_test",
srcs = ["invalid_call_argument_test.cc"],
language = "C++",
diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc
index 3d133cfc18..f7396a1684 100644
--- a/test/core/end2end/bad_server_response_test.cc
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -104,7 +104,7 @@ static void handle_write() {
grpc_slice_buffer_reset_and_unref(&state.outgoing_buffer);
grpc_slice_buffer_add(&state.outgoing_buffer, slice);
- grpc_endpoint_write(state.tcp, &state.outgoing_buffer, &on_write);
+ grpc_endpoint_write(state.tcp, &state.outgoing_buffer, &on_write, nullptr);
}
static void handle_read(void* arg, grpc_error* error) {
diff --git a/test/core/end2end/end2end_nosec_tests.cc b/test/core/end2end/end2end_nosec_tests.cc
index 59eb643a93..c6a4005fb3 100644
--- a/test/core/end2end/end2end_nosec_tests.cc
+++ b/test/core/end2end/end2end_nosec_tests.cc
@@ -54,6 +54,8 @@ extern void cancel_in_a_vacuum(grpc_end2end_test_config config);
extern void cancel_in_a_vacuum_pre_init(void);
extern void cancel_with_status(grpc_end2end_test_config config);
extern void cancel_with_status_pre_init(void);
+extern void channelz(grpc_end2end_test_config config);
+extern void channelz_pre_init(void);
extern void compressed_payload(grpc_end2end_test_config config);
extern void compressed_payload_pre_init(void);
extern void connectivity(grpc_end2end_test_config config);
@@ -86,8 +88,6 @@ extern void keepalive_timeout(grpc_end2end_test_config config);
extern void keepalive_timeout_pre_init(void);
extern void large_metadata(grpc_end2end_test_config config);
extern void large_metadata_pre_init(void);
-extern void load_reporting_hook(grpc_end2end_test_config config);
-extern void load_reporting_hook_pre_init(void);
extern void max_concurrent_streams(grpc_end2end_test_config config);
extern void max_concurrent_streams_pre_init(void);
extern void max_connection_age(grpc_end2end_test_config config);
@@ -100,6 +100,8 @@ extern void negative_deadline(grpc_end2end_test_config config);
extern void negative_deadline_pre_init(void);
extern void network_status_change(grpc_end2end_test_config config);
extern void network_status_change_pre_init(void);
+extern void no_error_on_hotpath(grpc_end2end_test_config config);
+extern void no_error_on_hotpath_pre_init(void);
extern void no_logging(grpc_end2end_test_config config);
extern void no_logging_pre_init(void);
extern void no_op(grpc_end2end_test_config config);
@@ -199,6 +201,7 @@ void grpc_end2end_tests_pre_init(void) {
cancel_before_invoke_pre_init();
cancel_in_a_vacuum_pre_init();
cancel_with_status_pre_init();
+ channelz_pre_init();
compressed_payload_pre_init();
connectivity_pre_init();
default_host_pre_init();
@@ -215,13 +218,13 @@ void grpc_end2end_tests_pre_init(void) {
invoke_large_request_pre_init();
keepalive_timeout_pre_init();
large_metadata_pre_init();
- load_reporting_hook_pre_init();
max_concurrent_streams_pre_init();
max_connection_age_pre_init();
max_connection_idle_pre_init();
max_message_length_pre_init();
negative_deadline_pre_init();
network_status_change_pre_init();
+ no_error_on_hotpath_pre_init();
no_logging_pre_init();
no_op_pre_init();
payload_pre_init();
@@ -284,6 +287,7 @@ void grpc_end2end_tests(int argc, char **argv,
cancel_before_invoke(config);
cancel_in_a_vacuum(config);
cancel_with_status(config);
+ channelz(config);
compressed_payload(config);
connectivity(config);
default_host(config);
@@ -300,13 +304,13 @@ void grpc_end2end_tests(int argc, char **argv,
invoke_large_request(config);
keepalive_timeout(config);
large_metadata(config);
- load_reporting_hook(config);
max_concurrent_streams(config);
max_connection_age(config);
max_connection_idle(config);
max_message_length(config);
negative_deadline(config);
network_status_change(config);
+ no_error_on_hotpath(config);
no_logging(config);
no_op(config);
payload(config);
@@ -400,6 +404,10 @@ void grpc_end2end_tests(int argc, char **argv,
cancel_with_status(config);
continue;
}
+ if (0 == strcmp("channelz", argv[i])) {
+ channelz(config);
+ continue;
+ }
if (0 == strcmp("compressed_payload", argv[i])) {
compressed_payload(config);
continue;
@@ -464,10 +472,6 @@ void grpc_end2end_tests(int argc, char **argv,
large_metadata(config);
continue;
}
- if (0 == strcmp("load_reporting_hook", argv[i])) {
- load_reporting_hook(config);
- continue;
- }
if (0 == strcmp("max_concurrent_streams", argv[i])) {
max_concurrent_streams(config);
continue;
@@ -492,6 +496,10 @@ void grpc_end2end_tests(int argc, char **argv,
network_status_change(config);
continue;
}
+ if (0 == strcmp("no_error_on_hotpath", argv[i])) {
+ no_error_on_hotpath(config);
+ continue;
+ }
if (0 == strcmp("no_logging", argv[i])) {
no_logging(config);
continue;
diff --git a/test/core/end2end/end2end_test.sh b/test/core/end2end/end2end_test.sh
index 5bfb253090..6b23d848be 100755
--- a/test/core/end2end/end2end_test.sh
+++ b/test/core/end2end/end2end_test.sh
@@ -15,7 +15,7 @@
# 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.
-if [ -z "$3" ]
+if [ -n "$3" ]
then
export GRPC_POLL_STRATEGY=$3
fi
diff --git a/test/core/end2end/end2end_tests.cc b/test/core/end2end/end2end_tests.cc
index 9f164b4ead..7748a39cb5 100644
--- a/test/core/end2end/end2end_tests.cc
+++ b/test/core/end2end/end2end_tests.cc
@@ -56,6 +56,8 @@ extern void cancel_in_a_vacuum(grpc_end2end_test_config config);
extern void cancel_in_a_vacuum_pre_init(void);
extern void cancel_with_status(grpc_end2end_test_config config);
extern void cancel_with_status_pre_init(void);
+extern void channelz(grpc_end2end_test_config config);
+extern void channelz_pre_init(void);
extern void compressed_payload(grpc_end2end_test_config config);
extern void compressed_payload_pre_init(void);
extern void connectivity(grpc_end2end_test_config config);
@@ -88,8 +90,6 @@ extern void keepalive_timeout(grpc_end2end_test_config config);
extern void keepalive_timeout_pre_init(void);
extern void large_metadata(grpc_end2end_test_config config);
extern void large_metadata_pre_init(void);
-extern void load_reporting_hook(grpc_end2end_test_config config);
-extern void load_reporting_hook_pre_init(void);
extern void max_concurrent_streams(grpc_end2end_test_config config);
extern void max_concurrent_streams_pre_init(void);
extern void max_connection_age(grpc_end2end_test_config config);
@@ -102,6 +102,8 @@ extern void negative_deadline(grpc_end2end_test_config config);
extern void negative_deadline_pre_init(void);
extern void network_status_change(grpc_end2end_test_config config);
extern void network_status_change_pre_init(void);
+extern void no_error_on_hotpath(grpc_end2end_test_config config);
+extern void no_error_on_hotpath_pre_init(void);
extern void no_logging(grpc_end2end_test_config config);
extern void no_logging_pre_init(void);
extern void no_op(grpc_end2end_test_config config);
@@ -202,6 +204,7 @@ void grpc_end2end_tests_pre_init(void) {
cancel_before_invoke_pre_init();
cancel_in_a_vacuum_pre_init();
cancel_with_status_pre_init();
+ channelz_pre_init();
compressed_payload_pre_init();
connectivity_pre_init();
default_host_pre_init();
@@ -218,13 +221,13 @@ void grpc_end2end_tests_pre_init(void) {
invoke_large_request_pre_init();
keepalive_timeout_pre_init();
large_metadata_pre_init();
- load_reporting_hook_pre_init();
max_concurrent_streams_pre_init();
max_connection_age_pre_init();
max_connection_idle_pre_init();
max_message_length_pre_init();
negative_deadline_pre_init();
network_status_change_pre_init();
+ no_error_on_hotpath_pre_init();
no_logging_pre_init();
no_op_pre_init();
payload_pre_init();
@@ -288,6 +291,7 @@ void grpc_end2end_tests(int argc, char **argv,
cancel_before_invoke(config);
cancel_in_a_vacuum(config);
cancel_with_status(config);
+ channelz(config);
compressed_payload(config);
connectivity(config);
default_host(config);
@@ -304,13 +308,13 @@ void grpc_end2end_tests(int argc, char **argv,
invoke_large_request(config);
keepalive_timeout(config);
large_metadata(config);
- load_reporting_hook(config);
max_concurrent_streams(config);
max_connection_age(config);
max_connection_idle(config);
max_message_length(config);
negative_deadline(config);
network_status_change(config);
+ no_error_on_hotpath(config);
no_logging(config);
no_op(config);
payload(config);
@@ -408,6 +412,10 @@ void grpc_end2end_tests(int argc, char **argv,
cancel_with_status(config);
continue;
}
+ if (0 == strcmp("channelz", argv[i])) {
+ channelz(config);
+ continue;
+ }
if (0 == strcmp("compressed_payload", argv[i])) {
compressed_payload(config);
continue;
@@ -472,10 +480,6 @@ void grpc_end2end_tests(int argc, char **argv,
large_metadata(config);
continue;
}
- if (0 == strcmp("load_reporting_hook", argv[i])) {
- load_reporting_hook(config);
- continue;
- }
if (0 == strcmp("max_concurrent_streams", argv[i])) {
max_concurrent_streams(config);
continue;
@@ -500,6 +504,10 @@ void grpc_end2end_tests(int argc, char **argv,
network_status_change(config);
continue;
}
+ if (0 == strcmp("no_error_on_hotpath", argv[i])) {
+ no_error_on_hotpath(config);
+ continue;
+ }
if (0 == strcmp("no_logging", argv[i])) {
no_logging(config);
continue;
diff --git a/test/core/end2end/fixtures/h2_load_reporting.cc b/test/core/end2end/fixtures/h2_load_reporting.cc
deleted file mode 100644
index 18ea10a8d2..0000000000
--- a/test/core/end2end/fixtures/h2_load_reporting.cc
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- *
- * Copyright 2016 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/end2end/end2end_tests.h"
-
-#include <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/sync.h>
-
-#include "src/core/ext/filters/client_channel/client_channel.h"
-#include "src/core/ext/filters/http/server/http_server_filter.h"
-#include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h"
-#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
-#include "src/core/lib/channel/channel_args.h"
-#include "src/core/lib/channel/connected_channel.h"
-#include "src/core/lib/gpr/host_port.h"
-#include "src/core/lib/surface/channel.h"
-#include "src/core/lib/surface/server.h"
-#include "test/core/util/port.h"
-#include "test/core/util/test_config.h"
-
-typedef struct load_reporting_fixture_data {
- char* localaddr;
-} load_reporting_fixture_data;
-
-static grpc_end2end_test_fixture chttp2_create_fixture_load_reporting(
- grpc_channel_args* client_args, grpc_channel_args* server_args) {
- grpc_end2end_test_fixture f;
- int port = grpc_pick_unused_port_or_die();
- load_reporting_fixture_data* ffd = static_cast<load_reporting_fixture_data*>(
- gpr_malloc(sizeof(load_reporting_fixture_data)));
- memset(&f, 0, sizeof(f));
-
- gpr_join_host_port(&ffd->localaddr, "localhost", port);
-
- f.fixture_data = ffd;
- f.cq = grpc_completion_queue_create_for_next(nullptr);
- f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
-
- return f;
-}
-
-void chttp2_init_client_load_reporting(grpc_end2end_test_fixture* f,
- grpc_channel_args* client_args) {
- load_reporting_fixture_data* ffd =
- static_cast<load_reporting_fixture_data*>(f->fixture_data);
- f->client =
- grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
- GPR_ASSERT(f->client);
-}
-
-void chttp2_init_server_load_reporting(grpc_end2end_test_fixture* f,
- grpc_channel_args* server_args) {
- load_reporting_fixture_data* ffd =
- static_cast<load_reporting_fixture_data*>(f->fixture_data);
- grpc_arg arg = grpc_load_reporting_enable_arg();
- if (f->server) {
- grpc_server_destroy(f->server);
- }
- server_args = grpc_channel_args_copy_and_add(server_args, &arg, 1);
- f->server = grpc_server_create(server_args, nullptr);
- {
- grpc_core::ExecCtx exec_ctx;
- grpc_channel_args_destroy(server_args);
- }
- grpc_server_register_completion_queue(f->server, f->cq, nullptr);
- GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
- grpc_server_start(f->server);
-}
-
-void chttp2_tear_down_load_reporting(grpc_end2end_test_fixture* f) {
- load_reporting_fixture_data* ffd =
- static_cast<load_reporting_fixture_data*>(f->fixture_data);
- gpr_free(ffd->localaddr);
- gpr_free(ffd);
-}
-
-/* All test configurations */
-static grpc_end2end_test_config configs[] = {
- {"chttp2/fullstack+load_reporting",
- FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
- FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
- FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER,
- nullptr, chttp2_create_fixture_load_reporting,
- chttp2_init_client_load_reporting, chttp2_init_server_load_reporting,
- chttp2_tear_down_load_reporting},
-};
-
-int main(int argc, char** argv) {
- size_t i;
-
- grpc_test_init(argc, argv);
- grpc_end2end_tests_pre_init();
- grpc_init();
-
- for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
- grpc_end2end_tests(argc, argv, configs[i]);
- }
-
- grpc_shutdown();
-
- return 0;
-}
diff --git a/test/core/end2end/fixtures/h2_local.cc b/test/core/end2end/fixtures/h2_local.cc
new file mode 100644
index 0000000000..cce8f1745a
--- /dev/null
+++ b/test/core/end2end/fixtures/h2_local.cc
@@ -0,0 +1,154 @@
+/*
+ *
+ * Copyright 2015 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/end2end/end2end_tests.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/sync.h>
+
+#include "src/core/ext/filters/client_channel/client_channel.h"
+#include "src/core/ext/filters/http/server/http_server_filter.h"
+#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include "src/core/lib/channel/connected_channel.h"
+#include "src/core/lib/gpr/host_port.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/security/credentials/credentials.h"
+#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/surface/server.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+typedef struct fullstack_fixture_data {
+ char* localaddr;
+} fullstack_fixture_data;
+
+static int unique = 1;
+
+static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
+ grpc_end2end_test_fixture f;
+ fullstack_fixture_data* ffd = static_cast<fullstack_fixture_data*>(
+ gpr_malloc(sizeof(fullstack_fixture_data)));
+ memset(&f, 0, sizeof(f));
+
+ gpr_asprintf(&ffd->localaddr, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(),
+ unique++);
+
+ f.fixture_data = ffd;
+ f.cq = grpc_completion_queue_create_for_next(nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
+
+ return f;
+}
+
+void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ grpc_channel_credentials* creds = grpc_local_credentials_create(UDS);
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
+ f->client =
+ grpc_secure_channel_create(creds, ffd->localaddr, client_args, nullptr);
+ GPR_ASSERT(f->client != nullptr);
+ grpc_channel_credentials_release(creds);
+}
+
+/*
+ * Check if server should fail auth check. If it is true, a different metadata
+ * processor will be installed that always fails in processing client's
+ * metadata.
+ */
+static bool fail_server_auth_check(grpc_channel_args* server_args) {
+ size_t i;
+ if (server_args == nullptr) return 0;
+ for (i = 0; i < server_args->num_args; i++) {
+ if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) ==
+ 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static void process_auth_failure(void* state, grpc_auth_context* ctx,
+ const grpc_metadata* md, size_t md_count,
+ grpc_process_auth_metadata_done_cb cb,
+ void* user_data) {
+ GPR_ASSERT(state == nullptr);
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
+}
+
+void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ grpc_server_credentials* creds = grpc_local_server_credentials_create(UDS);
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
+ if (f->server) {
+ grpc_server_destroy(f->server);
+ }
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
+ if (fail_server_auth_check(server_args)) {
+ grpc_auth_metadata_processor processor = {process_auth_failure, nullptr,
+ nullptr};
+ grpc_server_credentials_set_auth_metadata_processor(creds, processor);
+ }
+ GPR_ASSERT(
+ grpc_server_add_secure_http2_port(f->server, ffd->localaddr, creds));
+ grpc_server_credentials_release(creds);
+ grpc_server_start(f->server);
+}
+
+void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
+ fullstack_fixture_data* ffd =
+ static_cast<fullstack_fixture_data*>(f->fixture_data);
+ gpr_free(ffd->localaddr);
+ gpr_free(ffd);
+}
+
+/* All test configurations */
+static grpc_end2end_test_config configs[] = {
+ {"chttp2/fullstack_local",
+ FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION |
+ FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL |
+ FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER |
+ FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS,
+ nullptr, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack,
+ chttp2_init_server_fullstack, chttp2_tear_down_fullstack},
+};
+
+int main(int argc, char** argv) {
+ size_t i;
+
+ grpc_test_init(argc, argv);
+ grpc_end2end_tests_pre_init();
+ grpc_init();
+
+ for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
+ grpc_end2end_tests(argc, argv, configs[i]);
+ }
+
+ grpc_shutdown();
+
+ return 0;
+}
diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc
index d44aafd50a..37397d6450 100644
--- a/test/core/end2end/fixtures/h2_oauth2.cc
+++ b/test/core/end2end/fixtures/h2_oauth2.cc
@@ -146,7 +146,7 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_end2end_test_fixture* f, grpc_channel_args* client_args) {
grpc_core::ExecCtx exec_ctx;
grpc_channel_credentials* ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
+ grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr, nullptr);
grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create(
"authorization", oauth2_md, true /* is_async */);
grpc_channel_credentials* ssl_oauth2_creds =
diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc
index 999cd4cdfb..4d6c815716 100644
--- a/test/core/end2end/fixtures/h2_ssl.cc
+++ b/test/core/end2end/fixtures/h2_ssl.cc
@@ -101,7 +101,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture* f, grpc_channel_args* client_args) {
grpc_channel_credentials* ssl_creds =
- grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr);
grpc_arg ssl_name_override = {
GRPC_ARG_STRING,
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc
index 9ab50c6217..09cbf974b6 100644
--- a/test/core/end2end/fixtures/h2_ssl_proxy.cc
+++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc
@@ -55,7 +55,7 @@ static grpc_channel* create_proxy_client(const char* target,
grpc_channel_args* client_args) {
grpc_channel* channel;
grpc_channel_credentials* ssl_creds =
- grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr);
grpc_arg ssl_name_override = {
GRPC_ARG_STRING,
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
@@ -138,7 +138,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture* f, grpc_channel_args* client_args) {
grpc_channel_credentials* ssl_creds =
- grpc_ssl_credentials_create(nullptr, nullptr, nullptr);
+ grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr);
grpc_arg ssl_name_override = {
GRPC_ARG_STRING,
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc
index f02fa9d998..b235c10165 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -52,6 +52,16 @@
#include "test/core/util/port.h"
struct grpc_end2end_http_proxy {
+ grpc_end2end_http_proxy()
+ : proxy_name(nullptr),
+ server(nullptr),
+ channel_args(nullptr),
+ mu(nullptr),
+ pollset(nullptr),
+ combiner(nullptr) {
+ gpr_ref_init(&users, 1);
+ combiner = grpc_combiner_create();
+ }
char* proxy_name;
grpc_core::Thread thd;
grpc_tcp_server* server;
@@ -201,7 +211,7 @@ static void on_client_write_done(void* arg, grpc_error* error) {
&conn->client_write_buffer);
conn->client_is_writing = true;
grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
- &conn->on_client_write_done);
+ &conn->on_client_write_done, nullptr);
} else {
// No more writes. Unref the connection.
proxy_connection_unref(conn, "write_done");
@@ -226,7 +236,7 @@ static void on_server_write_done(void* arg, grpc_error* error) {
&conn->server_write_buffer);
conn->server_is_writing = true;
grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
- &conn->on_server_write_done);
+ &conn->on_server_write_done, nullptr);
} else {
// No more writes. Unref the connection.
proxy_connection_unref(conn, "server_write");
@@ -257,7 +267,7 @@ static void on_client_read_done(void* arg, grpc_error* error) {
proxy_connection_ref(conn, "client_read");
conn->server_is_writing = true;
grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
- &conn->on_server_write_done);
+ &conn->on_server_write_done, nullptr);
}
// Read more data.
grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
@@ -288,7 +298,7 @@ static void on_server_read_done(void* arg, grpc_error* error) {
proxy_connection_ref(conn, "server_read");
conn->client_is_writing = true;
grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
- &conn->on_client_write_done);
+ &conn->on_client_write_done, nullptr);
}
// Read more data.
grpc_endpoint_read(conn->server_endpoint, &conn->server_read_buffer,
@@ -340,7 +350,7 @@ static void on_server_connect_done(void* arg, grpc_error* error) {
grpc_slice_buffer_add(&conn->client_write_buffer, slice);
conn->client_is_writing = true;
grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
- &conn->on_write_response_done);
+ &conn->on_write_response_done, nullptr);
}
/**
@@ -519,11 +529,7 @@ static void thread_main(void* arg) {
grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
grpc_channel_args* args) {
grpc_core::ExecCtx exec_ctx;
- grpc_end2end_http_proxy* proxy =
- static_cast<grpc_end2end_http_proxy*>(gpr_malloc(sizeof(*proxy)));
- memset(proxy, 0, sizeof(*proxy));
- proxy->combiner = grpc_combiner_create();
- gpr_ref_init(&proxy->users, 1);
+ grpc_end2end_http_proxy* proxy = grpc_core::New<grpc_end2end_http_proxy>();
// Construct proxy address.
const int proxy_port = grpc_pick_unused_port_or_die();
gpr_join_host_port(&proxy->proxy_name, "localhost", proxy_port);
@@ -573,7 +579,7 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) {
GRPC_CLOSURE_CREATE(destroy_pollset, proxy->pollset,
grpc_schedule_on_exec_ctx));
GRPC_COMBINER_UNREF(proxy->combiner, "test");
- gpr_free(proxy);
+ grpc_core::Delete(proxy);
}
const char* grpc_end2end_http_proxy_get_proxy_name(
diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc
index 042c858b4c..869b6e846d 100644
--- a/test/core/end2end/fixtures/proxy.cc
+++ b/test/core/end2end/fixtures/proxy.cc
@@ -30,6 +30,17 @@
#include "test/core/util/port.h"
struct grpc_end2end_proxy {
+ grpc_end2end_proxy()
+ : proxy_port(nullptr),
+ server_port(nullptr),
+ cq(nullptr),
+ server(nullptr),
+ client(nullptr),
+ shutdown(false),
+ new_call(nullptr) {
+ memset(&new_call_details, 0, sizeof(new_call_details));
+ memset(&new_call_metadata, 0, sizeof(new_call_metadata));
+ }
grpc_core::Thread thd;
char* proxy_port;
char* server_port;
@@ -79,9 +90,7 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def,
int proxy_port = grpc_pick_unused_port_or_die();
int server_port = grpc_pick_unused_port_or_die();
- grpc_end2end_proxy* proxy =
- static_cast<grpc_end2end_proxy*>(gpr_malloc(sizeof(*proxy)));
- memset(proxy, 0, sizeof(*proxy));
+ grpc_end2end_proxy* proxy = grpc_core::New<grpc_end2end_proxy>();
gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port);
gpr_join_host_port(&proxy->server_port, "localhost", server_port);
@@ -128,7 +137,7 @@ void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy) {
grpc_channel_destroy(proxy->client);
grpc_completion_queue_destroy(proxy->cq);
grpc_call_details_destroy(&proxy->new_call_details);
- gpr_free(proxy);
+ grpc_core::Delete(proxy);
}
static void unrefpc(proxy_call* pc, const char* reason) {
diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc
index 36f257d6da..eacfd4a8c3 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.cc
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -222,7 +222,7 @@ static grpc_channel_credentials* read_ssl_channel_creds(input_stream* inp) {
grpc_channel_credentials* creds = grpc_ssl_credentials_create(
root_certs,
private_key != nullptr && certs != nullptr ? &key_cert_pair : nullptr,
- nullptr);
+ nullptr, nullptr);
cred_artifact_ctx_finish(&ctx);
return creds;
}
@@ -374,13 +374,11 @@ void my_resolve_address(const char* addr, const char* default_port,
static grpc_address_resolver_vtable fuzzer_resolver = {my_resolve_address,
nullptr};
-grpc_ares_request* my_dns_lookup_ares(const char* dns_server, const char* addr,
- const char* default_port,
- grpc_pollset_set* interested_parties,
- grpc_closure* on_done,
- grpc_lb_addresses** lb_addrs,
- bool check_grpclb,
- char** service_config_json) {
+grpc_ares_request* my_dns_lookup_ares_locked(
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs, bool check_grpclb, char** service_config_json,
+ grpc_combiner* combiner) {
addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r)));
r->addr = gpr_strdup(addr);
r->on_done = on_done;
@@ -706,7 +704,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_executor_set_threading(false);
}
grpc_set_resolver_impl(&fuzzer_resolver);
- grpc_dns_lookup_ares = my_dns_lookup_ares;
+ grpc_dns_lookup_ares_locked = my_dns_lookup_ares_locked;
GPR_ASSERT(g_channel == nullptr);
GPR_ASSERT(g_server == nullptr);
@@ -1048,6 +1046,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
op->reserved = nullptr;
op->flags = grpc_fuzzer_get_next_uint32(&inp);
}
+ if (g_channel == nullptr) ok = false;
if (ok) {
validator* v = make_finished_batch_validator(g_active_call, has_ops);
g_active_call->pending_ops++;
diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc
index 5eb83ede7a..248c34cbc1 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.cc
+++ b/test/core/end2end/fuzzers/server_fuzzer.cc
@@ -103,15 +103,33 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_metadata_array_destroy(&request_metadata1);
grpc_server_shutdown_and_notify(server, cq, tag(0xdead));
grpc_server_cancel_all_calls(server);
+ grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 5000;
for (int i = 0; i <= requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
- nullptr);
+ // A single grpc_completion_queue_next might not be sufficient for getting
+ // the tag from shutdown, because we might potentially get blocked by
+ // an operation happening on the timer thread.
+ // For example, the deadline timer might expire, leading to the timer
+ // thread trying to cancel the RPC and thereby acquiring a few references
+ // to the call. This will prevent the shutdown to complete till the timer
+ // thread releases those references.
+ // As a solution, we are going to keep performing a cq_next for a
+ // liberal period of 5 seconds for the timer thread to complete its work.
+ do {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+ } while (ev.type != GRPC_OP_COMPLETE &&
+ grpc_core::ExecCtx::Get()->Now() < deadline);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
}
grpc_completion_queue_shutdown(cq);
for (int i = 0; i <= requested_calls; i++) {
- ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
- nullptr);
+ do {
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN &&
+ grpc_core::ExecCtx::Get()->Now() < deadline);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
}
grpc_server_destroy(server);
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index c355fc24b5..39b9ba4a19 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -35,6 +35,9 @@ default_secure_fixture_options = default_unsecure_fixture_options._replace(
uds_fixture_options = default_unsecure_fixture_options._replace(
dns_resolver=False, platforms=['linux', 'mac', 'posix'],
exclude_iomgrs=['uv'])
+local_fixture_options = default_secure_fixture_options._replace(
+ dns_resolver=False, platforms=['linux', 'mac', 'posix'],
+ exclude_iomgrs=['uv'])
fd_unsecure_fixture_options = default_unsecure_fixture_options._replace(
dns_resolver=False, fullstack=False, platforms=['linux', 'mac', 'posix'],
exclude_iomgrs=['uv'], client_channel=False)
@@ -47,7 +50,9 @@ inproc_fixture_options = default_unsecure_fixture_options._replace(
END2END_FIXTURES = {
'h2_compress': default_unsecure_fixture_options._replace(enables_compression=True),
'h2_census': default_unsecure_fixture_options,
- 'h2_load_reporting': default_unsecure_fixture_options,
+ # This cmake target is disabled for now because it depends on OpenCensus,
+ # which is Bazel-only.
+ # 'h2_load_reporting': default_unsecure_fixture_options,
'h2_fakesec': default_secure_fixture_options._replace(ci_mac=False),
'h2_fd': fd_unsecure_fixture_options,
'h2_full': default_unsecure_fixture_options,
@@ -69,6 +74,7 @@ END2END_FIXTURES = {
'h2_sockpair+trace': socketpair_unsecure_fixture_options._replace(
ci_mac=False, tracing=True, large_writes=False, exclude_iomgrs=['uv']),
'h2_ssl': default_secure_fixture_options,
+ 'h2_local': local_fixture_options,
'h2_ssl_proxy': default_secure_fixture_options._replace(
includes_proxy=True, ci_mac=False, exclude_iomgrs=['uv']),
'h2_uds': uds_fixture_options,
@@ -106,6 +112,7 @@ END2END_TESTS = {
needs_compression=True),
'connectivity': connectivity_test_options._replace(needs_names=True,
proxyable=False, cpu_cost=LOWCPU, exclude_iomgrs=['uv']),
+ 'channelz': default_test_options,
'default_host': default_test_options._replace(
needs_fullstack=True, needs_dns=True, needs_names=True),
'call_host_override': default_test_options._replace(
@@ -138,10 +145,13 @@ END2END_TESTS = {
'max_message_length': default_test_options._replace(cpu_cost=LOWCPU),
'negative_deadline': default_test_options,
'network_status_change': default_test_options._replace(cpu_cost=LOWCPU),
+ 'no_error_on_hotpath': default_test_options._replace(proxyable=False),
'no_logging': default_test_options._replace(traceable=False),
'no_op': default_test_options,
'payload': default_test_options,
- 'load_reporting_hook': default_test_options,
+ # This cmake target is disabled for now because it depends on OpenCensus,
+ # which is Bazel-only.
+ # 'load_reporting_hook': default_test_options,
'ping_pong_streaming': default_test_options._replace(cpu_cost=LOWCPU),
'ping': connectivity_test_options._replace(proxyable=False,
cpu_cost=LOWCPU),
diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl
index 11fc576165..6d9ffcfb91 100755
--- a/test/core/end2end/generate_tests.bzl
+++ b/test/core/end2end/generate_tests.bzl
@@ -13,269 +13,347 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-POLLERS = ['epollex', 'epollsig', 'epoll1', 'poll', 'poll-cv']
-
-load("//bazel:grpc_build_system.bzl", "grpc_sh_test", "grpc_cc_binary", "grpc_cc_library")
-
"""Generates the appropriate build.json data for all the end2end tests."""
+load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library")
-def fixture_options(fullstack=True, includes_proxy=False, dns_resolver=True,
- name_resolution=True, secure=True, tracing=False,
- platforms=['windows', 'linux', 'mac', 'posix'],
- is_inproc=False, is_http2=True, supports_proxy_auth=False,
- supports_write_buffering=True, client_channel=True):
- return struct(
- fullstack=fullstack,
- includes_proxy=includes_proxy,
- dns_resolver=dns_resolver,
- name_resolution=name_resolution,
- secure=secure,
- tracing=tracing,
- is_inproc=is_inproc,
- is_http2=is_http2,
- supports_proxy_auth=supports_proxy_auth,
- supports_write_buffering=supports_write_buffering,
- client_channel=client_channel,
- #platforms=platforms,
- )
+POLLERS = ["epollex", "epoll1", "poll", "poll-cv"]
+def _fixture_options(
+ fullstack = True,
+ includes_proxy = False,
+ dns_resolver = True,
+ name_resolution = True,
+ secure = True,
+ tracing = False,
+ _platforms = ["windows", "linux", "mac", "posix"],
+ is_inproc = False,
+ is_http2 = True,
+ supports_proxy_auth = False,
+ supports_write_buffering = True,
+ client_channel = True):
+ return struct(
+ fullstack = fullstack,
+ includes_proxy = includes_proxy,
+ dns_resolver = dns_resolver,
+ name_resolution = name_resolution,
+ secure = secure,
+ tracing = tracing,
+ is_inproc = is_inproc,
+ is_http2 = is_http2,
+ supports_proxy_auth = supports_proxy_auth,
+ supports_write_buffering = supports_write_buffering,
+ client_channel = client_channel,
+ #_platforms=_platforms,
+ )
# maps fixture name to whether it requires the security library
END2END_FIXTURES = {
- 'h2_compress': fixture_options(),
- 'h2_census': fixture_options(),
- 'h2_load_reporting': fixture_options(),
- 'h2_fakesec': fixture_options(),
- 'h2_fd': fixture_options(dns_resolver=False, fullstack=False,
- client_channel=False,
- platforms=['linux', 'mac', 'posix']),
- 'h2_full': fixture_options(),
- 'h2_full+pipe': fixture_options(platforms=['linux']),
- 'h2_full+trace': fixture_options(tracing=True),
- 'h2_full+workarounds': fixture_options(),
- 'h2_http_proxy': fixture_options(supports_proxy_auth=True),
- 'h2_oauth2': fixture_options(),
- 'h2_proxy': fixture_options(includes_proxy=True),
- 'h2_sockpair_1byte': fixture_options(fullstack=False, dns_resolver=False,
- client_channel=False),
- 'h2_sockpair': fixture_options(fullstack=False, dns_resolver=False,
- client_channel=False),
- 'h2_sockpair+trace': fixture_options(fullstack=False, dns_resolver=False,
- tracing=True, client_channel=False),
- 'h2_ssl': fixture_options(secure=True),
- 'h2_ssl_proxy': fixture_options(includes_proxy=True, secure=True),
- 'h2_uds': fixture_options(dns_resolver=False,
- platforms=['linux', 'mac', 'posix']),
- 'inproc': fixture_options(fullstack=False, dns_resolver=False,
- name_resolution=False, is_inproc=True,
- is_http2=False, supports_write_buffering=False,
- client_channel=False),
+ "h2_compress": _fixture_options(),
+ "h2_census": _fixture_options(),
+ # TODO(juanlishen): This is disabled for now, but should be considered to re-enable once we have
+ # decided how the load reporting service should be enabled.
+ #'h2_load_reporting': _fixture_options(),
+ "h2_fakesec": _fixture_options(),
+ "h2_fd": _fixture_options(
+ dns_resolver = False,
+ fullstack = False,
+ client_channel = False,
+ _platforms = ["linux", "mac", "posix"],
+ ),
+ "h2_full": _fixture_options(),
+ "h2_full+pipe": _fixture_options(_platforms = ["linux"]),
+ "h2_full+trace": _fixture_options(tracing = True),
+ "h2_full+workarounds": _fixture_options(),
+ "h2_http_proxy": _fixture_options(supports_proxy_auth = True),
+ "h2_oauth2": _fixture_options(),
+ "h2_proxy": _fixture_options(includes_proxy = True),
+ "h2_sockpair_1byte": _fixture_options(
+ fullstack = False,
+ dns_resolver = False,
+ client_channel = False,
+ ),
+ "h2_sockpair": _fixture_options(
+ fullstack = False,
+ dns_resolver = False,
+ client_channel = False,
+ ),
+ "h2_sockpair+trace": _fixture_options(
+ fullstack = False,
+ dns_resolver = False,
+ tracing = True,
+ client_channel = False,
+ ),
+ "h2_ssl": _fixture_options(secure = True),
+ "h2_local": _fixture_options(secure = True, dns_resolver = False, _platforms = ["linux", "mac", "posix"]),
+ "h2_ssl_proxy": _fixture_options(includes_proxy = True, secure = True),
+ "h2_uds": _fixture_options(
+ dns_resolver = False,
+ _platforms = ["linux", "mac", "posix"],
+ ),
+ "inproc": _fixture_options(
+ fullstack = False,
+ dns_resolver = False,
+ name_resolution = False,
+ is_inproc = True,
+ is_http2 = False,
+ supports_write_buffering = False,
+ client_channel = False,
+ ),
}
-
-def test_options(needs_fullstack=False, needs_dns=False, needs_names=False,
- proxyable=True, secure=False, traceable=False,
- exclude_inproc=False, needs_http2=False,
- needs_proxy_auth=False, needs_write_buffering=False,
- needs_client_channel=False):
- return struct(
- needs_fullstack=needs_fullstack,
- needs_dns=needs_dns,
- needs_names=needs_names,
- proxyable=proxyable,
- secure=secure,
- traceable=traceable,
- exclude_inproc=exclude_inproc,
- needs_http2=needs_http2,
- needs_proxy_auth=needs_proxy_auth,
- needs_write_buffering=needs_write_buffering,
- needs_client_channel=needs_client_channel,
- )
-
+def _test_options(
+ needs_fullstack = False,
+ needs_dns = False,
+ needs_names = False,
+ proxyable = True,
+ secure = False,
+ traceable = False,
+ exclude_inproc = False,
+ needs_http2 = False,
+ needs_proxy_auth = False,
+ needs_write_buffering = False,
+ needs_client_channel = False):
+ return struct(
+ needs_fullstack = needs_fullstack,
+ needs_dns = needs_dns,
+ needs_names = needs_names,
+ proxyable = proxyable,
+ secure = secure,
+ traceable = traceable,
+ exclude_inproc = exclude_inproc,
+ needs_http2 = needs_http2,
+ needs_proxy_auth = needs_proxy_auth,
+ needs_write_buffering = needs_write_buffering,
+ needs_client_channel = needs_client_channel,
+ )
# maps test names to options
END2END_TESTS = {
- 'bad_hostname': test_options(needs_names=True),
- 'bad_ping': test_options(needs_fullstack=True,proxyable=False),
- 'binary_metadata': test_options(),
- 'resource_quota_server': test_options(proxyable=False),
- 'call_creds': test_options(secure=True),
- 'call_host_override': test_options(needs_fullstack=True, needs_dns=True,
- needs_names=True),
- 'cancel_after_accept': test_options(),
- 'cancel_after_client_done': test_options(),
- 'cancel_after_invoke': test_options(),
- 'cancel_after_round_trip': test_options(),
- 'cancel_before_invoke': test_options(),
- 'cancel_in_a_vacuum': test_options(),
- 'cancel_with_status': test_options(),
- 'compressed_payload': test_options(proxyable=False, exclude_inproc=True),
- 'connectivity': test_options(needs_fullstack=True, needs_names=True,
- proxyable=False),
- 'default_host': test_options(needs_fullstack=True, needs_dns=True,
- needs_names=True),
- 'disappearing_server': test_options(needs_fullstack=True,needs_names=True),
- 'empty_batch': test_options(),
- 'filter_causes_close': test_options(),
- 'filter_call_init_fails': test_options(),
- 'graceful_server_shutdown': test_options(exclude_inproc=True),
- 'hpack_size': test_options(proxyable=False, traceable=False,
- exclude_inproc=True),
- 'high_initial_seqno': test_options(),
- 'idempotent_request': test_options(),
- 'invoke_large_request': test_options(),
- 'keepalive_timeout': test_options(proxyable=False, needs_http2=True),
- 'large_metadata': test_options(),
- 'max_concurrent_streams': test_options(proxyable=False,
- exclude_inproc=True),
- 'max_connection_age': test_options(exclude_inproc=True),
- 'max_connection_idle': test_options(needs_fullstack=True, proxyable=False),
- 'max_message_length': test_options(),
- 'negative_deadline': test_options(),
- 'network_status_change': test_options(),
- 'no_logging': test_options(traceable=False),
- 'no_op': test_options(),
- 'payload': test_options(),
- 'load_reporting_hook': test_options(),
- 'ping_pong_streaming': test_options(),
- 'ping': test_options(needs_fullstack=True, proxyable=False),
- 'proxy_auth': test_options(needs_proxy_auth=True),
- 'registered_call': test_options(),
- 'request_with_flags': test_options(proxyable=False),
- 'request_with_payload': test_options(),
+ "bad_hostname": _test_options(needs_names = True),
+ "bad_ping": _test_options(needs_fullstack = True, proxyable = False),
+ "binary_metadata": _test_options(),
+ "resource_quota_server": _test_options(proxyable = False),
+ "call_creds": _test_options(secure = True),
+ "call_host_override": _test_options(
+ needs_fullstack = True,
+ needs_dns = True,
+ needs_names = True,
+ ),
+ "cancel_after_accept": _test_options(),
+ "cancel_after_client_done": _test_options(),
+ "cancel_after_invoke": _test_options(),
+ "cancel_after_round_trip": _test_options(),
+ "cancel_before_invoke": _test_options(),
+ "cancel_in_a_vacuum": _test_options(),
+ "cancel_with_status": _test_options(),
+ "compressed_payload": _test_options(proxyable = False, exclude_inproc = True),
+ "connectivity": _test_options(
+ needs_fullstack = True,
+ needs_names = True,
+ proxyable = False,
+ ),
+ "channelz": _test_options(),
+ "default_host": _test_options(
+ needs_fullstack = True,
+ needs_dns = True,
+ needs_names = True,
+ ),
+ "disappearing_server": _test_options(needs_fullstack = True, needs_names = True),
+ "empty_batch": _test_options(),
+ "filter_causes_close": _test_options(),
+ "filter_call_init_fails": _test_options(),
+ "graceful_server_shutdown": _test_options(exclude_inproc = True),
+ "hpack_size": _test_options(
+ proxyable = False,
+ traceable = False,
+ exclude_inproc = True,
+ ),
+ "high_initial_seqno": _test_options(),
+ "idempotent_request": _test_options(),
+ "invoke_large_request": _test_options(),
+ "keepalive_timeout": _test_options(proxyable = False, needs_http2 = True),
+ "large_metadata": _test_options(),
+ "max_concurrent_streams": _test_options(
+ proxyable = False,
+ exclude_inproc = True,
+ ),
+ "max_connection_age": _test_options(exclude_inproc = True),
+ "max_connection_idle": _test_options(needs_fullstack = True, proxyable = False),
+ "max_message_length": _test_options(),
+ "negative_deadline": _test_options(),
+ "network_status_change": _test_options(),
+ "no_error_on_hotpath": _test_options(proxyable = False),
+ "no_logging": _test_options(traceable = False),
+ "no_op": _test_options(),
+ "payload": _test_options(),
+ # TODO(juanlishen): This is disabled for now because it depends on some generated functions in
+ # end2end_tests.cc, which are not generated because they would depend on OpenCensus while
+ # OpenCensus can only be built via Bazel so far.
+ # 'load_reporting_hook': _test_options(),
+ "ping_pong_streaming": _test_options(),
+ "ping": _test_options(needs_fullstack = True, proxyable = False),
+ "proxy_auth": _test_options(needs_proxy_auth = True),
+ "registered_call": _test_options(),
+ "request_with_flags": _test_options(proxyable = False),
+ "request_with_payload": _test_options(),
# TODO(roth): Remove proxyable=False for all retry tests once we
# have a way for the proxy to propagate the fact that trailing
# metadata is available when initial metadata is returned.
# See https://github.com/grpc/grpc/issues/14467 for context.
- 'retry': test_options(needs_client_channel=True, proxyable=False),
- 'retry_cancellation': test_options(needs_client_channel=True,
- proxyable=False),
- 'retry_disabled': test_options(needs_client_channel=True, proxyable=False),
- 'retry_exceeds_buffer_size_in_initial_batch': test_options(
- needs_client_channel=True, proxyable=False),
- 'retry_exceeds_buffer_size_in_subsequent_batch': test_options(
- needs_client_channel=True, proxyable=False),
- 'retry_non_retriable_status': test_options(needs_client_channel=True,
- proxyable=False),
- 'retry_non_retriable_status_before_recv_trailing_metadata_started':
- test_options(needs_client_channel=True, proxyable=False),
- 'retry_recv_initial_metadata': test_options(needs_client_channel=True,
- proxyable=False),
- 'retry_recv_message': test_options(needs_client_channel=True,
- proxyable=False),
- 'retry_server_pushback_delay': test_options(needs_client_channel=True,
- proxyable=False),
- 'retry_server_pushback_disabled': test_options(needs_client_channel=True,
- proxyable=False),
- 'retry_streaming': test_options(needs_client_channel=True, proxyable=False),
- 'retry_streaming_after_commit': test_options(needs_client_channel=True,
- proxyable=False),
- 'retry_streaming_succeeds_before_replay_finished': test_options(
- needs_client_channel=True, proxyable=False),
- 'retry_throttled': test_options(needs_client_channel=True,
- proxyable=False),
- 'retry_too_many_attempts': test_options(needs_client_channel=True,
- proxyable=False),
- 'server_finishes_request': test_options(),
- 'shutdown_finishes_calls': test_options(),
- 'shutdown_finishes_tags': test_options(),
- 'simple_cacheable_request': test_options(),
- 'simple_delayed_request': test_options(needs_fullstack=True),
- 'simple_metadata': test_options(),
- 'simple_request': test_options(),
- 'streaming_error_response': test_options(),
- 'stream_compression_compressed_payload': test_options(proxyable=False,
- exclude_inproc=True),
- 'stream_compression_payload': test_options(exclude_inproc=True),
- 'stream_compression_ping_pong_streaming': test_options(exclude_inproc=True),
- 'trailing_metadata': test_options(),
- 'authority_not_supported': test_options(),
- 'filter_latency': test_options(),
- 'filter_status_code': test_options(),
- 'workaround_cronet_compression': test_options(),
- 'write_buffering': test_options(needs_write_buffering=True),
- 'write_buffering_at_end': test_options(needs_write_buffering=True),
+ "retry": _test_options(needs_client_channel = True, proxyable = False),
+ "retry_cancellation": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_disabled": _test_options(needs_client_channel = True, proxyable = False),
+ "retry_exceeds_buffer_size_in_initial_batch": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_exceeds_buffer_size_in_subsequent_batch": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_non_retriable_status": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_non_retriable_status_before_recv_trailing_metadata_started": _test_options(needs_client_channel = True, proxyable = False),
+ "retry_recv_initial_metadata": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_recv_message": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_server_pushback_delay": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_server_pushback_disabled": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_streaming": _test_options(needs_client_channel = True, proxyable = False),
+ "retry_streaming_after_commit": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_streaming_succeeds_before_replay_finished": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_throttled": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "retry_too_many_attempts": _test_options(
+ needs_client_channel = True,
+ proxyable = False,
+ ),
+ "server_finishes_request": _test_options(),
+ "shutdown_finishes_calls": _test_options(),
+ "shutdown_finishes_tags": _test_options(),
+ "simple_cacheable_request": _test_options(),
+ "simple_delayed_request": _test_options(needs_fullstack = True),
+ "simple_metadata": _test_options(),
+ "simple_request": _test_options(),
+ "streaming_error_response": _test_options(),
+ "stream_compression_compressed_payload": _test_options(
+ proxyable = False,
+ exclude_inproc = True,
+ ),
+ "stream_compression_payload": _test_options(exclude_inproc = True),
+ "stream_compression_ping_pong_streaming": _test_options(exclude_inproc = True),
+ "trailing_metadata": _test_options(),
+ "authority_not_supported": _test_options(),
+ "filter_latency": _test_options(),
+ "filter_status_code": _test_options(),
+ "workaround_cronet_compression": _test_options(),
+ "write_buffering": _test_options(needs_write_buffering = True),
+ "write_buffering_at_end": _test_options(needs_write_buffering = True),
}
-
-def compatible(fopt, topt):
- if topt.needs_fullstack:
- if not fopt.fullstack:
- return False
- if topt.needs_dns:
- if not fopt.dns_resolver:
- return False
- if topt.needs_names:
- if not fopt.name_resolution:
- return False
- if not topt.proxyable:
- if fopt.includes_proxy:
- return False
- if not topt.traceable:
- if fopt.tracing:
- return False
- if topt.exclude_inproc:
- if fopt.is_inproc:
- return False
- if topt.needs_http2:
- if not fopt.is_http2:
- return False
- if topt.needs_proxy_auth:
- if not fopt.supports_proxy_auth:
- return False
- if topt.needs_write_buffering:
- if not fopt.supports_write_buffering:
- return False
- if topt.needs_client_channel:
- if not fopt.client_channel:
- return False
- return True
-
+def _compatible(fopt, topt):
+ if topt.needs_fullstack:
+ if not fopt.fullstack:
+ return False
+ if topt.needs_dns:
+ if not fopt.dns_resolver:
+ return False
+ if topt.needs_names:
+ if not fopt.name_resolution:
+ return False
+ if not topt.proxyable:
+ if fopt.includes_proxy:
+ return False
+ if not topt.traceable:
+ if fopt.tracing:
+ return False
+ if topt.exclude_inproc:
+ if fopt.is_inproc:
+ return False
+ if topt.needs_http2:
+ if not fopt.is_http2:
+ return False
+ if topt.needs_proxy_auth:
+ if not fopt.supports_proxy_auth:
+ return False
+ if topt.needs_write_buffering:
+ if not fopt.supports_write_buffering:
+ return False
+ if topt.needs_client_channel:
+ if not fopt.client_channel:
+ return False
+ return True
def grpc_end2end_tests():
- grpc_cc_library(
- name = 'end2end_tests',
- srcs = ['end2end_tests.cc', 'end2end_test_utils.cc'] + [
- 'tests/%s.cc' % t
- for t in sorted(END2END_TESTS.keys())],
- hdrs = [
- 'tests/cancel_test_helpers.h',
- 'end2end_tests.h'
- ],
- language = "C++",
- deps = [
- ':cq_verifier',
- ':ssl_test_data',
- ':http_proxy',
- ':proxy',
- ]
- )
-
- for f, fopt in END2END_FIXTURES.items():
- grpc_cc_binary(
- name = '%s_test' % f,
- srcs = ['fixtures/%s.cc' % f],
- language = "C++",
- deps = [
- ':end2end_tests',
- '//test/core/util:grpc_test_util',
- '//:grpc',
- '//test/core/util:gpr_test_util',
- '//:gpr',
- ],
+ grpc_cc_library(
+ name = "end2end_tests",
+ srcs = ["end2end_tests.cc", "end2end_test_utils.cc"] + [
+ "tests/%s.cc" % t
+ for t in sorted(END2END_TESTS.keys())
+ ],
+ hdrs = [
+ "tests/cancel_test_helpers.h",
+ "end2end_tests.h",
+ ],
+ language = "C++",
+ deps = [
+ ":cq_verifier",
+ ":ssl_test_data",
+ ":http_proxy",
+ ":proxy",
+ ],
)
- for t, topt in END2END_TESTS.items():
- #print(compatible(fopt, topt), f, t, fopt, topt)
- if not compatible(fopt, topt): continue
- for poller in POLLERS:
- native.sh_test(
- name = '%s_test@%s@poller=%s' % (f, t, poller),
- data = [':%s_test' % f],
- srcs = ['end2end_test.sh'],
- args = [
- '$(location %s_test)' % f,
- t,
- poller,
- ],
+
+ for f, fopt in END2END_FIXTURES.items():
+ grpc_cc_binary(
+ name = "%s_test" % f,
+ srcs = ["fixtures/%s.cc" % f],
+ language = "C++",
+ deps = [
+ ":end2end_tests",
+ "//test/core/util:grpc_test_util",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//:gpr",
+ ],
)
+ for t, topt in END2END_TESTS.items():
+ #print(_compatible(fopt, topt), f, t, fopt, topt)
+ if not _compatible(fopt, topt):
+ continue
+ for poller in POLLERS:
+ native.sh_test(
+ name = "%s_test@%s@poller=%s" % (f, t, poller),
+ data = [":%s_test" % f],
+ srcs = ["end2end_test.sh"],
+ args = [
+ "$(location %s_test)" % f,
+ t,
+ poller,
+ ],
+ )
diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc
index 0188698f17..8904c3d325 100644
--- a/test/core/end2end/goaway_server_test.cc
+++ b/test/core/end2end/goaway_server_test.cc
@@ -44,11 +44,11 @@ static void* tag(intptr_t i) { return (void*)i; }
static gpr_mu g_mu;
static int g_resolve_port = -1;
-static grpc_ares_request* (*iomgr_dns_lookup_ares)(
+static grpc_ares_request* (*iomgr_dns_lookup_ares_locked)(
const char* dns_server, const char* addr, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_lb_addresses** addresses, bool check_grpclb,
- char** service_config_json);
+ char** service_config_json, grpc_combiner* combiner);
static void set_resolve_port(int port) {
gpr_mu_lock(&g_mu);
@@ -98,15 +98,15 @@ static grpc_error* my_blocking_resolve_address(
static grpc_address_resolver_vtable test_resolver = {
my_resolve_address, my_blocking_resolve_address};
-static grpc_ares_request* my_dns_lookup_ares(
+static grpc_ares_request* my_dns_lookup_ares_locked(
const char* dns_server, const char* addr, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
- grpc_lb_addresses** lb_addrs, bool check_grpclb,
- char** service_config_json) {
+ grpc_lb_addresses** lb_addrs, bool check_grpclb, char** service_config_json,
+ grpc_combiner* combiner) {
if (0 != strcmp(addr, "test")) {
- return iomgr_dns_lookup_ares(dns_server, addr, default_port,
- interested_parties, on_done, lb_addrs,
- check_grpclb, service_config_json);
+ return iomgr_dns_lookup_ares_locked(
+ dns_server, addr, default_port, interested_parties, on_done, lb_addrs,
+ check_grpclb, service_config_json, combiner);
}
grpc_error* error = GRPC_ERROR_NONE;
@@ -142,8 +142,8 @@ int main(int argc, char** argv) {
grpc_init();
default_resolver = grpc_resolve_address_impl;
grpc_set_resolver_impl(&test_resolver);
- iomgr_dns_lookup_ares = grpc_dns_lookup_ares;
- grpc_dns_lookup_ares = my_dns_lookup_ares;
+ iomgr_dns_lookup_ares_locked = grpc_dns_lookup_ares_locked;
+ grpc_dns_lookup_ares_locked = my_dns_lookup_ares_locked;
int was_cancelled1;
int was_cancelled2;
diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc
index 9ed6f23798..2c5ee3b156 100644
--- a/test/core/end2end/h2_ssl_cert_test.cc
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -169,8 +169,8 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype;
default: \
break; \
} \
- ssl_creds = \
- grpc_ssl_credentials_create(test_root_cert, key_cert_pair, NULL); \
+ ssl_creds = grpc_ssl_credentials_create(test_root_cert, key_cert_pair, \
+ NULL, NULL); \
grpc_arg ssl_name_override = { \
GRPC_ARG_STRING, \
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), \
diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc
index d5984be93f..b2f398625a 100644
--- a/test/core/end2end/h2_ssl_session_reuse_test.cc
+++ b/test/core/end2end/h2_ssl_session_reuse_test.cc
@@ -66,7 +66,7 @@ grpc_channel* client_create(char* server_addr, grpc_ssl_session_cache* cache) {
grpc_ssl_pem_key_cert_pair signed_client_key_cert_pair = {
test_signed_client_key, test_signed_client_cert};
grpc_channel_credentials* client_creds = grpc_ssl_credentials_create(
- test_root_cert, &signed_client_key_cert_pair, nullptr);
+ test_root_cert, &signed_client_key_cert_pair, nullptr, nullptr);
grpc_arg args[] = {
grpc_channel_arg_string_create(
diff --git a/test/core/end2end/inproc_callback_test.cc b/test/core/end2end/inproc_callback_test.cc
new file mode 100644
index 0000000000..310030046a
--- /dev/null
+++ b/test/core/end2end/inproc_callback_test.cc
@@ -0,0 +1,507 @@
+/*
+ *
+ * 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/end2end/end2end_tests.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+
+#include "src/core/ext/transport/inproc/inproc_transport.h"
+#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/surface/completion_queue.h"
+#include "src/core/lib/surface/server.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+typedef struct inproc_fixture_data {
+ bool dummy; // reserved for future expansion. Struct can't be empty
+} inproc_fixture_data;
+
+namespace {
+template <typename F>
+class CQDeletingCallback : public grpc_experimental_completion_queue_functor {
+ public:
+ explicit CQDeletingCallback(F f) : func_(f) {
+ functor_run = &CQDeletingCallback::Run;
+ }
+ ~CQDeletingCallback() {}
+ static void Run(grpc_experimental_completion_queue_functor* cb, int ok) {
+ auto* callback = static_cast<CQDeletingCallback*>(cb);
+ callback->func_(static_cast<bool>(ok));
+ grpc_core::Delete(callback);
+ }
+
+ private:
+ F func_;
+};
+
+template <typename F>
+grpc_experimental_completion_queue_functor* NewDeletingCallback(F f) {
+ return grpc_core::New<CQDeletingCallback<F>>(f);
+}
+
+class ShutdownCallback : public grpc_experimental_completion_queue_functor {
+ public:
+ ShutdownCallback() : done_(false) {
+ functor_run = &ShutdownCallback::StaticRun;
+ gpr_mu_init(&mu_);
+ gpr_cv_init(&cv_);
+ }
+ ~ShutdownCallback() {}
+ static void StaticRun(grpc_experimental_completion_queue_functor* cb,
+ int ok) {
+ auto* callback = static_cast<ShutdownCallback*>(cb);
+ callback->Run(static_cast<bool>(ok));
+ }
+ void Run(bool ok) {
+ gpr_log(GPR_DEBUG, "CQ shutdown notification invoked");
+ gpr_mu_lock(&mu_);
+ done_ = true;
+ gpr_cv_broadcast(&cv_);
+ gpr_mu_unlock(&mu_);
+ }
+ // The Wait function waits for a specified amount of
+ // time for the completion of the shutdown and returns
+ // whether it was successfully shut down
+ bool Wait(gpr_timespec deadline) {
+ gpr_mu_lock(&mu_);
+ while (!done_ && !gpr_cv_wait(&cv_, &mu_, deadline)) {
+ }
+ bool ret = done_;
+ gpr_mu_unlock(&mu_);
+ return ret;
+ }
+
+ private:
+ bool done_;
+ gpr_mu mu_;
+ gpr_cv cv_;
+};
+
+ShutdownCallback* g_shutdown_callback;
+} // namespace
+
+// The following global structure is the tag collection. It holds
+// all information related to tags expected and tags received
+// during the execution, with each callback setting a tag.
+// The tag sets are implemented and checked using arrays and
+// linear lookups (rather than maps) so that this test doesn't
+// need the C++ standard library.
+static gpr_mu tags_mu;
+static gpr_cv tags_cv;
+const size_t kAvailableTags = 4;
+bool tags[kAvailableTags];
+bool tags_valid[kAvailableTags];
+bool tags_expected[kAvailableTags];
+bool tags_needed[kAvailableTags];
+
+// Mark that a tag is expected; this function must be executed in the
+// main thread only while there are no other threads altering the
+// expectation set (e.g., by calling expect_tag or verify_tags)
+static void expect_tag(intptr_t tag, bool ok) {
+ size_t idx = static_cast<size_t>(tag);
+ GPR_ASSERT(idx < kAvailableTags);
+ tags_needed[idx] = true;
+ tags_expected[idx] = ok;
+}
+
+// Check that the expected tags have reached, within a certain
+// deadline. This must also be executed only on the main thread while
+// there are no other threads altering the expectation set (e.g., by
+// calling expect_tag or verify_tags). The tag verifier doesn't have
+// to drive the CQ at all (unlike the next-based end2end tests)
+// because the tags will get set when the callbacks are executed,
+// which happens when a particular batch related to a callback is
+// complete.
+static void verify_tags(gpr_timespec deadline) {
+ bool done = false;
+
+ gpr_mu_lock(&tags_mu);
+ while (!done) {
+ done = gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), deadline) > 0;
+ for (size_t i = 0; i < kAvailableTags; i++) {
+ if (tags_needed[i]) {
+ if (tags_valid[i]) {
+ gpr_log(GPR_DEBUG, "Verifying tag %d", static_cast<int>(i));
+ if (tags[i] != tags_expected[i]) {
+ gpr_log(GPR_ERROR, "Got wrong result (%d instead of %d) for tag %d",
+ tags[i], tags_expected[i], static_cast<int>(i));
+ GPR_ASSERT(false);
+ }
+ tags_valid[i] = false;
+ tags_needed[i] = false;
+ } else if (done) {
+ gpr_log(GPR_ERROR, "Didn't get tag %d", static_cast<int>(i));
+ GPR_ASSERT(false);
+ }
+ }
+ }
+ bool empty = true;
+ for (size_t i = 0; i < kAvailableTags; i++) {
+ if (tags_needed[i]) {
+ empty = false;
+ }
+ }
+ done = done || empty;
+ if (done) {
+ for (size_t i = 0; i < kAvailableTags; i++) {
+ if (tags_valid[i]) {
+ gpr_log(GPR_ERROR, "Got unexpected tag %d and result %d",
+ static_cast<int>(i), tags[i]);
+ GPR_ASSERT(false);
+ }
+ tags_valid[i] = false;
+ }
+ } else {
+ gpr_cv_wait(&tags_cv, &tags_mu, deadline);
+ }
+ }
+ gpr_mu_unlock(&tags_mu);
+}
+
+// This function creates a callback functor that emits the
+// desired tag into the global tag set
+static grpc_experimental_completion_queue_functor* tag(intptr_t t) {
+ auto func = [t](bool ok) {
+ gpr_mu_lock(&tags_mu);
+ gpr_log(GPR_DEBUG, "Completing operation %" PRIdPTR, t);
+ bool was_empty = true;
+ for (size_t i = 0; i < kAvailableTags; i++) {
+ if (tags_valid[i]) {
+ was_empty = false;
+ }
+ }
+ size_t idx = static_cast<size_t>(t);
+ tags[idx] = ok;
+ tags_valid[idx] = true;
+ if (was_empty) {
+ gpr_cv_signal(&tags_cv);
+ }
+ gpr_mu_unlock(&tags_mu);
+ };
+ auto cb = NewDeletingCallback(func);
+ return cb;
+}
+
+static grpc_end2end_test_fixture inproc_create_fixture(
+ grpc_channel_args* client_args, grpc_channel_args* server_args) {
+ grpc_end2end_test_fixture f;
+ inproc_fixture_data* ffd = static_cast<inproc_fixture_data*>(
+ gpr_malloc(sizeof(inproc_fixture_data)));
+ memset(&f, 0, sizeof(f));
+
+ f.fixture_data = ffd;
+ g_shutdown_callback = grpc_core::New<ShutdownCallback>();
+ f.cq =
+ grpc_completion_queue_create_for_callback(g_shutdown_callback, nullptr);
+ f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr);
+
+ return f;
+}
+
+void inproc_init_client(grpc_end2end_test_fixture* f,
+ grpc_channel_args* client_args) {
+ f->client = grpc_inproc_channel_create(f->server, client_args, nullptr);
+ GPR_ASSERT(f->client);
+}
+
+void inproc_init_server(grpc_end2end_test_fixture* f,
+ grpc_channel_args* server_args) {
+ if (f->server) {
+ grpc_server_destroy(f->server);
+ }
+ f->server = grpc_server_create(server_args, nullptr);
+ grpc_server_register_completion_queue(f->server, f->cq, nullptr);
+ grpc_server_start(f->server);
+}
+
+void inproc_tear_down(grpc_end2end_test_fixture* f) {
+ inproc_fixture_data* ffd = static_cast<inproc_fixture_data*>(f->fixture_data);
+ gpr_free(ffd);
+}
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_server(&f, server_args);
+ config.init_client(&f, client_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_from_now(int n) {
+ return grpc_timeout_seconds_to_deadline(n);
+}
+
+static gpr_timespec five_seconds_from_now() { return n_seconds_from_now(5); }
+
+static void drain_cq(grpc_completion_queue* cq) {
+ // Wait for the shutdown callback to arrive, or fail the test
+ GPR_ASSERT(g_shutdown_callback->Wait(five_seconds_from_now()));
+ gpr_log(GPR_DEBUG, "CQ shutdown wait complete");
+ grpc_core::Delete(g_shutdown_callback);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture* f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(
+ f->server, f->shutdown_cq,
+ reinterpret_cast<void*>(static_cast<intptr_t>(1000)));
+ GPR_ASSERT(
+ grpc_completion_queue_pluck(f->shutdown_cq, (void*)((intptr_t)1000),
+ grpc_timeout_seconds_to_deadline(5), nullptr)
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = nullptr;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture* f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = nullptr;
+}
+
+static void end_test(grpc_end2end_test_fixture* f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_destroy(f->shutdown_cq);
+}
+
+static void simple_request_body(grpc_end2end_test_config config,
+ grpc_end2end_test_fixture f) {
+ grpc_call* c;
+ grpc_call* s;
+ grpc_op ops[6];
+ grpc_op* op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ const char* error_string;
+ grpc_call_error error;
+ grpc_slice details;
+ int was_cancelled = 2;
+ char* peer;
+ gpr_timespec deadline = five_seconds_from_now();
+
+ c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ grpc_slice_from_static_string("/foo"), nullptr,
+ deadline, nullptr);
+ GPR_ASSERT(c);
+
+ peer = grpc_call_get_peer(c);
+ GPR_ASSERT(peer != nullptr);
+ gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer);
+ gpr_free(peer);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ // Create a basic client unary request batch (no payload)
+ 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_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.error_string = &error_string;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ // Register a call at the server-side to match the incoming client call
+ error = grpc_server_request_call(f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(2));
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ // We expect that the server call creation callback (and no others) will
+ // execute now since no other batch should be complete.
+ expect_tag(2, true);
+ verify_tags(deadline);
+
+ peer = grpc_call_get_peer(s);
+ GPR_ASSERT(peer != nullptr);
+ gpr_log(GPR_DEBUG, "server_peer=%s", peer);
+ gpr_free(peer);
+ peer = grpc_call_get_peer(c);
+ GPR_ASSERT(peer != nullptr);
+ gpr_log(GPR_DEBUG, "client_peer=%s", peer);
+ gpr_free(peer);
+
+ // Create the server response batch (no payload)
+ 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_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++;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ // Both the client request and server response batches should get complete
+ // now and we should see that their callbacks have been executed
+ expect_tag(3, true);
+ expect_tag(1, true);
+ verify_tags(deadline);
+
+ GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz"));
+ // the following sanity check makes sure that the requested error string is
+ // correctly populated by the core. It looks for certain substrings that are
+ // not likely to change much. Some parts of the error, like time created,
+ // obviously are not checked.
+ GPR_ASSERT(nullptr != strstr(error_string, "xyz"));
+ GPR_ASSERT(nullptr != strstr(error_string, "description"));
+ GPR_ASSERT(nullptr != strstr(error_string, "Error received from peer"));
+ GPR_ASSERT(nullptr != strstr(error_string, "grpc_message"));
+ GPR_ASSERT(nullptr != strstr(error_string, "grpc_status"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
+ GPR_ASSERT(0 == call_details.flags);
+ GPR_ASSERT(was_cancelled == 1);
+
+ grpc_slice_unref(details);
+ gpr_free(static_cast<void*>(const_cast<char*>(error_string)));
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_unref(c);
+ grpc_call_unref(s);
+
+ int expected_calls = 1;
+ if (config.feature_mask & FEATURE_MASK_SUPPORTS_REQUEST_PROXYING) {
+ expected_calls *= 2;
+ }
+}
+
+static void test_invoke_simple_request(grpc_end2end_test_config config) {
+ grpc_end2end_test_fixture f;
+
+ f = begin_test(config, "test_invoke_simple_request", nullptr, nullptr);
+ simple_request_body(config, f);
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+static void test_invoke_10_simple_requests(grpc_end2end_test_config config) {
+ int i;
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_invoke_10_simple_requests", nullptr, nullptr);
+ for (i = 0; i < 10; i++) {
+ simple_request_body(config, f);
+ gpr_log(GPR_INFO, "Running test: Passed simple request %d", i);
+ }
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+static void test_invoke_many_simple_requests(grpc_end2end_test_config config) {
+ int i;
+ const int many = 1000;
+ grpc_end2end_test_fixture f =
+ begin_test(config, "test_invoke_many_simple_requests", nullptr, nullptr);
+ gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC);
+ for (i = 0; i < many; i++) {
+ simple_request_body(config, f);
+ }
+ double us =
+ gpr_timespec_to_micros(gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), t1)) /
+ many;
+ gpr_log(GPR_INFO, "Time per ping %f us", us);
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+static void simple_request(grpc_end2end_test_config config) {
+ int i;
+ for (i = 0; i < 10; i++) {
+ test_invoke_simple_request(config);
+ }
+ test_invoke_10_simple_requests(config);
+ test_invoke_many_simple_requests(config);
+}
+
+static void simple_request_pre_init() {
+ gpr_mu_init(&tags_mu);
+ gpr_cv_init(&tags_cv);
+}
+
+/* All test configurations */
+static grpc_end2end_test_config configs[] = {
+ {"inproc-callback", FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, nullptr,
+ inproc_create_fixture, inproc_init_client, inproc_init_server,
+ inproc_tear_down},
+};
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+
+ simple_request_pre_init();
+ simple_request(configs[0]);
+
+ grpc_shutdown();
+
+ return 0;
+}
diff --git a/test/core/end2end/tests/channelz.cc b/test/core/end2end/tests/channelz.cc
new file mode 100644
index 0000000000..40a0370f0e
--- /dev/null
+++ b/test/core/end2end/tests/channelz.cc
@@ -0,0 +1,326 @@
+/*
+ *
+ * Copyright 2015 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/end2end/end2end_tests.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/surface/server.h"
+
+#include <grpc/byte_buffer.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include "src/core/lib/gpr/string.h"
+#include "test/core/end2end/cq_verifier.h"
+
+static void* tag(intptr_t t) { return (void*)t; }
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_server(&f, server_args);
+ config.init_client(&f, client_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_from_now(int n) {
+ return grpc_timeout_seconds_to_deadline(n);
+}
+
+static gpr_timespec five_seconds_from_now(void) {
+ return n_seconds_from_now(5);
+}
+
+static void drain_cq(grpc_completion_queue* cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture* f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
+ grpc_timeout_seconds_to_deadline(5),
+ nullptr)
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = nullptr;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture* f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = nullptr;
+}
+
+static void end_test(grpc_end2end_test_fixture* f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_destroy(f->shutdown_cq);
+}
+
+static void run_one_request(grpc_end2end_test_config config,
+ grpc_end2end_test_fixture f,
+ bool request_is_success) {
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
+ grpc_op ops[6];
+ grpc_op* op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ grpc_call_error error;
+ grpc_slice details;
+ int was_cancelled = 2;
+
+ gpr_timespec deadline = five_seconds_from_now();
+ c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ grpc_slice_from_static_string("/foo"), nullptr,
+ deadline, nullptr);
+ GPR_ASSERT(c);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ 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_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.error_string = nullptr;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ error =
+ grpc_server_request_call(f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(101));
+ GPR_ASSERT(GRPC_CALL_OK == error);
+ CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
+ cq_verify(cqv);
+
+ 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_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status =
+ request_is_success ? GRPC_STATUS_OK : 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++;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
+ CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz"));
+ GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
+ GPR_ASSERT(0 == call_details.flags);
+
+ grpc_slice_unref(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_unref(c);
+ grpc_call_unref(s);
+
+ cq_verifier_destroy(cqv);
+}
+
+static void test_channelz(grpc_end2end_test_config config) {
+ grpc_end2end_test_fixture f;
+
+ grpc_arg arg;
+ arg.type = GRPC_ARG_INTEGER;
+ arg.key = const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ);
+ arg.value.integer = true;
+ grpc_channel_args args = {1, &arg};
+
+ f = begin_test(config, "test_channelz", &args, &args);
+ grpc_core::channelz::ChannelNode* channelz_channel =
+ grpc_channel_get_channelz_node(f.client);
+ GPR_ASSERT(channelz_channel != nullptr);
+
+ grpc_core::channelz::ServerNode* channelz_server =
+ grpc_server_get_channelz_node(f.server);
+ GPR_ASSERT(channelz_server != nullptr);
+
+ char* json = channelz_channel->RenderJsonString();
+ GPR_ASSERT(json != nullptr);
+ // nothing is present yet
+ GPR_ASSERT(nullptr == strstr(json, "\"callsStarted\""));
+ GPR_ASSERT(nullptr == strstr(json, "\"callsFailed\""));
+ GPR_ASSERT(nullptr == strstr(json, "\"callsSucceeded\""));
+ gpr_free(json);
+
+ // one successful request
+ run_one_request(config, f, true);
+
+ json = channelz_channel->RenderJsonString();
+ GPR_ASSERT(json != nullptr);
+ GPR_ASSERT(nullptr != strstr(json, "\"callsStarted\":\"1\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"callsSucceeded\":\"1\""));
+ gpr_free(json);
+
+ // one failed request
+ run_one_request(config, f, false);
+
+ json = channelz_channel->RenderJsonString();
+ GPR_ASSERT(json != nullptr);
+ gpr_log(GPR_INFO, "%s", json);
+ GPR_ASSERT(nullptr != strstr(json, "\"callsStarted\":\"2\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"callsFailed\":\"1\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"callsSucceeded\":\"1\""));
+ // channel tracing is not enabled, so these should not be preset.
+ GPR_ASSERT(nullptr == strstr(json, "\"trace\""));
+ GPR_ASSERT(nullptr == strstr(json, "\"description\":\"Channel created\""));
+ GPR_ASSERT(nullptr == strstr(json, "\"severity\":\"CT_INFO\""));
+ gpr_free(json);
+
+ json = channelz_server->RenderJsonString();
+ GPR_ASSERT(json != nullptr);
+ gpr_log(GPR_INFO, "%s", json);
+ GPR_ASSERT(nullptr != strstr(json, "\"callsStarted\":\"2\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"callsFailed\":\"1\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"callsSucceeded\":\"1\""));
+ // channel tracing is not enabled, so these should not be preset.
+ GPR_ASSERT(nullptr == strstr(json, "\"trace\""));
+ GPR_ASSERT(nullptr == strstr(json, "\"description\":\"Channel created\""));
+ GPR_ASSERT(nullptr == strstr(json, "\"severity\":\"CT_INFO\""));
+ gpr_free(json);
+
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+static void test_channelz_with_channel_trace(grpc_end2end_test_config config) {
+ grpc_end2end_test_fixture f;
+
+ grpc_arg arg[2];
+ arg[0].type = GRPC_ARG_INTEGER;
+ arg[0].key = const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE);
+ arg[0].value.integer = 5;
+ arg[1].type = GRPC_ARG_INTEGER;
+ arg[1].key = const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ);
+ arg[1].value.integer = true;
+ grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg};
+
+ f = begin_test(config, "test_channelz_with_channel_trace", &args, &args);
+ grpc_core::channelz::ChannelNode* channelz_channel =
+ grpc_channel_get_channelz_node(f.client);
+ GPR_ASSERT(channelz_channel != nullptr);
+
+ grpc_core::channelz::ServerNode* channelz_server =
+ grpc_server_get_channelz_node(f.server);
+ GPR_ASSERT(channelz_server != nullptr);
+
+ char* json = channelz_channel->RenderJsonString();
+ GPR_ASSERT(json != nullptr);
+ gpr_log(GPR_INFO, "%s", json);
+ GPR_ASSERT(nullptr != strstr(json, "\"trace\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"description\":\"Channel created\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"severity\":\"CT_INFO\""));
+ gpr_free(json);
+
+ json = channelz_server->RenderJsonString();
+ GPR_ASSERT(json != nullptr);
+ gpr_log(GPR_INFO, "%s", json);
+ GPR_ASSERT(nullptr != strstr(json, "\"trace\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"description\":\"Server created\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"severity\":\"CT_INFO\""));
+ gpr_free(json);
+
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+static void test_channelz_disabled(grpc_end2end_test_config config) {
+ grpc_end2end_test_fixture f;
+
+ f = begin_test(config, "test_channelz_disabled", nullptr, nullptr);
+ grpc_core::channelz::ChannelNode* channelz_channel =
+ grpc_channel_get_channelz_node(f.client);
+ GPR_ASSERT(channelz_channel == nullptr);
+ // one successful request
+ run_one_request(config, f, true);
+ GPR_ASSERT(channelz_channel == nullptr);
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+void channelz(grpc_end2end_test_config config) {
+ test_channelz(config);
+ test_channelz_with_channel_trace(config);
+ test_channelz_disabled(config);
+}
+
+void channelz_pre_init(void) {}
diff --git a/test/core/end2end/tests/filter_status_code.cc b/test/core/end2end/tests/filter_status_code.cc
index ba3cbfa6d1..5ffc3d00a3 100644
--- a/test/core/end2end/tests/filter_status_code.cc
+++ b/test/core/end2end/tests/filter_status_code.cc
@@ -16,6 +16,14 @@
*
*/
+/* This test verifies -
+ * 1) grpc_call_final_info passed to the filters on destroying a call contains
+ * the proper status.
+ * 2) If the response has both an HTTP status code and a gRPC status code, then
+ * we should prefer the gRPC status code as mentioned in
+ * https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md
+ */
+
#include "test/core/end2end/end2end_tests.h"
#include <limits.h>
@@ -249,6 +257,22 @@ typedef struct final_status_data {
grpc_call_stack* call;
} final_status_data;
+static void server_start_transport_stream_op_batch(
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
+ auto* data = static_cast<final_status_data*>(elem->call_data);
+ if (data->call == g_server_call_stack) {
+ if (op->send_initial_metadata) {
+ auto* batch = op->payload->send_initial_metadata.send_initial_metadata;
+ if (batch->idx.named.status != nullptr) {
+ /* Replace the HTTP status with 404 */
+ grpc_metadata_batch_substitute(batch, batch->idx.named.status,
+ GRPC_MDELEM_STATUS_404);
+ }
+ }
+ }
+ grpc_call_next_op(elem, op);
+}
+
static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
final_status_data* data = static_cast<final_status_data*>(elem->call_data);
@@ -307,7 +331,7 @@ static const grpc_channel_filter test_client_filter = {
"client_filter_status_code"};
static const grpc_channel_filter test_server_filter = {
- grpc_call_next_op,
+ server_start_transport_stream_op_batch,
grpc_channel_next_op,
sizeof(final_status_data),
init_call_elem,
diff --git a/test/core/end2end/tests/no_error_on_hotpath.cc b/test/core/end2end/tests/no_error_on_hotpath.cc
new file mode 100644
index 0000000000..7afadf7d3a
--- /dev/null
+++ b/test/core/end2end/tests/no_error_on_hotpath.cc
@@ -0,0 +1,246 @@
+/*
+ *
+ * Copyright 2016 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/end2end/end2end_tests.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/byte_buffer.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/time.h>
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/iomgr/error.h"
+#include "test/core/end2end/cq_verifier.h"
+
+static void* tag(intptr_t t) { return (void*)t; }
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char* test_name,
+ grpc_channel_args* client_args,
+ grpc_channel_args* server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_server(&f, server_args);
+ config.init_client(&f, client_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_from_now(int n) {
+ return grpc_timeout_seconds_to_deadline(n);
+}
+
+static gpr_timespec five_seconds_from_now(void) {
+ return n_seconds_from_now(5);
+}
+
+static void drain_cq(grpc_completion_queue* cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, five_seconds_from_now(), nullptr);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture* f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000),
+ grpc_timeout_seconds_to_deadline(5),
+ nullptr)
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = nullptr;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture* f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = nullptr;
+}
+
+static void end_test(grpc_end2end_test_fixture* f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+ grpc_completion_queue_destroy(f->shutdown_cq);
+}
+
+static void simple_request_body(grpc_end2end_test_config config,
+ grpc_end2end_test_fixture f) {
+ grpc_call* c;
+ grpc_call* s;
+ cq_verifier* cqv = cq_verifier_create(f.cq);
+ grpc_op ops[6];
+ grpc_op* op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ grpc_call_error error;
+ grpc_slice details;
+ int was_cancelled = 2;
+ char* peer;
+
+ gpr_timespec deadline = five_seconds_from_now();
+ c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ grpc_slice_from_static_string("/foo"), nullptr,
+ deadline, nullptr);
+ GPR_ASSERT(c);
+
+ peer = grpc_call_get_peer(c);
+ GPR_ASSERT(peer != nullptr);
+ gpr_free(peer);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ 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_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ error =
+ grpc_server_request_call(f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(101));
+ GPR_ASSERT(GRPC_CALL_OK == error);
+ CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
+ cq_verify(cqv);
+
+ peer = grpc_call_get_peer(s);
+ GPR_ASSERT(peer != nullptr);
+ gpr_free(peer);
+ peer = grpc_call_get_peer(c);
+ GPR_ASSERT(peer != nullptr);
+ gpr_free(peer);
+
+ 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_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_OK;
+ op->data.send_status_from_server.status_details = nullptr;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
+ CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(status == GRPC_STATUS_OK);
+ GPR_ASSERT(GRPC_SLICE_LENGTH(details) == 0);
+ GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
+ GPR_ASSERT(0 == call_details.flags);
+ GPR_ASSERT(was_cancelled == 0);
+
+ grpc_slice_unref(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_unref(c);
+ grpc_call_unref(s);
+
+ cq_verifier_destroy(cqv);
+}
+
+static void test_no_error_on_hotpath_one_request(
+ grpc_end2end_test_config config) {
+ grpc_end2end_test_fixture f;
+
+ f = begin_test(config, "test_invoke_simple_request_with_no_error_logging",
+ nullptr, nullptr);
+ // First RPC is not considered the hotpath, since there are lots of things to
+ // set up.
+ simple_request_body(config, f);
+ grpc_disable_error_creation();
+ simple_request_body(config, f);
+ grpc_enable_error_creation();
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+static void test_no_error_on_hotpath_10_requests(
+ grpc_end2end_test_config config) {
+ int i;
+ grpc_end2end_test_fixture f = begin_test(
+ config, "test_no_error_on_hotpath_in_one_request", nullptr, nullptr);
+ // First RPC is not considered the hotpath, since there are lots of things to
+ // set up.
+ simple_request_body(config, f);
+ grpc_disable_error_creation();
+ for (i = 0; i < 10; i++) {
+ simple_request_body(config, f);
+ }
+ grpc_enable_error_creation();
+ end_test(&f);
+ config.tear_down_data(&f);
+}
+
+void no_error_on_hotpath(grpc_end2end_test_config config) {
+ test_no_error_on_hotpath_one_request(config);
+ test_no_error_on_hotpath_10_requests(config);
+}
+
+void no_error_on_hotpath_pre_init(void) {}
diff --git a/test/core/end2end/tests/retry_server_pushback_delay.cc b/test/core/end2end/tests/retry_server_pushback_delay.cc
index f6a979613d..221b416828 100644
--- a/test/core/end2end/tests/retry_server_pushback_delay.cc
+++ b/test/core/end2end/tests/retry_server_pushback_delay.cc
@@ -249,7 +249,7 @@ static void test_retry_server_pushback_delay(grpc_end2end_test_config config) {
retry_delay.tv_sec, retry_delay.tv_nsec);
GPR_ASSERT(retry_delay.tv_sec >= 1);
if (retry_delay.tv_sec == 1) {
- GPR_ASSERT(retry_delay.tv_nsec >= 900000000);
+ GPR_ASSERT(retry_delay.tv_nsec >= 800000000);
}
peer = grpc_call_get_peer(s);
diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc
index 2d6ccad0ec..941d9ae319 100644
--- a/test/core/end2end/tests/simple_request.cc
+++ b/test/core/end2end/tests/simple_request.cc
@@ -235,12 +235,14 @@ static void simple_request_body(grpc_end2end_test_config config,
if (config.feature_mask & FEATURE_MASK_SUPPORTS_REQUEST_PROXYING) {
expected_calls *= 2;
}
+#if defined(GRPC_COLLECT_STATS) || !defined(NDEBUG)
GPR_ASSERT(after->counters[GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED] -
before->counters[GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED] ==
expected_calls);
GPR_ASSERT(after->counters[GRPC_STATS_COUNTER_SERVER_CALLS_CREATED] -
before->counters[GRPC_STATS_COUNTER_SERVER_CALLS_CREATED] ==
expected_calls);
+#endif /* defined(GRPC_COLLECT_STATS) || !defined(NDEBUG) */
gpr_free(before);
gpr_free(after);
}
diff --git a/test/core/gpr/BUILD b/test/core/gpr/BUILD
index 5308ea0934..d58d4f2a14 100644
--- a/test/core/gpr/BUILD
+++ b/test/core/gpr/BUILD
@@ -86,6 +86,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:gpr_test_util",
],
+ data = ["//third_party/toolchains:RBE_USE_MACHINE_TYPE_LARGE"],
)
grpc_cc_test(
diff --git a/test/core/gpr/arena_test.cc b/test/core/gpr/arena_test.cc
index 111414ea3e..3e7c906591 100644
--- a/test/core/gpr/arena_test.cc
+++ b/test/core/gpr/arena_test.cc
@@ -71,7 +71,7 @@ static void test(const char* name, size_t init_size, const size_t* allocs,
static const size_t allocs_##name[] = {__VA_ARGS__}; \
test(#name, init_size, allocs_##name, GPR_ARRAY_SIZE(allocs_##name))
-#define CONCURRENT_TEST_THREADS 100
+#define CONCURRENT_TEST_THREADS 10
size_t concurrent_test_iterations() {
if (sizeof(void*) < 8) return 1000;
diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD
index a8a5739552..e7232d9df8 100644
--- a/test/core/gprpp/BUILD
+++ b/test/core/gprpp/BUILD
@@ -19,6 +19,16 @@ licenses(["notice"]) # Apache v2
grpc_package(name = "test/core/gprpp")
grpc_cc_test(
+ name = "fork_test",
+ srcs = ["fork_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//test/core/util:gpr_test_util",
+ ],
+)
+
+grpc_cc_test(
name = "manual_constructor_test",
srcs = ["manual_constructor_test.cc"],
language = "C++",
diff --git a/test/core/gprpp/fork_test.cc b/test/core/gprpp/fork_test.cc
new file mode 100644
index 0000000000..642f910489
--- /dev/null
+++ b/test/core/gprpp/fork_test.cc
@@ -0,0 +1,139 @@
+/*
+ *
+ * Copyright 2017 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 "src/core/lib/gprpp/fork.h"
+
+#include "src/core/lib/gprpp/thd.h"
+#include "test/core/util/test_config.h"
+
+static void test_init() {
+ GPR_ASSERT(!grpc_core::Fork::Enabled());
+
+ // Default fork support (disabled)
+ grpc_core::Fork::GlobalInit();
+ GPR_ASSERT(!grpc_core::Fork::Enabled());
+ grpc_core::Fork::GlobalShutdown();
+
+ // Explicitly disabled fork support
+ grpc_core::Fork::Enable(false);
+ grpc_core::Fork::GlobalInit();
+ GPR_ASSERT(!grpc_core::Fork::Enabled());
+ grpc_core::Fork::GlobalShutdown();
+
+ // Explicitly enabled fork support
+ grpc_core::Fork::Enable(true);
+ grpc_core::Fork::GlobalInit();
+ GPR_ASSERT(grpc_core::Fork::Enabled());
+ grpc_core::Fork::GlobalShutdown();
+}
+
+// This spawns CONCURRENT_TEST_THREADS that last up to
+// THREAD_DELAY_MS, and checks that the Fork::AwaitThreads()
+// returns roughly after THREAD_DELAY_MS. The epsilon is high
+// because tsan threads can take a while to spawn/join.
+#define THREAD_DELAY_MS 6000
+#define THREAD_DELAY_EPSILON 1500
+#define CONCURRENT_TEST_THREADS 100
+
+static void sleeping_thd(void* arg) {
+ int64_t sleep_ms = (int64_t)arg;
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(sleep_ms, GPR_TIMESPAN)));
+}
+
+static void test_thd_count() {
+ // Test no active threads
+ grpc_core::Fork::Enable(true);
+ grpc_core::Fork::GlobalInit();
+ grpc_core::Fork::AwaitThreads();
+ grpc_core::Fork::GlobalShutdown();
+
+ grpc_core::Fork::Enable(true);
+ grpc_core::Fork::GlobalInit();
+ grpc_core::Thread thds[CONCURRENT_TEST_THREADS];
+ gpr_timespec est_end_time =
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(THREAD_DELAY_MS, GPR_TIMESPAN));
+ gpr_timespec tolerance =
+ gpr_time_from_millis(THREAD_DELAY_EPSILON, GPR_TIMESPAN);
+ for (int i = 0; i < CONCURRENT_TEST_THREADS; i++) {
+ intptr_t sleep_time_ms =
+ (i * THREAD_DELAY_MS) / (CONCURRENT_TEST_THREADS - 1);
+ thds[i] =
+ grpc_core::Thread("grpc_fork_test", sleeping_thd, (void*)sleep_time_ms);
+ thds[i].Start();
+ }
+ grpc_core::Fork::AwaitThreads();
+ gpr_timespec end_time = gpr_now(GPR_CLOCK_REALTIME);
+ for (auto& thd : thds) {
+ thd.Join();
+ }
+ GPR_ASSERT(gpr_time_similar(end_time, est_end_time, tolerance));
+ grpc_core::Fork::GlobalShutdown();
+}
+
+static void exec_ctx_thread(void* arg) {
+ bool* exec_ctx_created = (bool*)arg;
+ grpc_core::Fork::IncExecCtxCount();
+ *exec_ctx_created = true;
+}
+
+static void test_exec_count() {
+ grpc_core::Fork::Enable(true);
+ grpc_core::Fork::GlobalInit();
+
+ grpc_core::Fork::IncExecCtxCount();
+ GPR_ASSERT(grpc_core::Fork::BlockExecCtx());
+ grpc_core::Fork::DecExecCtxCount();
+ grpc_core::Fork::AllowExecCtx();
+
+ grpc_core::Fork::IncExecCtxCount();
+ grpc_core::Fork::IncExecCtxCount();
+ GPR_ASSERT(!grpc_core::Fork::BlockExecCtx());
+ grpc_core::Fork::DecExecCtxCount();
+ grpc_core::Fork::DecExecCtxCount();
+
+ grpc_core::Fork::IncExecCtxCount();
+ GPR_ASSERT(grpc_core::Fork::BlockExecCtx());
+ grpc_core::Fork::DecExecCtxCount();
+ grpc_core::Fork::AllowExecCtx();
+
+ // Test that block_exec_ctx() blocks grpc_core::Fork::IncExecCtxCount
+ bool exec_ctx_created = false;
+ grpc_core::Thread thd =
+ grpc_core::Thread("grpc_fork_test", exec_ctx_thread, &exec_ctx_created);
+ grpc_core::Fork::IncExecCtxCount();
+ GPR_ASSERT(grpc_core::Fork::BlockExecCtx());
+ grpc_core::Fork::DecExecCtxCount();
+ thd.Start();
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(1, GPR_TIMESPAN)));
+ GPR_ASSERT(!exec_ctx_created);
+ grpc_core::Fork::AllowExecCtx();
+ thd.Join(); // This ensure that the call got un-blocked
+ grpc_core::Fork::GlobalShutdown();
+}
+
+int main(int argc, char* argv[]) {
+ grpc_test_init(argc, argv);
+ test_init();
+ test_thd_count();
+ test_exec_count();
+
+ return 0;
+}
diff --git a/test/core/gprpp/inlined_vector_test.cc b/test/core/gprpp/inlined_vector_test.cc
index ae34947718..e9d1eb2c76 100644
--- a/test/core/gprpp/inlined_vector_test.cc
+++ b/test/core/gprpp/inlined_vector_test.cc
@@ -17,20 +17,34 @@
*/
#include "src/core/lib/gprpp/inlined_vector.h"
+#include <grpc/support/log.h>
#include <gtest/gtest.h>
#include "src/core/lib/gprpp/memory.h"
#include "test/core/util/test_config.h"
namespace grpc_core {
namespace testing {
+namespace {
+
+template <typename Vector>
+static void FillVector(Vector* v, int len, int start = 0) {
+ for (int i = 0; i < len; i++) {
+ v->push_back(i + start);
+ EXPECT_EQ(i + 1UL, v->size());
+ }
+ EXPECT_EQ(static_cast<size_t>(len), v->size());
+ EXPECT_LE(static_cast<size_t>(len), v->capacity());
+}
+
+} // namespace
TEST(InlinedVectorTest, CreateAndIterate) {
const int kNumElements = 9;
InlinedVector<int, 2> v;
- for (int i = 0; i < kNumElements; ++i) {
- v.push_back(i);
- }
+ EXPECT_TRUE(v.empty());
+ FillVector(&v, kNumElements);
EXPECT_EQ(static_cast<size_t>(kNumElements), v.size());
+ EXPECT_FALSE(v.empty());
for (int i = 0; i < kNumElements; ++i) {
EXPECT_EQ(i, v[i]);
EXPECT_EQ(i, &v[i] - &v[0]); // Ensure contiguous allocation.
@@ -40,9 +54,7 @@ TEST(InlinedVectorTest, CreateAndIterate) {
TEST(InlinedVectorTest, ValuesAreInlined) {
const int kNumElements = 5;
InlinedVector<int, 10> v;
- for (int i = 0; i < kNumElements; ++i) {
- v.push_back(i);
- }
+ FillVector(&v, kNumElements);
EXPECT_EQ(static_cast<size_t>(kNumElements), v.size());
for (int i = 0; i < kNumElements; ++i) {
EXPECT_EQ(i, v[i]);
@@ -69,19 +81,13 @@ TEST(InlinedVectorTest, ClearAndRepopulate) {
const int kNumElements = 10;
InlinedVector<int, 5> v;
EXPECT_EQ(0UL, v.size());
- for (int i = 0; i < kNumElements; ++i) {
- v.push_back(i);
- EXPECT_EQ(i + 1UL, v.size());
- }
+ FillVector(&v, kNumElements);
for (int i = 0; i < kNumElements; ++i) {
EXPECT_EQ(i, v[i]);
}
v.clear();
EXPECT_EQ(0UL, v.size());
- for (int i = 0; i < kNumElements; ++i) {
- v.push_back(kNumElements + i);
- EXPECT_EQ(i + 1UL, v.size());
- }
+ FillVector(&v, kNumElements, kNumElements);
for (int i = 0; i < kNumElements; ++i) {
EXPECT_EQ(kNumElements + i, v[i]);
}
@@ -91,10 +97,7 @@ TEST(InlinedVectorTest, ConstIndexOperator) {
constexpr int kNumElements = 10;
InlinedVector<int, 5> v;
EXPECT_EQ(0UL, v.size());
- for (int i = 0; i < kNumElements; ++i) {
- v.push_back(i);
- EXPECT_EQ(i + 1UL, v.size());
- }
+ FillVector(&v, kNumElements);
// The following lambda function is exceptionally allowed to use an anonymous
// capture due to the erroneous behavior of the MSVC compiler, that refuses to
// capture the kNumElements constexpr, something allowed by the standard.
@@ -106,6 +109,161 @@ TEST(InlinedVectorTest, ConstIndexOperator) {
const_func(v);
}
+// the following constants and typedefs are used for copy/move
+// construction/assignment
+const size_t kInlinedLength = 8;
+typedef InlinedVector<int, kInlinedLength> IntVec8;
+const size_t kInlinedFillSize = kInlinedLength - 1;
+const size_t kAllocatedFillSize = kInlinedLength + 1;
+
+TEST(InlinedVectorTest, CopyConstructerInlined) {
+ IntVec8 original;
+ FillVector(&original, kInlinedFillSize);
+ IntVec8 copy_constructed(original);
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], copy_constructed[i]);
+ }
+}
+
+TEST(InlinedVectorTest, CopyConstructerAllocated) {
+ IntVec8 original;
+ FillVector(&original, kAllocatedFillSize);
+ IntVec8 copy_constructed(original);
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], copy_constructed[i]);
+ }
+}
+
+TEST(InlinedVectorTest, CopyAssignementInlinedInlined) {
+ IntVec8 original;
+ FillVector(&original, kInlinedFillSize);
+ IntVec8 copy_assigned;
+ FillVector(&copy_assigned, kInlinedFillSize, 99);
+ copy_assigned = original;
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], copy_assigned[i]);
+ }
+}
+
+TEST(InlinedVectorTest, CopyAssignementInlinedAllocated) {
+ IntVec8 original;
+ FillVector(&original, kInlinedFillSize);
+ IntVec8 copy_assigned;
+ FillVector(&copy_assigned, kAllocatedFillSize, 99);
+ copy_assigned = original;
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], copy_assigned[i]);
+ }
+}
+
+TEST(InlinedVectorTest, CopyAssignementAllocatedInlined) {
+ IntVec8 original;
+ FillVector(&original, kAllocatedFillSize);
+ IntVec8 copy_assigned;
+ FillVector(&copy_assigned, kInlinedFillSize, 99);
+ copy_assigned = original;
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], copy_assigned[i]);
+ }
+}
+
+TEST(InlinedVectorTest, CopyAssignementAllocatedAllocated) {
+ IntVec8 original;
+ FillVector(&original, kAllocatedFillSize);
+ IntVec8 copy_assigned;
+ FillVector(&copy_assigned, kAllocatedFillSize, 99);
+ copy_assigned = original;
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], copy_assigned[i]);
+ }
+}
+
+TEST(InlinedVectorTest, MoveConstructorInlined) {
+ IntVec8 original;
+ FillVector(&original, kInlinedFillSize);
+ IntVec8 tmp(original);
+ auto* old_data = tmp.data();
+ IntVec8 move_constructed(std::move(tmp));
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], move_constructed[i]);
+ }
+ // original data was inlined so it should have been copied, not moved.
+ EXPECT_NE(move_constructed.data(), old_data);
+}
+
+TEST(InlinedVectorTest, MoveConstructorAllocated) {
+ IntVec8 original;
+ FillVector(&original, kAllocatedFillSize);
+ IntVec8 tmp(original);
+ auto* old_data = tmp.data();
+ IntVec8 move_constructed(std::move(tmp));
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], move_constructed[i]);
+ }
+ // original data was allocated, so it should been moved, not copied
+ EXPECT_EQ(move_constructed.data(), old_data);
+}
+
+TEST(InlinedVectorTest, MoveAssignmentInlinedInlined) {
+ IntVec8 original;
+ FillVector(&original, kInlinedFillSize);
+ IntVec8 move_assigned;
+ FillVector(&move_assigned, kInlinedFillSize, 99); // Add dummy elements
+ IntVec8 tmp(original);
+ auto* old_data = tmp.data();
+ move_assigned = std::move(tmp);
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], move_assigned[i]);
+ }
+ // original data was inlined so it should have been copied, not moved.
+ EXPECT_NE(move_assigned.data(), old_data);
+}
+
+TEST(InlinedVectorTest, MoveAssignmentInlinedAllocated) {
+ IntVec8 original;
+ FillVector(&original, kInlinedFillSize);
+ IntVec8 move_assigned;
+ FillVector(&move_assigned, kAllocatedFillSize, 99); // Add dummy elements
+ IntVec8 tmp(original);
+ auto* old_data = tmp.data();
+ move_assigned = std::move(tmp);
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], move_assigned[i]);
+ }
+ // original data was inlined so it should have been copied, not moved.
+ EXPECT_NE(move_assigned.data(), old_data);
+}
+
+TEST(InlinedVectorTest, MoveAssignmentAllocatedInlined) {
+ IntVec8 original;
+ FillVector(&original, kAllocatedFillSize);
+ IntVec8 move_assigned;
+ FillVector(&move_assigned, kInlinedFillSize, 99); // Add dummy elements
+ IntVec8 tmp(original);
+ auto* old_data = tmp.data();
+ move_assigned = std::move(tmp);
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], move_assigned[i]);
+ }
+ // original data was allocated so it should have been moved, not copied.
+ EXPECT_EQ(move_assigned.data(), old_data);
+}
+
+TEST(InlinedVectorTest, MoveAssignmentAllocatedAllocated) {
+ IntVec8 original;
+ FillVector(&original, kAllocatedFillSize);
+ IntVec8 move_assigned;
+ FillVector(&move_assigned, kAllocatedFillSize, 99); // Add dummy elements
+ IntVec8 tmp(original);
+ auto* old_data = tmp.data();
+ move_assigned = std::move(tmp);
+ for (size_t i = 0; i < original.size(); ++i) {
+ EXPECT_EQ(original[i], move_assigned[i]);
+ }
+ // original data was allocated so it should have been moved, not copied.
+ EXPECT_EQ(move_assigned.data(), old_data);
+}
+
} // namespace testing
} // namespace grpc_core
diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc
index c810345166..463b5e8966 100644
--- a/test/core/gprpp/ref_counted_ptr_test.cc
+++ b/test/core/gprpp/ref_counted_ptr_test.cc
@@ -66,14 +66,14 @@ TEST(RefCountedPtr, MoveAssignment) {
TEST(RefCountedPtr, CopyConstructor) {
RefCountedPtr<Foo> foo(New<Foo>());
- RefCountedPtr<Foo> foo2(foo);
+ const RefCountedPtr<Foo>& foo2(foo);
EXPECT_NE(nullptr, foo.get());
EXPECT_EQ(foo.get(), foo2.get());
}
TEST(RefCountedPtr, CopyAssignment) {
RefCountedPtr<Foo> foo(New<Foo>());
- RefCountedPtr<Foo> foo2 = foo;
+ const RefCountedPtr<Foo>& foo2 = foo;
EXPECT_NE(nullptr, foo.get());
EXPECT_EQ(foo.get(), foo2.get());
}
@@ -127,7 +127,7 @@ TEST(RefCountedPtr, ResetFromNonNullToNull) {
TEST(RefCountedPtr, ResetFromNullToNull) {
RefCountedPtr<Foo> foo;
EXPECT_EQ(nullptr, foo.get());
- foo.reset(nullptr);
+ foo.reset();
EXPECT_EQ(nullptr, foo.get());
}
@@ -175,6 +175,67 @@ TEST(RefCountedPtr, RefCountedWithTracing) {
foo->Unref(DEBUG_LOCATION, "foo");
}
+class BaseClass : public RefCounted<BaseClass> {
+ public:
+ BaseClass() {}
+};
+
+class Subclass : public BaseClass {
+ public:
+ Subclass() {}
+};
+
+TEST(RefCountedPtr, ConstructFromSubclass) {
+ RefCountedPtr<BaseClass> p(New<Subclass>());
+}
+
+TEST(RefCountedPtr, CopyAssignFromSubclass) {
+ RefCountedPtr<BaseClass> b;
+ EXPECT_EQ(nullptr, b.get());
+ RefCountedPtr<Subclass> s = MakeRefCounted<Subclass>();
+ b = s;
+ EXPECT_NE(nullptr, b.get());
+}
+
+TEST(RefCountedPtr, MoveAssignFromSubclass) {
+ RefCountedPtr<BaseClass> b;
+ EXPECT_EQ(nullptr, b.get());
+ RefCountedPtr<Subclass> s = MakeRefCounted<Subclass>();
+ b = std::move(s);
+ EXPECT_NE(nullptr, b.get());
+}
+
+TEST(RefCountedPtr, ResetFromSubclass) {
+ RefCountedPtr<BaseClass> b;
+ EXPECT_EQ(nullptr, b.get());
+ b.reset(New<Subclass>());
+ EXPECT_NE(nullptr, b.get());
+}
+
+TEST(RefCountedPtr, EqualityWithSubclass) {
+ Subclass* s = New<Subclass>();
+ RefCountedPtr<BaseClass> b(s);
+ EXPECT_EQ(b, s);
+}
+
+void FunctionTakingBaseClass(RefCountedPtr<BaseClass> p) {
+ p.reset(); // To appease clang-tidy.
+}
+
+TEST(RefCountedPtr, CanPassSubclassToFunctionExpectingBaseClass) {
+ RefCountedPtr<Subclass> p = MakeRefCounted<Subclass>();
+ FunctionTakingBaseClass(p);
+}
+
+void FunctionTakingSubclass(RefCountedPtr<Subclass> p) {
+ p.reset(); // To appease clang-tidy.
+}
+
+TEST(RefCountedPtr, CanPassSubclassToFunctionExpectingSubclass) {
+ RefCountedPtr<Subclass> p = MakeRefCounted<Subclass>();
+ FunctionTakingSubclass(p);
+}
+
} // namespace
} // namespace testing
} // namespace grpc_core
diff --git a/test/core/handshake/BUILD b/test/core/handshake/BUILD
index a3276b9343..712cd59197 100644
--- a/test/core/handshake/BUILD
+++ b/test/core/handshake/BUILD
@@ -82,3 +82,21 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
],
)
+
+grpc_cc_test(
+ name = "handshake_verify_peer_options",
+ srcs = ["verify_peer_options.cc"],
+ language = "C++",
+ data = [
+ "//src/core/tsi/test_creds:ca.pem",
+ "//src/core/tsi/test_creds:server1.key",
+ "//src/core/tsi/test_creds:server1.pem",
+ ],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
diff --git a/test/core/handshake/client_ssl.cc b/test/core/handshake/client_ssl.cc
index 8ac763ac4b..467df6e229 100644
--- a/test/core/handshake/client_ssl.cc
+++ b/test/core/handshake/client_ssl.cc
@@ -251,8 +251,8 @@ static bool client_ssl_test(char* server_alpn_preferred) {
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain =
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice);
- grpc_channel_credentials* ssl_creds =
- grpc_ssl_credentials_create(ca_cert, &pem_key_cert_pair, nullptr);
+ grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(
+ ca_cert, &pem_key_cert_pair, nullptr, nullptr);
// Establish a channel pointing at the TLS server. Since the gRPC runtime is
// lazy, this won't necessarily establish a connection yet.
diff --git a/test/core/handshake/verify_peer_options.cc b/test/core/handshake/verify_peer_options.cc
new file mode 100644
index 0000000000..86c524b4a5
--- /dev/null
+++ b/test/core/handshake/verify_peer_options.cc
@@ -0,0 +1,275 @@
+/*
+ *
+ * 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 "src/core/lib/iomgr/port.h"
+
+// This test won't work except with posix sockets enabled
+#ifdef GRPC_POSIX_SOCKET
+
+#include <arpa/inet.h>
+#include <openssl/err.h>
+#include <openssl/ssl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include <grpc/grpc.h>
+#include <grpc/grpc_security.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/lib/gprpp/thd.h"
+#include "src/core/lib/iomgr/load_file.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+#define SSL_CERT_PATH "src/core/tsi/test_creds/server1.pem"
+#define SSL_KEY_PATH "src/core/tsi/test_creds/server1.key"
+#define SSL_CA_PATH "src/core/tsi/test_creds/ca.pem"
+
+// Simple gRPC server. This listens until client_handshake_complete occurs.
+static gpr_event client_handshake_complete;
+
+static void server_thread(void* arg) {
+ const int port = *static_cast<int*>(arg);
+
+ // Load key pair and establish server SSL credentials.
+ grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
+ grpc_slice ca_slice, cert_slice, key_slice;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(SSL_CA_PATH, 1, &ca_slice)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
+ const char* ca_cert =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(ca_slice);
+ pem_key_cert_pair.private_key =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice);
+ grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
+ ca_cert, &pem_key_cert_pair, 1, 0, nullptr);
+
+ // Start server listening on local port.
+ char* addr;
+ gpr_asprintf(&addr, "127.0.0.1:%d", port);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
+ GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds));
+ free(addr);
+
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+
+ grpc_server_register_completion_queue(server, cq, nullptr);
+ grpc_server_start(server);
+
+ // Wait a bounded number of time until client_handshake_complete is set,
+ // sleeping between polls. The total time spent (deadline * retries)
+ // should be strictly greater than the client retry limit so that the
+ // client will always timeout first.
+ int retries = 60;
+ while (!gpr_event_get(&client_handshake_complete) && retries-- > 0) {
+ const gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(1);
+ grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
+ }
+
+ gpr_log(GPR_INFO, "Shutting down server");
+ grpc_server_shutdown_and_notify(server, cq, nullptr);
+ grpc_server_cancel_all_calls(server);
+ grpc_completion_queue_shutdown(cq);
+
+ const gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(60);
+ grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, nullptr);
+ GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
+
+ grpc_server_destroy(server);
+ grpc_completion_queue_destroy(cq);
+ grpc_server_credentials_release(ssl_creds);
+ grpc_slice_unref(cert_slice);
+ grpc_slice_unref(key_slice);
+ grpc_slice_unref(ca_slice);
+}
+
+// This test launches a minimal TLS grpc server on a separate thread and then
+// establishes a TLS handshake via the core library to the server. The client
+// uses the supplied verify options.
+static bool verify_peer_options_test(verify_peer_options* verify_options) {
+ bool success = true;
+
+ grpc_init();
+ int port = grpc_pick_unused_port_or_die();
+ gpr_event_init(&client_handshake_complete);
+
+ // Launch the gRPC server thread.
+ bool ok;
+ grpc_core::Thread thd("grpc_client_ssl_test", server_thread, &port, &ok);
+ GPR_ASSERT(ok);
+ thd.Start();
+
+ // Load key pair and establish client SSL credentials.
+ grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
+ grpc_slice ca_slice, cert_slice, key_slice;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(SSL_CA_PATH, 1, &ca_slice)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
+ const char* ca_cert =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(ca_slice);
+ pem_key_cert_pair.private_key =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice);
+ grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(
+ ca_cert, &pem_key_cert_pair, verify_options, nullptr);
+
+ // Establish a channel pointing at the TLS server. Since the gRPC runtime is
+ // lazy, this won't necessarily establish a connection yet.
+ char* target;
+ gpr_asprintf(&target, "127.0.0.1:%d", port);
+ grpc_arg ssl_name_override = {
+ GRPC_ARG_STRING,
+ const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
+ {const_cast<char*>("foo.test.google.fr")}};
+ grpc_channel_args grpc_args;
+ grpc_args.num_args = 1;
+ grpc_args.args = &ssl_name_override;
+ grpc_channel* channel =
+ grpc_secure_channel_create(ssl_creds, target, &grpc_args, nullptr);
+ GPR_ASSERT(channel);
+ gpr_free(target);
+
+ // Initially the channel will be idle, the
+ // grpc_channel_check_connectivity_state triggers an attempt to connect.
+ GPR_ASSERT(grpc_channel_check_connectivity_state(
+ channel, 1 /* try_to_connect */) == GRPC_CHANNEL_IDLE);
+
+ // Wait a bounded number of times for the channel to be ready. When the
+ // channel is ready, the initial TLS handshake will have successfully
+ // completed. The total time spent on the client side (retries * deadline)
+ // should be greater than the server side time limit.
+ int retries = 10;
+ grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+
+ while (state != GRPC_CHANNEL_READY && retries-- > 0) {
+ grpc_channel_watch_connectivity_state(
+ channel, state, grpc_timeout_seconds_to_deadline(3), cq, nullptr);
+ gpr_timespec cq_deadline = grpc_timeout_seconds_to_deadline(5);
+ grpc_event ev = grpc_completion_queue_next(cq, cq_deadline, nullptr);
+ GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
+ state =
+ grpc_channel_check_connectivity_state(channel, 0 /* try_to_connect */);
+ }
+ grpc_completion_queue_destroy(cq);
+ if (retries < 0) {
+ success = false;
+ }
+
+ grpc_channel_destroy(channel);
+ grpc_channel_credentials_release(ssl_creds);
+ grpc_slice_unref(cert_slice);
+ grpc_slice_unref(key_slice);
+ grpc_slice_unref(ca_slice);
+
+ // Now that the client is completely cleaned up, trigger the server to
+ // shutdown
+ gpr_event_set(&client_handshake_complete, &client_handshake_complete);
+ // Wait for the server to completely shutdown
+ thd.Join();
+
+ grpc_shutdown();
+
+ return success;
+}
+
+static int callback_return_value = 0;
+static char callback_target_host[4096];
+static char callback_target_pem[4096];
+static void* callback_userdata = nullptr;
+static void* destruct_userdata = nullptr;
+
+static int verify_callback(const char* target_host, const char* target_pem,
+ void* userdata) {
+ if (target_host != nullptr) {
+ snprintf(callback_target_host, sizeof(callback_target_host), "%s",
+ target_host);
+ } else {
+ callback_target_host[0] = '\0';
+ }
+ if (target_pem != nullptr) {
+ snprintf(callback_target_pem, sizeof(callback_target_pem), "%s",
+ target_pem);
+ } else {
+ callback_target_pem[0] = '\0';
+ }
+ callback_userdata = userdata;
+ return callback_return_value;
+}
+
+static void verify_destruct(void* userdata) { destruct_userdata = userdata; }
+
+int main(int argc, char* argv[]) {
+ int userdata = 42;
+ verify_peer_options verify_options;
+
+ // Load the server's cert so that we can assert it gets passed to the callback
+ grpc_slice cert_slice;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
+ const char* server_cert =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice);
+
+ // Running with all-null values should have no effect
+ verify_options.verify_peer_callback = nullptr;
+ verify_options.verify_peer_callback_userdata = nullptr;
+ verify_options.verify_peer_destruct = nullptr;
+ GPR_ASSERT(verify_peer_options_test(&verify_options));
+ GPR_ASSERT(strlen(callback_target_host) == 0);
+ GPR_ASSERT(strlen(callback_target_pem) == 0);
+ GPR_ASSERT(callback_userdata == nullptr);
+ GPR_ASSERT(destruct_userdata == nullptr);
+
+ // Running with the callbacks and verify we get the expected values
+ verify_options.verify_peer_callback = verify_callback;
+ verify_options.verify_peer_callback_userdata = static_cast<void*>(&userdata);
+ verify_options.verify_peer_destruct = verify_destruct;
+ GPR_ASSERT(verify_peer_options_test(&verify_options));
+ GPR_ASSERT(strcmp(callback_target_host, "foo.test.google.fr") == 0);
+ GPR_ASSERT(strcmp(callback_target_pem, server_cert) == 0);
+ GPR_ASSERT(callback_userdata == static_cast<void*>(&userdata));
+ GPR_ASSERT(destruct_userdata == static_cast<void*>(&userdata));
+
+ // If the callback returns non-zero, initializing the channel should fail.
+ callback_return_value = 1;
+ GPR_ASSERT(!verify_peer_options_test(&verify_options));
+
+ grpc_slice_unref(cert_slice);
+
+ return 0;
+}
+
+#else /* GRPC_POSIX_SOCKET */
+
+int main(int argc, char** argv) { return 1; }
+
+#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc
index 16448d9e14..a51a0a5f6d 100644
--- a/test/core/http/httpcli_test.cc
+++ b/test/core/http/httpcli_test.cc
@@ -47,7 +47,8 @@ static void on_finish(void* arg, grpc_error* error) {
"<body><p>This is a test</p></body></html>";
grpc_http_response* response = static_cast<grpc_http_response*>(arg);
GPR_ASSERT(response);
- gpr_log(GPR_INFO, "response status %d", response->status);
+ gpr_log(GPR_INFO, "response status=%d error=%s", response->status,
+ grpc_error_string(error));
GPR_ASSERT(response->status == 200);
GPR_ASSERT(response->body_length == strlen(expect));
GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length));
diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc
index b8f2e438a4..3fecf2b08b 100644
--- a/test/core/http/httpscli_test.cc
+++ b/test/core/http/httpscli_test.cc
@@ -49,7 +49,8 @@ static void on_finish(void* arg, grpc_error* error) {
"<body><p>This is a test</p></body></html>";
grpc_http_response* response = static_cast<grpc_http_response*>(arg);
GPR_ASSERT(response);
- gpr_log(GPR_INFO, "response status %d", response->status);
+ gpr_log(GPR_INFO, "response status=%d error=%s", response->status,
+ grpc_error_string(error));
GPR_ASSERT(response->status == 200);
GPR_ASSERT(response->body_length == strlen(expect));
GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length));
diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD
index 349a06d578..70ee83acd2 100644
--- a/test/core/iomgr/BUILD
+++ b/test/core/iomgr/BUILD
@@ -18,7 +18,10 @@ licenses(["notice"]) # Apache v2
load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
-grpc_package(name = "test/core/iomgr", visibility = "public") # Useful for third party devs to test their io manager implementation.
+grpc_package(
+ name = "test/core/iomgr",
+ visibility = "public",
+) # Useful for third party devs to test their io manager implementation.
grpc_cc_library(
name = "endpoint_tests",
@@ -37,6 +40,7 @@ grpc_cc_library(
grpc_cc_test(
name = "combiner_test",
srcs = ["combiner_test.cc"],
+ data = ["//third_party/toolchains:RBE_USE_MACHINE_TYPE_LARGE"],
language = "C++",
deps = [
"//:gpr",
@@ -73,15 +77,15 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "ev_epollsig_linux_test",
- srcs = ["ev_epollsig_linux_test.cc"],
+ name = "ev_epollex_linux_test",
+ srcs = ["ev_epollex_linux_test.cc"],
+ language = "C++",
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
],
- language = "C++",
)
grpc_cc_test(
@@ -109,8 +113,8 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "load_file_test",
- srcs = ["load_file_test.cc"],
+ name = "grpc_ipv6_loopback_available_test",
+ srcs = ["grpc_ipv6_loopback_available_test.cc"],
language = "C++",
deps = [
"//:gpr",
@@ -121,8 +125,8 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "pollset_set_test",
- srcs = ["pollset_set_test.cc"],
+ name = "load_file_test",
+ srcs = ["load_file_test.cc"],
language = "C++",
deps = [
"//:gpr",
@@ -145,8 +149,26 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "resolve_address_test",
+ name = "resolve_address_using_ares_resolver_test",
srcs = ["resolve_address_test.cc"],
+ args = [
+ "--resolver=ares",
+ ],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "resolve_address_using_native_resolver_test",
+ srcs = ["resolve_address_test.cc"],
+ args = [
+ "--resolver=native",
+ ],
language = "C++",
deps = [
"//:gpr",
@@ -218,9 +240,22 @@ grpc_cc_test(
)
grpc_cc_test(
+ name = "buffer_list_test",
+ srcs = ["buffer_list_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
name = "tcp_server_posix_test",
srcs = ["tcp_server_posix_test.cc"],
language = "C++",
+ tags = ["manual"], # TODO(adelez): Remove once this works on Foundry.
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/iomgr/buffer_list_test.cc b/test/core/iomgr/buffer_list_test.cc
new file mode 100644
index 0000000000..c7f30fa092
--- /dev/null
+++ b/test/core/iomgr/buffer_list_test.cc
@@ -0,0 +1,111 @@
+/*
+ *
+ * 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 "src/core/lib/iomgr/port.h"
+
+#include "src/core/lib/iomgr/buffer_list.h"
+
+#include <grpc/grpc.h>
+
+#include "test/core/util/test_config.h"
+
+#ifdef GRPC_LINUX_ERRQUEUE
+
+static void TestShutdownFlushesListVerifier(void* arg,
+ grpc_core::Timestamps* ts,
+ grpc_error* error) {
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
+ GPR_ASSERT(arg != nullptr);
+ gpr_atm* done = reinterpret_cast<gpr_atm*>(arg);
+ gpr_atm_rel_store(done, static_cast<gpr_atm>(1));
+}
+
+/** Tests that all TracedBuffer elements in the list are flushed out on
+ * shutdown.
+ * Also tests that arg is passed correctly.
+ */
+static void TestShutdownFlushesList() {
+ grpc_core::grpc_tcp_set_write_timestamps_callback(
+ TestShutdownFlushesListVerifier);
+ grpc_core::TracedBuffer* list = nullptr;
+#define NUM_ELEM 5
+ gpr_atm verifier_called[NUM_ELEM];
+ for (auto i = 0; i < NUM_ELEM; i++) {
+ gpr_atm_rel_store(&verifier_called[i], static_cast<gpr_atm>(0));
+ grpc_core::TracedBuffer::AddNewEntry(
+ &list, i, static_cast<void*>(&verifier_called[i]));
+ }
+ grpc_core::TracedBuffer::Shutdown(&list, GRPC_ERROR_NONE);
+ GPR_ASSERT(list == nullptr);
+ for (auto i = 0; i < NUM_ELEM; i++) {
+ GPR_ASSERT(gpr_atm_acq_load(&verifier_called[i]) ==
+ static_cast<gpr_atm>(1));
+ }
+}
+
+static void TestVerifierCalledOnAckVerifier(void* arg,
+ grpc_core::Timestamps* ts,
+ grpc_error* error) {
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
+ GPR_ASSERT(arg != nullptr);
+ GPR_ASSERT(ts->acked_time.clock_type == GPR_CLOCK_REALTIME);
+ GPR_ASSERT(ts->acked_time.tv_sec == 123);
+ GPR_ASSERT(ts->acked_time.tv_nsec == 456);
+ gpr_atm* done = reinterpret_cast<gpr_atm*>(arg);
+ gpr_atm_rel_store(done, static_cast<gpr_atm>(1));
+}
+
+/** Tests that the timestamp verifier is called on an ACK timestamp.
+ */
+static void TestVerifierCalledOnAck() {
+ struct sock_extended_err serr;
+ serr.ee_data = 213;
+ serr.ee_info = grpc_core::SCM_TSTAMP_ACK;
+ struct grpc_core::scm_timestamping tss;
+ tss.ts[0].tv_sec = 123;
+ tss.ts[0].tv_nsec = 456;
+ grpc_core::grpc_tcp_set_write_timestamps_callback(
+ TestVerifierCalledOnAckVerifier);
+ grpc_core::TracedBuffer* list = nullptr;
+ gpr_atm verifier_called;
+ gpr_atm_rel_store(&verifier_called, static_cast<gpr_atm>(0));
+ grpc_core::TracedBuffer::AddNewEntry(&list, 213, &verifier_called);
+ grpc_core::TracedBuffer::ProcessTimestamp(&list, &serr, &tss);
+ GPR_ASSERT(gpr_atm_acq_load(&verifier_called) == static_cast<gpr_atm>(1));
+ GPR_ASSERT(list == nullptr);
+ grpc_core::TracedBuffer::Shutdown(&list, GRPC_ERROR_NONE);
+}
+
+static void TestTcpBufferList() {
+ TestVerifierCalledOnAck();
+ TestShutdownFlushesList();
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+ TestTcpBufferList();
+ grpc_shutdown();
+ return 0;
+}
+
+#else /* GRPC_LINUX_ERRQUEUE */
+
+int main(int argc, char** argv) { return 0; }
+
+#endif /* GRPC_LINUX_ERRQUEUE */
diff --git a/test/core/iomgr/endpoint_tests.cc b/test/core/iomgr/endpoint_tests.cc
index 8db8ac5ed6..a9e8ba86c5 100644
--- a/test/core/iomgr/endpoint_tests.cc
+++ b/test/core/iomgr/endpoint_tests.cc
@@ -150,8 +150,8 @@ static void read_and_write_test_write_handler(void* data, grpc_error* error) {
&state->current_write_data);
grpc_slice_buffer_reset_and_unref(&state->outgoing);
grpc_slice_buffer_addn(&state->outgoing, slices, nslices);
- grpc_endpoint_write(state->write_ep, &state->outgoing,
- &state->done_write);
+ grpc_endpoint_write(state->write_ep, &state->outgoing, &state->done_write,
+ nullptr);
gpr_free(slices);
return;
}
@@ -294,7 +294,8 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) {
grpc_slice_buffer_add(&slice_buffer, grpc_slice_from_copied_string("a"));
grpc_endpoint_write(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
- grpc_schedule_on_exec_ctx));
+ grpc_schedule_on_exec_ctx),
+ nullptr);
wait_for_fail_count(&fail_count, 3);
grpc_endpoint_shutdown(f.client_ep,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
diff --git a/test/core/iomgr/error_test.cc b/test/core/iomgr/error_test.cc
index a1628a1f71..d78a8c2af3 100644
--- a/test/core/iomgr/error_test.cc
+++ b/test/core/iomgr/error_test.cc
@@ -187,16 +187,6 @@ static void test_os_error() {
GRPC_ERROR_UNREF(error);
}
-static void test_special() {
- grpc_error* error = GRPC_ERROR_NONE;
- error = grpc_error_add_child(
- error, GRPC_ERROR_CREATE_FROM_STATIC_STRING("test child"));
- intptr_t i;
- GPR_ASSERT(grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, &i));
- GPR_ASSERT(i == GRPC_STATUS_OK);
- GRPC_ERROR_UNREF(error);
-}
-
static void test_overflow() {
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Overflow");
@@ -235,7 +225,6 @@ int main(int argc, char** argv) {
test_os_error();
test_create_referencing();
test_create_referencing_many();
- test_special();
test_overflow();
grpc_shutdown();
diff --git a/test/core/iomgr/ev_epollex_linux_test.cc b/test/core/iomgr/ev_epollex_linux_test.cc
new file mode 100644
index 0000000000..08d1e68b39
--- /dev/null
+++ b/test/core/iomgr/ev_epollex_linux_test.cc
@@ -0,0 +1,115 @@
+/*
+ *
+ * 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 "src/core/lib/iomgr/port.h"
+
+/* This test only relevant on linux systems where epoll() is available */
+#if defined(GRPC_LINUX_EPOLL_CREATE1) && defined(GRPC_LINUX_EVENTFD)
+#include "src/core/lib/iomgr/ev_epollex_linux.h"
+
+#include <grpc/grpc.h>
+#include <string.h>
+#include <sys/eventfd.h>
+
+#include "test/core/util/test_config.h"
+
+static void pollset_destroy(void* ps, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(ps));
+ gpr_free(ps);
+}
+
+// This test is added to cover the case found in bug:
+// https://github.com/grpc/grpc/issues/15760
+static void test_pollable_owner_fd() {
+ grpc_core::ExecCtx exec_ctx;
+ int ev_fd1;
+ int ev_fd2;
+ grpc_fd* grpc_fd1;
+ grpc_fd* grpc_fd2;
+ grpc_pollset* ps;
+ gpr_mu* mu;
+
+ // == Create two grpc_fds ==
+ // All we need is two file descriptors. Doesn't matter what type. We use
+ // eventfd type here for the purpose of this test
+ ev_fd1 = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+ ev_fd2 = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+ if (ev_fd1 < 0 || ev_fd2 < 0) {
+ gpr_log(GPR_ERROR, "Error in creating event fds for the test");
+ return;
+ }
+ grpc_fd1 = grpc_fd_create(ev_fd1, "epollex-test-fd1", false);
+ grpc_fd2 = grpc_fd_create(ev_fd2, "epollex-test-fd2", false);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ // == Create a pollset ==
+ ps = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(ps, &mu);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ // == Add fd1 to pollset ==
+ grpc_pollset_add_fd(ps, grpc_fd1);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ // == Destroy fd1 ==
+ grpc_fd_orphan(grpc_fd1, nullptr, nullptr, "test fd1 orphan");
+ grpc_core::ExecCtx::Get()->Flush();
+
+ // = Add fd2 to pollset ==
+ //
+ // Before https://github.com/grpc/grpc/issues/15760, the following line caused
+ // unexpected behavior (The previous grpc_pollset_add_fd(ps, grpc_fd1) created
+ // an underlying structure in epollex that held a reference to grpc_fd1 which
+ // was being accessed here even after grpc_fd_orphan(grpc_fd1) was called
+ grpc_pollset_add_fd(ps, grpc_fd2);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ // == Destroy fd2 ==
+ grpc_fd_orphan(grpc_fd2, nullptr, nullptr, "test fd2 orphan");
+ grpc_core::ExecCtx::Get()->Flush();
+
+ // == Destroy pollset
+ grpc_closure ps_destroy_closure;
+ GRPC_CLOSURE_INIT(&ps_destroy_closure, pollset_destroy, ps,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(ps, &ps_destroy_closure);
+ grpc_core::ExecCtx::Get()->Flush();
+}
+
+int main(int argc, char** argv) {
+ const char* poll_strategy = nullptr;
+ grpc_test_init(argc, argv);
+ grpc_init();
+ {
+ grpc_core::ExecCtx exec_ctx;
+ poll_strategy = grpc_get_poll_strategy_name();
+ if (poll_strategy != nullptr && strcmp(poll_strategy, "epollex") == 0) {
+ test_pollable_owner_fd();
+ } else {
+ gpr_log(GPR_INFO,
+ "Skipping the test. The test is only relevant for 'epollex' "
+ "strategy. and the current strategy is: '%s'",
+ poll_strategy);
+ }
+ }
+
+ grpc_shutdown();
+ return 0;
+}
+#else /* defined(GRPC_LINUX_EPOLL_CREATE1) && defined(GRPC_LINUX_EVENTFD) */
+int main(int argc, char** argv) { return 0; }
+#endif
diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc
deleted file mode 100644
index c3ba6d7c14..0000000000
--- a/test/core/iomgr/ev_epollsig_linux_test.cc
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- *
- * Copyright 2015 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 "src/core/lib/iomgr/port.h"
-
-/* This test only relevant on linux systems where epoll() is available */
-#ifdef GRPC_LINUX_EPOLL_CREATE1
-#include "src/core/lib/iomgr/ev_epollsig_linux.h"
-#include "src/core/lib/iomgr/ev_posix.h"
-
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-
-#include "src/core/lib/gpr/useful.h"
-#include "src/core/lib/gprpp/thd.h"
-#include "src/core/lib/iomgr/iomgr.h"
-#include "test/core/util/test_config.h"
-
-typedef struct test_pollset {
- grpc_pollset* pollset;
- gpr_mu* mu;
-} test_pollset;
-
-typedef struct test_fd {
- int inner_fd;
- grpc_fd* fd;
-} test_fd;
-
-/* num_fds should be an even number */
-static void test_fd_init(test_fd* tfds, int* fds, int num_fds) {
- int i;
- int r;
-
- /* Create some dummy file descriptors. Currently using pipe file descriptors
- * for this test but we could use any other type of file descriptors. Also,
- * since pipe() used in this test creates two fds in each call, num_fds should
- * be an even number */
- GPR_ASSERT((num_fds % 2) == 0);
- for (i = 0; i < num_fds; i = i + 2) {
- r = pipe(fds + i);
- if (r != 0) {
- gpr_log(GPR_ERROR, "Error in creating pipe. %d (%s)", errno,
- strerror(errno));
- return;
- }
- }
-
- for (i = 0; i < num_fds; i++) {
- tfds[i].inner_fd = fds[i];
- tfds[i].fd = grpc_fd_create(fds[i], "test_fd");
- }
-}
-
-static void test_fd_cleanup(test_fd* tfds, int num_fds) {
- int release_fd;
- int i;
-
- for (i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(tfds[i].fd,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_fd_cleanup"));
- grpc_core::ExecCtx::Get()->Flush();
-
- grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */,
- "test_fd_cleanup");
- grpc_core::ExecCtx::Get()->Flush();
-
- GPR_ASSERT(release_fd == tfds[i].inner_fd);
- close(tfds[i].inner_fd);
- }
-}
-
-static void test_pollset_init(test_pollset* pollsets, int num_pollsets) {
- int i;
- for (i = 0; i < num_pollsets; i++) {
- pollsets[i].pollset =
- static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
- grpc_pollset_init(pollsets[i].pollset, &pollsets[i].mu);
- }
-}
-
-static void destroy_pollset(void* p, grpc_error* error) {
- grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
-}
-
-static void test_pollset_cleanup(test_pollset* pollsets, int num_pollsets) {
- grpc_closure destroyed;
- int i;
-
- for (i = 0; i < num_pollsets; i++) {
- GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, pollsets[i].pollset,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(pollsets[i].pollset, &destroyed);
-
- grpc_core::ExecCtx::Get()->Flush();
- gpr_free(pollsets[i].pollset);
- }
-}
-
- /*
- * Cases to test:
- * case 1) Polling islands of both fd and pollset are NULL
- * case 2) Polling island of fd is NULL but that of pollset is not-NULL
- * case 3) Polling island of fd is not-NULL but that of pollset is NULL
- * case 4) Polling islands of both fd and pollset are not-NULL and:
- * case 4.1) Polling islands of fd and pollset are equal
- * case 4.2) Polling islands of fd and pollset are NOT-equal (This results
- * in a merge)
- * */
-
-#define NUM_FDS 8
-#define NUM_POLLSETS 4
-
-static void test_add_fd_to_pollset() {
- grpc_core::ExecCtx exec_ctx;
- test_fd tfds[NUM_FDS];
- int fds[NUM_FDS];
- test_pollset pollsets[NUM_POLLSETS];
- void* expected_pi = nullptr;
- int i;
-
- test_fd_init(tfds, fds, NUM_FDS);
- test_pollset_init(pollsets, NUM_POLLSETS);
-
- /*Step 1.
- * Create three polling islands (This will exercise test case 1 and 2) with
- * the following configuration:
- * polling island 0 = { fds:0,1,2, pollsets:0}
- * polling island 1 = { fds:3,4, pollsets:1}
- * polling island 2 = { fds:5,6,7 pollsets:2}
- *
- *Step 2.
- * Add pollset 3 to polling island 0 (by adding fds 0 and 1 to pollset 3)
- * (This will exercise test cases 3 and 4.1). The configuration becomes:
- * polling island 0 = { fds:0,1,2, pollsets:0,3} <<< pollset 3 added here
- * polling island 1 = { fds:3,4, pollsets:1}
- * polling island 2 = { fds:5,6,7 pollsets:2}
- *
- *Step 3.
- * Merge polling islands 0 and 1 by adding fd 0 to pollset 1 (This will
- * exercise test case 4.2). The configuration becomes:
- * polling island (merged) = {fds: 0,1,2,3,4, pollsets: 0,1,3}
- * polling island 2 = {fds: 5,6,7 pollsets: 2}
- *
- *Step 4.
- * Finally do one more merge by adding fd 3 to pollset 2.
- * polling island (merged) = {fds: 0,1,2,3,4,5,6,7, pollsets: 0,1,2,3}
- */
-
- /* == Step 1 == */
- for (i = 0; i <= 2; i++) {
- grpc_pollset_add_fd(pollsets[0].pollset, tfds[i].fd);
- grpc_core::ExecCtx::Get()->Flush();
- }
-
- for (i = 3; i <= 4; i++) {
- grpc_pollset_add_fd(pollsets[1].pollset, tfds[i].fd);
- grpc_core::ExecCtx::Get()->Flush();
- }
-
- for (i = 5; i <= 7; i++) {
- grpc_pollset_add_fd(pollsets[2].pollset, tfds[i].fd);
- grpc_core::ExecCtx::Get()->Flush();
- }
-
- /* == Step 2 == */
- for (i = 0; i <= 1; i++) {
- grpc_pollset_add_fd(pollsets[3].pollset, tfds[i].fd);
- grpc_core::ExecCtx::Get()->Flush();
- }
-
- /* == Step 3 == */
- grpc_pollset_add_fd(pollsets[1].pollset, tfds[0].fd);
- grpc_core::ExecCtx::Get()->Flush();
-
- /* == Step 4 == */
- grpc_pollset_add_fd(pollsets[2].pollset, tfds[3].fd);
- grpc_core::ExecCtx::Get()->Flush();
-
- /* All polling islands are merged at this point */
-
- /* Compare Fd:0's polling island with that of all other Fds */
- expected_pi = grpc_fd_get_polling_island(tfds[0].fd);
- for (i = 1; i < NUM_FDS; i++) {
- GPR_ASSERT(grpc_are_polling_islands_equal(
- expected_pi, grpc_fd_get_polling_island(tfds[i].fd)));
- }
-
- /* Compare Fd:0's polling island with that of all other pollsets */
- for (i = 0; i < NUM_POLLSETS; i++) {
- GPR_ASSERT(grpc_are_polling_islands_equal(
- expected_pi, grpc_pollset_get_polling_island(pollsets[i].pollset)));
- }
-
- test_fd_cleanup(tfds, NUM_FDS);
- test_pollset_cleanup(pollsets, NUM_POLLSETS);
-}
-
-#undef NUM_FDS
-#undef NUM_POLLSETS
-
-typedef struct threading_shared {
- gpr_mu* mu;
- grpc_pollset* pollset;
- grpc_wakeup_fd* wakeup_fd;
- grpc_fd* wakeup_desc;
- grpc_closure on_wakeup;
- int wakeups;
-} threading_shared;
-
-static __thread int thread_wakeups = 0;
-
-static void test_threading_loop(void* arg) {
- threading_shared* shared = static_cast<threading_shared*>(arg);
- while (thread_wakeups < 1000000) {
- grpc_core::ExecCtx exec_ctx;
- grpc_pollset_worker* worker;
- gpr_mu_lock(shared->mu);
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(shared->pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
- gpr_mu_unlock(shared->mu);
- }
-}
-
-static void test_threading_wakeup(void* arg, grpc_error* error) {
- threading_shared* shared = static_cast<threading_shared*>(arg);
- ++shared->wakeups;
- ++thread_wakeups;
- if (error == GRPC_ERROR_NONE) {
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "consume_wakeup", grpc_wakeup_fd_consume_wakeup(shared->wakeup_fd)));
- grpc_fd_notify_on_read(shared->wakeup_desc, &shared->on_wakeup);
- GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_next",
- grpc_wakeup_fd_wakeup(shared->wakeup_fd)));
- }
-}
-
-static void test_threading(void) {
- threading_shared shared;
- shared.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
- grpc_pollset_init(shared.pollset, &shared.mu);
-
- grpc_core::Thread thds[10];
- for (auto& th : thds) {
- th = grpc_core::Thread("test_thread", test_threading_loop, &shared);
- th.Start();
- }
- grpc_wakeup_fd fd;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&fd)));
- shared.wakeup_fd = &fd;
- shared.wakeup_desc = grpc_fd_create(fd.read_fd, "wakeup");
- shared.wakeups = 0;
- {
- grpc_core::ExecCtx exec_ctx;
- grpc_pollset_add_fd(shared.pollset, shared.wakeup_desc);
- grpc_fd_notify_on_read(
- shared.wakeup_desc,
- GRPC_CLOSURE_INIT(&shared.on_wakeup, test_threading_wakeup, &shared,
- grpc_schedule_on_exec_ctx));
- }
- GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_first",
- grpc_wakeup_fd_wakeup(shared.wakeup_fd)));
- for (auto& th : thds) {
- th.Join();
- }
- fd.read_fd = 0;
- grpc_wakeup_fd_destroy(&fd);
- {
- grpc_core::ExecCtx exec_ctx;
- grpc_fd_shutdown(shared.wakeup_desc, GRPC_ERROR_CANCELLED);
- grpc_fd_orphan(shared.wakeup_desc, nullptr, nullptr,
- false /* already_closed */, "done");
- grpc_pollset_shutdown(shared.pollset,
- GRPC_CLOSURE_CREATE(destroy_pollset, shared.pollset,
- grpc_schedule_on_exec_ctx));
- }
- gpr_free(shared.pollset);
-}
-
-int main(int argc, char** argv) {
- const char* poll_strategy = nullptr;
- grpc_test_init(argc, argv);
- grpc_init();
- {
- grpc_core::ExecCtx exec_ctx;
-
- poll_strategy = grpc_get_poll_strategy_name();
- if (poll_strategy != nullptr && strcmp(poll_strategy, "epollsig") == 0) {
- test_add_fd_to_pollset();
- test_threading();
- } else {
- gpr_log(GPR_INFO,
- "Skipping the test. The test is only relevant for 'epollsig' "
- "strategy. and the current strategy is: '%s'",
- poll_strategy);
- }
- }
-
- grpc_shutdown();
- return 0;
-}
-#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */
-int main(int argc, char** argv) { return 0; }
-#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */
diff --git a/test/core/iomgr/fd_posix_test.cc b/test/core/iomgr/fd_posix_test.cc
index b81c73b2c0..4ea2389bbd 100644
--- a/test/core/iomgr/fd_posix_test.cc
+++ b/test/core/iomgr/fd_posix_test.cc
@@ -115,7 +115,7 @@ static void session_shutdown_cb(void* arg, /*session */
bool success) {
session* se = static_cast<session*>(arg);
server* sv = se->sv;
- grpc_fd_orphan(se->em_fd, nullptr, nullptr, false /* already_closed */, "a");
+ grpc_fd_orphan(se->em_fd, nullptr, nullptr, "a");
gpr_free(se);
/* Start to shutdown listen fd. */
grpc_fd_shutdown(sv->em_fd,
@@ -171,7 +171,7 @@ static void session_read_cb(void* arg, /*session */
static void listen_shutdown_cb(void* arg /*server */, int success) {
server* sv = static_cast<server*>(arg);
- grpc_fd_orphan(sv->em_fd, nullptr, nullptr, false /* already_closed */, "b");
+ grpc_fd_orphan(sv->em_fd, nullptr, nullptr, "b");
gpr_mu_lock(g_mu);
sv->done = 1;
@@ -204,7 +204,7 @@ static void listen_cb(void* arg, /*=sv_arg*/
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
se = static_cast<session*>(gpr_malloc(sizeof(*se)));
se->sv = sv;
- se->em_fd = grpc_fd_create(fd, "listener");
+ se->em_fd = grpc_fd_create(fd, "listener", false);
grpc_pollset_add_fd(g_pollset, se->em_fd);
GRPC_CLOSURE_INIT(&se->session_read_closure, session_read_cb, se,
grpc_schedule_on_exec_ctx);
@@ -233,7 +233,7 @@ static int server_start(server* sv) {
port = ntohs(sin.sin_port);
GPR_ASSERT(listen(fd, MAX_NUM_FD) == 0);
- sv->em_fd = grpc_fd_create(fd, "server");
+ sv->em_fd = grpc_fd_create(fd, "server", false);
grpc_pollset_add_fd(g_pollset, sv->em_fd);
/* Register to be interested in reading from listen_fd. */
GRPC_CLOSURE_INIT(&sv->listen_closure, listen_cb, sv,
@@ -289,7 +289,7 @@ static void client_init(client* cl) {
/* Called when a client upload session is ready to shutdown. */
static void client_session_shutdown_cb(void* arg /*client */, int success) {
client* cl = static_cast<client*>(arg);
- grpc_fd_orphan(cl->em_fd, nullptr, nullptr, false /* already_closed */, "c");
+ grpc_fd_orphan(cl->em_fd, nullptr, nullptr, "c");
cl->done = 1;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
@@ -353,7 +353,7 @@ static void client_start(client* cl, int port) {
}
}
- cl->em_fd = grpc_fd_create(fd, "client");
+ cl->em_fd = grpc_fd_create(fd, "client", false);
grpc_pollset_add_fd(g_pollset, cl->em_fd);
client_session_write(cl, GRPC_ERROR_NONE);
@@ -454,7 +454,7 @@ static void test_grpc_fd_change(void) {
flags = fcntl(sv[1], F_GETFL, 0);
GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0);
- em_fd = grpc_fd_create(sv[0], "test_grpc_fd_change");
+ em_fd = grpc_fd_create(sv[0], "test_grpc_fd_change", false);
grpc_pollset_add_fd(g_pollset, em_fd);
/* Register the first callback, then make its FD readable */
@@ -502,7 +502,7 @@ static void test_grpc_fd_change(void) {
GPR_ASSERT(b.cb_that_ran == second_read_callback);
gpr_mu_unlock(g_mu);
- grpc_fd_orphan(em_fd, nullptr, nullptr, false /* already_closed */, "d");
+ grpc_fd_orphan(em_fd, nullptr, nullptr, "d");
destroy_change_data(&a);
destroy_change_data(&b);
diff --git a/test/core/statistics/quick_test.cc b/test/core/iomgr/grpc_ipv6_loopback_available_test.cc
index 91ecdde818..329aa9a851 100644
--- a/test/core/statistics/quick_test.cc
+++ b/test/core/iomgr/grpc_ipv6_loopback_available_test.cc
@@ -16,24 +16,33 @@
*
*/
-#include "test/core/statistics/census_log_tests.h"
+#include "src/core/lib/iomgr/port.h"
-#include <stdlib.h>
+// grpc_ipv6_loopback_available isn't currently available on UV.
+#ifndef GRPC_UV
-#include <grpc/support/time.h>
+#include <grpc/grpc.h>
+#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
+#ifdef GPR_WINDOWS
+#include "src/core/lib/iomgr/socket_windows.h"
+#else
+#include "src/core/lib/iomgr/socket_utils_posix.h"
+#endif
+
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
- test_invalid_record_size();
- test_end_write_with_different_size();
- test_read_pending_record();
- test_read_beyond_pending_record();
- test_detached_while_reading();
- test_fill_log_no_fragmentation();
- test_fill_circular_log_no_fragmentation();
- test_fill_log_with_straddling_records();
- test_fill_circular_log_with_straddling_records();
+ grpc_init();
+ // This test assumes that the ipv6 loopback is available
+ // in all environments in which grpc tests run in.
+ GPR_ASSERT(grpc_ipv6_loopback_available());
+ grpc_shutdown();
return 0;
}
+
+#else
+
+int main(int argc, char** argv) { return 0; }
+
+#endif /* GRPC_UV */
diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm
new file mode 100644
index 0000000000..414b6c78c0
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm
@@ -0,0 +1,201 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#import <XCTest/XCTest.h>
+
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_CFSTREAM
+
+#include <netinet/in.h>
+
+#include <grpc/impl/codegen/sync.h>
+#include <grpc/support/sync.h>
+
+#include "src/core/lib/iomgr/endpoint.h"
+#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/tcp_client.h"
+#include "test/core/util/test_config.h"
+
+// static int g_connections_complete = 0;
+static gpr_mu g_mu;
+static int g_connections_complete = 0;
+static grpc_endpoint* g_connecting = nullptr;
+
+static void finish_connection() {
+ gpr_mu_lock(&g_mu);
+ g_connections_complete++;
+ gpr_mu_unlock(&g_mu);
+}
+
+static void must_succeed(void* arg, grpc_error* error) {
+ GPR_ASSERT(g_connecting != nullptr);
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
+ grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called"));
+ grpc_endpoint_destroy(g_connecting);
+ g_connecting = nullptr;
+ finish_connection();
+}
+
+static void must_fail(void* arg, grpc_error* error) {
+ GPR_ASSERT(g_connecting == nullptr);
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
+ const char* error_str = grpc_error_string(error);
+ NSLog(@"%s", error_str);
+ finish_connection();
+}
+
+@interface CFStreamClientTests : XCTestCase
+
+@end
+
+@implementation CFStreamClientTests
+
++ (void)setUp {
+ grpc_init();
+ gpr_mu_init(&g_mu);
+}
+
++ (void)tearDown {
+ grpc_shutdown();
+}
+
+- (void)testSucceeds {
+ grpc_resolved_address resolved_addr;
+ struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
+ int svr_fd;
+ int r;
+ int connections_complete_before;
+ grpc_closure done;
+ grpc_core::ExecCtx exec_ctx;
+
+ gpr_log(GPR_DEBUG, "test_succeeds");
+
+ memset(&resolved_addr, 0, sizeof(resolved_addr));
+ resolved_addr.len = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+
+ /* create a dummy server */
+ svr_fd = socket(AF_INET, SOCK_STREAM, 0);
+ GPR_ASSERT(svr_fd >= 0);
+ GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr.len));
+ GPR_ASSERT(0 == listen(svr_fd, 1));
+
+ gpr_mu_lock(&g_mu);
+ connections_complete_before = g_connections_complete;
+ gpr_mu_unlock(&g_mu);
+
+ /* connect to it */
+ GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr.len) == 0);
+ GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_tcp_client_connect(&done, &g_connecting, nullptr, nullptr, &resolved_addr,
+ GRPC_MILLIS_INF_FUTURE);
+
+ /* await the connection */
+ do {
+ resolved_addr.len = sizeof(addr);
+ r = accept(svr_fd, reinterpret_cast<struct sockaddr*>(addr),
+ reinterpret_cast<socklen_t*>(&resolved_addr.len));
+ } while (r == -1 && errno == EINTR);
+ GPR_ASSERT(r >= 0);
+ close(r);
+
+ grpc_core::ExecCtx::Get()->Flush();
+
+ /* wait for the connection callback to finish */
+ gpr_mu_lock(&g_mu);
+ NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:5];
+ while (connections_complete_before == g_connections_complete) {
+ gpr_mu_unlock(&g_mu);
+ [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:deadline];
+ gpr_mu_lock(&g_mu);
+ }
+ XCTAssertGreaterThan(g_connections_complete, connections_complete_before);
+
+ gpr_mu_unlock(&g_mu);
+}
+
+- (void)testFails {
+ grpc_core::ExecCtx exec_ctx;
+
+ grpc_resolved_address resolved_addr;
+ struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
+ int connections_complete_before;
+ grpc_closure done;
+ int svr_fd;
+
+ gpr_log(GPR_DEBUG, "test_fails");
+
+ memset(&resolved_addr, 0, sizeof(resolved_addr));
+ resolved_addr.len = static_cast<socklen_t>(sizeof(struct sockaddr_in));
+ addr->sin_family = AF_INET;
+
+ svr_fd = socket(AF_INET, SOCK_STREAM, 0);
+ GPR_ASSERT(svr_fd >= 0);
+ GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr.len));
+ GPR_ASSERT(0 == listen(svr_fd, 1));
+ GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr.len) == 0);
+ close(svr_fd);
+
+ gpr_mu_lock(&g_mu);
+ connections_complete_before = g_connections_complete;
+ gpr_mu_unlock(&g_mu);
+
+ /* connect to a broken address */
+ GRPC_CLOSURE_INIT(&done, must_fail, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_tcp_client_connect(&done, &g_connecting, nullptr, nullptr, &resolved_addr,
+ GRPC_MILLIS_INF_FUTURE);
+
+ grpc_core::ExecCtx::Get()->Flush();
+
+ /* wait for the connection callback to finish */
+ gpr_mu_lock(&g_mu);
+ NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:5];
+ while (g_connections_complete == connections_complete_before) {
+ gpr_mu_unlock(&g_mu);
+ [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:deadline];
+ gpr_mu_lock(&g_mu);
+ }
+
+ XCTAssertGreaterThan(g_connections_complete, connections_complete_before);
+
+ gpr_mu_unlock(&g_mu);
+}
+
+@end
+
+#else // GRPC_CFSTREAM
+
+// Dummy test suite
+@interface CFStreamClientTests : XCTestCase
+
+@end
+
+@implementation CFStreamClientTests
+
+- (void)setUp {
+ [super setUp];
+}
+
+- (void)tearDown {
+ [super tearDown];
+}
+
+@end
+
+#endif // GRPC_CFSTREAM
diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm b/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm
new file mode 100644
index 0000000000..fbc34c74d6
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm
@@ -0,0 +1,344 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#import <XCTest/XCTest.h>
+
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_CFSTREAM
+
+#include <netinet/in.h>
+
+#include <grpc/impl/codegen/sync.h>
+#include <grpc/support/sync.h>
+
+#include "src/core/lib/iomgr/endpoint.h"
+#include "src/core/lib/iomgr/resolve_address.h"
+#include "src/core/lib/iomgr/tcp_client.h"
+#include "test/core/util/test_config.h"
+
+static const int kConnectTimeout = 5;
+static const int kWriteTimeout = 5;
+static const int kReadTimeout = 5;
+
+static const int kBufferSize = 10000;
+
+static const int kRunLoopTimeout = 1;
+
+static void set_atm(void *arg, grpc_error *error) {
+ gpr_atm *p = static_cast<gpr_atm *>(arg);
+ gpr_atm_full_cas(p, -1, reinterpret_cast<gpr_atm>(error));
+}
+
+static void init_event_closure(grpc_closure *closure, gpr_atm *atm) {
+ *atm = -1;
+ GRPC_CLOSURE_INIT(closure, set_atm, static_cast<void *>(atm), grpc_schedule_on_exec_ctx);
+}
+
+static bool compare_slice_buffer_with_buffer(grpc_slice_buffer *slices, const char *buffer,
+ size_t buffer_len) {
+ if (slices->length != buffer_len) {
+ return false;
+ }
+
+ for (int i = 0; i < slices->count; i++) {
+ grpc_slice slice = slices->slices[i];
+ if (0 != memcmp(buffer, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice))) {
+ return false;
+ }
+ buffer += GRPC_SLICE_LENGTH(slice);
+ }
+
+ return true;
+}
+
+@interface CFStreamEndpointTests : XCTestCase
+
+@end
+
+@implementation CFStreamEndpointTests {
+ grpc_endpoint *ep_;
+ int svr_fd_;
+}
+
+- (BOOL)waitForEvent:(gpr_atm *)event timeout:(int)timeout {
+ grpc_core::ExecCtx::Get()->Flush();
+
+ NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:kConnectTimeout];
+ while (gpr_atm_acq_load(event) == -1 && [deadline timeIntervalSinceNow] > 0) {
+ NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:kRunLoopTimeout];
+ [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:deadline];
+ }
+
+ return (gpr_atm_acq_load(event) != -1);
+}
+
++ (void)setUp {
+ grpc_init();
+}
+
++ (void)tearDown {
+ grpc_shutdown();
+}
+
+- (void)setUp {
+ self.continueAfterFailure = NO;
+
+ // Set up CFStream connection before testing the endpoint
+
+ grpc_core::ExecCtx exec_ctx;
+
+ grpc_resolved_address resolved_addr;
+ struct sockaddr_in *addr = reinterpret_cast<struct sockaddr_in *>(resolved_addr.addr);
+ int svr_fd;
+ int r;
+ gpr_atm connected = -1;
+ grpc_closure done;
+
+ gpr_log(GPR_DEBUG, "test_succeeds");
+
+ memset(&resolved_addr, 0, sizeof(resolved_addr));
+ resolved_addr.len = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+
+ /* create a dummy server */
+ svr_fd = socket(AF_INET, SOCK_STREAM, 0);
+ XCTAssertGreaterThanOrEqual(svr_fd, 0);
+ XCTAssertEqual(bind(svr_fd, (struct sockaddr *)addr, (socklen_t)resolved_addr.len), 0);
+ XCTAssertEqual(listen(svr_fd, 1), 0);
+
+ /* connect to it */
+ XCTAssertEqual(getsockname(svr_fd, (struct sockaddr *)addr, (socklen_t *)&resolved_addr.len), 0);
+ init_event_closure(&done, &connected);
+ grpc_tcp_client_connect(&done, &ep_, nullptr, nullptr, &resolved_addr, GRPC_MILLIS_INF_FUTURE);
+
+ /* await the connection */
+ do {
+ resolved_addr.len = sizeof(addr);
+ r = accept(svr_fd, reinterpret_cast<struct sockaddr *>(addr),
+ reinterpret_cast<socklen_t *>(&resolved_addr.len));
+ } while (r == -1 && errno == EINTR);
+ XCTAssertGreaterThanOrEqual(r, 0);
+ svr_fd_ = r;
+
+ /* wait for the connection callback to finish */
+ XCTAssertEqual([self waitForEvent:&connected timeout:kConnectTimeout], YES);
+ XCTAssertEqual(reinterpret_cast<grpc_error *>(connected), GRPC_ERROR_NONE);
+}
+
+- (void)tearDown {
+ grpc_core::ExecCtx exec_ctx;
+ close(svr_fd_);
+ grpc_endpoint_destroy(ep_);
+}
+
+- (void)testReadWrite {
+ grpc_core::ExecCtx exec_ctx;
+
+ gpr_atm read;
+ grpc_closure read_done;
+ grpc_slice_buffer read_slices;
+ grpc_slice_buffer read_one_slice;
+ gpr_atm write;
+ grpc_closure write_done;
+ grpc_slice_buffer write_slices;
+
+ grpc_slice slice;
+ char write_buffer[kBufferSize];
+ char read_buffer[kBufferSize];
+ size_t recv_size = 0;
+
+ grpc_slice_buffer_init(&write_slices);
+ slice = grpc_slice_from_static_buffer(write_buffer, kBufferSize);
+ grpc_slice_buffer_add(&write_slices, slice);
+ init_event_closure(&write_done, &write);
+ grpc_endpoint_write(ep_, &write_slices, &write_done);
+
+ XCTAssertEqual([self waitForEvent:&write timeout:kWriteTimeout], YES);
+ XCTAssertEqual(reinterpret_cast<grpc_error *>(write), GRPC_ERROR_NONE);
+
+ while (recv_size < kBufferSize) {
+ ssize_t size = recv(svr_fd_, read_buffer, kBufferSize, 0);
+ XCTAssertGreaterThanOrEqual(size, 0);
+ recv_size += size;
+ }
+
+ XCTAssertEqual(recv_size, kBufferSize);
+ XCTAssertEqual(memcmp(read_buffer, write_buffer, kBufferSize), 0);
+ ssize_t send_size = send(svr_fd_, read_buffer, kBufferSize, 0);
+ XCTAssertGreaterThanOrEqual(send_size, 0);
+
+ grpc_slice_buffer_init(&read_slices);
+ grpc_slice_buffer_init(&read_one_slice);
+ while (read_slices.length < kBufferSize) {
+ init_event_closure(&read_done, &read);
+ grpc_endpoint_read(ep_, &read_one_slice, &read_done);
+ XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], YES);
+ XCTAssertEqual(reinterpret_cast<grpc_error *>(read), GRPC_ERROR_NONE);
+ grpc_slice_buffer_move_into(&read_one_slice, &read_slices);
+ XCTAssertLessThanOrEqual(read_slices.length, kBufferSize);
+ }
+ XCTAssertTrue(compare_slice_buffer_with_buffer(&read_slices, read_buffer, kBufferSize));
+
+ grpc_endpoint_shutdown(ep_, GRPC_ERROR_NONE);
+ grpc_slice_buffer_reset_and_unref(&read_slices);
+ grpc_slice_buffer_reset_and_unref(&write_slices);
+ grpc_slice_buffer_reset_and_unref(&read_one_slice);
+}
+
+- (void)testShutdownBeforeRead {
+ grpc_core::ExecCtx exec_ctx;
+
+ gpr_atm read;
+ grpc_closure read_done;
+ grpc_slice_buffer read_slices;
+ gpr_atm write;
+ grpc_closure write_done;
+ grpc_slice_buffer write_slices;
+
+ grpc_slice slice;
+ char write_buffer[kBufferSize];
+ char read_buffer[kBufferSize];
+ size_t recv_size = 0;
+
+ grpc_slice_buffer_init(&read_slices);
+ init_event_closure(&read_done, &read);
+ grpc_endpoint_read(ep_, &read_slices, &read_done);
+
+ grpc_slice_buffer_init(&write_slices);
+ slice = grpc_slice_from_static_buffer(write_buffer, kBufferSize);
+ grpc_slice_buffer_add(&write_slices, slice);
+ init_event_closure(&write_done, &write);
+ grpc_endpoint_write(ep_, &write_slices, &write_done);
+
+ XCTAssertEqual([self waitForEvent:&write timeout:kWriteTimeout], YES);
+ XCTAssertEqual(reinterpret_cast<grpc_error *>(write), GRPC_ERROR_NONE);
+
+ while (recv_size < kBufferSize) {
+ ssize_t size = recv(svr_fd_, read_buffer, kBufferSize, 0);
+ XCTAssertGreaterThanOrEqual(size, 0);
+ recv_size += size;
+ }
+
+ XCTAssertEqual(recv_size, kBufferSize);
+ XCTAssertEqual(memcmp(read_buffer, write_buffer, kBufferSize), 0);
+
+ XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], NO);
+
+ grpc_endpoint_shutdown(ep_, GRPC_ERROR_NONE);
+
+ grpc_core::ExecCtx::Get()->Flush();
+ XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], YES);
+ XCTAssertNotEqual(reinterpret_cast<grpc_error *>(read), GRPC_ERROR_NONE);
+
+ grpc_slice_buffer_reset_and_unref(&read_slices);
+ grpc_slice_buffer_reset_and_unref(&write_slices);
+}
+
+- (void)testRemoteClosed {
+ grpc_core::ExecCtx exec_ctx;
+
+ gpr_atm read;
+ grpc_closure read_done;
+ grpc_slice_buffer read_slices;
+ gpr_atm write;
+ grpc_closure write_done;
+ grpc_slice_buffer write_slices;
+
+ grpc_slice slice;
+ char write_buffer[kBufferSize];
+ char read_buffer[kBufferSize];
+ size_t recv_size = 0;
+
+ init_event_closure(&read_done, &read);
+ grpc_slice_buffer_init(&read_slices);
+ grpc_endpoint_read(ep_, &read_slices, &read_done);
+
+ grpc_slice_buffer_init(&write_slices);
+ slice = grpc_slice_from_static_buffer(write_buffer, kBufferSize);
+ grpc_slice_buffer_add(&write_slices, slice);
+ init_event_closure(&write_done, &write);
+ grpc_endpoint_write(ep_, &write_slices, &write_done);
+
+ XCTAssertEqual([self waitForEvent:&write timeout:kWriteTimeout], YES);
+ XCTAssertEqual(reinterpret_cast<grpc_error *>(write), GRPC_ERROR_NONE);
+
+ while (recv_size < kBufferSize) {
+ ssize_t size = recv(svr_fd_, read_buffer, kBufferSize, 0);
+ XCTAssertGreaterThanOrEqual(size, 0);
+ recv_size += size;
+ }
+
+ XCTAssertEqual(recv_size, kBufferSize);
+ XCTAssertEqual(memcmp(read_buffer, write_buffer, kBufferSize), 0);
+
+ close(svr_fd_);
+
+ XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], YES);
+ XCTAssertNotEqual(reinterpret_cast<grpc_error *>(read), GRPC_ERROR_NONE);
+
+ grpc_endpoint_shutdown(ep_, GRPC_ERROR_NONE);
+ grpc_slice_buffer_reset_and_unref(&read_slices);
+ grpc_slice_buffer_reset_and_unref(&write_slices);
+}
+
+- (void)testRemoteReset {
+ grpc_core::ExecCtx exec_ctx;
+
+ gpr_atm read;
+ grpc_closure read_done;
+ grpc_slice_buffer read_slices;
+
+ init_event_closure(&read_done, &read);
+ grpc_slice_buffer_init(&read_slices);
+ grpc_endpoint_read(ep_, &read_slices, &read_done);
+
+ struct linger so_linger;
+ so_linger.l_onoff = 1;
+ so_linger.l_linger = 0;
+ setsockopt(svr_fd_, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger));
+
+ close(svr_fd_);
+
+ XCTAssertEqual([self waitForEvent:&read timeout:kReadTimeout], YES);
+ XCTAssertNotEqual(reinterpret_cast<grpc_error *>(read), GRPC_ERROR_NONE);
+
+ grpc_endpoint_shutdown(ep_, GRPC_ERROR_NONE);
+ grpc_slice_buffer_reset_and_unref(&read_slices);
+}
+
+@end
+
+#else // GRPC_CFSTREAM
+
+// Dummy test suite
+@interface CFStreamEndpointTests : XCTestCase
+@end
+
+@implementation CFStreamEndpointTests
+- (void)setUp {
+ [super setUp];
+}
+
+- (void)tearDown {
+ [super tearDown];
+}
+
+@end
+
+#endif // GRPC_CFSTREAM
diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj
new file mode 100644
index 0000000000..2218f129ae
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/project.pbxproj
@@ -0,0 +1,338 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 48;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 5E143B892069D72200715A6E /* CFStreamClientTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E143B882069D72200715A6E /* CFStreamClientTests.mm */; };
+ 5E143B8C206B5F9F00715A6E /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5E143B8A2069D72700715A6E /* Info.plist */; };
+ 5E143B8E206C5B9A00715A6E /* CFStreamEndpointTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E143B8D206C5B9A00715A6E /* CFStreamEndpointTests.mm */; };
+ 604EA96D9CD477A8EA411BDF /* libPods-CFStreamTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AFFA154D492751CEAC05D591 /* libPods-CFStreamTests.a */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 5E143B792069D67300715A6E /* CFStreamTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CFStreamTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5E143B882069D72200715A6E /* CFStreamClientTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CFStreamClientTests.mm; sourceTree = "<group>"; };
+ 5E143B8A2069D72700715A6E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 5E143B8D206C5B9A00715A6E /* CFStreamEndpointTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CFStreamEndpointTests.mm; sourceTree = "<group>"; };
+ 8CB4409E07E180CCA59987DF /* Pods-CFStreamTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CFStreamTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CFStreamTests/Pods-CFStreamTests.release.xcconfig"; sourceTree = "<group>"; };
+ 9E3FAF9DA6B98ED4FE6D6848 /* Pods-CFStreamTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CFStreamTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CFStreamTests/Pods-CFStreamTests.debug.xcconfig"; sourceTree = "<group>"; };
+ AFFA154D492751CEAC05D591 /* libPods-CFStreamTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CFStreamTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 5E143B762069D67300715A6E /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 604EA96D9CD477A8EA411BDF /* libPods-CFStreamTests.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 5E143B582069D67300715A6E = {
+ isa = PBXGroup;
+ children = (
+ 5E143B8D206C5B9A00715A6E /* CFStreamEndpointTests.mm */,
+ 5E143B8A2069D72700715A6E /* Info.plist */,
+ 5E143B882069D72200715A6E /* CFStreamClientTests.mm */,
+ 5E143B622069D67300715A6E /* Products */,
+ A331D95F7F230B507FBF6D22 /* Pods */,
+ 6AC36F6C5DB5CA8F717D1B67 /* Frameworks */,
+ );
+ sourceTree = "<group>";
+ };
+ 5E143B622069D67300715A6E /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 5E143B792069D67300715A6E /* CFStreamTests.xctest */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 6AC36F6C5DB5CA8F717D1B67 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ AFFA154D492751CEAC05D591 /* libPods-CFStreamTests.a */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ A331D95F7F230B507FBF6D22 /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ 9E3FAF9DA6B98ED4FE6D6848 /* Pods-CFStreamTests.debug.xcconfig */,
+ 8CB4409E07E180CCA59987DF /* Pods-CFStreamTests.release.xcconfig */,
+ );
+ name = Pods;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 5E143B782069D67300715A6E /* CFStreamTests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5E143B852069D67300715A6E /* Build configuration list for PBXNativeTarget "CFStreamTests" */;
+ buildPhases = (
+ 4EBA55D3E23FC6C84596E3D5 /* [CP] Check Pods Manifest.lock */,
+ 5E143B752069D67300715A6E /* Sources */,
+ 5E143B762069D67300715A6E /* Frameworks */,
+ 5E143B772069D67300715A6E /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = CFStreamTests;
+ productName = CFStreamTestsTests;
+ productReference = 5E143B792069D67300715A6E /* CFStreamTests.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 5E143B592069D67300715A6E /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0920;
+ ORGANIZATIONNAME = gRPC;
+ TargetAttributes = {
+ 5E143B782069D67300715A6E = {
+ CreatedOnToolsVersion = 9.2;
+ ProvisioningStyle = Automatic;
+ };
+ };
+ };
+ buildConfigurationList = 5E143B5C2069D67300715A6E /* Build configuration list for PBXProject "CFStreamTests" */;
+ compatibilityVersion = "Xcode 8.0";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 5E143B582069D67300715A6E;
+ productRefGroup = 5E143B622069D67300715A6E /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 5E143B782069D67300715A6E /* CFStreamTests */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 5E143B772069D67300715A6E /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E143B8C206B5F9F00715A6E /* Info.plist in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 4EBA55D3E23FC6C84596E3D5 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-CFStreamTests-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 5E143B752069D67300715A6E /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E143B892069D72200715A6E /* CFStreamClientTests.mm in Sources */,
+ 5E143B8E206C5B9A00715A6E /* CFStreamEndpointTests.mm in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 5E143B802069D67300715A6E /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ 5E143B812069D67300715A6E /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 5E143B862069D67300715A6E /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 9E3FAF9DA6B98ED4FE6D6848 /* Pods-CFStreamTests.debug.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "$(inherited)",
+ "COCOAPODS=1",
+ "$(inherited)",
+ "PB_FIELD_32BIT=1",
+ "PB_NO_PACKED_STRUCTS=1",
+ "GRPC_CFSTREAM=1",
+ );
+ INFOPLIST_FILE = Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CFStreamTestsTests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ USER_HEADER_SEARCH_PATHS = ../../../../..;
+ };
+ name = Debug;
+ };
+ 5E143B872069D67300715A6E /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 8CB4409E07E180CCA59987DF /* Pods-CFStreamTests.release.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ INFOPLIST_FILE = Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.CFStreamTestsTests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ USER_HEADER_SEARCH_PATHS = ../../../../..;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 5E143B5C2069D67300715A6E /* Build configuration list for PBXProject "CFStreamTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E143B802069D67300715A6E /* Debug */,
+ 5E143B812069D67300715A6E /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 5E143B852069D67300715A6E /* Build configuration list for PBXNativeTarget "CFStreamTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E143B862069D67300715A6E /* Debug */,
+ 5E143B872069D67300715A6E /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 5E143B592069D67300715A6E /* Project object */;
+}
diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests.xcscheme b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests.xcscheme
new file mode 100644
index 0000000000..25d6f780a1
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests.xcscheme
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0920"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5E143B782069D67300715A6E"
+ BuildableName = "CFStreamTests.xctest"
+ BlueprintName = "CFStreamTests"
+ ReferencedContainer = "container:CFStreamTests.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Asan.xcscheme b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Asan.xcscheme
new file mode 100644
index 0000000000..6c5c43aa72
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Asan.xcscheme
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0920"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ enableAddressSanitizer = "YES"
+ enableASanStackUseAfterReturn = "YES"
+ language = ""
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5E143B782069D67300715A6E"
+ BuildableName = "CFStreamTests.xctest"
+ BlueprintName = "CFStreamTests"
+ ReferencedContainer = "container:CFStreamTests.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ enableASanStackUseAfterReturn = "YES"
+ language = ""
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Msan.xcscheme b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Msan.xcscheme
new file mode 100644
index 0000000000..3e39ff84d0
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Msan.xcscheme
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0920"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5E143B782069D67300715A6E"
+ BuildableName = "CFStreamTests.xctest"
+ BlueprintName = "CFStreamTests"
+ ReferencedContainer = "container:CFStreamTests.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <AdditionalOptions>
+ <AdditionalOption
+ key = "DYLD_INSERT_LIBRARIES"
+ value = "/usr/lib/libgmalloc.dylib"
+ isEnabled = "YES">
+ </AdditionalOption>
+ <AdditionalOption
+ key = "NSZombieEnabled"
+ value = "YES"
+ isEnabled = "YES">
+ </AdditionalOption>
+ <AdditionalOption
+ key = "MallocGuardEdges"
+ value = ""
+ isEnabled = "YES">
+ </AdditionalOption>
+ <AdditionalOption
+ key = "MallocScribble"
+ value = ""
+ isEnabled = "YES">
+ </AdditionalOption>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Tsan.xcscheme b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Tsan.xcscheme
new file mode 100644
index 0000000000..f0bde837c5
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/CFStreamTests.xcodeproj/xcshareddata/xcschemes/CFStreamTests_Tsan.xcscheme
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0920"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ enableThreadSanitizer = "YES"
+ language = ""
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5E143B782069D67300715A6E"
+ BuildableName = "CFStreamTests.xctest"
+ BlueprintName = "CFStreamTests"
+ ReferencedContainer = "container:CFStreamTests.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ language = ""
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ stopOnEveryThreadSanitizerIssue = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/test/core/iomgr/ios/CFStreamTests/Info.plist b/test/core/iomgr/ios/CFStreamTests/Info.plist
new file mode 100644
index 0000000000..6c40a6cd0c
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/test/core/iomgr/ios/CFStreamTests/Podfile b/test/core/iomgr/ios/CFStreamTests/Podfile
new file mode 100644
index 0000000000..e6ec66d549
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/Podfile
@@ -0,0 +1,51 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+install! 'cocoapods', :deterministic_uuids => false
+
+# Location of gRPC's repo root relative to this file.
+GRPC_LOCAL_SRC = '../../../../..'
+
+# Install the dependencies in the main target plus all test targets.
+target 'CFStreamTests' do
+ pod 'gRPC-Core/CFStream-Implementation', :path => GRPC_LOCAL_SRC
+ pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true
+end
+
+pre_install do |installer|
+ # This is the gRPC-Core podspec object, as initialized by its podspec file.
+ grpc_core_spec = installer.pod_targets.find{|t| t.name == 'gRPC-Core'}.root_spec
+
+ # Copied from gRPC-Core.podspec, except for the adjusted src_root:
+ src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}"
+ grpc_core_spec.pod_target_xcconfig = {
+ 'GRPC_SRC_ROOT' => src_root,
+ 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
+ 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
+ # If we don't set these two settings, `include/grpc/support/time.h` and
+ # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
+ # build.
+ 'USE_HEADERMAP' => 'NO',
+ 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
+ }
+end
+
+post_install do |installer|
+ installer.pods_project.targets.each do |target|
+ target.build_configurations.each do |config|
+ config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES'
+ end
+
+ # CocoaPods creates duplicated library targets of gRPC-Core when the test targets include
+ # non-default subspecs of gRPC-Core. All of these library targets start with prefix 'gRPC-Core'
+ # and require the same error suppresion.
+ if target.name.start_with?('gRPC-Core')
+ target.build_configurations.each do |config|
+ # TODO(zyc): Remove this setting after the issue is resolved
+ # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void
+ # function" warning
+ config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO'
+ end
+ end
+ end
+end
diff --git a/test/core/iomgr/ios/CFStreamTests/build_tests.sh b/test/core/iomgr/ios/CFStreamTests/build_tests.sh
new file mode 100755
index 0000000000..d23f26f5db
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/build_tests.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+# 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.
+
+# Don't run this script standalone. Instead, run from the repository root:
+# ./tools/run_tests/run_tests.py -l objc
+
+set -e
+
+# CocoaPods requires the terminal to be using UTF-8 encoding.
+export LANG=en_US.UTF-8
+
+cd "$(dirname "$0")"
+
+hash pod 2>/dev/null || { echo >&2 "Cocoapods needs to be installed."; exit 1; }
+hash xcodebuild 2>/dev/null || {
+ echo >&2 "XCode command-line tools need to be installed."
+ exit 1
+}
+
+# clean the directory
+rm -rf Pods
+rm -rf CFStreamTests.xcworkspace
+rm -f Podfile.lock
+
+echo "TIME: $(date)"
+pod install
+
diff --git a/test/core/iomgr/ios/CFStreamTests/run_tests.sh b/test/core/iomgr/ios/CFStreamTests/run_tests.sh
new file mode 100755
index 0000000000..1045ec10a8
--- /dev/null
+++ b/test/core/iomgr/ios/CFStreamTests/run_tests.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+# 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.
+
+# Don't run this script standalone. Instead, run from the repository root:
+# ./tools/run_tests/run_tests.py -l objc
+
+set -ev
+
+cd "$(dirname "$0")"
+
+echo "TIME: $(date)"
+
+XCODEBUILD_FILTER='(^CompileC |^Ld |^ *[^ ]*clang |^ *cd |^ *export |^Libtool |^ *[^ ]*libtool |^CpHeader |^ *builtin-copy )'
+
+xcodebuild \
+ -workspace CFStreamTests.xcworkspace \
+ -scheme CFStreamTests \
+ -destination name="iPhone 8" \
+ test \
+ | egrep -v "$XCODEBUILD_FILTER" \
+ | egrep -v '^$' \
+ | egrep -v "(GPBDictionary|GPBArray)" -
+
+echo "TIME: $(date)"
+
+xcodebuild \
+ -workspace CFStreamTests.xcworkspace \
+ -scheme CFStreamTests_Asan \
+ -destination name="iPhone 8" \
+ test \
+ | egrep -v "$XCODEBUILD_FILTER" \
+ | egrep -v '^$' \
+ | egrep -v "(GPBDictionary|GPBArray)" -
+
+echo "TIME: $(date)"
+
+xcodebuild \
+ -workspace CFStreamTests.xcworkspace \
+ -scheme CFStreamTests_Tsan \
+ -destination name="iPhone 8" \
+ test \
+ | egrep -v "$XCODEBUILD_FILTER" \
+ | egrep -v '^$' \
+ | egrep -v "(GPBDictionary|GPBArray)" -
+
+echo "TIME: $(date)"
+
+xcodebuild \
+ -workspace CFStreamTests.xcworkspace \
+ -scheme CFStreamTests_Msan \
+ -destination name="iPhone 8" \
+ test \
+ | egrep -v "$XCODEBUILD_FILTER" \
+ | egrep -v '^$' \
+ | egrep -v "(GPBDictionary|GPBArray)" -
diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc
deleted file mode 100644
index 0dc75a5f3f..0000000000
--- a/test/core/iomgr/pollset_set_test.cc
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- *
- * Copyright 2016 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 "src/core/lib/iomgr/port.h"
-
-/* This test only relevant on linux systems where epoll is available */
-#ifdef GRPC_LINUX_EPOLL_CREATE1
-
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <grpc/grpc.h>
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-
-#include "src/core/lib/gpr/useful.h"
-#include "src/core/lib/iomgr/ev_posix.h"
-#include "src/core/lib/iomgr/iomgr.h"
-#include "test/core/util/test_config.h"
-
-/*******************************************************************************
- * test_pollset_set
- */
-
-typedef struct test_pollset_set {
- grpc_pollset_set* pss;
-} test_pollset_set;
-
-void init_test_pollset_sets(test_pollset_set* pollset_sets, const int num_pss) {
- for (int i = 0; i < num_pss; i++) {
- pollset_sets[i].pss = grpc_pollset_set_create();
- }
-}
-
-void cleanup_test_pollset_sets(test_pollset_set* pollset_sets,
- const int num_pss) {
- for (int i = 0; i < num_pss; i++) {
- grpc_pollset_set_destroy(pollset_sets[i].pss);
- pollset_sets[i].pss = nullptr;
- }
-}
-
-/*******************************************************************************
- * test_pollset
- */
-
-typedef struct test_pollset {
- grpc_pollset* ps;
- gpr_mu* mu;
-} test_pollset;
-
-static void init_test_pollsets(test_pollset* pollsets, const int num_pollsets) {
- for (int i = 0; i < num_pollsets; i++) {
- pollsets[i].ps =
- static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
- grpc_pollset_init(pollsets[i].ps, &pollsets[i].mu);
- }
-}
-
-static void destroy_pollset(void* p, grpc_error* error) {
- grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
-}
-
-static void cleanup_test_pollsets(test_pollset* pollsets,
- const int num_pollsets) {
- grpc_closure destroyed;
- for (int i = 0; i < num_pollsets; i++) {
- GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, pollsets[i].ps,
- grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(pollsets[i].ps, &destroyed);
-
- grpc_core::ExecCtx::Get()->Flush();
- gpr_free(pollsets[i].ps);
- pollsets[i].ps = nullptr;
- }
-}
-
-/*******************************************************************************
- * test_fd
- */
-
-typedef struct test_fd {
- grpc_fd* fd;
- grpc_wakeup_fd wakeup_fd;
-
- bool is_on_readable_called; /* Is on_readable closure is called ? */
- grpc_closure on_readable; /* Closure to call when this fd is readable */
-} test_fd;
-
-void on_readable(void* tfd, grpc_error* error) {
- (static_cast<test_fd*>(tfd))->is_on_readable_called = true;
-}
-
-static void reset_test_fd(test_fd* tfd) {
- tfd->is_on_readable_called = false;
-
- GRPC_CLOSURE_INIT(&tfd->on_readable, on_readable, tfd,
- grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(tfd->fd, &tfd->on_readable);
-}
-
-static void init_test_fds(test_fd* tfds, const int num_fds) {
- for (int i = 0; i < num_fds; i++) {
- GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd));
- tfds[i].fd = grpc_fd_create(GRPC_WAKEUP_FD_GET_READ_FD(&tfds[i].wakeup_fd),
- "test_fd");
- reset_test_fd(&tfds[i]);
- }
-}
-
-static void cleanup_test_fds(test_fd* tfds, const int num_fds) {
- int release_fd;
-
- for (int i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(tfds[i].fd,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("fd cleanup"));
- grpc_core::ExecCtx::Get()->Flush();
-
- /* grpc_fd_orphan frees the memory allocated for grpc_fd. Normally it also
- * calls close() on the underlying fd. In our case, we are using
- * grpc_wakeup_fd and we would like to destroy it ourselves (by calling
- * grpc_wakeup_fd_destroy). To prevent grpc_fd from calling close() on the
- * underlying fd, call it with a non-NULL 'release_fd' parameter */
- grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */,
- "test_fd_cleanup");
- grpc_core::ExecCtx::Get()->Flush();
-
- grpc_wakeup_fd_destroy(&tfds[i].wakeup_fd);
- }
-}
-
-static void make_test_fds_readable(test_fd* tfds, const int num_fds) {
- for (int i = 0; i < num_fds; i++) {
- GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_wakeup(&tfds[i].wakeup_fd));
- }
-}
-
-static void verify_readable_and_reset(test_fd* tfds, const int num_fds) {
- for (int i = 0; i < num_fds; i++) {
- /* Verify that the on_readable callback was called */
- GPR_ASSERT(tfds[i].is_on_readable_called);
-
- /* Reset the tfd[i] structure */
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_wakeup_fd_consume_wakeup(&tfds[i].wakeup_fd));
- reset_test_fd(&tfds[i]);
- }
-}
-
-/*******************************************************************************
- * Main tests
- */
-
-/* Test some typical scenarios in pollset_set */
-static void pollset_set_test_basic() {
- /* We construct the following structure for this test:
- *
- * +---> FD0 (Added before PSS1, PS1 and PS2 are added to PSS0)
- * |
- * +---> FD5 (Added after PSS1, PS1 and PS2 are added to PSS0)
- * |
- * |
- * | +---> FD1 (Added before PSS1 is added to PSS0)
- * | |
- * | +---> FD6 (Added after PSS1 is added to PSS0)
- * | |
- * +---> PSS1--+ +--> FD2 (Added before PS0 is added to PSS1)
- * | | |
- * | +---> PS0---+
- * | |
- * PSS0---+ +--> FD7 (Added after PS0 is added to PSS1)
- * |
- * |
- * | +---> FD3 (Added before PS1 is added to PSS0)
- * | |
- * +---> PS1---+
- * | |
- * | +---> FD8 (Added after PS1 added to PSS0)
- * |
- * |
- * | +---> FD4 (Added before PS2 is added to PSS0)
- * | |
- * +---> PS2---+
- * |
- * +---> FD9 (Added after PS2 is added to PSS0)
- */
- grpc_core::ExecCtx exec_ctx;
- grpc_pollset_worker* worker;
- grpc_millis deadline;
-
- test_fd tfds[10];
- test_pollset pollsets[3];
- test_pollset_set pollset_sets[2];
- const int num_fds = GPR_ARRAY_SIZE(tfds);
- const int num_ps = GPR_ARRAY_SIZE(pollsets);
- const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
-
- init_test_fds(tfds, num_fds);
- init_test_pollsets(pollsets, num_ps);
- init_test_pollset_sets(pollset_sets, num_pss);
-
- /* Construct the pollset_set/pollset/fd tree (see diagram above) */
-
- grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[1].fd);
-
- grpc_pollset_add_fd(pollsets[0].ps, tfds[2].fd);
- grpc_pollset_add_fd(pollsets[1].ps, tfds[3].fd);
- grpc_pollset_add_fd(pollsets[2].ps, tfds[4].fd);
-
- grpc_pollset_set_add_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
-
- grpc_pollset_set_add_pollset(pollset_sets[1].pss, pollsets[0].ps);
- grpc_pollset_set_add_pollset(pollset_sets[0].pss, pollsets[1].ps);
- grpc_pollset_set_add_pollset(pollset_sets[0].pss, pollsets[2].ps);
-
- grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[5].fd);
- grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[6].fd);
-
- grpc_pollset_add_fd(pollsets[0].ps, tfds[7].fd);
- grpc_pollset_add_fd(pollsets[1].ps, tfds[8].fd);
- grpc_pollset_add_fd(pollsets[2].ps, tfds[9].fd);
-
- grpc_core::ExecCtx::Get()->Flush();
-
- /* Test that if any FD in the above structure is readable, it is observable by
- * doing grpc_pollset_work on any pollset
- *
- * For every pollset, do the following:
- * - (Ensure that all FDs are in reset state)
- * - Make all FDs readable
- * - Call grpc_pollset_work() on the pollset
- * - Flush the exec_ctx
- * - Verify that on_readable call back was called for all FDs (and
- * reset the FDs)
- * */
- for (int i = 0; i < num_ps; i++) {
- make_test_fds_readable(tfds, num_fds);
-
- gpr_mu_lock(pollsets[i].mu);
- deadline = grpc_timespec_to_millis_round_up(
- grpc_timeout_milliseconds_to_deadline(2));
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(pollsets[i].ps, &worker, deadline));
- gpr_mu_unlock(pollsets[i].mu);
-
- grpc_core::ExecCtx::Get()->Flush();
-
- verify_readable_and_reset(tfds, num_fds);
- grpc_core::ExecCtx::Get()->Flush();
- }
-
- /* Test tear down */
- grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[5].fd);
- grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[6].fd);
- grpc_core::ExecCtx::Get()->Flush();
-
- grpc_pollset_set_del_pollset(pollset_sets[1].pss, pollsets[0].ps);
- grpc_pollset_set_del_pollset(pollset_sets[0].pss, pollsets[1].ps);
- grpc_pollset_set_del_pollset(pollset_sets[0].pss, pollsets[2].ps);
-
- grpc_pollset_set_del_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
- grpc_core::ExecCtx::Get()->Flush();
-
- cleanup_test_fds(tfds, num_fds);
- cleanup_test_pollsets(pollsets, num_ps);
- cleanup_test_pollset_sets(pollset_sets, num_pss);
-}
-
-/* Same FD added multiple times to the pollset_set tree */
-void pollset_set_test_dup_fds() {
- /* We construct the following structure for this test:
- *
- * +---> FD0
- * |
- * |
- * PSS0---+
- * | +---> FD0 (also under PSS0)
- * | |
- * +---> PSS1--+ +--> FD1 (also under PSS1)
- * | |
- * +---> PS ---+
- * | |
- * | +--> FD2
- * +---> FD1
- */
- grpc_core::ExecCtx exec_ctx;
- grpc_pollset_worker* worker;
- grpc_millis deadline;
-
- test_fd tfds[3];
- test_pollset pollset;
- test_pollset_set pollset_sets[2];
- const int num_fds = GPR_ARRAY_SIZE(tfds);
- const int num_ps = 1;
- const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
-
- init_test_fds(tfds, num_fds);
- init_test_pollsets(&pollset, num_ps);
- init_test_pollset_sets(pollset_sets, num_pss);
-
- /* Construct the structure */
- grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[1].fd);
-
- grpc_pollset_add_fd(pollset.ps, tfds[1].fd);
- grpc_pollset_add_fd(pollset.ps, tfds[2].fd);
-
- grpc_pollset_set_add_pollset(pollset_sets[1].pss, pollset.ps);
- grpc_pollset_set_add_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
-
- /* Test. Make all FDs readable and make sure that can be observed by doing a
- * grpc_pollset_work on the pollset 'PS' */
- make_test_fds_readable(tfds, num_fds);
-
- gpr_mu_lock(pollset.mu);
- deadline = grpc_timespec_to_millis_round_up(
- grpc_timeout_milliseconds_to_deadline(2));
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(pollset.ps, &worker, deadline));
- gpr_mu_unlock(pollset.mu);
- grpc_core::ExecCtx::Get()->Flush();
-
- verify_readable_and_reset(tfds, num_fds);
- grpc_core::ExecCtx::Get()->Flush();
-
- /* Tear down */
- grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[1].fd);
-
- grpc_pollset_set_del_pollset(pollset_sets[1].pss, pollset.ps);
- grpc_pollset_set_del_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
- grpc_core::ExecCtx::Get()->Flush();
-
- cleanup_test_fds(tfds, num_fds);
- cleanup_test_pollsets(&pollset, num_ps);
- cleanup_test_pollset_sets(pollset_sets, num_pss);
-}
-
-/* Pollset_set with an empty pollset */
-void pollset_set_test_empty_pollset() {
- /* We construct the following structure for this test:
- *
- * +---> PS0 (EMPTY)
- * |
- * +---> FD0
- * |
- * PSS0---+
- * | +---> FD1
- * | |
- * +---> PS1--+
- * |
- * +---> FD2
- */
- grpc_core::ExecCtx exec_ctx;
- grpc_pollset_worker* worker;
- grpc_millis deadline;
-
- test_fd tfds[3];
- test_pollset pollsets[2];
- test_pollset_set pollset_set;
- const int num_fds = GPR_ARRAY_SIZE(tfds);
- const int num_ps = GPR_ARRAY_SIZE(pollsets);
- const int num_pss = 1;
-
- init_test_fds(tfds, num_fds);
- init_test_pollsets(pollsets, num_ps);
- init_test_pollset_sets(&pollset_set, num_pss);
-
- /* Construct the structure */
- grpc_pollset_set_add_fd(pollset_set.pss, tfds[0].fd);
- grpc_pollset_add_fd(pollsets[1].ps, tfds[1].fd);
- grpc_pollset_add_fd(pollsets[1].ps, tfds[2].fd);
-
- grpc_pollset_set_add_pollset(pollset_set.pss, pollsets[0].ps);
- grpc_pollset_set_add_pollset(pollset_set.pss, pollsets[1].ps);
-
- /* Test. Make all FDs readable and make sure that can be observed by doing
- * grpc_pollset_work on the empty pollset 'PS0' */
- make_test_fds_readable(tfds, num_fds);
-
- gpr_mu_lock(pollsets[0].mu);
- deadline = grpc_timespec_to_millis_round_up(
- grpc_timeout_milliseconds_to_deadline(2));
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(pollsets[0].ps, &worker, deadline));
- gpr_mu_unlock(pollsets[0].mu);
- grpc_core::ExecCtx::Get()->Flush();
-
- verify_readable_and_reset(tfds, num_fds);
- grpc_core::ExecCtx::Get()->Flush();
-
- /* Tear down */
- grpc_pollset_set_del_fd(pollset_set.pss, tfds[0].fd);
- grpc_pollset_set_del_pollset(pollset_set.pss, pollsets[0].ps);
- grpc_pollset_set_del_pollset(pollset_set.pss, pollsets[1].ps);
- grpc_core::ExecCtx::Get()->Flush();
-
- cleanup_test_fds(tfds, num_fds);
- cleanup_test_pollsets(pollsets, num_ps);
- cleanup_test_pollset_sets(&pollset_set, num_pss);
-}
-
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- grpc_init();
- {
- grpc_core::ExecCtx exec_ctx;
- const char* poll_strategy = grpc_get_poll_strategy_name();
-
- if (poll_strategy != nullptr &&
- (strcmp(poll_strategy, "epollsig") == 0 ||
- strcmp(poll_strategy, "epoll-threadpool") == 0)) {
- pollset_set_test_basic();
- pollset_set_test_dup_fds();
- pollset_set_test_empty_pollset();
- } else {
- gpr_log(GPR_INFO,
- "Skipping the test. The test is only relevant for 'epoll' "
- "strategy. and the current strategy is: '%s'",
- poll_strategy);
- }
- }
- grpc_shutdown();
- return 0;
-}
-#else /* defined(GRPC_LINUX_EPOLL_CREATE1) */
-int main(int argc, char** argv) { return 0; }
-#endif /* !defined(GRPC_LINUX_EPOLL_CREATE1) */
diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc
index 79b2b50e70..e495e4c877 100644
--- a/test/core/iomgr/resolve_address_posix_test.cc
+++ b/test/core/iomgr/resolve_address_posix_test.cc
@@ -91,7 +91,7 @@ static void actually_poll(void* argsp) {
break;
}
grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now();
- gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
+ gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu);
diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc
index a0dc484f3e..52e4840c7c 100644
--- a/test/core/iomgr/resolve_address_test.cc
+++ b/test/core/iomgr/resolve_address_test.cc
@@ -22,8 +22,14 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
+
+#include <string.h>
+
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
+#include "test/core/util/cmdline.h"
#include "test/core/util/test_config.h"
static gpr_timespec test_deadline(void) {
@@ -82,7 +88,7 @@ static void poll_pollset_until_request_done(args_struct* args) {
break;
}
grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now();
- gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
+ gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu);
@@ -240,6 +246,28 @@ static void test_unparseable_hostports(void) {
}
int main(int argc, char** argv) {
+ // First set the resolver type based off of --resolver
+ const char* resolver_type = nullptr;
+ gpr_cmdline* cl = gpr_cmdline_create("resolve address test");
+ gpr_cmdline_add_string(cl, "resolver", "Resolver type (ares or native)",
+ &resolver_type);
+ gpr_cmdline_parse(cl, argc, argv);
+ const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER");
+ if (cur_resolver != nullptr && strlen(cur_resolver) != 0) {
+ gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s",
+ cur_resolver);
+ }
+ if (gpr_stricmp(resolver_type, "native") == 0) {
+ gpr_setenv("GRPC_DNS_RESOLVER", "native");
+ } else if (gpr_stricmp(resolver_type, "ares") == 0) {
+#ifndef GRPC_UV
+ gpr_setenv("GRPC_DNS_RESOLVER", "ares");
+#endif
+ } else {
+ gpr_log(GPR_ERROR, "--resolver_type was not set to ares or native");
+ abort();
+ }
+ // Run the test.
grpc_test_init(argc, argv);
grpc_init();
{
@@ -250,10 +278,18 @@ int main(int argc, char** argv) {
test_missing_default_port();
test_ipv6_with_port();
test_ipv6_without_port();
- test_invalid_ip_addresses();
- test_unparseable_hostports();
+ if (gpr_stricmp(resolver_type, "ares") != 0) {
+ // These tests can trigger DNS queries to the nearby nameserver
+ // that need to come back in order for the test to succeed.
+ // c-ares is prone to not using the local system caches that the
+ // native getaddrinfo implementations take advantage of, so running
+ // these unit tests under c-ares risks flakiness.
+ test_invalid_ip_addresses();
+ test_unparseable_hostports();
+ }
grpc_executor_shutdown();
}
+ gpr_cmdline_destroy(cl);
grpc_shutdown();
return 0;
diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc
index 059ff7b5f8..f3b35fed32 100644
--- a/test/core/iomgr/resource_quota_test.cc
+++ b/test/core/iomgr/resource_quota_test.cc
@@ -798,6 +798,98 @@ static void test_negative_rq_free_pool(void) {
}
}
+// Simple test to check resource quota thread limits
+static void test_thread_limit() {
+ grpc_core::ExecCtx exec_ctx;
+
+ grpc_resource_quota* rq = grpc_resource_quota_create("test_thread_limit");
+ grpc_resource_user* ru1 = grpc_resource_user_create(rq, "ru1");
+ grpc_resource_user* ru2 = grpc_resource_user_create(rq, "ru2");
+
+ // Max threads = 100
+ grpc_resource_quota_set_max_threads(rq, 100);
+
+ // Request quota for 100 threads (50 for ru1, 50 for ru2)
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru1, 10));
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru2, 10));
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru1, 40));
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru2, 40));
+
+ // Threads exhausted. Next request must fail
+ GPR_ASSERT(!grpc_resource_user_allocate_threads(ru2, 20));
+
+ // Free 20 threads from two different users
+ grpc_resource_user_free_threads(ru1, 10);
+ grpc_resource_user_free_threads(ru2, 10);
+
+ // Next request to 20 threads must succeed
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru2, 20));
+
+ // No more thread quota again
+ GPR_ASSERT(!grpc_resource_user_allocate_threads(ru1, 20));
+
+ // Free 10 more
+ grpc_resource_user_free_threads(ru1, 10);
+
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru1, 5));
+ GPR_ASSERT(
+ !grpc_resource_user_allocate_threads(ru2, 10)); // Only 5 available
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru2, 5));
+
+ // Teardown (ru1 and ru2 release all the quota back to rq)
+ grpc_resource_user_unref(ru1);
+ grpc_resource_user_unref(ru2);
+ grpc_resource_quota_unref(rq);
+}
+
+// Change max quota in either direction dynamically
+static void test_thread_maxquota_change() {
+ grpc_core::ExecCtx exec_ctx;
+
+ grpc_resource_quota* rq =
+ grpc_resource_quota_create("test_thread_maxquota_change");
+ grpc_resource_user* ru1 = grpc_resource_user_create(rq, "ru1");
+ grpc_resource_user* ru2 = grpc_resource_user_create(rq, "ru2");
+
+ // Max threads = 100
+ grpc_resource_quota_set_max_threads(rq, 100);
+
+ // Request quota for 100 threads (50 for ru1, 50 for ru2)
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru1, 50));
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru2, 50));
+
+ // Threads exhausted. Next request must fail
+ GPR_ASSERT(!grpc_resource_user_allocate_threads(ru2, 20));
+
+ // Increase maxquota and retry
+ // Max threads = 150;
+ grpc_resource_quota_set_max_threads(rq, 150);
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru2, 20)); // ru2=70, ru1=50
+
+ // Decrease maxquota (Note: Quota already given to ru1 and ru2 is unaffected)
+ // Max threads = 10;
+ grpc_resource_quota_set_max_threads(rq, 10);
+
+ // New requests will fail until quota is available
+ GPR_ASSERT(!grpc_resource_user_allocate_threads(ru1, 10));
+
+ // Make quota available
+ grpc_resource_user_free_threads(ru1, 50); // ru1 now has 0
+ GPR_ASSERT(!grpc_resource_user_allocate_threads(ru1, 10)); // not enough
+
+ grpc_resource_user_free_threads(ru2, 70); // ru2 now has 0
+
+ // Now we can get quota up-to 10, the current max
+ GPR_ASSERT(grpc_resource_user_allocate_threads(ru2, 10));
+ // No more thread quota again
+ GPR_ASSERT(!grpc_resource_user_allocate_threads(ru1, 10));
+
+ // Teardown (ru1 and ru2 release all the quota back to rq)
+ grpc_resource_user_unref(ru1);
+ grpc_resource_user_unref(ru2);
+ grpc_resource_quota_unref(rq);
+}
+
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
@@ -827,6 +919,11 @@ int main(int argc, char** argv) {
test_negative_rq_free_pool();
gpr_mu_destroy(&g_mu);
gpr_cv_destroy(&g_cv);
+
+ // Resource quota thread related
+ test_thread_limit();
+ test_thread_maxquota_change();
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc
index f4df6fca23..6447cc234d 100644
--- a/test/core/iomgr/tcp_posix_test.cc
+++ b/test/core/iomgr/tcp_posix_test.cc
@@ -36,6 +36,9 @@
#include <grpc/support/time.h>
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/iomgr/buffer_list.h"
+#include "src/core/lib/iomgr/ev_posix.h"
+#include "src/core/lib/iomgr/sockaddr_posix.h"
#include "src/core/lib/slice/slice_internal.h"
#include "test/core/iomgr/endpoint_tests.h"
#include "test/core/util/test_config.h"
@@ -68,6 +71,43 @@ static void create_sockets(int sv[2]) {
GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0);
}
+static void create_inet_sockets(int sv[2]) {
+ /* Prepare listening socket */
+ struct sockaddr_in addr;
+ memset(&addr, 0, sizeof(struct sockaddr_in));
+ addr.sin_family = AF_INET;
+ int sock = socket(AF_INET, SOCK_STREAM, 0);
+ GPR_ASSERT(sock);
+ GPR_ASSERT(bind(sock, (sockaddr*)&addr, sizeof(sockaddr_in)) == 0);
+ listen(sock, 1);
+
+ /* Prepare client socket and connect to server */
+ socklen_t len = sizeof(sockaddr_in);
+ GPR_ASSERT(getsockname(sock, (sockaddr*)&addr, &len) == 0);
+
+ int client = socket(AF_INET, SOCK_STREAM, 0);
+ GPR_ASSERT(client);
+ int ret;
+ do {
+ ret = connect(client, (sockaddr*)&addr, sizeof(sockaddr_in));
+ } while (ret == -1 && errno == EINTR);
+
+ /* Accept client connection */
+ len = sizeof(socklen_t);
+ int server;
+ do {
+ server = accept(sock, (sockaddr*)&addr, (socklen_t*)&len);
+ } while (server == -1 && errno == EINTR);
+ GPR_ASSERT(server != -1);
+
+ sv[0] = server;
+ sv[1] = client;
+ int flags = fcntl(sv[0], F_GETFL, 0);
+ GPR_ASSERT(fcntl(sv[0], F_SETFL, flags | O_NONBLOCK) == 0);
+ flags = fcntl(sv[1], F_GETFL, 0);
+ GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0);
+}
+
static ssize_t fill_socket(int fd) {
ssize_t write_bytes;
ssize_t total_bytes = 0;
@@ -176,7 +216,8 @@ static void read_test(size_t num_bytes, size_t slice_size) {
a[0].type = GRPC_ARG_INTEGER,
a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
+ ep =
+ grpc_tcp_create(grpc_fd_create(sv[1], "read_test", false), &args, "test");
grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
@@ -226,7 +267,8 @@ static void large_read_test(size_t slice_size) {
a[0].type = GRPC_ARG_INTEGER;
a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test"), &args, "test");
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test", false), &args,
+ "test");
grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket(sv[0]);
@@ -287,11 +329,10 @@ static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size,
static void write_done(void* user_data /* write_socket_state */,
grpc_error* error) {
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
struct write_socket_state* state =
static_cast<struct write_socket_state*>(user_data);
- gpr_log(GPR_INFO, "Write done callback called");
gpr_mu_lock(g_mu);
- gpr_log(GPR_INFO, "Signalling write done");
state->write_done = 1;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
@@ -338,10 +379,24 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
gpr_free(buf);
}
+/* Verifier for timestamps callback for write_test */
+void timestamps_verifier(void* arg, grpc_core::Timestamps* ts,
+ grpc_error* error) {
+ GPR_ASSERT(error == GRPC_ERROR_NONE);
+ GPR_ASSERT(arg != nullptr);
+ GPR_ASSERT(ts->sendmsg_time.clock_type == GPR_CLOCK_REALTIME);
+ GPR_ASSERT(ts->scheduled_time.clock_type == GPR_CLOCK_REALTIME);
+ GPR_ASSERT(ts->acked_time.clock_type == GPR_CLOCK_REALTIME);
+ gpr_atm* done_timestamps = (gpr_atm*)arg;
+ gpr_atm_rel_store(done_timestamps, static_cast<gpr_atm>(1));
+}
+
/* Write to a socket using the grpc_tcp API, then drain it directly.
Note that if the write does not complete immediately we need to drain the
- socket in parallel with the read. */
-static void write_test(size_t num_bytes, size_t slice_size) {
+ socket in parallel with the read. If collect_timestamps is true, it will
+ try to get timestamps for the write. */
+static void write_test(size_t num_bytes, size_t slice_size,
+ bool collect_timestamps) {
int sv[2];
grpc_endpoint* ep;
struct write_socket_state state;
@@ -354,18 +409,27 @@ static void write_test(size_t num_bytes, size_t slice_size) {
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
grpc_core::ExecCtx exec_ctx;
+ if (collect_timestamps && !grpc_event_engine_can_track_errors()) {
+ return;
+ }
+
gpr_log(GPR_INFO,
"Start write test with %" PRIuPTR " bytes, slice size %" PRIuPTR,
num_bytes, slice_size);
- create_sockets(sv);
+ if (collect_timestamps) {
+ create_inet_sockets(sv);
+ } else {
+ create_sockets(sv);
+ }
grpc_arg a[1];
a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
a[0].type = GRPC_ARG_INTEGER,
a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test"), &args, "test");
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test", collect_timestamps),
+ &args, "test");
grpc_endpoint_add_to_pollset(ep, g_pollset);
state.ep = ep;
@@ -378,18 +442,26 @@ static void write_test(size_t num_bytes, size_t slice_size) {
GRPC_CLOSURE_INIT(&write_done_closure, write_done, &state,
grpc_schedule_on_exec_ctx);
- grpc_endpoint_write(ep, &outgoing, &write_done_closure);
+ gpr_atm done_timestamps;
+ gpr_atm_rel_store(&done_timestamps, static_cast<gpr_atm>(0));
+ grpc_endpoint_write(ep, &outgoing, &write_done_closure,
+ grpc_event_engine_can_track_errors() && collect_timestamps
+ ? (void*)&done_timestamps
+ : nullptr);
drain_socket_blocking(sv[0], num_bytes, num_bytes);
+ exec_ctx.Flush();
gpr_mu_lock(g_mu);
for (;;) {
grpc_pollset_worker* worker = nullptr;
- if (state.write_done) {
+ if (state.write_done &&
+ (!(grpc_event_engine_can_track_errors() && collect_timestamps) ||
+ gpr_atm_acq_load(&done_timestamps) == static_cast<gpr_atm>(1))) {
break;
}
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
-
+ exec_ctx.Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -433,7 +505,8 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
a[0].type = GRPC_ARG_INTEGER;
a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
+ ep =
+ grpc_tcp_create(grpc_fd_create(sv[1], "read_test", false), &args, "test");
GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0);
grpc_endpoint_add_to_pollset(ep, g_pollset);
@@ -493,14 +566,21 @@ void run_tests(void) {
large_read_test(8192);
large_read_test(1);
- write_test(100, 8192);
- write_test(100, 1);
- write_test(100000, 8192);
- write_test(100000, 1);
- write_test(100000, 137);
+ write_test(100, 8192, false);
+ write_test(100, 1, false);
+ write_test(100000, 8192, false);
+ write_test(100000, 1, false);
+ write_test(100000, 137, false);
+
+ write_test(100, 8192, true);
+ write_test(100, 1, true);
+ write_test(100000, 8192, true);
+ write_test(100000, 1, true);
+ write_test(100, 137, true);
for (i = 1; i < 1000; i = GPR_MAX(i + 1, i * 5 / 4)) {
- write_test(40320, i);
+ write_test(40320, i, false);
+ write_test(40320, i, true);
}
release_fd_test(100, 8192);
@@ -522,10 +602,10 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
a[0].type = GRPC_ARG_INTEGER;
a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- f.client_ep =
- grpc_tcp_create(grpc_fd_create(sv[0], "fixture:client"), &args, "test");
- f.server_ep =
- grpc_tcp_create(grpc_fd_create(sv[1], "fixture:server"), &args, "test");
+ f.client_ep = grpc_tcp_create(grpc_fd_create(sv[0], "fixture:client", false),
+ &args, "test");
+ f.server_ep = grpc_tcp_create(grpc_fd_create(sv[1], "fixture:server", false),
+ &args, "test");
grpc_resource_quota_unref_internal(resource_quota);
grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
grpc_endpoint_add_to_pollset(f.server_ep, g_pollset);
@@ -545,6 +625,7 @@ int main(int argc, char** argv) {
grpc_closure destroyed;
grpc_test_init(argc, argv);
grpc_init();
+ grpc_core::grpc_tcp_set_write_timestamps_callback(timestamps_verifier);
{
grpc_core::ExecCtx exec_ctx;
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
diff --git a/test/core/iomgr/timer_heap_test.cc b/test/core/iomgr/timer_heap_test.cc
index ebe5e32f3a..ebe5e6610d 100644
--- a/test/core/iomgr/timer_heap_test.cc
+++ b/test/core/iomgr/timer_heap_test.cc
@@ -204,7 +204,7 @@ static void test2(void) {
}
if (num_inserted) {
- gpr_atm* min_deadline = nullptr;
+ grpc_millis* min_deadline = nullptr;
for (size_t i = 0; i < elems_size; i++) {
if (elems[i].inserted) {
if (min_deadline == nullptr) {
diff --git a/test/core/iomgr/timer_list_test.cc b/test/core/iomgr/timer_list_test.cc
index b1d919b292..fd65d1abf1 100644
--- a/test/core/iomgr/timer_list_test.cc
+++ b/test/core/iomgr/timer_list_test.cc
@@ -38,6 +38,8 @@ extern grpc_core::TraceFlag grpc_timer_trace;
extern grpc_core::TraceFlag grpc_timer_check_trace;
static int cb_called[MAX_CB][2];
+static const int64_t kMillisIn25Days = 2160000000;
+static const int64_t kHoursIn25Days = 600;
static void cb(void* arg, grpc_error* error) {
cb_called[(intptr_t)arg][error == GRPC_ERROR_NONE]++;
@@ -151,17 +153,108 @@ void destruction_test(void) {
GPR_ASSERT(1 == cb_called[2][0]);
}
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- grpc_core::ExecCtx::GlobalInit();
+/* Cleans up a list with pending timers that simulate long-running-services.
+ This test does the following:
+ 1) Simulates grpc server start time to 25 days in the past (completed in
+ `main` using TestOnlyGlobalInit())
+ 2) Creates 4 timers - one with a deadline 25 days in the future, one just
+ 3 milliseconds in future, one way out in the future, and one using the
+ grpc_timespec_to_millis_round_up function to compute a deadline of 25
+ days in the future
+ 3) Simulates 4 milliseconds of elapsed time by changing `now` (cached at
+ step 1) to `now+4`
+ 4) Shuts down the timer list
+ https://github.com/grpc/grpc/issues/15904 */
+void long_running_service_cleanup_test(void) {
+ grpc_timer timers[4];
grpc_core::ExecCtx exec_ctx;
- grpc_determine_iomgr_platform();
- grpc_iomgr_platform_init();
- gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
- add_test();
- destruction_test();
- grpc_iomgr_platform_shutdown();
+
+ gpr_log(GPR_INFO, "long_running_service_cleanup_test");
+
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
+ GPR_ASSERT(now >= kMillisIn25Days);
+ grpc_timer_list_init();
+ grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_trace);
+ grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_check_trace);
+ memset(cb_called, 0, sizeof(cb_called));
+
+ grpc_timer_init(
+ &timers[0], now + kMillisIn25Days,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)0, grpc_schedule_on_exec_ctx));
+ grpc_timer_init(
+ &timers[1], now + 3,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)1, grpc_schedule_on_exec_ctx));
+ grpc_timer_init(
+ &timers[2], GRPC_MILLIS_INF_FUTURE - 1,
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)2, grpc_schedule_on_exec_ctx));
+
+ gpr_timespec deadline_spec = grpc_millis_to_timespec(
+ now + kMillisIn25Days, gpr_clock_type::GPR_CLOCK_MONOTONIC);
+
+ /* grpc_timespec_to_millis_round_up is how users usually compute a millisecond
+ input value into grpc_timer_init, so we mimic that behavior here */
+ grpc_timer_init(
+ &timers[3], grpc_timespec_to_millis_round_up(deadline_spec),
+ GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)3, grpc_schedule_on_exec_ctx));
+
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(now + 4);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(0 == cb_called[0][0]); // Timer 0 not called
+ GPR_ASSERT(0 == cb_called[0][1]);
+ GPR_ASSERT(0 == cb_called[1][0]);
+ GPR_ASSERT(1 == cb_called[1][1]); // Timer 1 fired
+ GPR_ASSERT(0 == cb_called[2][0]); // Timer 2 not called
+ GPR_ASSERT(0 == cb_called[2][1]);
+ GPR_ASSERT(0 == cb_called[3][0]); // Timer 3 not called
+ GPR_ASSERT(0 == cb_called[3][1]);
+
+ grpc_timer_list_shutdown();
+ grpc_core::ExecCtx::Get()->Flush();
+ /* Timers 0, 2, and 3 were fired with an error during cleanup */
+ GPR_ASSERT(1 == cb_called[0][0]);
+ GPR_ASSERT(0 == cb_called[1][0]);
+ GPR_ASSERT(1 == cb_called[2][0]);
+ GPR_ASSERT(1 == cb_called[3][0]);
+}
+
+int main(int argc, char** argv) {
+ /* Tests with default g_start_time */
+ {
+ grpc_test_init(argc, argv);
+ grpc_core::ExecCtx::GlobalInit();
+ grpc_core::ExecCtx exec_ctx;
+ grpc_determine_iomgr_platform();
+ grpc_iomgr_platform_init();
+ gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
+ add_test();
+ destruction_test();
+ grpc_iomgr_platform_shutdown();
+ }
grpc_core::ExecCtx::GlobalShutdown();
+
+ /* Begin long running service tests */
+ {
+ grpc_test_init(argc, argv);
+ /* Set g_start_time back 25 days. */
+ /* We set g_start_time here in case there are any initialization
+ dependencies that use g_start_time. */
+ gpr_timespec new_start =
+ gpr_time_sub(gpr_now(gpr_clock_type::GPR_CLOCK_MONOTONIC),
+ gpr_time_from_hours(kHoursIn25Days,
+ gpr_clock_type::GPR_CLOCK_MONOTONIC));
+ grpc_core::ExecCtx::TestOnlyGlobalInit(new_start);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_determine_iomgr_platform();
+ grpc_iomgr_platform_init();
+ gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
+ long_running_service_cleanup_test();
+ add_test();
+ destruction_test();
+ grpc_iomgr_platform_shutdown();
+ }
+ grpc_core::ExecCtx::GlobalShutdown();
+
return 0;
}
diff --git a/test/core/security/BUILD b/test/core/security/BUILD
index 70bcc8c9c3..b7de955cdb 100644
--- a/test/core/security/BUILD
+++ b/test/core/security/BUILD
@@ -129,6 +129,27 @@ grpc_cc_test(
)
grpc_cc_test(
+ name = "linux_system_roots_test",
+ srcs = ["linux_system_roots_test.cc"],
+ data = [
+ "//test/core/security/etc:bundle.pem",
+ "//test/core/security/etc:test_roots/cert1.pem",
+ "//test/core/security/etc:test_roots/cert2.pem",
+ "//test/core/security/etc:test_roots/cert3.pem",
+ ],
+ language = "C++",
+ external_deps = [
+ "gtest",
+ ],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
name = "ssl_credentials_test",
srcs = ["ssl_credentials_test.cc"],
language = "C++",
@@ -183,6 +204,7 @@ grpc_cc_test(
"//:gpr",
"//:gpr_base",
"//:grpc",
+ "//test/core/util:gpr_test_util",
],
)
@@ -195,6 +217,7 @@ grpc_cc_test(
"//:gpr",
"//:gpr_base",
"//:grpc",
+ "//test/core/util:gpr_test_util",
],
)
@@ -206,6 +229,7 @@ grpc_cc_test(
"//:alts_util",
"//:gpr",
"//:grpc",
+ "//test/core/util:gpr_test_util",
],
)
@@ -216,9 +240,10 @@ grpc_cc_test(
deps = [
"//:gpr",
"//:grpc",
- "//:grpc_base_c",
+ "//:grpc_base_c",
"//:grpc_secure",
- "//:tsi",
+ "//:tsi",
"//:tsi_interface",
+ "//test/core/util:gpr_test_util",
],
)
diff --git a/test/core/security/check_gcp_environment_linux_test.cc b/test/core/security/check_gcp_environment_linux_test.cc
index 6c436a3945..b01471abd3 100644
--- a/test/core/security/check_gcp_environment_linux_test.cc
+++ b/test/core/security/check_gcp_environment_linux_test.cc
@@ -16,6 +16,8 @@
*
*/
+#include <grpc/support/port_platform.h>
+
#include "src/core/lib/security/credentials/alts/check_gcp_environment.h"
#if GPR_LINUX
@@ -67,6 +69,7 @@ static void test_gcp_environment_check_failure() {
GPR_ASSERT(!check_bios_data_linux_test("Amazon"));
GPR_ASSERT(!check_bios_data_linux_test("Google-Chrome\t\t"));
GPR_ASSERT(!check_bios_data_linux_test("Amazon"));
+ GPR_ASSERT(!check_bios_data_linux_test("\n"));
}
int main(int argc, char** argv) {
diff --git a/test/core/security/check_gcp_environment_windows_test.cc b/test/core/security/check_gcp_environment_windows_test.cc
index 46179b747d..2b9407e8ca 100644
--- a/test/core/security/check_gcp_environment_windows_test.cc
+++ b/test/core/security/check_gcp_environment_windows_test.cc
@@ -16,6 +16,8 @@
*
*/
+#include <grpc/support/port_platform.h>
+
#include "src/core/lib/security/credentials/alts/check_gcp_environment.h"
#ifdef GPR_WINDOWS
diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc
index 2b90939ab8..97156761bd 100644
--- a/test/core/security/credentials_test.cc
+++ b/test/core/security/credentials_test.cc
@@ -43,6 +43,8 @@
#include "src/core/lib/security/transport/auth_filters.h"
#include "test/core/util/test_config.h"
+using grpc_core::internal::set_gce_tenancy_checker_for_testing;
+
/* -- Mock channel credentials. -- */
static grpc_channel_credentials* grpc_mock_channel_credentials_create(
@@ -120,6 +122,12 @@ static const char other_test_service_url[] = "https://bar.com/bar.v1";
static const char test_method[] = "ThisIsNotAMethod";
+/* -- Global state flags. -- */
+
+static bool g_test_is_on_gce = false;
+
+static bool g_test_gce_tenancy_checker_called = false;
+
/* -- Utils. -- */
static char* test_json_key_str(void) {
@@ -602,7 +610,7 @@ static void test_compute_engine_creds_failure(void) {
grpc_core::ExecCtx exec_ctx;
request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Error occured when fetching oauth2 token."),
+ "Error occurred when fetching oauth2 token."),
nullptr, 0);
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
@@ -691,7 +699,7 @@ static void test_refresh_token_creds_failure(void) {
grpc_core::ExecCtx exec_ctx;
request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Error occured when fetching oauth2 token."),
+ "Error occurred when fetching oauth2 token."),
nullptr, 0);
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
@@ -910,24 +918,13 @@ static void test_google_default_creds_refresh_token(void) {
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
}
-static int default_creds_gce_detection_httpcli_get_success_override(
- const grpc_httpcli_request* request, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
- *response = http_response(200, "");
- grpc_http_header* headers =
- static_cast<grpc_http_header*>(gpr_malloc(sizeof(*headers) * 1));
- headers[0].key = gpr_strdup("Metadata-Flavor");
- headers[0].value = gpr_strdup("Google");
- response->hdr_count = 1;
- response->hdrs = headers;
- GPR_ASSERT(strcmp(request->http.path, "/") == 0);
- GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
- GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
- return 1;
-}
-
static char* null_well_known_creds_path_getter(void) { return nullptr; }
+static bool test_gce_tenancy_checker(void) {
+ g_test_gce_tenancy_checker_called = true;
+ return g_test_is_on_gce;
+}
+
static void test_google_default_creds_gce(void) {
grpc_core::ExecCtx exec_ctx;
expected_md emd[] = {
@@ -940,11 +937,11 @@ static void test_google_default_creds_gce(void) {
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
grpc_override_well_known_credentials_path_getter(
null_well_known_creds_path_getter);
+ set_gce_tenancy_checker_for_testing(test_gce_tenancy_checker);
+ g_test_gce_tenancy_checker_called = false;
+ g_test_is_on_gce = true;
/* Simulate a successful detection of GCE. */
- grpc_httpcli_set_override(
- default_creds_gce_detection_httpcli_get_success_override,
- httpcli_post_should_not_be_called);
grpc_composite_channel_credentials* creds =
reinterpret_cast<grpc_composite_channel_credentials*>(
grpc_google_default_credentials_create());
@@ -960,11 +957,11 @@ static void test_google_default_creds_gce(void) {
/* Check that we get a cached creds if we call
grpc_google_default_credentials_create again.
GCE detection should not occur anymore either. */
- grpc_httpcli_set_override(httpcli_get_should_not_be_called,
- httpcli_post_should_not_be_called);
+ g_test_gce_tenancy_checker_called = false;
grpc_channel_credentials* cached_creds =
grpc_google_default_credentials_create();
GPR_ASSERT(cached_creds == &creds->base);
+ GPR_ASSERT(g_test_gce_tenancy_checker_called == false);
/* Cleanup. */
grpc_channel_credentials_unref(cached_creds);
@@ -973,36 +970,25 @@ static void test_google_default_creds_gce(void) {
grpc_override_well_known_credentials_path_getter(nullptr);
}
-static int default_creds_gce_detection_httpcli_get_failure_override(
- const grpc_httpcli_request* request, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
- /* No magic header. */
- GPR_ASSERT(strcmp(request->http.path, "/") == 0);
- GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
- *response = http_response(200, "");
- GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
- return 1;
-}
-
static void test_no_google_default_creds(void) {
grpc_flush_cached_google_default_credentials();
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
grpc_override_well_known_credentials_path_getter(
null_well_known_creds_path_getter);
+ set_gce_tenancy_checker_for_testing(test_gce_tenancy_checker);
+ g_test_gce_tenancy_checker_called = false;
+ g_test_is_on_gce = false;
+
/* Simulate a successful detection of GCE. */
- grpc_httpcli_set_override(
- default_creds_gce_detection_httpcli_get_failure_override,
- httpcli_post_should_not_be_called);
GPR_ASSERT(grpc_google_default_credentials_create() == nullptr);
/* Try a cached one. GCE detection should not occur anymore. */
- grpc_httpcli_set_override(httpcli_get_should_not_be_called,
- httpcli_post_should_not_be_called);
+ g_test_gce_tenancy_checker_called = false;
GPR_ASSERT(grpc_google_default_credentials_create() == nullptr);
+ GPR_ASSERT(g_test_gce_tenancy_checker_called == false);
/* Cleanup. */
- grpc_httpcli_set_override(nullptr, nullptr);
grpc_override_well_known_credentials_path_getter(nullptr);
}
diff --git a/test/cpp/naming/create_private_dns_zone.sh b/test/core/security/etc/BUILD
index 5c9364ca1a..2c6ab64a3b 100755..100644
--- a/test/cpp/naming/create_private_dns_zone.sh
+++ b/test/core/security/etc/BUILD
@@ -1,5 +1,4 @@
-#!/bin/bash
-# Copyright 2015 gRPC authors.
+# 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.
@@ -13,15 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# This file is auto-generated
+licenses(["notice"]) # Apache v2
-set -ex
-
-cd "$(dirname "$0")/../../.."
-
-gcloud alpha dns managed-zones create \
- resolver-tests-version-4-grpctestingexp-zone-id \
- --dns-name=resolver-tests-version-4.grpctestingexp. \
- --description="GCE-DNS-private-zone-for-GRPC-testing" \
- --visibility=private \
- --networks=default
+exports_files([
+ "bundle.pem",
+ "test_roots/cert1.pem",
+ "test_roots/cert2.pem",
+ "test_roots/cert3.pem",
+])
diff --git a/test/core/security/etc/README b/test/core/security/etc/README
new file mode 100644
index 0000000000..6ba4382586
--- /dev/null
+++ b/test/core/security/etc/README
@@ -0,0 +1,2 @@
+These files are manual copies of a pem cert from the /etc/ssl/certs/ directory.
+They serve only as dummy certificate test files.
diff --git a/test/core/security/etc/bundle.pem b/test/core/security/etc/bundle.pem
new file mode 100644
index 0000000000..07d7672f83
--- /dev/null
+++ b/test/core/security/etc/bundle.pem
@@ -0,0 +1,63 @@
+-----BEGIN CERTIFICATE-----
+MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE
+AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG
+EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM
+FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC
+REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp
+Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM
+VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+
+SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ
+4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L
+cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi
+eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV
+HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG
+A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3
+DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j
+vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP
+DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc
+maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D
+lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv
+KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE
+AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG
+EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM
+FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC
+REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp
+Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM
+VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+
+SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ
+4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L
+cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi
+eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV
+HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG
+A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3
+DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j
+vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP
+DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc
+maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D
+lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv
+KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE
+AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG
+EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM
+FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC
+REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp
+Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM
+VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+
+SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ
+4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L
+cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi
+eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV
+HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG
+A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3
+DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j
+vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP
+DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc
+maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D
+lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv
+KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
+-----END CERTIFICATE-----
diff --git a/test/core/security/etc/test_roots/cert1.pem b/test/core/security/etc/test_roots/cert1.pem
new file mode 100644
index 0000000000..988cc68aac
--- /dev/null
+++ b/test/core/security/etc/test_roots/cert1.pem
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE
+AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG
+EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM
+FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC
+REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp
+Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM
+VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+
+SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ
+4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L
+cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi
+eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV
+HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG
+A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3
+DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j
+vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP
+DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc
+maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D
+lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv
+KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
+-----END CERTIFICATE-----
diff --git a/test/core/security/etc/test_roots/cert2.pem b/test/core/security/etc/test_roots/cert2.pem
new file mode 100644
index 0000000000..988cc68aac
--- /dev/null
+++ b/test/core/security/etc/test_roots/cert2.pem
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE
+AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG
+EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM
+FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC
+REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp
+Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM
+VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+
+SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ
+4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L
+cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi
+eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV
+HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG
+A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3
+DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j
+vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP
+DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc
+maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D
+lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv
+KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
+-----END CERTIFICATE-----
diff --git a/test/core/security/etc/test_roots/cert3.pem b/test/core/security/etc/test_roots/cert3.pem
new file mode 100644
index 0000000000..988cc68aac
--- /dev/null
+++ b/test/core/security/etc/test_roots/cert3.pem
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE
+AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG
+EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM
+FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC
+REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp
+Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM
+VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+
+SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ
+4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L
+cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi
+eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV
+HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG
+A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3
+DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j
+vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP
+DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc
+maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D
+lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv
+KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
+-----END CERTIFICATE-----
diff --git a/test/core/security/linux_system_roots_test.cc b/test/core/security/linux_system_roots_test.cc
new file mode 100644
index 0000000000..24d446de35
--- /dev/null
+++ b/test/core/security/linux_system_roots_test.cc
@@ -0,0 +1,98 @@
+/*
+ *
+ * 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 <grpc/support/port_platform.h>
+#include <stdio.h>
+
+#ifdef GPR_LINUX
+#include <grpc/grpc_security.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <string.h>
+#include <sys/param.h>
+
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/tmpfile.h"
+#include "src/core/lib/iomgr/load_file.h"
+#include "src/core/lib/security/context/security_context.h"
+#include "src/core/lib/security/security_connector/load_system_roots.h"
+#include "src/core/lib/security/security_connector/load_system_roots_linux.h"
+#include "src/core/lib/security/security_connector/security_connector.h"
+#include "src/core/lib/slice/slice_string_helpers.h"
+#include "src/core/tsi/ssl_transport_security.h"
+#include "src/core/tsi/transport_security.h"
+#include "test/core/util/test_config.h"
+
+#include "gtest/gtest.h"
+
+namespace grpc {
+namespace {
+
+TEST(AbsoluteFilePathTest, ConcatenatesCorrectly) {
+ const char* directory = "nonexistent/test/directory";
+ const char* filename = "doesnotexist.txt";
+ char result_path[MAXPATHLEN];
+ grpc_core::GetAbsoluteFilePath(directory, filename, result_path);
+ EXPECT_STREQ(result_path, "nonexistent/test/directory/doesnotexist.txt");
+}
+
+TEST(CreateRootCertsBundleTest, ReturnsEmpty) {
+ // Test that CreateRootCertsBundle returns an empty slice for null or
+ // nonexistent cert directories.
+ grpc_slice result_slice = grpc_core::CreateRootCertsBundle(nullptr);
+ EXPECT_TRUE(GRPC_SLICE_IS_EMPTY(result_slice));
+ grpc_slice_unref(result_slice);
+ result_slice = grpc_core::CreateRootCertsBundle("does/not/exist");
+ EXPECT_TRUE(GRPC_SLICE_IS_EMPTY(result_slice));
+ grpc_slice_unref(result_slice);
+}
+
+TEST(CreateRootCertsBundleTest, BundlesCorrectly) {
+ // Test that CreateRootCertsBundle returns a correct slice.
+ grpc_slice roots_bundle = grpc_empty_slice();
+ GRPC_LOG_IF_ERROR(
+ "load_file",
+ grpc_load_file("test/core/security/etc/bundle.pem", 1, &roots_bundle));
+ // result_slice should have the same content as roots_bundle.
+ grpc_slice result_slice =
+ grpc_core::CreateRootCertsBundle("test/core/security/etc/test_roots");
+ char* result_str = grpc_slice_to_c_string(result_slice);
+ char* bundle_str = grpc_slice_to_c_string(roots_bundle);
+ EXPECT_STREQ(result_str, bundle_str);
+ // Clean up.
+ gpr_free(result_str);
+ gpr_free(bundle_str);
+ grpc_slice_unref(roots_bundle);
+ grpc_slice_unref(result_slice);
+}
+
+} // namespace
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+#else
+int main() {
+ printf("*** WARNING: this test is only supported on Linux systems ***\n");
+ return 0;
+}
+#endif // GPR_LINUX
diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc
index e4c3ace6b4..9dd37b975b 100644
--- a/test/core/security/security_connector_test.cc
+++ b/test/core/security/security_connector_test.cc
@@ -363,7 +363,7 @@ static void test_ipv6_address_san(void) {
namespace grpc_core {
namespace {
-class TestDefafaultSllRootStore : public DefaultSslRootStore {
+class TestDefaultSslRootStore : public DefaultSslRootStore {
public:
static grpc_slice ComputePemRootCertsForTesting() {
return ComputePemRootCerts();
@@ -389,7 +389,7 @@ static void test_default_ssl_roots(void) {
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, "");
grpc_set_ssl_roots_override_callback(override_roots_success);
grpc_slice roots =
- grpc_core::TestDefafaultSllRootStore::ComputePemRootCertsForTesting();
+ grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting();
char* roots_contents = grpc_slice_to_c_string(roots);
grpc_slice_unref(roots);
GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0);
@@ -398,7 +398,7 @@ static void test_default_ssl_roots(void) {
/* Now let's set the env var: We should get the contents pointed value
instead. */
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_env_var_file_path);
- roots = grpc_core::TestDefafaultSllRootStore::ComputePemRootCertsForTesting();
+ roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting();
roots_contents = grpc_slice_to_c_string(roots);
grpc_slice_unref(roots);
GPR_ASSERT(strcmp(roots_contents, roots_for_env_var) == 0);
@@ -407,7 +407,7 @@ static void test_default_ssl_roots(void) {
/* Now reset the env var. We should fall back to the value overridden using
the api. */
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, "");
- roots = grpc_core::TestDefafaultSllRootStore::ComputePemRootCertsForTesting();
+ roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting();
roots_contents = grpc_slice_to_c_string(roots);
grpc_slice_unref(roots);
GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0);
@@ -415,11 +415,12 @@ static void test_default_ssl_roots(void) {
/* Now setup a permanent failure for the overridden roots and we should get
an empty slice. */
+ gpr_setenv("GRPC_NOT_USE_SYSTEM_SSL_ROOTS", "true");
grpc_set_ssl_roots_override_callback(override_roots_permanent_failure);
- roots = grpc_core::TestDefafaultSllRootStore::ComputePemRootCertsForTesting();
+ roots = grpc_core::TestDefaultSslRootStore::ComputePemRootCertsForTesting();
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(roots));
const tsi_ssl_root_certs_store* root_store =
- grpc_core::TestDefafaultSllRootStore::GetRootStore();
+ grpc_core::TestDefaultSslRootStore::GetRootStore();
GPR_ASSERT(root_store == nullptr);
/* Cleanup. */
diff --git a/test/core/statistics/census_log_tests.h b/test/core/statistics/census_log_tests.h
deleted file mode 100644
index ed808636e3..0000000000
--- a/test/core/statistics/census_log_tests.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * Copyright 2015 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.
- *
- */
-
-#ifndef GRPC_TEST_CORE_STATISTICS_CENSUS_LOG_TESTS_H
-#define GRPC_TEST_CORE_STATISTICS_CENSUS_LOG_TESTS_H
-
-void test_invalid_record_size();
-void test_end_write_with_different_size();
-void test_read_pending_record();
-void test_read_beyond_pending_record();
-void test_detached_while_reading();
-void test_fill_log_no_fragmentation();
-void test_fill_circular_log_no_fragmentation();
-void test_fill_log_with_straddling_records();
-void test_fill_circular_log_with_straddling_records();
-void test_multiple_writers_circular_log();
-void test_multiple_writers();
-void test_performance();
-void test_small_log();
-
-#endif /* GRPC_TEST_CORE_STATISTICS_CENSUS_LOG_TESTS_H */
diff --git a/test/core/statistics/census_stub_test.cc b/test/core/statistics/census_stub_test.cc
deleted file mode 100644
index 507ae0a9fa..0000000000
--- a/test/core/statistics/census_stub_test.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *
- * Copyright 2015 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 <stdio.h>
-#include <stdlib.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include "src/core/ext/census/census_interface.h"
-#include "src/core/ext/census/census_rpc_stats.h"
-#include "test/core/util/test_config.h"
-
-/* Tests census noop stubs in a simulated rpc flow */
-void test_census_stubs(void) {
- census_op_id op_id;
- census_rpc_stats* stats = census_rpc_stats_create_empty();
- census_aggregated_rpc_stats data_map = {0, NULL};
-
- /* Initializes census library at server start up time. */
- census_init();
- /* Starts tracing at the beginning of a rpc. */
- op_id = census_tracing_start_op();
- /* Appends custom annotations on a trace object. */
- census_tracing_print(op_id, "annotation foo");
- census_tracing_print(op_id, "annotation bar");
- /* Appends method tag on the trace object. */
- census_add_method_tag(op_id, "service_foo/method.bar");
- /* Either record client side stats or server side stats associated with the
- op_id. Here for testing purpose, we record both. */
- census_record_rpc_client_stats(op_id, stats);
- census_record_rpc_server_stats(op_id, stats);
- /* Ends a tracing. */
- census_tracing_end_op(op_id);
- /* In process stats queries. */
- census_get_server_stats(&data_map);
- census_aggregated_rpc_stats_set_empty(&data_map);
- census_get_client_stats(&data_map);
- census_aggregated_rpc_stats_set_empty(&data_map);
- gpr_free(stats);
- census_shutdown();
-}
-
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- test_census_stubs();
- return 0;
-}
diff --git a/test/core/statistics/rpc_stats_test.cc b/test/core/statistics/rpc_stats_test.cc
deleted file mode 100644
index a2a648e2ad..0000000000
--- a/test/core/statistics/rpc_stats_test.cc
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- *
- * Copyright 2015 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 <string.h>
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/port_platform.h>
-#include <grpc/support/string.h>
-#include <grpc/support/time.h>
-
-#include "src/core/ext/census/census_interface.h"
-#include "src/core/ext/census/census_rpc_stats.h"
-#include "src/core/ext/census/census_tracing.h"
-#include "test/core/util/test_config.h"
-
-/* Ensure all possible state transitions are called without causing problem */
-static void test_init_shutdown(void) {
- census_stats_store_init();
- census_stats_store_init();
- census_stats_store_shutdown();
- census_stats_store_shutdown();
- census_stats_store_init();
-}
-
-static void test_create_and_destroy(void) {
- census_rpc_stats* stats = NULL;
- census_aggregated_rpc_stats agg_stats = {0, NULL};
-
- stats = census_rpc_stats_create_empty();
- GPR_ASSERT(stats != NULL);
- GPR_ASSERT(stats->cnt == 0 && stats->rpc_error_cnt == 0 &&
- stats->app_error_cnt == 0 && stats->elapsed_time_ms == 0.0 &&
- stats->api_request_bytes == 0 && stats->wire_request_bytes == 0 &&
- stats->api_response_bytes == 0 && stats->wire_response_bytes == 0);
- gpr_free(stats);
-
- census_aggregated_rpc_stats_set_empty(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 0);
- GPR_ASSERT(agg_stats.stats == NULL);
- agg_stats.num_entries = 1;
- agg_stats.stats = (census_per_method_rpc_stats*)gpr_malloc(
- sizeof(census_per_method_rpc_stats));
- agg_stats.stats[0].method = gpr_strdup("foo");
- census_aggregated_rpc_stats_set_empty(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 0);
- GPR_ASSERT(agg_stats.stats == NULL);
-}
-
-#define ASSERT_NEAR(a, b) \
- GPR_ASSERT((a - b) * (a - b) < 1e-24 * (a + b) * (a + b))
-
-static void test_record_and_get_stats(void) {
- census_rpc_stats stats = {1, 2, 3, 4, 5.1, 6.2, 7.3, 8.4};
- census_op_id id;
- census_aggregated_rpc_stats agg_stats = {0, NULL};
-
- /* Record client stats twice with the same op_id. */
- census_init();
- id = census_tracing_start_op();
- census_add_method_tag(id, "m1");
- census_record_rpc_client_stats(id, &stats);
- census_record_rpc_client_stats(id, &stats);
- census_tracing_end_op(id);
- /* Server stats expect to be empty */
- census_get_server_stats(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 0);
- GPR_ASSERT(agg_stats.stats == NULL);
- /* Client stats expect to have one entry */
- census_get_client_stats(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 1);
- GPR_ASSERT(agg_stats.stats != NULL);
- GPR_ASSERT(strcmp(agg_stats.stats[0].method, "m1") == 0);
- GPR_ASSERT(agg_stats.stats[0].minute_stats.cnt == 2 &&
- agg_stats.stats[0].hour_stats.cnt == 2 &&
- agg_stats.stats[0].total_stats.cnt == 2);
- ASSERT_NEAR(agg_stats.stats[0].minute_stats.wire_response_bytes, 16.8);
- ASSERT_NEAR(agg_stats.stats[0].hour_stats.wire_response_bytes, 16.8);
- ASSERT_NEAR(agg_stats.stats[0].total_stats.wire_response_bytes, 16.8);
- /* Get stats again, results should be the same. */
- census_get_client_stats(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 1);
- census_aggregated_rpc_stats_set_empty(&agg_stats);
- census_shutdown();
-
- /* Record both server (once) and client (twice) stats with different op_ids.
- */
- census_init();
- id = census_tracing_start_op();
- census_add_method_tag(id, "m2");
- census_record_rpc_client_stats(id, &stats);
- census_tracing_end_op(id);
- id = census_tracing_start_op();
- census_add_method_tag(id, "m3");
- census_record_rpc_server_stats(id, &stats);
- census_tracing_end_op(id);
- id = census_tracing_start_op();
- census_add_method_tag(id, "m4");
- census_record_rpc_client_stats(id, &stats);
- census_tracing_end_op(id);
- /* Check server stats */
- census_get_server_stats(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 1);
- GPR_ASSERT(strcmp(agg_stats.stats[0].method, "m3") == 0);
- GPR_ASSERT(agg_stats.stats[0].minute_stats.app_error_cnt == 3 &&
- agg_stats.stats[0].hour_stats.app_error_cnt == 3 &&
- agg_stats.stats[0].total_stats.app_error_cnt == 3);
- census_aggregated_rpc_stats_set_empty(&agg_stats);
- /* Check client stats */
- census_get_client_stats(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 2);
- GPR_ASSERT(agg_stats.stats != NULL);
- GPR_ASSERT((strcmp(agg_stats.stats[0].method, "m2") == 0 &&
- strcmp(agg_stats.stats[1].method, "m4") == 0) ||
- (strcmp(agg_stats.stats[0].method, "m4") == 0 &&
- strcmp(agg_stats.stats[1].method, "m2") == 0));
- GPR_ASSERT(agg_stats.stats[0].minute_stats.cnt == 1 &&
- agg_stats.stats[1].minute_stats.cnt == 1);
- census_aggregated_rpc_stats_set_empty(&agg_stats);
- census_shutdown();
-}
-
-static void test_record_stats_on_unknown_op_id(void) {
- census_op_id unknown_id = {0xDEAD, 0xBEEF};
- census_rpc_stats stats = {1, 2, 3, 4, 5.1, 6.2, 7.3, 8.4};
- census_aggregated_rpc_stats agg_stats = {0, NULL};
-
- census_init();
- /* Tests that recording stats against unknown id is noop. */
- census_record_rpc_client_stats(unknown_id, &stats);
- census_record_rpc_server_stats(unknown_id, &stats);
- census_get_server_stats(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 0);
- GPR_ASSERT(agg_stats.stats == NULL);
- census_get_client_stats(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 0);
- GPR_ASSERT(agg_stats.stats == NULL);
- census_aggregated_rpc_stats_set_empty(&agg_stats);
- census_shutdown();
-}
-
-/* Test that record stats is noop when trace store is uninitialized. */
-static void test_record_stats_with_trace_store_uninitialized(void) {
- census_rpc_stats stats = {1, 2, 3, 4, 5.1, 6.2, 7.3, 8.4};
- census_op_id id = {0, 0};
- census_aggregated_rpc_stats agg_stats = {0, NULL};
-
- census_init();
- id = census_tracing_start_op();
- census_add_method_tag(id, "m");
- census_tracing_end_op(id);
- /* shuts down trace store only. */
- census_tracing_shutdown();
- census_record_rpc_client_stats(id, &stats);
- census_get_client_stats(&agg_stats);
- GPR_ASSERT(agg_stats.num_entries == 0);
- census_stats_store_shutdown();
-}
-
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- test_init_shutdown();
- test_create_and_destroy();
- test_record_and_get_stats();
- test_record_stats_on_unknown_op_id();
- test_record_stats_with_trace_store_uninitialized();
- return 0;
-}
diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc
index 68129146cc..f7ce8a7042 100644
--- a/test/core/surface/completion_queue_test.cc
+++ b/test/core/surface/completion_queue_test.cc
@@ -22,6 +22,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "test/core/util/test_config.h"
@@ -41,11 +42,18 @@ static void shutdown_and_destroy(grpc_completion_queue* cc) {
case GRPC_CQ_NEXT: {
ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
break;
}
case GRPC_CQ_PLUCK: {
ev = grpc_completion_queue_pluck(
cc, create_test_tag(), gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
+ break;
+ }
+ case GRPC_CQ_CALLBACK: {
+ // Nothing to do here. The shutdown callback will be invoked when
+ // possible.
break;
}
default: {
@@ -54,7 +62,6 @@ static void shutdown_and_destroy(grpc_completion_queue* cc) {
}
}
- GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
@@ -350,6 +357,83 @@ static void test_pluck_after_shutdown(void) {
}
}
+static void test_callback(void) {
+ grpc_completion_queue* cc;
+ void* tags[128];
+ grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)];
+ grpc_cq_polling_type polling_types[] = {
+ GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
+ grpc_completion_queue_attributes attr;
+ unsigned i;
+
+ LOG_TEST("test_callback");
+
+ bool got_shutdown = false;
+ class ShutdownCallback : public grpc_experimental_completion_queue_functor {
+ public:
+ ShutdownCallback(bool* done) : done_(done) {
+ functor_run = &ShutdownCallback::Run;
+ }
+ ~ShutdownCallback() {}
+ static void Run(grpc_experimental_completion_queue_functor* cb, int ok) {
+ *static_cast<ShutdownCallback*>(cb)->done_ = static_cast<bool>(ok);
+ }
+
+ private:
+ bool* done_;
+ };
+ ShutdownCallback shutdown_cb(&got_shutdown);
+
+ attr.version = 2;
+ attr.cq_completion_type = GRPC_CQ_CALLBACK;
+ attr.cq_shutdown_cb = &shutdown_cb;
+
+ for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) {
+ grpc_core::ExecCtx exec_ctx; // reset exec_ctx
+ attr.cq_polling_type = polling_types[pidx];
+ cc = grpc_completion_queue_create(
+ grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
+
+ int counter = 0;
+ class TagCallback : public grpc_experimental_completion_queue_functor {
+ public:
+ TagCallback(int* counter, int tag) : counter_(counter), tag_(tag) {
+ functor_run = &TagCallback::Run;
+ }
+ ~TagCallback() {}
+ static void Run(grpc_experimental_completion_queue_functor* cb, int ok) {
+ GPR_ASSERT(static_cast<bool>(ok));
+ auto* callback = static_cast<TagCallback*>(cb);
+ *callback->counter_ += callback->tag_;
+ grpc_core::Delete(callback);
+ };
+
+ private:
+ int* counter_;
+ int tag_;
+ };
+
+ int sumtags = 0;
+ for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
+ tags[i] = static_cast<void*>(grpc_core::New<TagCallback>(&counter, i));
+ sumtags += i;
+ }
+
+ for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
+ GPR_ASSERT(grpc_cq_begin_op(cc, tags[i]));
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
+ }
+
+ GPR_ASSERT(sumtags == counter);
+
+ shutdown_and_destroy(cc);
+
+ GPR_ASSERT(got_shutdown);
+ got_shutdown = false;
+ }
+}
+
struct thread_state {
grpc_completion_queue* cc;
void* tag;
@@ -368,6 +452,7 @@ int main(int argc, char** argv) {
test_pluck_after_shutdown();
test_cq_tls_cache_full();
test_cq_tls_cache_empty();
+ test_callback();
grpc_shutdown();
return 0;
}
diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc
index 467deeeaec..7b7a0b6dfc 100644
--- a/test/core/surface/num_external_connectivity_watchers_test.cc
+++ b/test/core/surface/num_external_connectivity_watchers_test.cc
@@ -168,7 +168,7 @@ static const test_fixture insecure_test = {
static grpc_channel* secure_test_create_channel(const char* addr) {
grpc_channel_credentials* ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
+ grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr, nullptr);
grpc_arg ssl_name_override = {
GRPC_ARG_STRING,
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index 52a1b03998..3ebdb88a08 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -33,6 +33,7 @@
#include <grpc/impl/codegen/gpr_slice.h>
#include <grpc/impl/codegen/gpr_types.h>
#include <grpc/impl/codegen/grpc_types.h>
+#include <grpc/impl/codegen/log.h>
#include <grpc/impl/codegen/port_platform.h>
#include <grpc/impl/codegen/propagation_bits.h>
#include <grpc/impl/codegen/slice.h>
@@ -76,11 +77,13 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) grpc_register_plugin);
printf("%lx", (unsigned long) grpc_init);
printf("%lx", (unsigned long) grpc_shutdown);
+ printf("%lx", (unsigned long) grpc_is_initialized);
printf("%lx", (unsigned long) grpc_version_string);
printf("%lx", (unsigned long) grpc_g_stands_for);
printf("%lx", (unsigned long) grpc_completion_queue_factory_lookup);
printf("%lx", (unsigned long) grpc_completion_queue_create_for_next);
printf("%lx", (unsigned long) grpc_completion_queue_create_for_pluck);
+ printf("%lx", (unsigned long) grpc_completion_queue_create_for_callback);
printf("%lx", (unsigned long) grpc_completion_queue_create);
printf("%lx", (unsigned long) grpc_completion_queue_next);
printf("%lx", (unsigned long) grpc_completion_queue_pluck);
@@ -103,11 +106,10 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) grpc_census_call_get_context);
printf("%lx", (unsigned long) grpc_channel_get_target);
printf("%lx", (unsigned long) grpc_channel_get_info);
+ printf("%lx", (unsigned long) grpc_channel_reset_connect_backoff);
printf("%lx", (unsigned long) grpc_insecure_channel_create);
printf("%lx", (unsigned long) grpc_lame_client_channel_create);
printf("%lx", (unsigned long) grpc_channel_destroy);
- printf("%lx", (unsigned long) grpc_channel_get_trace);
- printf("%lx", (unsigned long) grpc_channel_get_uuid);
printf("%lx", (unsigned long) grpc_call_cancel);
printf("%lx", (unsigned long) grpc_call_cancel_with_status);
printf("%lx", (unsigned long) grpc_call_ref);
@@ -131,7 +133,13 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) grpc_resource_quota_ref);
printf("%lx", (unsigned long) grpc_resource_quota_unref);
printf("%lx", (unsigned long) grpc_resource_quota_resize);
+ printf("%lx", (unsigned long) grpc_resource_quota_set_max_threads);
printf("%lx", (unsigned long) grpc_resource_quota_arg_vtable);
+ printf("%lx", (unsigned long) grpc_channelz_get_top_channels);
+ printf("%lx", (unsigned long) grpc_channelz_get_servers);
+ printf("%lx", (unsigned long) grpc_channelz_get_channel);
+ printf("%lx", (unsigned long) grpc_channelz_get_subchannel);
+ printf("%lx", (unsigned long) grpc_channelz_get_socket);
printf("%lx", (unsigned long) grpc_auth_property_iterator_next);
printf("%lx", (unsigned long) grpc_auth_context_property_iterator);
printf("%lx", (unsigned long) grpc_auth_context_peer_identity);
@@ -179,6 +187,8 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) grpc_alts_credentials_options_destroy);
printf("%lx", (unsigned long) grpc_alts_credentials_create);
printf("%lx", (unsigned long) grpc_alts_server_credentials_create);
+ printf("%lx", (unsigned long) grpc_local_credentials_create);
+ printf("%lx", (unsigned long) grpc_local_server_credentials_create);
printf("%lx", (unsigned long) grpc_raw_byte_buffer_create);
printf("%lx", (unsigned long) grpc_raw_compressed_byte_buffer_create);
printf("%lx", (unsigned long) grpc_byte_buffer_copy);
@@ -189,6 +199,13 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) grpc_byte_buffer_reader_next);
printf("%lx", (unsigned long) grpc_byte_buffer_reader_readall);
printf("%lx", (unsigned long) grpc_raw_byte_buffer_from_reader);
+ printf("%lx", (unsigned long) gpr_log_severity_string);
+ printf("%lx", (unsigned long) gpr_log);
+ printf("%lx", (unsigned long) gpr_should_log);
+ printf("%lx", (unsigned long) gpr_log_message);
+ printf("%lx", (unsigned long) gpr_set_log_verbosity);
+ printf("%lx", (unsigned long) gpr_log_verbosity_init);
+ printf("%lx", (unsigned long) gpr_set_log_function);
printf("%lx", (unsigned long) grpc_slice_ref);
printf("%lx", (unsigned long) grpc_slice_unref);
printf("%lx", (unsigned long) grpc_slice_copy);
@@ -247,13 +264,6 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) gpr_get_allocation_functions);
printf("%lx", (unsigned long) gpr_cpu_num_cores);
printf("%lx", (unsigned long) gpr_cpu_current_cpu);
- printf("%lx", (unsigned long) gpr_log_severity_string);
- printf("%lx", (unsigned long) gpr_log);
- printf("%lx", (unsigned long) gpr_should_log);
- printf("%lx", (unsigned long) gpr_log_message);
- printf("%lx", (unsigned long) gpr_set_log_verbosity);
- printf("%lx", (unsigned long) gpr_log_verbosity_init);
- printf("%lx", (unsigned long) gpr_set_log_function);
printf("%lx", (unsigned long) gpr_strdup);
printf("%lx", (unsigned long) gpr_asprintf);
printf("%lx", (unsigned long) gpr_mu_init);
diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc
index 9aba4c499e..10562b3be9 100644
--- a/test/core/surface/sequential_connectivity_test.cc
+++ b/test/core/surface/sequential_connectivity_test.cc
@@ -144,7 +144,7 @@ static void secure_test_add_port(grpc_server* server, const char* addr) {
static grpc_channel* secure_test_create_channel(const char* addr) {
grpc_channel_credentials* ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
+ grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr, nullptr);
grpc_arg ssl_name_override = {
GRPC_ARG_STRING,
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
diff --git a/test/core/transport/BUILD b/test/core/transport/BUILD
index 84fb3a1421..7ca1c1d943 100644
--- a/test/core/transport/BUILD
+++ b/test/core/transport/BUILD
@@ -129,6 +129,7 @@ grpc_cc_test(
language = "C++",
deps = [
"//:grpc",
+ "//test/core/util:gpr_test_util",
],
external_deps = [
"gtest",
diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc
index d3ba50a91c..ab819f9092 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.cc
+++ b/test/core/transport/chttp2/hpack_encoder_test.cc
@@ -160,6 +160,8 @@ static void encode_int_to_str(int i, char* p) {
}
static void test_decode_table_overflow() {
+ // Decrease the default table size to make decode table overflow easier.
+ grpc_chttp2_hpack_compressor_set_max_table_size(&g_compressor, 1024);
int i;
char key[3], value[3];
char* expect;
@@ -170,27 +172,20 @@ static void test_decode_table_overflow() {
false,
};
- for (i = 0; i < 114; i++) {
+ for (i = 0; i < 29; i++) {
encode_int_to_str(i, key);
encode_int_to_str(i + 1, value);
-
- if (i + 61 >= 127) {
+ if (i == 0) {
+ // 3fe107 corresponds to the table size update.
gpr_asprintf(&expect,
- "000009 0104 deadbeef ff%02x 40 02%02x%02x 02%02x%02x",
- i + 61 - 127, key[0], key[1], value[0], value[1]);
- } else if (i > 0) {
+ "00000a 0104 deadbeef 3fe107 40 02%02x%02x 02%02x%02x",
+ key[0], key[1], value[0], value[1]);
+ verify(params, expect, 1, key, value);
+ } else {
gpr_asprintf(&expect,
"000008 0104 deadbeef %02x 40 02%02x%02x 02%02x%02x",
0x80 + 61 + i, key[0], key[1], value[0], value[1]);
- } else {
- gpr_asprintf(&expect, "000007 0104 deadbeef 40 02%02x%02x 02%02x%02x",
- key[0], key[1], value[0], value[1]);
- }
-
- if (i > 0) {
verify(params, expect, 2, "aa", "ba", key, value);
- } else {
- verify(params, expect, 1, key, value);
}
gpr_free(expect);
}
@@ -207,7 +202,7 @@ static void verify_table_size_change_match_elem_size(const char* key,
grpc_mdelem elem = grpc_mdelem_from_slices(
grpc_slice_intern(grpc_slice_from_static_string(key)),
grpc_slice_intern(grpc_slice_from_static_string(value)));
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, use_true_binary);
+ size_t elem_size = grpc_chttp2_get_size_in_hpack_table(elem, use_true_binary);
size_t initial_table_size = g_compressor.table_size;
grpc_linked_mdelem* e =
static_cast<grpc_linked_mdelem*>(gpr_malloc(sizeof(*e)));
diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc
index 4be34f72d9..8ab9639dfa 100644
--- a/test/core/transport/metadata_test.cc
+++ b/test/core/transport/metadata_test.cc
@@ -27,6 +27,7 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
+#include "src/core/ext/transport/chttp2/transport/hpack_table.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"
@@ -293,7 +294,7 @@ static void verify_ascii_header_size(const char* key, const char* value,
grpc_mdelem elem = grpc_mdelem_from_slices(
maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_string(value), intern_value));
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false);
+ size_t elem_size = grpc_chttp2_get_size_in_hpack_table(elem, false);
size_t expected_size = 32 + strlen(key) + strlen(value);
GPR_ASSERT(expected_size == elem_size);
GRPC_MDELEM_UNREF(elem);
@@ -307,7 +308,7 @@ static void verify_binary_header_size(const char* key, const uint8_t* value,
maybe_intern(grpc_slice_from_static_buffer(value, value_len),
intern_value));
GPR_ASSERT(grpc_is_binary_header(GRPC_MDKEY(elem)));
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false);
+ size_t elem_size = grpc_chttp2_get_size_in_hpack_table(elem, false);
grpc_slice value_slice = grpc_slice_from_copied_buffer(
reinterpret_cast<const char*>(value), value_len);
grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice);
diff --git a/test/core/transport/status_conversion_test.cc b/test/core/transport/status_conversion_test.cc
index 1ed6ccfba6..f7b3c62a40 100644
--- a/test/core/transport/status_conversion_test.cc
+++ b/test/core/transport/status_conversion_test.cc
@@ -33,12 +33,7 @@
#define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \
GPR_ASSERT(grpc_http2_status_to_grpc_status(a) == (b))
-int main(int argc, char** argv) {
- int i;
-
- grpc_test_init(argc, argv);
- grpc_init();
-
+static void test_grpc_status_to_http2_error() {
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OK, GRPC_HTTP2_NO_ERROR);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_CANCELLED, GRPC_HTTP2_CANCEL);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNKNOWN, GRPC_HTTP2_INTERNAL_ERROR);
@@ -65,7 +60,9 @@ int main(int argc, char** argv) {
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNAVAILABLE,
GRPC_HTTP2_REFUSED_STREAM);
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DATA_LOSS, GRPC_HTTP2_INTERNAL_ERROR);
+}
+static void test_grpc_status_to_http2_status() {
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_OK, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_CANCELLED, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNKNOWN, 200);
@@ -83,7 +80,9 @@ int main(int argc, char** argv) {
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_INTERNAL, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNAVAILABLE, 200);
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_DATA_LOSS, 200);
+}
+static void test_http2_error_to_grpc_status() {
const grpc_millis before_deadline = GRPC_MILLIS_INF_FUTURE;
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, before_deadline,
GRPC_STATUS_INTERNAL);
@@ -144,7 +143,9 @@ int main(int argc, char** argv) {
GRPC_STATUS_RESOURCE_EXHAUSTED);
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, after_deadline,
GRPC_STATUS_PERMISSION_DENIED);
+}
+static void test_http2_status_to_grpc_status() {
HTTP2_STATUS_TO_GRPC_STATUS(200, GRPC_STATUS_OK);
HTTP2_STATUS_TO_GRPC_STATUS(400, GRPC_STATUS_INVALID_ARGUMENT);
HTTP2_STATUS_TO_GRPC_STATUS(401, GRPC_STATUS_UNAUTHENTICATED);
@@ -157,6 +158,18 @@ int main(int argc, char** argv) {
HTTP2_STATUS_TO_GRPC_STATUS(500, GRPC_STATUS_UNKNOWN);
HTTP2_STATUS_TO_GRPC_STATUS(503, GRPC_STATUS_UNAVAILABLE);
HTTP2_STATUS_TO_GRPC_STATUS(504, GRPC_STATUS_DEADLINE_EXCEEDED);
+}
+
+int main(int argc, char** argv) {
+ int i;
+
+ grpc_test_init(argc, argv);
+ grpc_init();
+
+ test_grpc_status_to_http2_error();
+ test_grpc_status_to_http2_status();
+ test_http2_error_to_grpc_status();
+ test_http2_status_to_grpc_status();
/* check all status values can be converted */
for (i = 0; i <= 999; i++) {
diff --git a/test/core/transport/timeout_encoding_test.cc b/test/core/transport/timeout_encoding_test.cc
index 2367accc2e..b7044b5b41 100644
--- a/test/core/transport/timeout_encoding_test.cc
+++ b/test/core/transport/timeout_encoding_test.cc
@@ -71,7 +71,7 @@ static void assert_decodes_as(const char* buffer, grpc_millis expected) {
GPR_ASSERT(1 == grpc_http2_decode_timeout(
grpc_slice_from_static_string(buffer), &got));
if (got != expected) {
- gpr_log(GPR_ERROR, "got:'%" PRIdPTR "' != expected:'%" PRIdPTR "'", got,
+ gpr_log(GPR_ERROR, "got:'%" PRId64 "' != expected:'%" PRId64 "'", got,
expected);
abort();
}
diff --git a/test/core/tsi/alts/crypt/BUILD b/test/core/tsi/alts/crypt/BUILD
index cf9dbca316..abe1e83656 100644
--- a/test/core/tsi/alts/crypt/BUILD
+++ b/test/core/tsi/alts/crypt/BUILD
@@ -27,6 +27,7 @@ grpc_cc_test(
"//:alts_frame_protector",
"//:gpr",
"//:grpc",
+ "//test/core/util:gpr_test_util",
],
)
diff --git a/test/core/tsi/alts/fake_handshaker/BUILD b/test/core/tsi/alts/fake_handshaker/BUILD
index a09a046d27..98cd628a7d 100644
--- a/test/core/tsi/alts/fake_handshaker/BUILD
+++ b/test/core/tsi/alts/fake_handshaker/BUILD
@@ -37,21 +37,22 @@ grpc_cc_library(
name = "fake_handshaker_lib",
testonly = True,
srcs = ["fake_handshaker_server.cc"],
+ hdrs = ["fake_handshaker_server.h"],
language = "C++",
deps = [
"handshaker_proto",
"transport_security_common_proto",
"//:grpc++",
- "//test/cpp/util:test_config",
],
)
grpc_cc_binary(
name = "fake_handshaker_server",
testonly = True,
- srcs = ["fake_handshaker_server.cc"],
+ srcs = ["fake_handshaker_server_main.cc"],
language = "C++",
deps = [
+ "//test/cpp/util:test_config",
"fake_handshaker_lib",
],
)
diff --git a/test/core/tsi/alts/fake_handshaker/fake_handshaker_server.cc b/test/core/tsi/alts/fake_handshaker/fake_handshaker_server.cc
index f6a4791b49..ba246b07eb 100644
--- a/test/core/tsi/alts/fake_handshaker/fake_handshaker_server.cc
+++ b/test/core/tsi/alts/fake_handshaker/fake_handshaker_server.cc
@@ -15,12 +15,12 @@
* limitations under the License.
*
*/
+#include "test/core/tsi/alts/fake_handshaker/fake_handshaker_server.h"
#include <memory>
#include <sstream>
#include <string>
-#include <gflags/gflags.h>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpcpp/impl/codegen/async_stream.h>
@@ -32,10 +32,6 @@
#include "test/core/tsi/alts/fake_handshaker/handshaker.grpc.pb.h"
#include "test/core/tsi/alts/fake_handshaker/handshaker.pb.h"
#include "test/core/tsi/alts/fake_handshaker/transport_security_common.pb.h"
-#include "test/cpp/util/test_config.h"
-
-DEFINE_int32(handshaker_port, 55056,
- "TCP port on which the fake handshaker server listens to.");
// Fake handshake messages.
constexpr char kClientInitFrame[] = "ClientInit";
@@ -243,26 +239,9 @@ class FakeHandshakerService : public HandshakerService::Service {
}
};
-} // namespace gcp
-} // namespace grpc
-
-void RunServer() {
- GPR_ASSERT(FLAGS_handshaker_port != 0);
- std::ostringstream server_address;
- server_address << "[::1]:" << FLAGS_handshaker_port;
- grpc::gcp::FakeHandshakerService service;
- grpc::ServerBuilder builder;
- builder.AddListeningPort(server_address.str(),
- grpc::InsecureServerCredentials());
- builder.RegisterService(&service);
- std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
- gpr_log(GPR_INFO, "Fake handshaker server listening on %s",
- server_address.str().c_str());
- server->Wait();
+std::unique_ptr<grpc::Service> CreateFakeHandshakerService() {
+ return std::unique_ptr<grpc::Service>{new grpc::gcp::FakeHandshakerService};
}
-int main(int argc, char** argv) {
- grpc::testing::InitTest(&argc, &argv, true);
- RunServer();
- return 0;
-}
+} // namespace gcp
+} // namespace grpc
diff --git a/test/core/statistics/multiple_writers_circular_buffer_test.cc b/test/core/tsi/alts/fake_handshaker/fake_handshaker_server.h
index 6d3411289e..eb4bfdffa1 100644
--- a/test/core/statistics/multiple_writers_circular_buffer_test.cc
+++ b/test/core/tsi/alts/fake_handshaker/fake_handshaker_server.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015 gRPC authors.
+ * 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.
@@ -15,17 +15,15 @@
* limitations under the License.
*
*/
+#include <memory>
+#include <string>
-#include "test/core/statistics/census_log_tests.h"
+#include <grpcpp/grpcpp.h>
-#include <stdlib.h>
+namespace grpc {
+namespace gcp {
-#include <grpc/support/time.h>
-#include "test/core/util/test_config.h"
+std::unique_ptr<grpc::Service> CreateFakeHandshakerService();
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
- test_multiple_writers_circular_log();
- return 0;
-}
+} // namespace gcp
+} // namespace grpc
diff --git a/test/core/tsi/alts/fake_handshaker/fake_handshaker_server_main.cc b/test/core/tsi/alts/fake_handshaker/fake_handshaker_server_main.cc
new file mode 100644
index 0000000000..60351533d9
--- /dev/null
+++ b/test/core/tsi/alts/fake_handshaker/fake_handshaker_server_main.cc
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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/tsi/alts/fake_handshaker/fake_handshaker_server.h"
+
+#include <sstream>
+
+#include <gflags/gflags.h>
+#include <grpc/support/log.h>
+#include <grpcpp/impl/codegen/service_type.h>
+#include <grpcpp/server_builder.h>
+
+#include "test/cpp/util/test_config.h"
+
+DEFINE_int32(handshaker_port, 55056,
+ "TCP port on which the fake handshaker server listens to.");
+
+static void RunFakeHandshakerServer(const std::string& server_address) {
+ std::unique_ptr<grpc::Service> service =
+ grpc::gcp::CreateFakeHandshakerService();
+ grpc::ServerBuilder builder;
+ builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
+ builder.RegisterService(service.get());
+ gpr_log(GPR_INFO, "Fake handshaker server listening on %s",
+ server_address.c_str());
+ std::unique_ptr<grpc::Server> server = builder.BuildAndStart();
+ server->Wait();
+}
+
+int main(int argc, char** argv) {
+ grpc::testing::InitTest(&argc, &argv, true);
+
+ GPR_ASSERT(FLAGS_handshaker_port != 0);
+ std::ostringstream server_address;
+ server_address << "[::1]:" << FLAGS_handshaker_port;
+
+ RunFakeHandshakerServer(server_address.str());
+ return 0;
+}
diff --git a/test/core/tsi/alts/frame_protector/BUILD b/test/core/tsi/alts/frame_protector/BUILD
index dd1966b379..6ff3015f4d 100644
--- a/test/core/tsi/alts/frame_protector/BUILD
+++ b/test/core/tsi/alts/frame_protector/BUILD
@@ -27,6 +27,7 @@ grpc_cc_test(
"//:gpr",
"//:grpc",
"//test/core/tsi/alts/crypt:alts_crypt_test_util",
+ "//test/core/util:gpr_test_util",
],
)
@@ -39,6 +40,7 @@ grpc_cc_test(
"//:gpr",
"//:grpc",
"//test/core/tsi/alts/crypt:alts_crypt_test_util",
+ "//test/core/util:gpr_test_util",
],
)
@@ -54,6 +56,7 @@ grpc_cc_test(
"//:tsi_interface",
"//test/core/tsi/alts/crypt:alts_crypt_test_util",
"//test/core/tsi:transport_security_test_lib",
+ "//test/core/util:gpr_test_util",
],
)
@@ -67,5 +70,6 @@ grpc_cc_test(
"//:gpr_base",
"//:grpc",
"//test/core/tsi/alts/crypt:alts_crypt_test_util",
+ "//test/core/util:gpr_test_util",
],
)
diff --git a/test/core/tsi/alts/handshaker/BUILD b/test/core/tsi/alts/handshaker/BUILD
index 809742744c..3f1a681c1a 100644
--- a/test/core/tsi/alts/handshaker/BUILD
+++ b/test/core/tsi/alts/handshaker/BUILD
@@ -37,6 +37,7 @@ grpc_cc_test(
"//:tsi",
"//:tsi_interface",
"//:grpc",
+ "//test/core/util:gpr_test_util",
],
)
@@ -47,6 +48,7 @@ grpc_cc_test(
deps = [
":alts_handshaker_service_api_test_lib",
"//:grpc",
+ "//test/core/util:gpr_test_util",
],
)
@@ -60,6 +62,7 @@ grpc_cc_test(
"//:gpr_base",
"//:grpc",
"//:tsi",
+ "//test/core/util:gpr_test_util",
],
)
@@ -71,6 +74,7 @@ grpc_cc_test(
":alts_handshaker_service_api_test_lib",
"//:grpc",
"//:tsi",
+ "//test/core/util:gpr_test_util",
],
)
@@ -81,6 +85,7 @@ grpc_cc_test(
deps = [
"//:alts_util",
"//:grpc",
+ "//test/core/util:gpr_test_util",
],
)
diff --git a/test/core/tsi/alts/zero_copy_frame_protector/BUILD b/test/core/tsi/alts/zero_copy_frame_protector/BUILD
index 2b41dae043..a3b797327e 100644
--- a/test/core/tsi/alts/zero_copy_frame_protector/BUILD
+++ b/test/core/tsi/alts/zero_copy_frame_protector/BUILD
@@ -28,6 +28,7 @@ grpc_cc_test(
"//:grpc",
"//:grpc_base_c",
"//test/core/tsi/alts/crypt:alts_crypt_test_util",
+ "//test/core/util:gpr_test_util",
],
)
@@ -40,6 +41,7 @@ grpc_cc_test(
"//:gpr",
"//:grpc",
"//test/core/tsi/alts/crypt:alts_crypt_test_util",
+ "//test/core/util:gpr_test_util",
],
)
@@ -53,5 +55,6 @@ grpc_cc_test(
"//:grpc",
"//:grpc_base_c",
"//test/core/tsi/alts/crypt:alts_crypt_test_util",
+ "//test/core/util:gpr_test_util",
],
)
diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc
index b763f19d50..3ae64d6f20 100644
--- a/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc
+++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_test.cc
@@ -109,7 +109,7 @@ static void alter_random_byte(grpc_slice_buffer* sb) {
}
static alts_grpc_record_protocol_test_fixture*
-test_fixture_integrity_only_create(bool rekey) {
+test_fixture_integrity_only_create(bool rekey, bool extra_copy) {
alts_grpc_record_protocol_test_fixture* fixture =
static_cast<alts_grpc_record_protocol_test_fixture*>(
gpr_zalloc(sizeof(alts_grpc_record_protocol_test_fixture)));
@@ -124,41 +124,46 @@ test_fixture_integrity_only_create(bool rekey) {
&crypter, nullptr) == GRPC_STATUS_OK);
GPR_ASSERT(alts_grpc_integrity_only_record_protocol_create(
crypter, 8, /*is_client=*/true, /*is_protect=*/true,
- &fixture->client_protect) == TSI_OK);
+ extra_copy, &fixture->client_protect) == TSI_OK);
/* Create client record protocol for unprotect. */
GPR_ASSERT(gsec_aes_gcm_aead_crypter_create(
key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey,
&crypter, nullptr) == GRPC_STATUS_OK);
GPR_ASSERT(alts_grpc_integrity_only_record_protocol_create(
crypter, 8, /*is_client=*/true, /*is_protect=*/false,
- &fixture->client_unprotect) == TSI_OK);
+ extra_copy, &fixture->client_unprotect) == TSI_OK);
/* Create server record protocol for protect. */
GPR_ASSERT(gsec_aes_gcm_aead_crypter_create(
key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey,
&crypter, nullptr) == GRPC_STATUS_OK);
GPR_ASSERT(alts_grpc_integrity_only_record_protocol_create(
crypter, 8, /*is_client=*/false, /*is_protect=*/true,
- &fixture->server_protect) == TSI_OK);
+ extra_copy, &fixture->server_protect) == TSI_OK);
/* Create server record protocol for unprotect. */
GPR_ASSERT(gsec_aes_gcm_aead_crypter_create(
key, key_length, kAesGcmNonceLength, kAesGcmTagLength, rekey,
&crypter, nullptr) == GRPC_STATUS_OK);
GPR_ASSERT(alts_grpc_integrity_only_record_protocol_create(
crypter, 8, /*is_client=*/false, /*is_protect=*/false,
- &fixture->server_unprotect) == TSI_OK);
+ extra_copy, &fixture->server_unprotect) == TSI_OK);
gpr_free(key);
return fixture;
}
static alts_grpc_record_protocol_test_fixture*
-test_fixture_integrity_only_no_rekey_create() {
- return test_fixture_integrity_only_create(false);
+test_fixture_integrity_only_no_rekey_no_extra_copy_create() {
+ return test_fixture_integrity_only_create(false, false);
}
static alts_grpc_record_protocol_test_fixture*
test_fixture_integrity_only_rekey_create() {
- return test_fixture_integrity_only_create(true);
+ return test_fixture_integrity_only_create(true, false);
+}
+
+static alts_grpc_record_protocol_test_fixture*
+test_fixture_integrity_only_extra_copy_create() {
+ return test_fixture_integrity_only_create(false, true);
}
static alts_grpc_record_protocol_test_fixture*
@@ -440,9 +445,12 @@ static void alts_grpc_record_protocol_tests(
}
int main(int argc, char** argv) {
- alts_grpc_record_protocol_tests(&test_fixture_integrity_only_no_rekey_create);
+ alts_grpc_record_protocol_tests(
+ &test_fixture_integrity_only_no_rekey_no_extra_copy_create);
alts_grpc_record_protocol_tests(&test_fixture_integrity_only_rekey_create);
alts_grpc_record_protocol_tests(
+ &test_fixture_integrity_only_extra_copy_create);
+ alts_grpc_record_protocol_tests(
&test_fixture_privacy_integrity_no_rekey_create);
alts_grpc_record_protocol_tests(&test_fixture_privacy_integrity_rekey_create);
diff --git a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc
index 32159e22f2..3ee8323a31 100644
--- a/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc
+++ b/test/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector_test.cc
@@ -100,7 +100,8 @@ static bool are_slice_buffers_equal(grpc_slice_buffer* first,
static alts_zero_copy_grpc_protector_test_fixture*
alts_zero_copy_grpc_protector_test_fixture_create(bool rekey,
- bool integrity_only) {
+ bool integrity_only,
+ bool enable_extra_copy) {
alts_zero_copy_grpc_protector_test_fixture* fixture =
static_cast<alts_zero_copy_grpc_protector_test_fixture*>(
gpr_zalloc(sizeof(alts_zero_copy_grpc_protector_test_fixture)));
@@ -111,10 +112,12 @@ alts_zero_copy_grpc_protector_test_fixture_create(bool rekey,
gsec_test_random_array(&key, key_length);
GPR_ASSERT(alts_zero_copy_grpc_protector_create(
key, key_length, rekey, /*is_client=*/true, integrity_only,
- &max_protected_frame_size, &fixture->client) == TSI_OK);
+ enable_extra_copy, &max_protected_frame_size,
+ &fixture->client) == TSI_OK);
GPR_ASSERT(alts_zero_copy_grpc_protector_create(
key, key_length, rekey, /*is_client=*/false, integrity_only,
- &max_protected_frame_size, &fixture->server) == TSI_OK);
+ enable_extra_copy, &max_protected_frame_size,
+ &fixture->server) == TSI_OK);
gpr_free(key);
grpc_core::ExecCtx::Get()->Flush();
return fixture;
@@ -229,62 +232,70 @@ static void seal_unseal_large_buffer(tsi_zero_copy_grpc_protector* sender,
/* --- Test cases. --- */
-static void alts_zero_copy_protector_seal_unseal_small_buffer_tests() {
+static void alts_zero_copy_protector_seal_unseal_small_buffer_tests(
+ bool enable_extra_copy) {
alts_zero_copy_grpc_protector_test_fixture* fixture =
alts_zero_copy_grpc_protector_test_fixture_create(
- /*rekey=*/false, /*integrity_only=*/true);
+ /*rekey=*/false, /*integrity_only=*/true, enable_extra_copy);
seal_unseal_small_buffer(fixture->client, fixture->server);
seal_unseal_small_buffer(fixture->server, fixture->client);
alts_zero_copy_grpc_protector_test_fixture_destroy(fixture);
fixture = alts_zero_copy_grpc_protector_test_fixture_create(
- /*rekey=*/false, /*integrity_only=*/false);
+ /*rekey=*/false, /*integrity_only=*/false, enable_extra_copy);
seal_unseal_small_buffer(fixture->client, fixture->server);
seal_unseal_small_buffer(fixture->server, fixture->client);
alts_zero_copy_grpc_protector_test_fixture_destroy(fixture);
fixture = alts_zero_copy_grpc_protector_test_fixture_create(
- /*rekey=*/true, /*integrity_only=*/true);
+ /*rekey=*/true, /*integrity_only=*/true, enable_extra_copy);
seal_unseal_small_buffer(fixture->client, fixture->server);
seal_unseal_small_buffer(fixture->server, fixture->client);
alts_zero_copy_grpc_protector_test_fixture_destroy(fixture);
fixture = alts_zero_copy_grpc_protector_test_fixture_create(
- /*rekey=*/true, /*integrity_only=*/false);
+ /*rekey=*/true, /*integrity_only=*/false, enable_extra_copy);
seal_unseal_small_buffer(fixture->client, fixture->server);
seal_unseal_small_buffer(fixture->server, fixture->client);
alts_zero_copy_grpc_protector_test_fixture_destroy(fixture);
}
-static void alts_zero_copy_protector_seal_unseal_large_buffer_tests() {
+static void alts_zero_copy_protector_seal_unseal_large_buffer_tests(
+ bool enable_extra_copy) {
alts_zero_copy_grpc_protector_test_fixture* fixture =
alts_zero_copy_grpc_protector_test_fixture_create(
- /*rekey=*/false, /*integrity_only=*/true);
+ /*rekey=*/false, /*integrity_only=*/true, enable_extra_copy);
seal_unseal_large_buffer(fixture->client, fixture->server);
seal_unseal_large_buffer(fixture->server, fixture->client);
alts_zero_copy_grpc_protector_test_fixture_destroy(fixture);
fixture = alts_zero_copy_grpc_protector_test_fixture_create(
- /*rekey=*/false, /*integrity_only=*/false);
+ /*rekey=*/false, /*integrity_only=*/false, enable_extra_copy);
seal_unseal_large_buffer(fixture->client, fixture->server);
seal_unseal_large_buffer(fixture->server, fixture->client);
alts_zero_copy_grpc_protector_test_fixture_destroy(fixture);
fixture = alts_zero_copy_grpc_protector_test_fixture_create(
- /*rekey=*/true, /*integrity_only=*/true);
+ /*rekey=*/true, /*integrity_only=*/true, enable_extra_copy);
seal_unseal_large_buffer(fixture->client, fixture->server);
seal_unseal_large_buffer(fixture->server, fixture->client);
alts_zero_copy_grpc_protector_test_fixture_destroy(fixture);
fixture = alts_zero_copy_grpc_protector_test_fixture_create(
- /*rekey=*/true, /*integrity_only=*/false);
+ /*rekey=*/true, /*integrity_only=*/false, enable_extra_copy);
seal_unseal_large_buffer(fixture->client, fixture->server);
seal_unseal_large_buffer(fixture->server, fixture->client);
alts_zero_copy_grpc_protector_test_fixture_destroy(fixture);
}
int main(int argc, char** argv) {
- alts_zero_copy_protector_seal_unseal_small_buffer_tests();
- alts_zero_copy_protector_seal_unseal_large_buffer_tests();
+ alts_zero_copy_protector_seal_unseal_small_buffer_tests(
+ /*enable_extra_copy=*/false);
+ alts_zero_copy_protector_seal_unseal_small_buffer_tests(
+ /*enable_extra_copy=*/true);
+ alts_zero_copy_protector_seal_unseal_large_buffer_tests(
+ /*enable_extra_copy=*/false);
+ alts_zero_copy_protector_seal_unseal_large_buffer_tests(
+ /*enable_extra_copy=*/true);
return 0;
}
diff --git a/test/core/tsi/ssl_transport_security_test.cc b/test/core/tsi/ssl_transport_security_test.cc
index b477904d60..baffad6ea3 100644
--- a/test/core/tsi/ssl_transport_security_test.cc
+++ b/test/core/tsi/ssl_transport_security_test.cc
@@ -208,9 +208,11 @@ static void check_session_reusage(ssl_tsi_test_fixture* ssl_fixture,
tsi_peer_get_property_by_name(peer, TSI_SSL_SESSION_REUSED_PEER_PROPERTY);
GPR_ASSERT(session_reused != nullptr);
if (ssl_fixture->session_reused) {
- GPR_ASSERT(strcmp(session_reused->value.data, "true") == 0);
+ GPR_ASSERT(strncmp(session_reused->value.data, "true",
+ session_reused->value.length) == 0);
} else {
- GPR_ASSERT(strcmp(session_reused->value.data, "false") == 0);
+ GPR_ASSERT(strncmp(session_reused->value.data, "false",
+ session_reused->value.length) == 0);
}
}
diff --git a/test/core/util/BUILD b/test/core/util/BUILD
index f52570cde5..5492dcfa79 100644
--- a/test/core/util/BUILD
+++ b/test/core/util/BUILD
@@ -32,6 +32,11 @@ grpc_cc_library(
"test_config.h",
],
deps = ["//:gpr"],
+ data = [
+ "lsan_suppressions.txt",
+ "tsan_suppressions.txt",
+ "ubsan_suppressions.txt",
+ ],
)
grpc_cc_library(
diff --git a/test/core/util/lsan_suppressions.txt b/test/core/util/lsan_suppressions.txt
new file mode 100644
index 0000000000..204ddbef5e
--- /dev/null
+++ b/test/core/util/lsan_suppressions.txt
@@ -0,0 +1,6 @@
+# this is busted in BoringSSL
+leak:CRYPTO_set_thread_local
+leak:err_get_state
+leak:ERR_add_error_dataf
+leak:err_add_error_vdata
+leak:RAND_bytes_with_additional_data
diff --git a/test/core/util/mock_endpoint.cc b/test/core/util/mock_endpoint.cc
index 1156cd5fc5..ef6fd62b51 100644
--- a/test/core/util/mock_endpoint.cc
+++ b/test/core/util/mock_endpoint.cc
@@ -55,7 +55,7 @@ static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
}
static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
- grpc_closure* cb) {
+ grpc_closure* cb, void* arg) {
mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep);
for (size_t i = 0; i < slices->count; i++) {
m->on_write(slices->slices[i]);
diff --git a/test/core/util/passthru_endpoint.cc b/test/core/util/passthru_endpoint.cc
index 5958216747..3cc8ad6fe1 100644
--- a/test/core/util/passthru_endpoint.cc
+++ b/test/core/util/passthru_endpoint.cc
@@ -76,7 +76,7 @@ static half* other_half(half* h) {
}
static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
- grpc_closure* cb) {
+ grpc_closure* cb, void* arg) {
half* m = other_half(reinterpret_cast<half*>(ep));
gpr_mu_lock(&m->parent->mu);
grpc_error* error = GRPC_ERROR_NONE;
diff --git a/test/core/util/port_isolated_runtime_environment.cc b/test/core/util/port_isolated_runtime_environment.cc
index ff8342ff4a..1f678c08e5 100644
--- a/test/core/util/port_isolated_runtime_environment.cc
+++ b/test/core/util/port_isolated_runtime_environment.cc
@@ -16,9 +16,12 @@
*
*/
-/* When running tests on remote machines, the framework takes a round-robin pick
- * of a port within certain range. There is no need to recycle ports.
+/* When individual tests run in an isolated runtime environment (e.g. each test
+ * runs in a separate container) the framework takes a round-robin pick of a
+ * port within certain range. There is no need to recycle ports.
*/
+#include <grpc/support/atm.h>
+#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <stdlib.h>
#include "src/core/lib/iomgr/port.h"
@@ -27,23 +30,25 @@
#include "test/core/util/port.h"
-#define MIN_PORT 49152
-#define MAX_PORT 65536
+#define MIN_PORT 1025
+#define MAX_PORT 32766
-int get_random_starting_port() {
+static int get_random_port_offset() {
srand(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
- return rand() % (MAX_PORT - MIN_PORT + 1) + MIN_PORT;
+ double rnd = static_cast<double>(rand()) /
+ (static_cast<double>(RAND_MAX) + 1.0); // values from [0,1)
+ return static_cast<int>(rnd * (MAX_PORT - MIN_PORT + 1));
}
-static int s_allocated_port = get_random_starting_port();
+static int s_initial_offset = get_random_port_offset();
+static gpr_atm s_pick_counter = 0;
int grpc_pick_unused_port_or_die(void) {
- int allocated_port = s_allocated_port++;
- if (s_allocated_port == MAX_PORT) {
- s_allocated_port = MIN_PORT;
- }
-
- return allocated_port;
+ int orig_counter_val =
+ static_cast<int>(gpr_atm_full_fetch_add(&s_pick_counter, 1));
+ GPR_ASSERT(orig_counter_val < (MAX_PORT - MIN_PORT + 1));
+ return MIN_PORT +
+ (s_initial_offset + orig_counter_val) % (MAX_PORT - MIN_PORT + 1);
}
void grpc_recycle_unused_port(int port) { (void)port; }
diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc
index f2efb049b4..62ed72a629 100644
--- a/test/core/util/trickle_endpoint.cc
+++ b/test/core/util/trickle_endpoint.cc
@@ -62,7 +62,7 @@ static void maybe_call_write_cb_locked(trickle_endpoint* te) {
}
static void te_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
- grpc_closure* cb) {
+ grpc_closure* cb, void* arg) {
trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
gpr_mu_lock(&te->mu);
GPR_ASSERT(te->write_cb == nullptr);
@@ -186,7 +186,8 @@ size_t grpc_trickle_endpoint_trickle(grpc_endpoint* ep) {
te->last_write = now;
grpc_endpoint_write(
te->wrapped, &te->writing_buffer,
- GRPC_CLOSURE_CREATE(te_finish_write, te, grpc_schedule_on_exec_ctx));
+ GRPC_CLOSURE_CREATE(te_finish_write, te, grpc_schedule_on_exec_ctx),
+ nullptr);
maybe_call_write_cb_locked(te);
}
}
diff --git a/test/core/util/tsan_suppressions.txt b/test/core/util/tsan_suppressions.txt
new file mode 100644
index 0000000000..e0c7907228
--- /dev/null
+++ b/test/core/util/tsan_suppressions.txt
@@ -0,0 +1,13 @@
+# OPENSSL_cleanse does racy access to a global
+race:OPENSSL_cleanse
+race:cleanse_ctr
+# these are legitimate races in OpenSSL, and it appears those folks are looking at it
+# https://www.mail-archive.com/openssl-dev@openssl.org/msg09019.html
+race:ssleay_rand_add
+race:ssleay_rand_bytes
+race:__sleep_for
+# protobuf has an idempotent write race in ByteSize/GetCachedSize
+# https://github.com/google/protobuf/issues/2169
+race:ByteSize
+race:ByteSizeLong
+race:GetCachedSize
diff --git a/test/core/util/ubsan_suppressions.txt b/test/core/util/ubsan_suppressions.txt
new file mode 100644
index 0000000000..2268adc169
--- /dev/null
+++ b/test/core/util/ubsan_suppressions.txt
@@ -0,0 +1,17 @@
+# boringssl stuff
+nonnull-attribute:bn_wexpand
+nonnull-attribute:CBB_add_bytes
+nonnull-attribute:rsa_blinding_get
+nonnull-attribute:ssl_copy_key_material
+alignment:CRYPTO_cbc128_encrypt
+alignment:CRYPTO_gcm128_encrypt
+alignment:poly1305_block_copy
+nonnull-attribute:google::protobuf::*
+alignment:google::protobuf::*
+nonnull-attribute:_tr_stored_block
+# The following 5 suppressors should be removed as part of C++ cleanup
+enum:client_fuzzer_one_entry
+enum:message_compress_test
+enum:transport_security_test
+enum:algorithm_test
+alignment:transport_security_test
diff --git a/test/cpp/client/BUILD b/test/cpp/client/BUILD
index 12825e88c2..c03ea92d34 100644
--- a/test/cpp/client/BUILD
+++ b/test/cpp/client/BUILD
@@ -28,6 +28,7 @@ grpc_cc_test(
"//:gpr",
"//:grpc",
"//:grpc++",
+ "//test/core/util:gpr_test_util",
],
)
diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden
index ca7db5db32..93e1e68654 100644
--- a/test/cpp/codegen/compiler_test_golden
+++ b/test/cpp/codegen/compiler_test_golden
@@ -26,6 +26,8 @@
#include "src/proto/grpc/testing/compiler_test.pb.h"
+#include <functional>
+#include <grpcpp/impl/codegen/async_generic_service.h>
#include <grpcpp/impl/codegen/async_stream.h>
#include <grpcpp/impl/codegen/async_unary_call.h>
#include <grpcpp/impl/codegen/method_handler_impl.h>
@@ -104,6 +106,23 @@ class ServiceA final {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>>(PrepareAsyncMethodA4Raw(context, cq));
}
// Method A4 trailing comment 1
+ class experimental_async_interface {
+ public:
+ virtual ~experimental_async_interface() {}
+ // MethodA1 leading comment 1
+ virtual void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) = 0;
+ // MethodA1 trailing comment 1
+ // MethodA2 detached leading comment 1
+ //
+ // Method A2 leading comment 1
+ // Method A2 leading comment 2
+ // MethodA2 trailing comment 1
+ // Method A3 leading comment 1
+ // Method A3 trailing comment 1
+ // Method A4 leading comment 1
+ // Method A4 trailing comment 1
+ };
+ virtual class experimental_async_interface* experimental_async() { return nullptr; }
private:
virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* AsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0;
@@ -154,9 +173,21 @@ class ServiceA final {
std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>> PrepareAsyncMethodA4(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>>(PrepareAsyncMethodA4Raw(context, cq));
}
+ class experimental_async final :
+ public StubInterface::experimental_async_interface {
+ public:
+ void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) override;
+ private:
+ friend class Stub;
+ explicit experimental_async(Stub* stub): stub_(stub) { }
+ Stub* stub() { return stub_; }
+ Stub* stub_;
+ };
+ class experimental_async_interface* experimental_async() override { return &async_stub_; }
private:
std::shared_ptr< ::grpc::ChannelInterface> channel_;
+ class experimental_async async_stub_{this};
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* AsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientWriter< ::grpc::testing::Request>* MethodA2Raw(::grpc::ClientContext* context, ::grpc::testing::Response* response) override;
@@ -207,7 +238,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
+ ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -227,7 +258,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) final override {
+ ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -247,7 +278,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) final override {
+ ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -267,7 +298,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) final override {
+ ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -288,7 +319,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
+ ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -305,7 +336,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) final override {
+ ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -322,7 +353,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) final override {
+ ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -339,12 +370,92 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) final override {
+ ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
};
template <class BaseClass>
+ class WithRawMethod_MethodA1 : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service *service) {}
+ public:
+ WithRawMethod_MethodA1() {
+ ::grpc::Service::MarkMethodRaw(0);
+ }
+ ~WithRawMethod_MethodA1() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestMethodA1(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithRawMethod_MethodA2 : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service *service) {}
+ public:
+ WithRawMethod_MethodA2() {
+ ::grpc::Service::MarkMethodRaw(1);
+ }
+ ~WithRawMethod_MethodA2() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestMethodA2(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncClientStreaming(1, context, reader, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithRawMethod_MethodA3 : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service *service) {}
+ public:
+ WithRawMethod_MethodA3() {
+ ::grpc::Service::MarkMethodRaw(2);
+ }
+ ~WithRawMethod_MethodA3() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestMethodA3(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncWriter< ::grpc::ByteBuffer>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncServerStreaming(2, context, request, writer, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
+ class WithRawMethod_MethodA4 : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service *service) {}
+ public:
+ WithRawMethod_MethodA4() {
+ ::grpc::Service::MarkMethodRaw(3);
+ }
+ ~WithRawMethod_MethodA4() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestMethodA4(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncBidiStreaming(3, context, stream, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
class WithStreamedUnaryMethod_MethodA1 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
@@ -357,7 +468,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
- ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
+ ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -378,7 +489,7 @@ class ServiceA final {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
- ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) final override {
+ ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -407,6 +518,14 @@ class ServiceB final {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>>(PrepareAsyncMethodB1Raw(context, request, cq));
}
// MethodB1 trailing comment 1
+ class experimental_async_interface {
+ public:
+ virtual ~experimental_async_interface() {}
+ // MethodB1 leading comment 1
+ virtual void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) = 0;
+ // MethodB1 trailing comment 1
+ };
+ virtual class experimental_async_interface* experimental_async() { return nullptr; }
private:
virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* AsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0;
@@ -421,9 +540,21 @@ class ServiceB final {
std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>> PrepareAsyncMethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>>(PrepareAsyncMethodB1Raw(context, request, cq));
}
+ class experimental_async final :
+ public StubInterface::experimental_async_interface {
+ public:
+ void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) override;
+ private:
+ friend class Stub;
+ explicit experimental_async(Stub* stub): stub_(stub) { }
+ Stub* stub() { return stub_; }
+ Stub* stub_;
+ };
+ class experimental_async_interface* experimental_async() override { return &async_stub_; }
private:
std::shared_ptr< ::grpc::ChannelInterface> channel_;
+ class experimental_async async_stub_{this};
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* AsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override;
const ::grpc::internal::RpcMethod rpcmethod_MethodB1_;
@@ -450,7 +581,7 @@ class ServiceB final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
+ ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
@@ -471,12 +602,32 @@ class ServiceB final {
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
- ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
+ ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
};
template <class BaseClass>
+ class WithRawMethod_MethodB1 : public BaseClass {
+ private:
+ void BaseClassMustBeDerivedFromService(const Service *service) {}
+ public:
+ WithRawMethod_MethodB1() {
+ ::grpc::Service::MarkMethodRaw(0);
+ }
+ ~WithRawMethod_MethodB1() override {
+ BaseClassMustBeDerivedFromService(this);
+ }
+ // disable synchronous version of this method
+ ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
+ abort();
+ return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+ }
+ void RequestMethodB1(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+ ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
+ }
+ };
+ template <class BaseClass>
class WithStreamedUnaryMethod_MethodB1 : public BaseClass {
private:
void BaseClassMustBeDerivedFromService(const Service *service) {}
@@ -489,7 +640,7 @@ class ServiceB final {
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
- ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) final override {
+ ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override {
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
diff --git a/test/cpp/codegen/golden_file_test.cc b/test/cpp/codegen/golden_file_test.cc
index 7e4d15a7c9..bfd3649494 100644
--- a/test/cpp/codegen/golden_file_test.cc
+++ b/test/cpp/codegen/golden_file_test.cc
@@ -37,8 +37,8 @@ DEFINE_string(
const char kGoldenFilePath[] = "test/cpp/codegen/compiler_test_golden";
const char kMockGoldenFilePath[] = "test/cpp/codegen/compiler_test_mock_golden";
-void run_test(std::basic_string<char> generated_file,
- std::basic_string<char> golden_file) {
+void run_test(const std::basic_string<char>& generated_file,
+ const std::basic_string<char>& golden_file) {
std::ifstream generated(generated_file);
std::ifstream golden(golden_file);
diff --git a/test/cpp/common/alarm_test.cc b/test/cpp/common/alarm_test.cc
index 57d958349e..e909d03658 100644
--- a/test/cpp/common/alarm_test.cc
+++ b/test/cpp/common/alarm_test.cc
@@ -16,9 +16,13 @@
*
*/
+#include <condition_variable>
+#include <memory>
+#include <mutex>
+#include <thread>
+
#include <grpcpp/alarm.h>
#include <grpcpp/completion_queue.h>
-#include <thread>
#include <gtest/gtest.h>
@@ -43,6 +47,66 @@ TEST(AlarmTest, RegularExpiry) {
EXPECT_EQ(junk, output_tag);
}
+struct Completion {
+ bool completed = false;
+ std::mutex mu;
+ std::condition_variable cv;
+};
+
+TEST(AlarmTest, CallbackRegularExpiry) {
+ Alarm alarm;
+
+ auto c = std::make_shared<Completion>();
+ alarm.experimental().Set(
+ std::chrono::system_clock::now() + std::chrono::seconds(1), [c](bool ok) {
+ EXPECT_TRUE(ok);
+ std::lock_guard<std::mutex> l(c->mu);
+ c->completed = true;
+ c->cv.notify_one();
+ });
+
+ std::unique_lock<std::mutex> l(c->mu);
+ EXPECT_TRUE(c->cv.wait_until(
+ l, std::chrono::system_clock::now() + std::chrono::seconds(10),
+ [c] { return c->completed; }));
+}
+
+TEST(AlarmTest, CallbackZeroExpiry) {
+ Alarm alarm;
+
+ auto c = std::make_shared<Completion>();
+ alarm.experimental().Set(grpc_timeout_seconds_to_deadline(0), [c](bool ok) {
+ EXPECT_TRUE(ok);
+ std::lock_guard<std::mutex> l(c->mu);
+ c->completed = true;
+ c->cv.notify_one();
+ });
+
+ std::unique_lock<std::mutex> l(c->mu);
+ EXPECT_TRUE(c->cv.wait_until(
+ l, std::chrono::system_clock::now() + std::chrono::seconds(10),
+ [c] { return c->completed; }));
+}
+
+TEST(AlarmTest, CallbackNegativeExpiry) {
+ Alarm alarm;
+
+ auto c = std::make_shared<Completion>();
+ alarm.experimental().Set(
+ std::chrono::system_clock::now() + std::chrono::seconds(-1),
+ [c](bool ok) {
+ EXPECT_TRUE(ok);
+ std::lock_guard<std::mutex> l(c->mu);
+ c->completed = true;
+ c->cv.notify_one();
+ });
+
+ std::unique_lock<std::mutex> l(c->mu);
+ EXPECT_TRUE(c->cv.wait_until(
+ l, std::chrono::system_clock::now() + std::chrono::seconds(10),
+ [c] { return c->completed; }));
+}
+
TEST(AlarmTest, MultithreadedRegularExpiry) {
CompletionQueue cq;
void* junk = reinterpret_cast<void*>(1618033);
@@ -182,6 +246,26 @@ TEST(AlarmTest, Cancellation) {
EXPECT_EQ(junk, output_tag);
}
+TEST(AlarmTest, CallbackCancellation) {
+ Alarm alarm;
+
+ auto c = std::make_shared<Completion>();
+ alarm.experimental().Set(
+ std::chrono::system_clock::now() + std::chrono::seconds(10),
+ [c](bool ok) {
+ EXPECT_FALSE(ok);
+ std::lock_guard<std::mutex> l(c->mu);
+ c->completed = true;
+ c->cv.notify_one();
+ });
+ alarm.Cancel();
+
+ std::unique_lock<std::mutex> l(c->mu);
+ EXPECT_TRUE(c->cv.wait_until(
+ l, std::chrono::system_clock::now() + std::chrono::seconds(1),
+ [c] { return c->completed; }));
+}
+
TEST(AlarmTest, SetDestruction) {
CompletionQueue cq;
void* junk = reinterpret_cast<void*>(1618033);
@@ -200,6 +284,26 @@ TEST(AlarmTest, SetDestruction) {
EXPECT_EQ(junk, output_tag);
}
+TEST(AlarmTest, CallbackSetDestruction) {
+ auto c = std::make_shared<Completion>();
+ {
+ Alarm alarm;
+ alarm.experimental().Set(
+ std::chrono::system_clock::now() + std::chrono::seconds(10),
+ [c](bool ok) {
+ EXPECT_FALSE(ok);
+ std::lock_guard<std::mutex> l(c->mu);
+ c->completed = true;
+ c->cv.notify_one();
+ });
+ }
+
+ std::unique_lock<std::mutex> l(c->mu);
+ EXPECT_TRUE(c->cv.wait_until(
+ l, std::chrono::system_clock::now() + std::chrono::seconds(1),
+ [c] { return c->completed; }));
+}
+
TEST(AlarmTest, UnsetDestruction) {
CompletionQueue cq;
Alarm alarm;
diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD
index 8ab0811ffa..0415efc1ef 100644
--- a/test/cpp/end2end/BUILD
+++ b/test/cpp/end2end/BUILD
@@ -14,7 +14,7 @@
licenses(["notice"]) # Apache v2
-load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package", "grpc_cc_binary")
+load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package")
grpc_package(
name = "test/cpp/end2end",
@@ -98,6 +98,25 @@ grpc_cc_binary(
],
)
+grpc_cc_test(
+ name = "client_callback_end2end_test",
+ srcs = ["client_callback_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ deps = [
+ ":test_service_impl",
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//src/proto/grpc/testing:echo_messages_proto",
+ "//src/proto/grpc/testing:echo_proto",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_util",
+ ],
+)
+
grpc_cc_library(
name = "end2end_test_lib",
testonly = True,
@@ -120,6 +139,27 @@ grpc_cc_library(
)
grpc_cc_test(
+ name = "channelz_service_test",
+ srcs = ["channelz_service_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ deps = [
+ ":test_service_impl",
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//:grpcpp_channelz",
+ "//src/proto/grpc/channelz:channelz_proto",
+ "//src/proto/grpc/testing:echo_messages_proto",
+ "//src/proto/grpc/testing:echo_proto",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_util",
+ ],
+)
+
+grpc_cc_test(
name = "server_early_return_test",
srcs = ["server_early_return_test.cc"],
external_deps = [
@@ -242,6 +282,26 @@ grpc_cc_test(
)
grpc_cc_test(
+ name = "raw_end2end_test",
+ srcs = ["raw_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ deps = [
+ ":test_service_impl",
+ "//:gpr",
+ "//:grpc",
+ "//:grpc++",
+ "//src/proto/grpc/testing:echo_messages_proto",
+ "//src/proto/grpc/testing:echo_proto",
+ "//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_util",
+ ],
+)
+
+grpc_cc_test(
name = "mock_test",
srcs = ["mock_test.cc"],
external_deps = [
@@ -410,6 +470,20 @@ grpc_cc_binary(
)
grpc_cc_test(
+ name = "server_load_reporting_end2end_test",
+ srcs = ["server_load_reporting_end2end_test.cc"],
+ external_deps = [
+ "gtest",
+ "gmock",
+ ],
+ deps = [
+ "//:grpcpp_server_load_reporting",
+ "//src/proto/grpc/testing:echo_proto",
+ "//test/cpp/util:test_util",
+ ],
+)
+
+grpc_cc_test(
name = "shutdown_test",
srcs = ["shutdown_test.cc"],
external_deps = [
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index e8d2325b7d..d97ea071d1 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -142,7 +142,7 @@ class Verifier {
// to call the lambda
void Verify(CompletionQueue* cq,
std::chrono::system_clock::time_point deadline,
- std::function<void(void)> lambda) {
+ const std::function<void(void)>& lambda) {
if (expectations_.empty()) {
bool ok;
void* got_tag;
@@ -178,7 +178,7 @@ class Verifier {
EXPECT_EQ(it2->second.ok, ok);
}
} else {
- gpr_log(GPR_ERROR, "Unexpected tag: %p", tag);
+ gpr_log(GPR_ERROR, "Unexpected tag: %p", got_tag);
abort();
}
}
@@ -891,7 +891,7 @@ TEST_P(AsyncEnd2endTest, ClientInitialMetadataRpc) {
cq_.get(), tag(2));
Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
- auto client_initial_metadata = srv_ctx.client_metadata();
+ const auto& client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second,
ToString(client_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
@@ -937,7 +937,7 @@ TEST_P(AsyncEnd2endTest, ServerInitialMetadataRpc) {
srv_ctx.AddInitialMetadata(meta2.first, meta2.second);
response_writer.SendInitialMetadata(tag(3));
Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
- auto server_initial_metadata = cli_ctx.GetServerInitialMetadata();
+ const auto& server_initial_metadata = cli_ctx.GetServerInitialMetadata();
EXPECT_EQ(meta1.second,
ToString(server_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
@@ -990,7 +990,7 @@ TEST_P(AsyncEnd2endTest, ServerTrailingMetadataRpc) {
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.ok());
- auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
+ const auto& server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
EXPECT_EQ(meta1.second,
ToString(server_trailing_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
@@ -1038,7 +1038,7 @@ TEST_P(AsyncEnd2endTest, MetadataRpc) {
cq_.get(), tag(2));
Verifier().Expect(2, true).Verify(cq_.get());
EXPECT_EQ(send_request.message(), recv_request.message());
- auto client_initial_metadata = srv_ctx.client_metadata();
+ const auto& client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second,
ToString(client_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
@@ -1049,7 +1049,7 @@ TEST_P(AsyncEnd2endTest, MetadataRpc) {
srv_ctx.AddInitialMetadata(meta4.first, meta4.second);
response_writer.SendInitialMetadata(tag(3));
Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
- auto server_initial_metadata = cli_ctx.GetServerInitialMetadata();
+ const auto& server_initial_metadata = cli_ctx.GetServerInitialMetadata();
EXPECT_EQ(meta3.second,
ToString(server_initial_metadata.find(meta3.first)->second));
EXPECT_EQ(meta4.second,
@@ -1066,7 +1066,7 @@ TEST_P(AsyncEnd2endTest, MetadataRpc) {
EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.ok());
- auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
+ const auto& server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
EXPECT_EQ(meta5.second,
ToString(server_trailing_metadata.find(meta5.first)->second));
EXPECT_EQ(meta6.second,
@@ -1144,7 +1144,7 @@ TEST_P(AsyncEnd2endTest, ServerCheckDone) {
TEST_P(AsyncEnd2endTest, UnimplementedRpc) {
ChannelArguments args;
- auto channel_creds = GetCredentialsProvider()->GetChannelCredentials(
+ const auto& channel_creds = GetCredentialsProvider()->GetChannelCredentials(
GetParam().credentials_type, &args);
std::shared_ptr<Channel> channel =
!(GetParam().inproc)
@@ -1709,7 +1709,7 @@ TEST_P(AsyncEnd2endServerTryCancelTest, ServerBidiStreamingTryCancelAfter) {
}
std::vector<TestScenario> CreateTestScenarios(bool test_secure,
- int test_big_limit) {
+ bool test_message_size_limit) {
std::vector<TestScenario> scenarios;
std::vector<grpc::string> credentials_types;
std::vector<grpc::string> messages;
@@ -1731,13 +1731,18 @@ std::vector<TestScenario> CreateTestScenarios(bool test_secure,
GPR_ASSERT(!credentials_types.empty());
messages.push_back("Hello");
- for (int sz = 1; sz <= test_big_limit; sz *= 32) {
- grpc::string big_msg;
- for (int i = 0; i < sz * 1024; i++) {
- char c = 'a' + (i % 26);
- big_msg += c;
+ if (test_message_size_limit) {
+ for (size_t k = 1; k < GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH / 1024;
+ k *= 32) {
+ grpc::string big_msg;
+ for (size_t i = 0; i < k * 1024; ++i) {
+ char c = 'a' + (i % 26);
+ big_msg += c;
+ }
+ messages.push_back(big_msg);
}
- messages.push_back(big_msg);
+ messages.push_back(
+ grpc::string(GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH - 10, 'a'));
}
// TODO (sreek) Renable tests with health check service after the issue
@@ -1758,10 +1763,10 @@ std::vector<TestScenario> CreateTestScenarios(bool test_secure,
}
INSTANTIATE_TEST_CASE_P(AsyncEnd2end, AsyncEnd2endTest,
- ::testing::ValuesIn(CreateTestScenarios(true, 1024)));
+ ::testing::ValuesIn(CreateTestScenarios(true, true)));
INSTANTIATE_TEST_CASE_P(AsyncEnd2endServerTryCancel,
AsyncEnd2endServerTryCancelTest,
- ::testing::ValuesIn(CreateTestScenarios(false, 0)));
+ ::testing::ValuesIn(CreateTestScenarios(false, false)));
} // namespace
} // namespace testing
diff --git a/test/cpp/end2end/channelz_service_test.cc b/test/cpp/end2end/channelz_service_test.cc
new file mode 100644
index 0000000000..e96d68f93b
--- /dev/null
+++ b/test/cpp/end2end/channelz_service_test.cc
@@ -0,0 +1,458 @@
+/*
+ *
+ * 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 <grpc/support/port_platform.h>
+
+#include <grpc/grpc.h>
+#include <grpcpp/channel.h>
+#include <grpcpp/client_context.h>
+#include <grpcpp/create_channel.h>
+#include <grpcpp/security/credentials.h>
+#include <grpcpp/security/server_credentials.h>
+#include <grpcpp/server.h>
+#include <grpcpp/server_builder.h>
+#include <grpcpp/server_context.h>
+
+#include <grpcpp/ext/channelz_service_plugin.h>
+#include "src/proto/grpc/channelz/channelz.grpc.pb.h"
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+#include "test/cpp/end2end/test_service_impl.h"
+
+#include <google/protobuf/text_format.h>
+
+#include <gtest/gtest.h>
+
+using grpc::channelz::v1::GetChannelRequest;
+using grpc::channelz::v1::GetChannelResponse;
+using grpc::channelz::v1::GetServersRequest;
+using grpc::channelz::v1::GetServersResponse;
+using grpc::channelz::v1::GetSubchannelRequest;
+using grpc::channelz::v1::GetSubchannelResponse;
+using grpc::channelz::v1::GetTopChannelsRequest;
+using grpc::channelz::v1::GetTopChannelsResponse;
+
+namespace grpc {
+namespace testing {
+namespace {
+
+// Proxy service supports N backends. Sends RPC to backend dictated by
+// request->backend_channel_idx().
+class Proxy : public ::grpc::testing::EchoTestService::Service {
+ public:
+ Proxy() {}
+
+ void AddChannelToBackend(const std::shared_ptr<Channel>& channel) {
+ stubs_.push_back(grpc::testing::EchoTestService::NewStub(channel));
+ }
+
+ Status Echo(ServerContext* server_context, const EchoRequest* request,
+ EchoResponse* response) override {
+ std::unique_ptr<ClientContext> client_context =
+ ClientContext::FromServerContext(*server_context);
+ size_t idx = request->param().backend_channel_idx();
+ GPR_ASSERT(idx < stubs_.size());
+ return stubs_[idx]->Echo(client_context.get(), *request, response);
+ }
+
+ private:
+ std::vector<std::unique_ptr<::grpc::testing::EchoTestService::Stub>> stubs_;
+};
+
+} // namespace
+
+class ChannelzServerTest : public ::testing::Test {
+ public:
+ ChannelzServerTest() {}
+
+ void SetUp() override {
+ // ensure channel server is brought up on all severs we build.
+ ::grpc::channelz::experimental::InitChannelzService();
+
+ // We set up a proxy server with channelz enabled.
+ proxy_port_ = grpc_pick_unused_port_or_die();
+ ServerBuilder proxy_builder;
+ grpc::string proxy_server_address = "localhost:" + to_string(proxy_port_);
+ proxy_builder.AddListeningPort(proxy_server_address,
+ InsecureServerCredentials());
+ // forces channelz and channel tracing to be enabled.
+ proxy_builder.AddChannelArgument(GRPC_ARG_ENABLE_CHANNELZ, 1);
+ proxy_builder.AddChannelArgument(GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE,
+ 10);
+ proxy_builder.RegisterService(&proxy_service_);
+ proxy_server_ = proxy_builder.BuildAndStart();
+ }
+
+ // Sets the proxy up to have an arbitrary number of backends.
+ void ConfigureProxy(size_t num_backends) {
+ backends_.resize(num_backends);
+ for (size_t i = 0; i < num_backends; ++i) {
+ // create a new backend.
+ backends_[i].port = grpc_pick_unused_port_or_die();
+ ServerBuilder backend_builder;
+ grpc::string backend_server_address =
+ "localhost:" + to_string(backends_[i].port);
+ backend_builder.AddListeningPort(backend_server_address,
+ InsecureServerCredentials());
+ backends_[i].service.reset(new TestServiceImpl);
+ // ensure that the backend itself has channelz disabled.
+ backend_builder.AddChannelArgument(GRPC_ARG_ENABLE_CHANNELZ, 0);
+ backend_builder.RegisterService(backends_[i].service.get());
+ backends_[i].server = backend_builder.BuildAndStart();
+ // set up a channel to the backend. We ensure that this channel has
+ // channelz enabled since these channels (proxy outbound to backends)
+ // are the ones that our test will actually be validating.
+ ChannelArguments args;
+ args.SetInt(GRPC_ARG_ENABLE_CHANNELZ, 1);
+ args.SetInt(GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE, 10);
+ std::shared_ptr<Channel> channel_to_backend = CreateCustomChannel(
+ backend_server_address, InsecureChannelCredentials(), args);
+ proxy_service_.AddChannelToBackend(channel_to_backend);
+ }
+ }
+
+ void ResetStubs() {
+ string target = "dns:localhost:" + to_string(proxy_port_);
+ ChannelArguments args;
+ // disable channelz. We only want to focus on proxy to backend outbound.
+ args.SetInt(GRPC_ARG_ENABLE_CHANNELZ, 0);
+ std::shared_ptr<Channel> channel =
+ CreateCustomChannel(target, InsecureChannelCredentials(), args);
+ channelz_stub_ = grpc::channelz::v1::Channelz::NewStub(channel);
+ echo_stub_ = grpc::testing::EchoTestService::NewStub(channel);
+ }
+
+ void SendSuccessfulEcho(int channel_idx) {
+ EchoRequest request;
+ EchoResponse response;
+ request.set_message("Hello channelz");
+ request.mutable_param()->set_backend_channel_idx(channel_idx);
+ ClientContext context;
+ Status s = echo_stub_->Echo(&context, request, &response);
+ EXPECT_EQ(response.message(), request.message());
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ }
+
+ void SendFailedEcho(int channel_idx) {
+ EchoRequest request;
+ EchoResponse response;
+ request.set_message("Hello channelz");
+ request.mutable_param()->set_backend_channel_idx(channel_idx);
+ auto* error = request.mutable_param()->mutable_expected_error();
+ error->set_code(13); // INTERNAL
+ error->set_error_message("error");
+ ClientContext context;
+ Status s = echo_stub_->Echo(&context, request, &response);
+ EXPECT_FALSE(s.ok());
+ }
+
+ // Uses GetTopChannels to return the channel_id of a particular channel,
+ // so that the unit tests may test GetChannel call.
+ intptr_t GetChannelId(int channel_idx) {
+ GetTopChannelsRequest request;
+ GetTopChannelsResponse response;
+ request.set_start_channel_id(0);
+ ClientContext context;
+ Status s = channelz_stub_->GetTopChannels(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_GT(response.channel_size(), channel_idx);
+ return response.channel(channel_idx).ref().channel_id();
+ }
+
+ static string to_string(const int number) {
+ std::stringstream strs;
+ strs << number;
+ return strs.str();
+ }
+
+ protected:
+ // package of data needed for each backend server.
+ struct BackendData {
+ std::unique_ptr<Server> server;
+ int port;
+ std::unique_ptr<TestServiceImpl> service;
+ };
+
+ std::unique_ptr<grpc::channelz::v1::Channelz::Stub> channelz_stub_;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> echo_stub_;
+
+ // proxy server to ping with channelz requests.
+ std::unique_ptr<Server> proxy_server_;
+ int proxy_port_;
+ Proxy proxy_service_;
+
+ // backends. All implement the echo service.
+ std::vector<BackendData> backends_;
+};
+
+TEST_F(ChannelzServerTest, BasicTest) {
+ ResetStubs();
+ ConfigureProxy(1);
+ GetTopChannelsRequest request;
+ GetTopChannelsResponse response;
+ request.set_start_channel_id(0);
+ ClientContext context;
+ Status s = channelz_stub_->GetTopChannels(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel_size(), 1);
+}
+
+TEST_F(ChannelzServerTest, HighStartId) {
+ ResetStubs();
+ ConfigureProxy(1);
+ GetTopChannelsRequest request;
+ GetTopChannelsResponse response;
+ request.set_start_channel_id(10000);
+ ClientContext context;
+ Status s = channelz_stub_->GetTopChannels(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel_size(), 0);
+}
+
+TEST_F(ChannelzServerTest, SuccessfulRequestTest) {
+ ResetStubs();
+ ConfigureProxy(1);
+ SendSuccessfulEcho(0);
+ GetChannelRequest request;
+ GetChannelResponse response;
+ request.set_channel_id(GetChannelId(0));
+ ClientContext context;
+ Status s = channelz_stub_->GetChannel(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel().data().calls_started(), 1);
+ EXPECT_EQ(response.channel().data().calls_succeeded(), 1);
+ EXPECT_EQ(response.channel().data().calls_failed(), 0);
+}
+
+TEST_F(ChannelzServerTest, FailedRequestTest) {
+ ResetStubs();
+ ConfigureProxy(1);
+ SendFailedEcho(0);
+ GetChannelRequest request;
+ GetChannelResponse response;
+ request.set_channel_id(GetChannelId(0));
+ ClientContext context;
+ Status s = channelz_stub_->GetChannel(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel().data().calls_started(), 1);
+ EXPECT_EQ(response.channel().data().calls_succeeded(), 0);
+ EXPECT_EQ(response.channel().data().calls_failed(), 1);
+}
+
+TEST_F(ChannelzServerTest, ManyRequestsTest) {
+ ResetStubs();
+ ConfigureProxy(1);
+ // send some RPCs
+ const int kNumSuccess = 10;
+ const int kNumFailed = 11;
+ for (int i = 0; i < kNumSuccess; ++i) {
+ SendSuccessfulEcho(0);
+ }
+ for (int i = 0; i < kNumFailed; ++i) {
+ SendFailedEcho(0);
+ }
+ GetChannelRequest request;
+ GetChannelResponse response;
+ request.set_channel_id(GetChannelId(0));
+ ClientContext context;
+ Status s = channelz_stub_->GetChannel(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel().data().calls_started(),
+ kNumSuccess + kNumFailed);
+ EXPECT_EQ(response.channel().data().calls_succeeded(), kNumSuccess);
+ EXPECT_EQ(response.channel().data().calls_failed(), kNumFailed);
+}
+
+TEST_F(ChannelzServerTest, ManyChannels) {
+ ResetStubs();
+ const int kNumChannels = 4;
+ ConfigureProxy(kNumChannels);
+ GetTopChannelsRequest request;
+ GetTopChannelsResponse response;
+ request.set_start_channel_id(0);
+ ClientContext context;
+ Status s = channelz_stub_->GetTopChannels(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel_size(), kNumChannels);
+}
+
+TEST_F(ChannelzServerTest, ManyRequestsManyChannels) {
+ ResetStubs();
+ const int kNumChannels = 4;
+ ConfigureProxy(kNumChannels);
+ const int kNumSuccess = 10;
+ const int kNumFailed = 11;
+ for (int i = 0; i < kNumSuccess; ++i) {
+ SendSuccessfulEcho(0);
+ SendSuccessfulEcho(2);
+ }
+ for (int i = 0; i < kNumFailed; ++i) {
+ SendFailedEcho(1);
+ SendFailedEcho(2);
+ }
+
+ // the first channel saw only successes
+ {
+ GetChannelRequest request;
+ GetChannelResponse response;
+ request.set_channel_id(GetChannelId(0));
+ ClientContext context;
+ Status s = channelz_stub_->GetChannel(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel().data().calls_started(), kNumSuccess);
+ EXPECT_EQ(response.channel().data().calls_succeeded(), kNumSuccess);
+ EXPECT_EQ(response.channel().data().calls_failed(), 0);
+ }
+
+ // the second channel saw only failures
+ {
+ GetChannelRequest request;
+ GetChannelResponse response;
+ request.set_channel_id(GetChannelId(1));
+ ClientContext context;
+ Status s = channelz_stub_->GetChannel(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel().data().calls_started(), kNumFailed);
+ EXPECT_EQ(response.channel().data().calls_succeeded(), 0);
+ EXPECT_EQ(response.channel().data().calls_failed(), kNumFailed);
+ }
+
+ // the third channel saw both
+ {
+ GetChannelRequest request;
+ GetChannelResponse response;
+ request.set_channel_id(GetChannelId(2));
+ ClientContext context;
+ Status s = channelz_stub_->GetChannel(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel().data().calls_started(),
+ kNumSuccess + kNumFailed);
+ EXPECT_EQ(response.channel().data().calls_succeeded(), kNumSuccess);
+ EXPECT_EQ(response.channel().data().calls_failed(), kNumFailed);
+ }
+
+ // the fourth channel saw nothing
+ {
+ GetChannelRequest request;
+ GetChannelResponse response;
+ request.set_channel_id(GetChannelId(3));
+ ClientContext context;
+ Status s = channelz_stub_->GetChannel(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.channel().data().calls_started(), 0);
+ EXPECT_EQ(response.channel().data().calls_succeeded(), 0);
+ EXPECT_EQ(response.channel().data().calls_failed(), 0);
+ }
+}
+
+TEST_F(ChannelzServerTest, ManySubchannels) {
+ ResetStubs();
+ const int kNumChannels = 4;
+ ConfigureProxy(kNumChannels);
+ const int kNumSuccess = 10;
+ const int kNumFailed = 11;
+ for (int i = 0; i < kNumSuccess; ++i) {
+ SendSuccessfulEcho(0);
+ SendSuccessfulEcho(2);
+ }
+ for (int i = 0; i < kNumFailed; ++i) {
+ SendFailedEcho(1);
+ SendFailedEcho(2);
+ }
+ GetTopChannelsRequest gtc_request;
+ GetTopChannelsResponse gtc_response;
+ gtc_request.set_start_channel_id(0);
+ ClientContext context;
+ Status s =
+ channelz_stub_->GetTopChannels(&context, gtc_request, &gtc_response);
+ EXPECT_TRUE(s.ok()) << s.error_message();
+ EXPECT_EQ(gtc_response.channel_size(), kNumChannels);
+ for (int i = 0; i < gtc_response.channel_size(); ++i) {
+ // if the channel sent no RPCs, then expect no subchannels to have been
+ // created.
+ if (gtc_response.channel(i).data().calls_started() == 0) {
+ EXPECT_EQ(gtc_response.channel(i).subchannel_ref_size(), 0);
+ continue;
+ }
+ // The resolver must return at least one address.
+ ASSERT_GT(gtc_response.channel(i).subchannel_ref_size(), 0);
+ GetSubchannelRequest gsc_request;
+ GetSubchannelResponse gsc_response;
+ gsc_request.set_subchannel_id(
+ gtc_response.channel(i).subchannel_ref(0).subchannel_id());
+ ClientContext context;
+ Status s =
+ channelz_stub_->GetSubchannel(&context, gsc_request, &gsc_response);
+ EXPECT_TRUE(s.ok()) << s.error_message();
+ EXPECT_EQ(gtc_response.channel(i).data().calls_started(),
+ gsc_response.subchannel().data().calls_started());
+ EXPECT_EQ(gtc_response.channel(i).data().calls_succeeded(),
+ gsc_response.subchannel().data().calls_succeeded());
+ EXPECT_EQ(gtc_response.channel(i).data().calls_failed(),
+ gsc_response.subchannel().data().calls_failed());
+ }
+}
+
+TEST_F(ChannelzServerTest, BasicServerTest) {
+ ResetStubs();
+ ConfigureProxy(1);
+ GetServersRequest request;
+ GetServersResponse response;
+ request.set_start_server_id(0);
+ ClientContext context;
+ Status s = channelz_stub_->GetServers(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.server_size(), 1);
+}
+
+TEST_F(ChannelzServerTest, ServerCallTest) {
+ ResetStubs();
+ ConfigureProxy(1);
+ const int kNumSuccess = 10;
+ const int kNumFailed = 11;
+ for (int i = 0; i < kNumSuccess; ++i) {
+ SendSuccessfulEcho(0);
+ }
+ for (int i = 0; i < kNumFailed; ++i) {
+ SendFailedEcho(0);
+ }
+ GetServersRequest request;
+ GetServersResponse response;
+ request.set_start_server_id(0);
+ ClientContext context;
+ Status s = channelz_stub_->GetServers(&context, request, &response);
+ EXPECT_TRUE(s.ok()) << "s.error_message() = " << s.error_message();
+ EXPECT_EQ(response.server_size(), 1);
+ EXPECT_EQ(response.server(0).data().calls_succeeded(), kNumSuccess);
+ EXPECT_EQ(response.server(0).data().calls_failed(), kNumFailed);
+ // This is success+failure+1 because the call that retrieved this information
+ // will be counted as started. It will not track success/failure until after
+ // it has returned, so that is not included in the response.
+ EXPECT_EQ(response.server(0).data().calls_started(),
+ kNumSuccess + kNumFailed + 1);
+}
+
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc
new file mode 100644
index 0000000000..62a85641c7
--- /dev/null
+++ b/test/cpp/end2end/client_callback_end2end_test.cc
@@ -0,0 +1,241 @@
+/*
+ *
+ * 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 <functional>
+#include <mutex>
+#include <thread>
+
+#include <grpcpp/channel.h>
+#include <grpcpp/client_context.h>
+#include <grpcpp/create_channel.h>
+#include <grpcpp/generic/generic_stub.h>
+#include <grpcpp/impl/codegen/proto_utils.h>
+#include <grpcpp/server.h>
+#include <grpcpp/server_builder.h>
+#include <grpcpp/server_context.h>
+#include <grpcpp/support/client_callback.h>
+
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/test_config.h"
+#include "test/cpp/end2end/test_service_impl.h"
+#include "test/cpp/util/byte_buffer_proto_helper.h"
+
+#include <gtest/gtest.h>
+
+namespace grpc {
+namespace testing {
+namespace {
+
+class ClientCallbackEnd2endTest : public ::testing::Test {
+ protected:
+ ClientCallbackEnd2endTest() {}
+
+ void SetUp() override {
+ ServerBuilder builder;
+ builder.RegisterService(&service_);
+
+ server_ = builder.BuildAndStart();
+ is_server_started_ = true;
+ }
+
+ void ResetStub() {
+ ChannelArguments args;
+ channel_ = server_->InProcessChannel(args);
+ stub_ = grpc::testing::EchoTestService::NewStub(channel_);
+ generic_stub_.reset(new GenericStub(channel_));
+ }
+
+ void TearDown() override {
+ if (is_server_started_) {
+ server_->Shutdown();
+ }
+ }
+
+ void SendRpcs(int num_rpcs, bool with_binary_metadata) {
+ grpc::string test_string("");
+ for (int i = 0; i < num_rpcs; i++) {
+ EchoRequest request;
+ EchoResponse response;
+ ClientContext cli_ctx;
+
+ test_string += "Hello world. ";
+ request.set_message(test_string);
+
+ if (with_binary_metadata) {
+ char bytes[8] = {'\0', '\1', '\2', '\3',
+ '\4', '\5', '\6', static_cast<char>(i)};
+ cli_ctx.AddMetadata("custom-bin", grpc::string(bytes, 8));
+ }
+
+ cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP);
+
+ std::mutex mu;
+ std::condition_variable cv;
+ bool done = false;
+ stub_->experimental_async()->Echo(
+ &cli_ctx, &request, &response,
+ [&request, &response, &done, &mu, &cv](Status s) {
+ GPR_ASSERT(s.ok());
+
+ EXPECT_EQ(request.message(), response.message());
+ std::lock_guard<std::mutex> l(mu);
+ done = true;
+ cv.notify_one();
+ });
+ std::unique_lock<std::mutex> l(mu);
+ while (!done) {
+ cv.wait(l);
+ }
+ }
+ }
+
+ void SendRpcsGeneric(int num_rpcs, bool maybe_except) {
+ const grpc::string kMethodName("/grpc.testing.EchoTestService/Echo");
+ grpc::string test_string("");
+ for (int i = 0; i < num_rpcs; i++) {
+ EchoRequest request;
+ std::unique_ptr<ByteBuffer> send_buf;
+ ByteBuffer recv_buf;
+ ClientContext cli_ctx;
+
+ test_string += "Hello world. ";
+ request.set_message(test_string);
+ send_buf = SerializeToByteBuffer(&request);
+
+ std::mutex mu;
+ std::condition_variable cv;
+ bool done = false;
+ generic_stub_->experimental().UnaryCall(
+ &cli_ctx, kMethodName, send_buf.get(), &recv_buf,
+ [&request, &recv_buf, &done, &mu, &cv, maybe_except](Status s) {
+ GPR_ASSERT(s.ok());
+
+ EchoResponse response;
+ EXPECT_TRUE(ParseFromByteBuffer(&recv_buf, &response));
+ EXPECT_EQ(request.message(), response.message());
+ std::lock_guard<std::mutex> l(mu);
+ done = true;
+ cv.notify_one();
+#if GRPC_ALLOW_EXCEPTIONS
+ if (maybe_except) {
+ throw - 1;
+ }
+#else
+ GPR_ASSERT(!maybe_except);
+#endif
+ });
+ std::unique_lock<std::mutex> l(mu);
+ while (!done) {
+ cv.wait(l);
+ }
+ }
+ }
+
+ bool is_server_started_;
+ std::shared_ptr<Channel> channel_;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
+ std::unique_ptr<grpc::GenericStub> generic_stub_;
+ TestServiceImpl service_;
+ std::unique_ptr<Server> server_;
+};
+
+TEST_F(ClientCallbackEnd2endTest, SimpleRpc) {
+ ResetStub();
+ SendRpcs(1, false);
+}
+
+TEST_F(ClientCallbackEnd2endTest, SequentialRpcs) {
+ ResetStub();
+ SendRpcs(10, false);
+}
+
+TEST_F(ClientCallbackEnd2endTest, SequentialRpcsWithVariedBinaryMetadataValue) {
+ ResetStub();
+ SendRpcs(10, true);
+}
+
+TEST_F(ClientCallbackEnd2endTest, SequentialGenericRpcs) {
+ ResetStub();
+ SendRpcsGeneric(10, false);
+}
+
+#if GRPC_ALLOW_EXCEPTIONS
+TEST_F(ClientCallbackEnd2endTest, ExceptingRpc) {
+ ResetStub();
+ SendRpcsGeneric(10, true);
+}
+#endif
+
+TEST_F(ClientCallbackEnd2endTest, MultipleRpcsWithVariedBinaryMetadataValue) {
+ ResetStub();
+ std::vector<std::thread> threads;
+ threads.reserve(10);
+ for (int i = 0; i < 10; ++i) {
+ threads.emplace_back([this] { SendRpcs(10, true); });
+ }
+ for (int i = 0; i < 10; ++i) {
+ threads[i].join();
+ }
+}
+
+TEST_F(ClientCallbackEnd2endTest, MultipleRpcs) {
+ ResetStub();
+ std::vector<std::thread> threads;
+ threads.reserve(10);
+ for (int i = 0; i < 10; ++i) {
+ threads.emplace_back([this] { SendRpcs(10, false); });
+ }
+ for (int i = 0; i < 10; ++i) {
+ threads[i].join();
+ }
+}
+
+TEST_F(ClientCallbackEnd2endTest, CancelRpcBeforeStart) {
+ ResetStub();
+ EchoRequest request;
+ EchoResponse response;
+ ClientContext context;
+ request.set_message("hello");
+ context.TryCancel();
+
+ std::mutex mu;
+ std::condition_variable cv;
+ bool done = false;
+ stub_->experimental_async()->Echo(
+ &context, &request, &response, [&response, &done, &mu, &cv](Status s) {
+ EXPECT_EQ("", response.message());
+ EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code());
+ std::lock_guard<std::mutex> l(mu);
+ done = true;
+ cv.notify_one();
+ });
+ std::unique_lock<std::mutex> l(mu);
+ while (!done) {
+ cv.wait(l);
+ }
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc
index a39e443cf0..a9d68ab058 100644
--- a/test/cpp/end2end/client_lb_end2end_test.cc
+++ b/test/cpp/end2end/client_lb_end2end_test.cc
@@ -119,6 +119,7 @@ class ClientLbEnd2endTest : public ::testing::Test {
}
void SetUp() override {
+ grpc_init();
response_generator_ =
grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>();
}
@@ -127,14 +128,26 @@ class ClientLbEnd2endTest : public ::testing::Test {
for (size_t i = 0; i < servers_.size(); ++i) {
servers_[i]->Shutdown();
}
+ grpc_shutdown();
}
- void StartServers(size_t num_servers,
- std::vector<int> ports = std::vector<int>()) {
+ void CreateServers(size_t num_servers,
+ std::vector<int> ports = std::vector<int>()) {
+ servers_.clear();
for (size_t i = 0; i < num_servers; ++i) {
int port = 0;
if (ports.size() == num_servers) port = ports[i];
- servers_.emplace_back(new ServerData(server_host_, port));
+ servers_.emplace_back(new ServerData(port));
+ }
+ }
+
+ void StartServer(size_t index) { servers_[index]->Start(server_host_); }
+
+ void StartServers(size_t num_servers,
+ std::vector<int> ports = std::vector<int>()) {
+ CreateServers(num_servers, ports);
+ for (size_t i = 0; i < num_servers; ++i) {
+ StartServer(i);
}
}
@@ -198,7 +211,8 @@ class ClientLbEnd2endTest : public ::testing::Test {
bool SendRpc(
const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub,
- EchoResponse* response = nullptr, int timeout_ms = 1000) {
+ EchoResponse* response = nullptr, int timeout_ms = 1000,
+ Status* result = nullptr) {
const bool local_response = (response == nullptr);
if (local_response) response = new EchoResponse;
EchoRequest request;
@@ -206,6 +220,7 @@ class ClientLbEnd2endTest : public ::testing::Test {
ClientContext context;
context.set_deadline(grpc_timeout_milliseconds_to_deadline(timeout_ms));
Status status = stub->Echo(&context, request, response);
+ if (result != nullptr) *result = status;
if (local_response) delete response;
return status.ok();
}
@@ -214,12 +229,15 @@ class ClientLbEnd2endTest : public ::testing::Test {
const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub,
const grpc_core::DebugLocation& location) {
EchoResponse response;
- const bool success = SendRpc(stub, &response);
- if (!success) abort();
- ASSERT_TRUE(success) << "From " << location.file() << ":"
- << location.line();
+ Status status;
+ const bool success = SendRpc(stub, &response, 2000, &status);
+ ASSERT_TRUE(success) << "From " << location.file() << ":" << location.line()
+ << "\n"
+ << "Error: " << status.error_message() << " "
+ << status.error_details();
ASSERT_EQ(response.message(), kRequestMessage_)
<< "From " << location.file() << ":" << location.line();
+ if (!success) abort();
}
void CheckRpcSendFailure(
@@ -235,20 +253,23 @@ class ClientLbEnd2endTest : public ::testing::Test {
std::unique_ptr<std::thread> thread_;
bool server_ready_ = false;
- explicit ServerData(const grpc::string& server_host, int port = 0) {
+ explicit ServerData(int port = 0) {
port_ = port > 0 ? port : grpc_pick_unused_port_or_die();
+ }
+
+ void Start(const grpc::string& server_host) {
gpr_log(GPR_INFO, "starting server on port %d", port_);
std::mutex mu;
std::unique_lock<std::mutex> lock(mu);
std::condition_variable cond;
thread_.reset(new std::thread(
- std::bind(&ServerData::Start, this, server_host, &mu, &cond)));
+ std::bind(&ServerData::Serve, this, server_host, &mu, &cond)));
cond.wait(lock, [this] { return server_ready_; });
server_ready_ = false;
gpr_log(GPR_INFO, "server startup complete");
}
- void Start(const grpc::string& server_host, std::mutex* mu,
+ void Serve(const grpc::string& server_host, std::mutex* mu,
std::condition_variable* cond) {
std::ostringstream server_address;
server_address << server_host << ":" << port_;
@@ -274,13 +295,29 @@ class ClientLbEnd2endTest : public ::testing::Test {
void WaitForServer(
const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub,
- size_t server_idx, const grpc_core::DebugLocation& location) {
+ size_t server_idx, const grpc_core::DebugLocation& location,
+ bool ignore_failure = false) {
do {
- CheckRpcSendOk(stub, location);
+ if (ignore_failure) {
+ SendRpc(stub);
+ } else {
+ CheckRpcSendOk(stub, location);
+ }
} while (servers_[server_idx]->service_.request_count() == 0);
ResetCounters();
}
+ bool WaitForChannelNotReady(Channel* channel, int timeout_seconds = 5) {
+ const gpr_timespec deadline =
+ grpc_timeout_seconds_to_deadline(timeout_seconds);
+ grpc_connectivity_state state;
+ while ((state = channel->GetState(false /* try_to_connect */)) ==
+ GRPC_CHANNEL_READY) {
+ if (!channel->WaitForStateChange(state, deadline)) return false;
+ }
+ return true;
+ }
+
bool SeenAllServers() {
for (const auto& server : servers_) {
if (server->service_.request_count() == 0) return false;
@@ -343,6 +380,23 @@ TEST_F(ClientLbEnd2endTest, PickFirst) {
EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName());
}
+TEST_F(ClientLbEnd2endTest, PickFirstProcessPending) {
+ StartServers(1); // Single server
+ auto channel = BuildChannel(""); // test that pick first is the default.
+ auto stub = BuildStub(channel);
+ SetNextResolution({servers_[0]->port_});
+ WaitForServer(stub, 0, DEBUG_LOCATION);
+ // Create a new channel and its corresponding PF LB policy, which will pick
+ // the subchannels in READY state from the previous RPC against the same
+ // target (even if it happened over a different channel, because subchannels
+ // are globally reused). Progress should happen without any transition from
+ // this READY state.
+ auto second_channel = BuildChannel("");
+ auto second_stub = BuildStub(second_channel);
+ SetNextResolution({servers_[0]->port_});
+ CheckRpcSendOk(second_stub, DEBUG_LOCATION);
+}
+
TEST_F(ClientLbEnd2endTest, PickFirstBackOffInitialReconnect) {
ChannelArguments args;
constexpr int kInitialBackOffMs = 100;
@@ -362,7 +416,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstBackOffInitialReconnect) {
grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 2)));
const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC);
const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0));
- gpr_log(GPR_DEBUG, "Waited %ld milliseconds", waited_ms);
+ gpr_log(GPR_DEBUG, "Waited %" PRId64 " milliseconds", waited_ms);
// We should have waited at least kInitialBackOffMs. We substract one to
// account for test and precision accuracy drift.
EXPECT_GE(waited_ms, kInitialBackOffMs - 1);
@@ -391,13 +445,43 @@ TEST_F(ClientLbEnd2endTest, PickFirstBackOffMinReconnect) {
grpc_timeout_milliseconds_to_deadline(kMinReconnectBackOffMs * 2));
const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC);
const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0));
- gpr_log(GPR_DEBUG, "Waited %ld ms", waited_ms);
+ gpr_log(GPR_DEBUG, "Waited %" PRId64 " ms", waited_ms);
// We should have waited at least kMinReconnectBackOffMs. We substract one to
// account for test and precision accuracy drift.
EXPECT_GE(waited_ms, kMinReconnectBackOffMs - 1);
gpr_atm_rel_store(&g_connection_delay_ms, 0);
}
+TEST_F(ClientLbEnd2endTest, PickFirstResetConnectionBackoff) {
+ ChannelArguments args;
+ constexpr int kInitialBackOffMs = 1000;
+ args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs);
+ const std::vector<int> ports = {grpc_pick_unused_port_or_die()};
+ auto channel = BuildChannel("pick_first", args);
+ auto stub = BuildStub(channel);
+ SetNextResolution(ports);
+ // The channel won't become connected (there's no server).
+ EXPECT_FALSE(
+ channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(10)));
+ // Bring up a server on the chosen port.
+ StartServers(1, ports);
+ const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC);
+ // Wait for connect, but not long enough. This proves that we're
+ // being throttled by initial backoff.
+ EXPECT_FALSE(
+ channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(10)));
+ // Reset connection backoff.
+ experimental::ChannelResetConnectionBackoff(channel.get());
+ // Wait for connect. Should happen ~immediately.
+ EXPECT_TRUE(
+ channel->WaitForConnected(grpc_timeout_milliseconds_to_deadline(10)));
+ const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC);
+ const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0));
+ gpr_log(GPR_DEBUG, "Waited %" PRId64 " milliseconds", waited_ms);
+ // We should have waited less than kInitialBackOffMs.
+ EXPECT_LT(waited_ms, kInitialBackOffMs);
+}
+
TEST_F(ClientLbEnd2endTest, PickFirstUpdates) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
@@ -478,7 +562,23 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdateSuperset) {
EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName());
}
-TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) {
+class ClientLbEnd2endWithParamTest
+ : public ClientLbEnd2endTest,
+ public ::testing::WithParamInterface<bool> {
+ protected:
+ void SetUp() override {
+ grpc_subchannel_index_test_only_set_force_creation(GetParam());
+ ClientLbEnd2endTest::SetUp();
+ }
+
+ void TearDown() override {
+ ClientLbEnd2endTest::TearDown();
+ grpc_subchannel_index_test_only_set_force_creation(false);
+ }
+};
+
+TEST_P(ClientLbEnd2endWithParamTest, PickFirstManyUpdates) {
+ gpr_log(GPR_INFO, "subchannel force creation: %d", GetParam());
// Start servers and send one RPC per server.
const int kNumServers = 3;
StartServers(kNumServers);
@@ -488,20 +588,129 @@ TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) {
for (size_t i = 0; i < servers_.size(); ++i) {
ports.emplace_back(servers_[i]->port_);
}
- for (const bool force_creation : {true, false}) {
- grpc_subchannel_index_test_only_set_force_creation(force_creation);
- gpr_log(GPR_INFO, "Force subchannel creation: %d", force_creation);
- for (size_t i = 0; i < 1000; ++i) {
- std::shuffle(ports.begin(), ports.end(),
- std::mt19937(std::random_device()()));
- SetNextResolution(ports);
- if (i % 10 == 0) CheckRpcSendOk(stub, DEBUG_LOCATION);
+ for (size_t i = 0; i < 1000; ++i) {
+ std::shuffle(ports.begin(), ports.end(),
+ std::mt19937(std::random_device()()));
+ SetNextResolution(ports);
+ // We should re-enter core at the end of the loop to give the resolution
+ // setting closure a chance to run.
+ if ((i + 1) % 10 == 0) CheckRpcSendOk(stub, DEBUG_LOCATION);
+ }
+ // Check LB policy name for the channel.
+ EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName());
+}
+
+INSTANTIATE_TEST_CASE_P(SubchannelForceCreation, ClientLbEnd2endWithParamTest,
+ ::testing::Bool());
+
+TEST_F(ClientLbEnd2endTest, PickFirstReresolutionNoSelected) {
+ // Prepare the ports for up servers and down servers.
+ const int kNumServers = 3;
+ const int kNumAliveServers = 1;
+ StartServers(kNumAliveServers);
+ std::vector<int> alive_ports, dead_ports;
+ for (size_t i = 0; i < kNumServers; ++i) {
+ if (i < kNumAliveServers) {
+ alive_ports.emplace_back(servers_[i]->port_);
+ } else {
+ dead_ports.emplace_back(grpc_pick_unused_port_or_die());
}
}
+ auto channel = BuildChannel("pick_first");
+ auto stub = BuildStub(channel);
+ // The initial resolution only contains dead ports. There won't be any
+ // selected subchannel. Re-resolution will return the same result.
+ SetNextResolution(dead_ports);
+ gpr_log(GPR_INFO, "****** INITIAL RESOLUTION SET *******");
+ for (size_t i = 0; i < 10; ++i) CheckRpcSendFailure(stub);
+ // Set a re-resolution result that contains reachable ports, so that the
+ // pick_first LB policy can recover soon.
+ SetNextResolutionUponError(alive_ports);
+ gpr_log(GPR_INFO, "****** RE-RESOLUTION SET *******");
+ WaitForServer(stub, 0, DEBUG_LOCATION, true /* ignore_failure */);
+ CheckRpcSendOk(stub, DEBUG_LOCATION);
+ EXPECT_EQ(servers_[0]->service_.request_count(), 1);
// Check LB policy name for the channel.
EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName());
}
+TEST_F(ClientLbEnd2endTest, PickFirstReconnectWithoutNewResolverResult) {
+ std::vector<int> ports = {grpc_pick_unused_port_or_die()};
+ StartServers(1, ports);
+ auto channel = BuildChannel("pick_first");
+ auto stub = BuildStub(channel);
+ SetNextResolution(ports);
+ gpr_log(GPR_INFO, "****** INITIAL CONNECTION *******");
+ WaitForServer(stub, 0, DEBUG_LOCATION);
+ gpr_log(GPR_INFO, "****** STOPPING SERVER ******");
+ servers_[0]->Shutdown();
+ EXPECT_TRUE(WaitForChannelNotReady(channel.get()));
+ gpr_log(GPR_INFO, "****** RESTARTING SERVER ******");
+ StartServers(1, ports);
+ WaitForServer(stub, 0, DEBUG_LOCATION);
+}
+
+TEST_F(ClientLbEnd2endTest,
+ PickFirstReconnectWithoutNewResolverResultStartsFromTopOfList) {
+ std::vector<int> ports = {grpc_pick_unused_port_or_die(),
+ grpc_pick_unused_port_or_die()};
+ CreateServers(2, ports);
+ StartServer(1);
+ auto channel = BuildChannel("pick_first");
+ auto stub = BuildStub(channel);
+ SetNextResolution(ports);
+ gpr_log(GPR_INFO, "****** INITIAL CONNECTION *******");
+ WaitForServer(stub, 1, DEBUG_LOCATION);
+ gpr_log(GPR_INFO, "****** STOPPING SERVER ******");
+ servers_[1]->Shutdown();
+ EXPECT_TRUE(WaitForChannelNotReady(channel.get()));
+ gpr_log(GPR_INFO, "****** STARTING BOTH SERVERS ******");
+ StartServers(2, ports);
+ WaitForServer(stub, 0, DEBUG_LOCATION);
+}
+
+TEST_F(ClientLbEnd2endTest, PickFirstCheckStateBeforeStartWatch) {
+ std::vector<int> ports = {grpc_pick_unused_port_or_die()};
+ StartServers(1, ports);
+ auto channel_1 = BuildChannel("pick_first");
+ auto stub_1 = BuildStub(channel_1);
+ SetNextResolution(ports);
+ gpr_log(GPR_INFO, "****** RESOLUTION SET FOR CHANNEL 1 *******");
+ WaitForServer(stub_1, 0, DEBUG_LOCATION);
+ gpr_log(GPR_INFO, "****** CHANNEL 1 CONNECTED *******");
+ servers_[0]->Shutdown();
+ // Channel 1 will receive a re-resolution containing the same server. It will
+ // create a new subchannel and hold a ref to it.
+ StartServers(1, ports);
+ gpr_log(GPR_INFO, "****** SERVER RESTARTED *******");
+ auto channel_2 = BuildChannel("pick_first");
+ auto stub_2 = BuildStub(channel_2);
+ // TODO(juanlishen): This resolution result will only be visible to channel 2
+ // since the response generator is only associated with channel 2 now. We
+ // should change the response generator to be able to deliver updates to
+ // multiple channels at once.
+ SetNextResolution(ports);
+ gpr_log(GPR_INFO, "****** RESOLUTION SET FOR CHANNEL 2 *******");
+ WaitForServer(stub_2, 0, DEBUG_LOCATION, true);
+ gpr_log(GPR_INFO, "****** CHANNEL 2 CONNECTED *******");
+ servers_[0]->Shutdown();
+ // Wait until the disconnection has triggered the connectivity notification.
+ // Otherwise, the subchannel may be picked for next call but will fail soon.
+ EXPECT_TRUE(WaitForChannelNotReady(channel_2.get()));
+ // Channel 2 will also receive a re-resolution containing the same server.
+ // Both channels will ref the same subchannel that failed.
+ StartServers(1, ports);
+ gpr_log(GPR_INFO, "****** SERVER RESTARTED AGAIN *******");
+ gpr_log(GPR_INFO, "****** CHANNEL 2 STARTING A CALL *******");
+ // The first call after the server restart will succeed.
+ CheckRpcSendOk(stub_2, DEBUG_LOCATION);
+ gpr_log(GPR_INFO, "****** CHANNEL 2 FINISHED A CALL *******");
+ // Check LB policy name for the channel.
+ EXPECT_EQ("pick_first", channel_1->GetLoadBalancingPolicyName());
+ // Check LB policy name for the channel.
+ EXPECT_EQ("pick_first", channel_2->GetLoadBalancingPolicyName());
+}
+
TEST_F(ClientLbEnd2endTest, RoundRobin) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
@@ -534,6 +743,23 @@ TEST_F(ClientLbEnd2endTest, RoundRobin) {
EXPECT_EQ("round_robin", channel->GetLoadBalancingPolicyName());
}
+TEST_F(ClientLbEnd2endTest, RoundRobinProcessPending) {
+ StartServers(1); // Single server
+ auto channel = BuildChannel("round_robin");
+ auto stub = BuildStub(channel);
+ SetNextResolution({servers_[0]->port_});
+ WaitForServer(stub, 0, DEBUG_LOCATION);
+ // Create a new channel and its corresponding RR LB policy, which will pick
+ // the subchannels in READY state from the previous RPC against the same
+ // target (even if it happened over a different channel, because subchannels
+ // are globally reused). Progress should happen without any transition from
+ // this READY state.
+ auto second_channel = BuildChannel("round_robin");
+ auto second_stub = BuildStub(second_channel);
+ SetNextResolution({servers_[0]->port_});
+ CheckRpcSendOk(second_stub, DEBUG_LOCATION);
+}
+
TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) {
// Start servers and send one RPC per server.
const int kNumServers = 3;
@@ -681,9 +907,11 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) {
const int kNumServers = 3;
std::vector<int> first_ports;
std::vector<int> second_ports;
+ first_ports.reserve(kNumServers);
for (int i = 0; i < kNumServers; ++i) {
first_ports.push_back(grpc_pick_unused_port_or_die());
}
+ second_ports.reserve(kNumServers);
for (int i = 0; i < kNumServers; ++i) {
second_ports.push_back(grpc_pick_unused_port_or_die());
}
@@ -698,7 +926,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) {
// Kill all servers
gpr_log(GPR_INFO, "****** ABOUT TO KILL SERVERS *******");
for (size_t i = 0; i < servers_.size(); ++i) {
- servers_[i]->Shutdown(false);
+ servers_[i]->Shutdown(true);
}
gpr_log(GPR_INFO, "****** SERVERS KILLED *******");
gpr_log(GPR_INFO, "****** SENDING DOOMED REQUESTS *******");
@@ -759,7 +987,8 @@ TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) {
// No requests have gone to the deceased server.
EXPECT_EQ(pre_death, post_death);
// Bring the first server back up.
- servers_[0].reset(new ServerData(server_host_, ports[0]));
+ servers_[0].reset(new ServerData(ports[0]));
+ StartServer(0);
// Requests should start arriving at the first server either right away (if
// the server managed to start before the RR policy retried the subchannel) or
// after the subchannel retry delay otherwise (RR's subchannel retried before
@@ -774,8 +1003,6 @@ TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
grpc_test_init(argc, argv);
- grpc_init();
const auto result = RUN_ALL_TESTS();
- grpc_shutdown();
return result;
}
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 60238e930d..fc07681535 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -71,8 +71,8 @@ class TestMetadataCredentialsPlugin : public MetadataCredentialsPlugin {
static const char kGoodMetadataKey[];
static const char kBadMetadataKey[];
- TestMetadataCredentialsPlugin(grpc::string_ref metadata_key,
- grpc::string_ref metadata_value,
+ TestMetadataCredentialsPlugin(const grpc::string_ref& metadata_key,
+ const grpc::string_ref& metadata_value,
bool is_blocking, bool is_successful)
: metadata_key_(metadata_key.data(), metadata_key.length()),
metadata_value_(metadata_value.data(), metadata_value.length()),
@@ -168,7 +168,7 @@ const char TestAuthMetadataProcessor::kIdentityPropName[] = "novel identity";
class Proxy : public ::grpc::testing::EchoTestService::Service {
public:
- Proxy(std::shared_ptr<Channel> channel)
+ Proxy(const std::shared_ptr<Channel>& channel)
: stub_(grpc::testing::EchoTestService::NewStub(channel)) {}
Status Echo(ServerContext* server_context, const EchoRequest* request,
@@ -683,6 +683,7 @@ TEST_P(End2endTest, SimpleRpcWithCustomUserAgentPrefix) {
TEST_P(End2endTest, MultipleRpcsWithVariedBinaryMetadataValue) {
ResetStub();
std::vector<std::thread> threads;
+ threads.reserve(10);
for (int i = 0; i < 10; ++i) {
threads.emplace_back(SendRpc, stub_.get(), 10, true);
}
@@ -694,6 +695,7 @@ TEST_P(End2endTest, MultipleRpcsWithVariedBinaryMetadataValue) {
TEST_P(End2endTest, MultipleRpcs) {
ResetStub();
std::vector<std::thread> threads;
+ threads.reserve(10);
for (int i = 0; i < 10; ++i) {
threads.emplace_back(SendRpc, stub_.get(), 10, false);
}
@@ -1209,8 +1211,13 @@ TEST_P(End2endTest, ExpectErrorTest) {
std::vector<ErrorStatus> expected_status;
expected_status.emplace_back();
expected_status.back().set_code(13); // INTERNAL
+ // No Error message or details
+
+ expected_status.emplace_back();
+ expected_status.back().set_code(13); // INTERNAL
expected_status.back().set_error_message("text error message");
expected_status.back().set_binary_error_details("text error details");
+
expected_status.emplace_back();
expected_status.back().set_code(13); // INTERNAL
expected_status.back().set_error_message("text error message");
@@ -1267,6 +1274,7 @@ TEST_P(ProxyEnd2endTest, SimpleRpcWithEmptyMessages) {
TEST_P(ProxyEnd2endTest, MultipleRpcs) {
ResetStub();
std::vector<std::thread> threads;
+ threads.reserve(10);
for (int i = 0; i < 10; ++i) {
threads.emplace_back(SendRpc, stub_.get(), 10, false);
}
diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc
index 7aab035e76..b69b861fcf 100644
--- a/test/cpp/end2end/grpclb_end2end_test.cc
+++ b/test/cpp/end2end/grpclb_end2end_test.cc
@@ -734,6 +734,25 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) {
EXPECT_EQ(2U, balancer_servers_[0].service_->response_count());
}
+TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) {
+ SetNextResolutionAllBalancers();
+ const size_t kNumUnreachableServers = 5;
+ std::vector<int> ports;
+ for (size_t i = 0; i < kNumUnreachableServers; ++i) {
+ ports.push_back(grpc_pick_unused_port_or_die());
+ }
+ ScheduleResponseForBalancer(
+ 0, BalancerServiceImpl::BuildResponseForBackends(ports, {}), 0);
+ const Status status = SendRpc();
+ // The error shouldn't be DEADLINE_EXCEEDED.
+ EXPECT_EQ(StatusCode::UNAVAILABLE, status.error_code());
+ balancers_[0]->NotifyDoneWithServerlists();
+ // The balancer got a single request.
+ EXPECT_EQ(1U, balancer_servers_[0].service_->request_count());
+ // and sent a single response.
+ EXPECT_EQ(1U, balancer_servers_[0].service_->response_count());
+}
+
TEST_F(SingleBalancerTest, Fallback) {
SetNextResolutionAllBalancers();
const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor();
@@ -1380,7 +1399,7 @@ TEST_F(SingleBalancerTest, DropAll) {
class SingleBalancerWithClientLoadReportingTest : public GrpclbEnd2endTest {
public:
- SingleBalancerWithClientLoadReportingTest() : GrpclbEnd2endTest(4, 1, 2) {}
+ SingleBalancerWithClientLoadReportingTest() : GrpclbEnd2endTest(4, 1, 3) {}
};
TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) {
diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc
index 10e16429e6..339eadde92 100644
--- a/test/cpp/end2end/hybrid_end2end_test.cc
+++ b/test/cpp/end2end/hybrid_end2end_test.cc
@@ -74,6 +74,27 @@ void HandleEcho(Service* service, ServerCompletionQueue* cq, bool dup_service) {
Verify(cq, 2, true);
}
+// Handlers to handle raw request at a server. To be run in a
+// separate thread. Note that this is the same as the async version, except
+// that the req/resp are ByteBuffers
+template <class Service>
+void HandleRawEcho(Service* service, ServerCompletionQueue* cq,
+ bool dup_service) {
+ ServerContext srv_ctx;
+ GenericServerAsyncResponseWriter response_writer(&srv_ctx);
+ ByteBuffer recv_buffer;
+ service->RequestEcho(&srv_ctx, &recv_buffer, &response_writer, cq, cq,
+ tag(1));
+ Verify(cq, 1, true);
+ EchoRequest recv_request;
+ EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request));
+ EchoResponse send_response;
+ send_response.set_message(recv_request.message());
+ auto send_buffer = SerializeToByteBuffer(&send_response);
+ response_writer.Finish(*send_buffer, Status::OK, tag(2));
+ Verify(cq, 2, true);
+}
+
template <class Service>
void HandleClientStreaming(Service* service, ServerCompletionQueue* cq) {
ServerContext srv_ctx;
@@ -93,6 +114,30 @@ void HandleClientStreaming(Service* service, ServerCompletionQueue* cq) {
}
template <class Service>
+void HandleRawClientStreaming(Service* service, ServerCompletionQueue* cq) {
+ ServerContext srv_ctx;
+ ByteBuffer recv_buffer;
+ EchoRequest recv_request;
+ EchoResponse send_response;
+ GenericServerAsyncReader srv_stream(&srv_ctx);
+ service->RequestRequestStream(&srv_ctx, &srv_stream, cq, cq, tag(1));
+ Verify(cq, 1, true);
+ int i = 1;
+ while (true) {
+ i++;
+ srv_stream.Read(&recv_buffer, tag(i));
+ if (!VerifyReturnSuccess(cq, i)) {
+ break;
+ }
+ EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request));
+ send_response.mutable_message()->append(recv_request.message());
+ }
+ auto send_buffer = SerializeToByteBuffer(&send_response);
+ srv_stream.Finish(*send_buffer, Status::OK, tag(100));
+ Verify(cq, 100, true);
+}
+
+template <class Service>
void HandleServerStreaming(Service* service, ServerCompletionQueue* cq) {
ServerContext srv_ctx;
EchoRequest recv_request;
@@ -379,6 +424,61 @@ TEST_F(HybridEnd2endTest, AsyncEcho) {
echo_handler_thread.join();
}
+TEST_F(HybridEnd2endTest, RawEcho) {
+ typedef EchoTestService::WithRawMethod_Echo<TestServiceImpl> SType;
+ SType service;
+ SetUpServer(&service, nullptr, nullptr);
+ ResetStub();
+ std::thread echo_handler_thread(HandleRawEcho<SType>, &service, cqs_[0].get(),
+ false);
+ TestAllMethods();
+ echo_handler_thread.join();
+}
+
+TEST_F(HybridEnd2endTest, RawRequestStream) {
+ typedef EchoTestService::WithRawMethod_RequestStream<TestServiceImpl> SType;
+ SType service;
+ SetUpServer(&service, nullptr, nullptr);
+ ResetStub();
+ std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>,
+ &service, cqs_[0].get());
+ TestAllMethods();
+ request_stream_handler_thread.join();
+}
+
+TEST_F(HybridEnd2endTest, AsyncEchoRawRequestStream) {
+ typedef EchoTestService::WithRawMethod_RequestStream<
+ EchoTestService::WithAsyncMethod_Echo<TestServiceImpl>>
+ SType;
+ SType service;
+ SetUpServer(&service, nullptr, nullptr);
+ ResetStub();
+ std::thread echo_handler_thread(HandleEcho<SType>, &service, cqs_[0].get(),
+ false);
+ std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>,
+ &service, cqs_[1].get());
+ TestAllMethods();
+ request_stream_handler_thread.join();
+ echo_handler_thread.join();
+}
+
+TEST_F(HybridEnd2endTest, GenericEchoRawRequestStream) {
+ typedef EchoTestService::WithRawMethod_RequestStream<
+ EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
+ SType;
+ SType service;
+ AsyncGenericService generic_service;
+ SetUpServer(&service, nullptr, &generic_service);
+ ResetStub();
+ std::thread generic_handler_thread(HandleGenericCall, &generic_service,
+ cqs_[0].get());
+ std::thread request_stream_handler_thread(HandleRawClientStreaming<SType>,
+ &service, cqs_[1].get());
+ TestAllMethods();
+ generic_handler_thread.join();
+ request_stream_handler_thread.join();
+}
+
TEST_F(HybridEnd2endTest, AsyncEchoRequestStream) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl>>
diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc
index ff49902fea..ba3122c895 100644
--- a/test/cpp/end2end/mock_test.cc
+++ b/test/cpp/end2end/mock_test.cc
@@ -186,7 +186,7 @@ class TestServiceImpl : public EchoTestService::Service {
ServerWriter<EchoResponse>* writer) override {
EchoResponse response;
vector<grpc::string> tokens = split(request->message());
- for (grpc::string token : tokens) {
+ for (const grpc::string& token : tokens) {
response.set_message(token);
writer->Write(response);
}
diff --git a/test/cpp/end2end/raw_end2end_test.cc b/test/cpp/end2end/raw_end2end_test.cc
new file mode 100644
index 0000000000..a413905ef7
--- /dev/null
+++ b/test/cpp/end2end/raw_end2end_test.cc
@@ -0,0 +1,370 @@
+/*
+ *
+ * Copyright 2015 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 <cinttypes>
+#include <memory>
+#include <thread>
+
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include <grpcpp/channel.h>
+#include <grpcpp/client_context.h>
+#include <grpcpp/create_channel.h>
+#include <grpcpp/server.h>
+#include <grpcpp/server_builder.h>
+#include <grpcpp/server_context.h>
+
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/iomgr/port.h"
+#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+#include "test/cpp/util/byte_buffer_proto_helper.h"
+#include "test/cpp/util/string_ref_helper.h"
+
+#include <gtest/gtest.h>
+
+using grpc::testing::EchoRequest;
+using grpc::testing::EchoResponse;
+
+namespace grpc {
+namespace testing {
+
+namespace {
+
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
+int detag(void* p) { return static_cast<int>(reinterpret_cast<intptr_t>(p)); }
+
+class Verifier {
+ public:
+ Verifier() {}
+
+ // Expect sets the expected ok value for a specific tag
+ Verifier& Expect(int i, bool expect_ok) {
+ expectations_[tag(i)] = expect_ok;
+ return *this;
+ }
+
+ // Next waits for 1 async tag to complete, checks its
+ // expectations, and returns the tag
+ int Next(CompletionQueue* cq, bool ignore_ok) {
+ bool ok;
+ void* got_tag;
+ EXPECT_TRUE(cq->Next(&got_tag, &ok));
+ GotTag(got_tag, ok, ignore_ok);
+ return detag(got_tag);
+ }
+
+ // Verify keeps calling Next until all currently set
+ // expected tags are complete
+ void Verify(CompletionQueue* cq) {
+ GPR_ASSERT(!expectations_.empty());
+ while (!expectations_.empty()) {
+ Next(cq, false);
+ }
+ }
+
+ private:
+ void GotTag(void* got_tag, bool ok, bool ignore_ok) {
+ auto it = expectations_.find(got_tag);
+ if (it != expectations_.end()) {
+ if (!ignore_ok) {
+ EXPECT_EQ(it->second, ok);
+ }
+ expectations_.erase(it);
+ }
+ }
+
+ std::map<void*, bool> expectations_;
+};
+
+class RawEnd2EndTest : public ::testing::Test {
+ protected:
+ RawEnd2EndTest() {}
+
+ void SetUp() override {
+ port_ = grpc_pick_unused_port_or_die();
+ server_address_ << "localhost:" << port_;
+ }
+
+ void TearDown() override {
+ server_->Shutdown();
+ void* ignored_tag;
+ bool ignored_ok;
+ cq_->Shutdown();
+ while (cq_->Next(&ignored_tag, &ignored_ok))
+ ;
+ stub_.reset();
+ grpc_recycle_unused_port(port_);
+ }
+
+ template <typename ServerType>
+ std::unique_ptr<ServerType> BuildAndStartServer() {
+ ServerBuilder builder;
+ builder.AddListeningPort(server_address_.str(),
+ grpc::InsecureServerCredentials());
+ std::unique_ptr<ServerType> service(new ServerType());
+ builder.RegisterService(service.get());
+ cq_ = builder.AddCompletionQueue();
+ server_ = builder.BuildAndStart();
+ return service;
+ }
+
+ void ResetStub() {
+ ChannelArguments args;
+ std::shared_ptr<Channel> channel = CreateChannel(
+ server_address_.str(), grpc::InsecureChannelCredentials());
+ stub_ = grpc::testing::EchoTestService::NewStub(channel);
+ }
+
+ std::unique_ptr<ServerCompletionQueue> cq_;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
+ std::unique_ptr<Server> server_;
+ std::ostringstream server_address_;
+ int port_;
+
+ // For the client application to populate and send to server.
+ EchoRequest send_request_;
+ ::grpc::ByteBuffer send_request_buffer_;
+
+ // For the server to give to gRPC to be populated by incoming request
+ // from client.
+ EchoRequest recv_request_;
+ ::grpc::ByteBuffer recv_request_buffer_;
+
+ // For the server application to populate and send back to client.
+ EchoResponse send_response_;
+ ::grpc::ByteBuffer send_response_buffer_;
+
+ // For the client to give to gRPC to be populated by incoming response
+ // from server.
+ EchoResponse recv_response_;
+ ::grpc::ByteBuffer recv_response_buffer_;
+ Status recv_status_;
+
+ // Both sides need contexts
+ ClientContext cli_ctx_;
+ ServerContext srv_ctx_;
+};
+
+// Regular Async, both peers use proto
+TEST_F(RawEnd2EndTest, PureAsyncService) {
+ typedef grpc::testing::EchoTestService::AsyncService SType;
+ ResetStub();
+ auto service = BuildAndStartServer<SType>();
+ grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx_);
+
+ send_request_.set_message("hello");
+ std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader(
+ stub_->AsyncEcho(&cli_ctx_, send_request_, cq_.get()));
+ service->RequestEcho(&srv_ctx_, &recv_request_, &response_writer, cq_.get(),
+ cq_.get(), tag(2));
+ response_reader->Finish(&recv_response_, &recv_status_, tag(4));
+ Verifier().Expect(2, true).Verify(cq_.get());
+ EXPECT_EQ(send_request_.message(), recv_request_.message());
+ send_response_.set_message(recv_request_.message());
+ response_writer.Finish(send_response_, Status::OK, tag(3));
+ Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
+
+ EXPECT_EQ(send_response_.message(), recv_response_.message());
+ EXPECT_TRUE(recv_status_.ok());
+}
+
+// Client uses proto, server uses generic codegen, unary
+TEST_F(RawEnd2EndTest, RawServerUnary) {
+ typedef grpc::testing::EchoTestService::WithRawMethod_Echo<
+ grpc::testing::EchoTestService::Service>
+ SType;
+ ResetStub();
+ auto service = BuildAndStartServer<SType>();
+ grpc::GenericServerAsyncResponseWriter response_writer(&srv_ctx_);
+
+ send_request_.set_message("hello unary");
+ std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader(
+ stub_->AsyncEcho(&cli_ctx_, send_request_, cq_.get()));
+ service->RequestEcho(&srv_ctx_, &recv_request_buffer_, &response_writer,
+ cq_.get(), cq_.get(), tag(2));
+ response_reader->Finish(&recv_response_, &recv_status_, tag(4));
+ Verifier().Expect(2, true).Verify(cq_.get());
+ EXPECT_TRUE(ParseFromByteBuffer(&recv_request_buffer_, &recv_request_));
+ EXPECT_EQ(send_request_.message(), recv_request_.message());
+ send_response_.set_message(recv_request_.message());
+ EXPECT_TRUE(
+ SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_));
+ response_writer.Finish(send_response_buffer_, Status::OK, tag(3));
+ Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
+
+ EXPECT_EQ(send_response_.message(), recv_response_.message());
+ EXPECT_TRUE(recv_status_.ok());
+}
+
+// Client uses proto, server uses generic codegen, client streaming
+TEST_F(RawEnd2EndTest, RawServerClientStreaming) {
+ typedef grpc::testing::EchoTestService::WithRawMethod_RequestStream<
+ grpc::testing::EchoTestService::Service>
+ SType;
+ ResetStub();
+ auto service = BuildAndStartServer<SType>();
+
+ grpc::GenericServerAsyncReader srv_stream(&srv_ctx_);
+
+ send_request_.set_message("hello client streaming");
+ std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream(
+ stub_->AsyncRequestStream(&cli_ctx_, &recv_response_, cq_.get(), tag(1)));
+
+ service->RequestRequestStream(&srv_ctx_, &srv_stream, cq_.get(), cq_.get(),
+ tag(2));
+
+ Verifier().Expect(2, true).Expect(1, true).Verify(cq_.get());
+
+ cli_stream->Write(send_request_, tag(3));
+ srv_stream.Read(&recv_request_buffer_, tag(4));
+ Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
+ ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
+ EXPECT_EQ(send_request_.message(), recv_request_.message());
+
+ cli_stream->Write(send_request_, tag(5));
+ srv_stream.Read(&recv_request_buffer_, tag(6));
+ Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get());
+
+ ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
+ EXPECT_EQ(send_request_.message(), recv_request_.message());
+ cli_stream->WritesDone(tag(7));
+ srv_stream.Read(&recv_request_buffer_, tag(8));
+ Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get());
+
+ ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
+ send_response_.set_message(recv_request_.message());
+ SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_);
+ srv_stream.Finish(send_response_buffer_, Status::OK, tag(9));
+ cli_stream->Finish(&recv_status_, tag(10));
+ Verifier().Expect(9, true).Expect(10, true).Verify(cq_.get());
+
+ EXPECT_EQ(send_response_.message(), recv_response_.message());
+ EXPECT_TRUE(recv_status_.ok());
+}
+
+// Client uses proto, server uses generic codegen, server streaming
+TEST_F(RawEnd2EndTest, RawServerServerStreaming) {
+ typedef grpc::testing::EchoTestService::WithRawMethod_ResponseStream<
+ grpc::testing::EchoTestService::Service>
+ SType;
+ ResetStub();
+ auto service = BuildAndStartServer<SType>();
+ grpc::GenericServerAsyncWriter srv_stream(&srv_ctx_);
+
+ send_request_.set_message("hello server streaming");
+ std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream(
+ stub_->AsyncResponseStream(&cli_ctx_, send_request_, cq_.get(), tag(1)));
+
+ service->RequestResponseStream(&srv_ctx_, &recv_request_buffer_, &srv_stream,
+ cq_.get(), cq_.get(), tag(2));
+
+ Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get());
+ ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
+ EXPECT_EQ(send_request_.message(), recv_request_.message());
+
+ send_response_.set_message(recv_request_.message());
+ SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_);
+ srv_stream.Write(send_response_buffer_, tag(3));
+ cli_stream->Read(&recv_response_, tag(4));
+ Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
+ EXPECT_EQ(send_response_.message(), recv_response_.message());
+
+ srv_stream.Write(send_response_buffer_, tag(5));
+ cli_stream->Read(&recv_response_, tag(6));
+ Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get());
+ EXPECT_EQ(send_response_.message(), recv_response_.message());
+
+ srv_stream.Finish(Status::OK, tag(7));
+ cli_stream->Read(&recv_response_, tag(8));
+ Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get());
+
+ cli_stream->Finish(&recv_status_, tag(9));
+ Verifier().Expect(9, true).Verify(cq_.get());
+
+ EXPECT_TRUE(recv_status_.ok());
+}
+
+// Client uses proto, server uses generic codegen, bidi streaming
+TEST_F(RawEnd2EndTest, RawServerBidiStreaming) {
+ typedef grpc::testing::EchoTestService::WithRawMethod_BidiStream<
+ grpc::testing::EchoTestService::Service>
+ SType;
+ ResetStub();
+ auto service = BuildAndStartServer<SType>();
+
+ grpc::GenericServerAsyncReaderWriter srv_stream(&srv_ctx_);
+
+ send_request_.set_message("hello bidi streaming");
+ std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>>
+ cli_stream(stub_->AsyncBidiStream(&cli_ctx_, cq_.get(), tag(1)));
+
+ service->RequestBidiStream(&srv_ctx_, &srv_stream, cq_.get(), cq_.get(),
+ tag(2));
+
+ Verifier().Expect(1, true).Expect(2, true).Verify(cq_.get());
+
+ cli_stream->Write(send_request_, tag(3));
+ srv_stream.Read(&recv_request_buffer_, tag(4));
+ Verifier().Expect(3, true).Expect(4, true).Verify(cq_.get());
+ ParseFromByteBuffer(&recv_request_buffer_, &recv_request_);
+ EXPECT_EQ(send_request_.message(), recv_request_.message());
+
+ send_response_.set_message(recv_request_.message());
+ SerializeToByteBufferInPlace(&send_response_, &send_response_buffer_);
+ srv_stream.Write(send_response_buffer_, tag(5));
+ cli_stream->Read(&recv_response_, tag(6));
+ Verifier().Expect(5, true).Expect(6, true).Verify(cq_.get());
+ EXPECT_EQ(send_response_.message(), recv_response_.message());
+
+ cli_stream->WritesDone(tag(7));
+ srv_stream.Read(&recv_request_buffer_, tag(8));
+ Verifier().Expect(7, true).Expect(8, false).Verify(cq_.get());
+
+ srv_stream.Finish(Status::OK, tag(9));
+ cli_stream->Finish(&recv_status_, tag(10));
+ Verifier().Expect(9, true).Expect(10, true).Verify(cq_.get());
+
+ EXPECT_TRUE(recv_status_.ok());
+}
+
+// Testing that this pattern compiles
+TEST_F(RawEnd2EndTest, CompileTest) {
+ typedef grpc::testing::EchoTestService::WithRawMethod_Echo<
+ grpc::testing::EchoTestService::AsyncService>
+ SType;
+ ResetStub();
+ auto service = BuildAndStartServer<SType>();
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ // Change the backup poll interval from 5s to 100ms to speed up the
+ // ReconnectChannel test
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ int ret = RUN_ALL_TESTS();
+ return ret;
+}
diff --git a/test/cpp/end2end/round_robin_end2end_test.cc b/test/cpp/end2end/round_robin_end2end_test.cc
deleted file mode 100644
index 846347e110..0000000000
--- a/test/cpp/end2end/round_robin_end2end_test.cc
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- *
- * Copyright 2016 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 <memory>
-#include <mutex>
-#include <thread>
-
-#include <grpc/grpc.h>
-#include <grpc/support/log.h>
-#include <grpc/support/time.h>
-#include <grpcpp/channel.h>
-#include <grpcpp/client_context.h>
-#include <grpcpp/create_channel.h>
-#include <grpcpp/server.h>
-#include <grpcpp/server_builder.h>
-
-#include "src/proto/grpc/testing/echo.grpc.pb.h"
-#include "test/core/util/port.h"
-#include "test/core/util/test_config.h"
-#include "test/cpp/end2end/test_service_impl.h"
-
-#include <gtest/gtest.h>
-
-using grpc::testing::EchoRequest;
-using grpc::testing::EchoResponse;
-using std::chrono::system_clock;
-
-namespace grpc {
-namespace testing {
-namespace {
-
-// Subclass of TestServiceImpl that increments a request counter for
-// every call to the Echo RPC.
-class MyTestServiceImpl : public TestServiceImpl {
- public:
- MyTestServiceImpl() : request_count_(0) {}
-
- Status Echo(ServerContext* context, const EchoRequest* request,
- EchoResponse* response) override {
- {
- std::unique_lock<std::mutex> lock(mu_);
- ++request_count_;
- }
- return TestServiceImpl::Echo(context, request, response);
- }
-
- int request_count() {
- std::unique_lock<std::mutex> lock(mu_);
- return request_count_;
- }
-
- private:
- std::mutex mu_;
- int request_count_;
-};
-
-class RoundRobinEnd2endTest : public ::testing::Test {
- protected:
- RoundRobinEnd2endTest() : server_host_("localhost") {}
-
- void StartServers(size_t num_servers,
- std::vector<int> ports = std::vector<int>()) {
- for (size_t i = 0; i < num_servers; ++i) {
- int port = 0;
- if (ports.size() == num_servers) port = ports[i];
- servers_.emplace_back(new ServerData(server_host_, port));
- }
- }
-
- void TearDown() override {
- for (size_t i = 0; i < servers_.size(); ++i) {
- servers_[i]->Shutdown();
- }
- }
-
- void ResetStub(bool round_robin) {
- ChannelArguments args;
- if (round_robin) args.SetLoadBalancingPolicyName("round_robin");
- std::ostringstream uri;
- uri << "ipv4:///";
- for (size_t i = 0; i < servers_.size() - 1; ++i) {
- uri << "127.0.0.1:" << servers_[i]->port_ << ",";
- }
- uri << "127.0.0.1:" << servers_[servers_.size() - 1]->port_;
- channel_ =
- CreateCustomChannel(uri.str(), InsecureChannelCredentials(), args);
- stub_ = grpc::testing::EchoTestService::NewStub(channel_);
- }
-
- void SendRpc(int num_rpcs, bool expect_ok = true) {
- EchoRequest request;
- EchoResponse response;
- request.set_message("Live long and prosper.");
- for (int i = 0; i < num_rpcs; i++) {
- ClientContext context;
- Status status = stub_->Echo(&context, request, &response);
- if (expect_ok) {
- EXPECT_TRUE(status.ok());
- EXPECT_EQ(response.message(), request.message());
- } else {
- EXPECT_FALSE(status.ok());
- }
- }
- }
-
- struct ServerData {
- int port_;
- std::unique_ptr<Server> server_;
- MyTestServiceImpl service_;
-
- explicit ServerData(const grpc::string& server_host, int port = 0) {
- port_ = port > 0 ? port : grpc_pick_unused_port_or_die();
- gpr_log(GPR_INFO, "starting server on port %d", port_);
- std::ostringstream server_address;
- server_address << server_host << ":" << port_;
- ServerBuilder builder;
- builder.AddListeningPort(server_address.str(),
- InsecureServerCredentials());
- builder.RegisterService(&service_);
- server_ = builder.BuildAndStart();
- gpr_log(GPR_INFO, "server startup complete");
- }
-
- void Shutdown() { server_->Shutdown(); }
- };
-
- const grpc::string server_host_;
- std::shared_ptr<Channel> channel_;
- std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
- std::vector<std::unique_ptr<ServerData>> servers_;
-};
-
-TEST_F(RoundRobinEnd2endTest, PickFirst) {
- // Start servers and send one RPC per server.
- const int kNumServers = 3;
- StartServers(kNumServers);
- ResetStub(false /* round_robin */);
- SendRpc(kNumServers);
- // All requests should have gone to a single server.
- bool found = false;
- for (size_t i = 0; i < servers_.size(); ++i) {
- const int request_count = servers_[i]->service_.request_count();
- if (request_count == kNumServers) {
- found = true;
- } else {
- EXPECT_EQ(0, request_count);
- }
- }
- EXPECT_TRUE(found);
- // Check LB policy name for the channel.
- EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName());
-}
-
-TEST_F(RoundRobinEnd2endTest, RoundRobin) {
- // Start servers and send one RPC per server.
- const int kNumServers = 3;
- StartServers(kNumServers);
- ResetStub(true /* round_robin */);
- // Send one RPC per backend and make sure they are used in order.
- // Note: This relies on the fact that the subchannels are reported in
- // state READY in the order in which the addresses are specified,
- // which is only true because the backends are all local.
- for (size_t i = 0; i < servers_.size(); ++i) {
- SendRpc(1);
- EXPECT_EQ(1, servers_[i]->service_.request_count()) << "for backend #" << i;
- }
- // Check LB policy name for the channel.
- EXPECT_EQ("round_robin", channel_->GetLoadBalancingPolicyName());
-}
-
-TEST_F(RoundRobinEnd2endTest, RoundRobinReconnect) {
- // Start servers and send one RPC per server.
- const int kNumServers = 1;
- std::vector<int> ports;
- ports.push_back(grpc_pick_unused_port_or_die());
- StartServers(kNumServers, ports);
- ResetStub(true /* round_robin */);
- // Send one RPC per backend and make sure they are used in order.
- // Note: This relies on the fact that the subchannels are reported in
- // state READY in the order in which the addresses are specified,
- // which is only true because the backends are all local.
- for (size_t i = 0; i < servers_.size(); ++i) {
- SendRpc(1);
- EXPECT_EQ(1, servers_[i]->service_.request_count()) << "for backend #" << i;
- }
- // Check LB policy name for the channel.
- EXPECT_EQ("round_robin", channel_->GetLoadBalancingPolicyName());
-
- // Kill all servers
- for (size_t i = 0; i < servers_.size(); ++i) {
- servers_[i]->Shutdown();
- }
- // Client request should fail.
- SendRpc(1, false);
-
- // Bring servers back up on the same port (we aren't recreating the channel).
- StartServers(kNumServers, ports);
-
- // Client request should succeed.
- SendRpc(1);
-}
-
-} // namespace
-} // namespace testing
-} // namespace grpc
-
-int main(int argc, char** argv) {
- grpc_test_init(argc, argv);
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/cpp/end2end/server_load_reporting_end2end_test.cc b/test/cpp/end2end/server_load_reporting_end2end_test.cc
new file mode 100644
index 0000000000..7bc9af2a6e
--- /dev/null
+++ b/test/cpp/end2end/server_load_reporting_end2end_test.cc
@@ -0,0 +1,191 @@
+/*
+ *
+ * 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 <grpc/support/port_platform.h>
+
+#include <thread>
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include <grpc++/grpc++.h>
+#include <grpc/grpc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpcpp/ext/server_load_reporting.h>
+#include <grpcpp/server_builder.h>
+
+#include "src/proto/grpc/lb/v1/load_reporter.grpc.pb.h"
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/port.h"
+
+namespace grpc {
+namespace testing {
+namespace {
+
+constexpr double kMetricValue = 3.1415;
+constexpr char kMetricName[] = "METRIC_PI";
+
+// Different messages result in different response statuses. For simplicity in
+// computing request bytes, the message sizes should be the same.
+const char kOkMessage[] = "hello";
+const char kServerErrorMessage[] = "sverr";
+const char kClientErrorMessage[] = "clerr";
+
+class EchoTestServiceImpl : public EchoTestService::Service {
+ public:
+ ~EchoTestServiceImpl() override {}
+
+ Status Echo(ServerContext* context, const EchoRequest* request,
+ EchoResponse* response) override {
+ if (request->message() == kServerErrorMessage) {
+ return Status(StatusCode::UNKNOWN, "Server error requested");
+ }
+ if (request->message() == kClientErrorMessage) {
+ return Status(StatusCode::FAILED_PRECONDITION, "Client error requested");
+ }
+ response->set_message(request->message());
+ ::grpc::load_reporter::experimental::AddLoadReportingCost(
+ context, kMetricName, kMetricValue);
+ return Status::OK;
+ }
+};
+
+class ServerLoadReportingEnd2endTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ server_address_ =
+ "localhost:" + std::to_string(grpc_pick_unused_port_or_die());
+ server_ =
+ ServerBuilder()
+ .AddListeningPort(server_address_, InsecureServerCredentials())
+ .RegisterService(&echo_service_)
+ .SetOption(std::unique_ptr<::grpc::ServerBuilderOption>(
+ new ::grpc::load_reporter::experimental::
+ LoadReportingServiceServerBuilderOption()))
+ .BuildAndStart();
+ server_thread_ =
+ std::thread(&ServerLoadReportingEnd2endTest::RunServerLoop, this);
+ }
+
+ void RunServerLoop() { server_->Wait(); }
+
+ void TearDown() override {
+ server_->Shutdown();
+ server_thread_.join();
+ }
+
+ void ClientMakeEchoCalls(const grpc::string& lb_id,
+ const grpc::string& lb_tag,
+ const grpc::string& message, size_t num_requests) {
+ auto stub = EchoTestService::NewStub(
+ CreateChannel(server_address_, InsecureChannelCredentials()));
+ grpc::string lb_token = lb_id + lb_tag;
+ for (int i = 0; i < num_requests; ++i) {
+ ClientContext ctx;
+ if (!lb_token.empty()) ctx.AddMetadata(GRPC_LB_TOKEN_MD_KEY, lb_token);
+ EchoRequest request;
+ EchoResponse response;
+ request.set_message(message);
+ Status status = stub->Echo(&ctx, request, &response);
+ if (message == kOkMessage) {
+ ASSERT_EQ(status.error_code(), StatusCode::OK);
+ ASSERT_EQ(request.message(), response.message());
+ } else if (message == kServerErrorMessage) {
+ ASSERT_EQ(status.error_code(), StatusCode::UNKNOWN);
+ } else if (message == kClientErrorMessage) {
+ ASSERT_EQ(status.error_code(), StatusCode::FAILED_PRECONDITION);
+ }
+ }
+ }
+
+ grpc::string server_address_;
+ std::unique_ptr<Server> server_;
+ std::thread server_thread_;
+ EchoTestServiceImpl echo_service_;
+};
+
+TEST_F(ServerLoadReportingEnd2endTest, NoCall) {}
+
+TEST_F(ServerLoadReportingEnd2endTest, BasicReport) {
+ auto channel =
+ grpc::CreateChannel(server_address_, InsecureChannelCredentials());
+ auto stub = ::grpc::lb::v1::LoadReporter::NewStub(channel);
+ ClientContext ctx;
+ auto stream = stub->ReportLoad(&ctx);
+ ::grpc::lb::v1::LoadReportRequest request;
+ request.mutable_initial_request()->set_load_balanced_hostname(
+ server_address_);
+ request.mutable_initial_request()->set_load_key("LOAD_KEY");
+ request.mutable_initial_request()
+ ->mutable_load_report_interval()
+ ->set_seconds(5);
+ stream->Write(request);
+ gpr_log(GPR_INFO, "Initial request sent.");
+ ::grpc::lb::v1::LoadReportResponse response;
+ stream->Read(&response);
+ const grpc::string& lb_id = response.initial_response().load_balancer_id();
+ gpr_log(GPR_INFO, "Initial response received (lb_id: %s).", lb_id.c_str());
+ ClientMakeEchoCalls(lb_id, "LB_TAG", kOkMessage, 1);
+ while (true) {
+ stream->Read(&response);
+ if (!response.load().empty()) {
+ ASSERT_EQ(response.load().size(), 3);
+ for (const auto& load : response.load()) {
+ if (load.in_progress_report_case()) {
+ // The special load record that reports the number of in-progress
+ // calls.
+ ASSERT_EQ(load.num_calls_in_progress(), 1);
+ } else if (load.orphaned_load_case()) {
+ // The call from the balancer doesn't have any valid LB token.
+ ASSERT_EQ(load.orphaned_load_case(), load.kLoadKeyUnknown);
+ ASSERT_EQ(load.num_calls_started(), 1);
+ ASSERT_EQ(load.num_calls_finished_without_error(), 0);
+ ASSERT_EQ(load.num_calls_finished_with_error(), 0);
+ } else {
+ // This corresponds to the calls from the client.
+ ASSERT_EQ(load.num_calls_started(), 1);
+ ASSERT_EQ(load.num_calls_finished_without_error(), 1);
+ ASSERT_EQ(load.num_calls_finished_with_error(), 0);
+ ASSERT_GE(load.total_bytes_received(), sizeof(kOkMessage));
+ ASSERT_GE(load.total_bytes_sent(), sizeof(kOkMessage));
+ ASSERT_EQ(load.metric_data().size(), 1);
+ ASSERT_EQ(load.metric_data().Get(0).metric_name(), kMetricName);
+ ASSERT_EQ(load.metric_data().Get(0).num_calls_finished_with_metric(),
+ 1);
+ ASSERT_EQ(load.metric_data().Get(0).total_metric_value(),
+ kMetricValue);
+ }
+ }
+ break;
+ }
+ }
+ stream->WritesDone();
+ ASSERT_EQ(stream->Finish().error_code(), StatusCode::CANCELLED);
+}
+
+// TODO(juanlishen): Add more tests.
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index e709a25356..1a5ed28a2c 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -16,6 +16,7 @@
*
*/
+#include <cinttypes>
#include <mutex>
#include <thread>
@@ -24,6 +25,7 @@
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
+#include <grpcpp/resource_quota.h>
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
@@ -51,63 +53,13 @@ namespace testing {
class TestServiceImpl : public ::grpc::testing::EchoTestService::Service {
public:
- TestServiceImpl() : signal_client_(false) {}
+ TestServiceImpl() {}
Status Echo(ServerContext* context, const EchoRequest* request,
EchoResponse* response) override {
response->set_message(request->message());
return Status::OK;
}
-
- // Unimplemented is left unimplemented to test the returned error.
-
- Status RequestStream(ServerContext* context,
- ServerReader<EchoRequest>* reader,
- EchoResponse* response) override {
- EchoRequest request;
- response->set_message("");
- while (reader->Read(&request)) {
- response->mutable_message()->append(request.message());
- }
- return Status::OK;
- }
-
- // Return 3 messages.
- // TODO(yangg) make it generic by adding a parameter into EchoRequest
- Status ResponseStream(ServerContext* context, const EchoRequest* request,
- ServerWriter<EchoResponse>* writer) override {
- EchoResponse response;
- response.set_message(request->message() + "0");
- writer->Write(response);
- response.set_message(request->message() + "1");
- writer->Write(response);
- response.set_message(request->message() + "2");
- writer->Write(response);
-
- return Status::OK;
- }
-
- Status BidiStream(
- ServerContext* context,
- ServerReaderWriter<EchoResponse, EchoRequest>* stream) override {
- EchoRequest request;
- EchoResponse response;
- while (stream->Read(&request)) {
- gpr_log(GPR_INFO, "recv msg %s", request.message().c_str());
- response.set_message(request.message());
- stream->Write(response);
- }
- return Status::OK;
- }
-
- bool signal_client() {
- std::unique_lock<std::mutex> lock(mu_);
- return signal_client_;
- }
-
- private:
- bool signal_client_;
- std::mutex mu_;
};
template <class Service>
@@ -118,6 +70,7 @@ class CommonStressTest {
virtual void SetUp() = 0;
virtual void TearDown() = 0;
virtual void ResetStub() = 0;
+ virtual bool AllowExhaustion() = 0;
grpc::testing::EchoTestService::Stub* GetStub() { return stub_.get(); }
protected:
@@ -146,6 +99,7 @@ class CommonStressTestInsecure : public CommonStressTest<Service> {
CreateChannel(server_address_.str(), InsecureChannelCredentials());
this->stub_ = grpc::testing::EchoTestService::NewStub(channel);
}
+ bool AllowExhaustion() override { return false; }
protected:
void SetUpStart(ServerBuilder* builder, Service* service) override {
@@ -161,7 +115,7 @@ class CommonStressTestInsecure : public CommonStressTest<Service> {
std::ostringstream server_address_;
};
-template <class Service>
+template <class Service, bool allow_resource_exhaustion>
class CommonStressTestInproc : public CommonStressTest<Service> {
public:
void ResetStub() override {
@@ -169,6 +123,7 @@ class CommonStressTestInproc : public CommonStressTest<Service> {
std::shared_ptr<Channel> channel = this->server_->InProcessChannel(args);
this->stub_ = grpc::testing::EchoTestService::NewStub(channel);
}
+ bool AllowExhaustion() override { return allow_resource_exhaustion; }
protected:
void SetUpStart(ServerBuilder* builder, Service* service) override {
@@ -194,6 +149,26 @@ class CommonStressTestSyncServer : public BaseClass {
};
template <class BaseClass>
+class CommonStressTestSyncServerLowThreadCount : public BaseClass {
+ public:
+ void SetUp() override {
+ ServerBuilder builder;
+ ResourceQuota quota;
+ this->SetUpStart(&builder, &service_);
+ quota.SetMaxThreads(4);
+ builder.SetResourceQuota(quota);
+ this->SetUpEnd(&builder);
+ }
+ void TearDown() override {
+ this->TearDownStart();
+ this->TearDownEnd();
+ }
+
+ private:
+ TestServiceImpl service_;
+};
+
+template <class BaseClass>
class CommonStressTestAsyncServer : public BaseClass {
public:
CommonStressTestAsyncServer() : contexts_(kNumAsyncServerThreads * 100) {}
@@ -293,7 +268,8 @@ class End2endTest : public ::testing::Test {
Common common_;
};
-static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs) {
+static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs,
+ bool allow_exhaustion, gpr_atm* errors) {
EchoRequest request;
EchoResponse response;
request.set_message("Hello");
@@ -301,33 +277,53 @@ static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs) {
for (int i = 0; i < num_rpcs; ++i) {
ClientContext context;
Status s = stub->Echo(&context, request, &response);
- EXPECT_EQ(response.message(), request.message());
+ EXPECT_TRUE(s.ok() || (allow_exhaustion &&
+ s.error_code() == StatusCode::RESOURCE_EXHAUSTED));
if (!s.ok()) {
- gpr_log(GPR_ERROR, "RPC error: %d: %s", s.error_code(),
- s.error_message().c_str());
+ if (!(allow_exhaustion &&
+ s.error_code() == StatusCode::RESOURCE_EXHAUSTED)) {
+ gpr_log(GPR_ERROR, "RPC error: %d: %s", s.error_code(),
+ s.error_message().c_str());
+ }
+ gpr_atm_no_barrier_fetch_add(errors, static_cast<gpr_atm>(1));
+ } else {
+ EXPECT_EQ(response.message(), request.message());
}
- ASSERT_TRUE(s.ok());
}
}
typedef ::testing::Types<
CommonStressTestSyncServer<CommonStressTestInsecure<TestServiceImpl>>,
- CommonStressTestSyncServer<CommonStressTestInproc<TestServiceImpl>>,
+ CommonStressTestSyncServer<CommonStressTestInproc<TestServiceImpl, false>>,
+ CommonStressTestSyncServerLowThreadCount<
+ CommonStressTestInproc<TestServiceImpl, true>>,
CommonStressTestAsyncServer<
CommonStressTestInsecure<grpc::testing::EchoTestService::AsyncService>>,
- CommonStressTestAsyncServer<
- CommonStressTestInproc<grpc::testing::EchoTestService::AsyncService>>>
+ CommonStressTestAsyncServer<CommonStressTestInproc<
+ grpc::testing::EchoTestService::AsyncService, false>>>
CommonTypes;
TYPED_TEST_CASE(End2endTest, CommonTypes);
TYPED_TEST(End2endTest, ThreadStress) {
this->common_.ResetStub();
std::vector<std::thread> threads;
+ gpr_atm errors;
+ gpr_atm_rel_store(&errors, static_cast<gpr_atm>(0));
+ threads.reserve(kNumThreads);
for (int i = 0; i < kNumThreads; ++i) {
- threads.emplace_back(SendRpc, this->common_.GetStub(), kNumRpcs);
+ threads.emplace_back(SendRpc, this->common_.GetStub(), kNumRpcs,
+ this->common_.AllowExhaustion(), &errors);
}
for (int i = 0; i < kNumThreads; ++i) {
threads[i].join();
}
+ uint64_t error_cnt = static_cast<uint64_t>(gpr_atm_no_barrier_load(&errors));
+ if (error_cnt != 0) {
+ gpr_log(GPR_INFO, "RPC error count: %" PRIu64, error_cnt);
+ }
+ // If this test allows resource exhaustion, expect that it actually sees some
+ if (this->common_.AllowExhaustion()) {
+ EXPECT_GT(error_cnt, static_cast<uint64_t>(0));
+ }
}
template <class Common>
diff --git a/test/cpp/ext/filters/census/BUILD b/test/cpp/ext/filters/census/BUILD
new file mode 100644
index 0000000000..6567dc667a
--- /dev/null
+++ b/test/cpp/ext/filters/census/BUILD
@@ -0,0 +1,42 @@
+# 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.
+
+load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package")
+load("//bazel:cc_grpc_library.bzl", "cc_grpc_library")
+
+licenses(["notice"]) # Apache v2
+
+grpc_package(name = "test/core/ext/census")
+
+grpc_cc_test(
+ name = "grpc_opencensus_plugin_test",
+ srcs = [
+ "stats_plugin_end2end_test.cc",
+ ],
+ language = "C++",
+ external_deps = [
+ "gtest",
+ "gmock",
+ "opencensus-stats-test",
+ ],
+ deps = [
+ "//:grpc++",
+ "//:grpc_opencensus_plugin",
+ "//src/proto/grpc/testing:echo_proto",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_util",
+ "//test/cpp/util:test_config",
+ ],
+)
diff --git a/test/cpp/ext/filters/census/stats_plugin_end2end_test.cc b/test/cpp/ext/filters/census/stats_plugin_end2end_test.cc
new file mode 100644
index 0000000000..664504a090
--- /dev/null
+++ b/test/cpp/ext/filters/census/stats_plugin_end2end_test.cc
@@ -0,0 +1,376 @@
+/*
+ *
+ * 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 <string>
+#include <thread> // NOLINT
+#include <vector>
+
+#include "absl/strings/str_cat.h"
+#include "absl/strings/string_view.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include "include/grpc++/grpc++.h"
+#include "opencensus/stats/stats.h"
+#include "opencensus/stats/testing/test_utils.h"
+#include "src/cpp/ext/filters/census/grpc_plugin.h"
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc {
+namespace testing {
+namespace {
+
+using ::opencensus::stats::Aggregation;
+using ::opencensus::stats::Distribution;
+using ::opencensus::stats::View;
+using ::opencensus::stats::ViewDescriptor;
+using ::opencensus::stats::testing::TestUtils;
+
+class EchoServer final : public EchoTestService::Service {
+ ::grpc::Status Echo(::grpc::ServerContext* context,
+ const EchoRequest* request,
+ EchoResponse* response) override {
+ if (request->param().expected_error().code() == 0) {
+ response->set_message(request->message());
+ return ::grpc::Status::OK;
+ } else {
+ return ::grpc::Status(static_cast<::grpc::StatusCode>(
+ request->param().expected_error().code()),
+ "");
+ }
+ }
+};
+
+class StatsPluginEnd2EndTest : public ::testing::Test {
+ protected:
+ static void SetUpTestCase() { RegisterOpenCensusPlugin(); }
+
+ void SetUp() {
+ // Set up a synchronous server on a different thread to avoid the asynch
+ // interface.
+ ::grpc::ServerBuilder builder;
+ int port;
+ // Use IPv4 here because it's less flaky than IPv6 ("[::]:0") on Travis.
+ builder.AddListeningPort("0.0.0.0:0", ::grpc::InsecureServerCredentials(),
+ &port);
+ builder.RegisterService(&service_);
+ server_ = builder.BuildAndStart();
+ ASSERT_NE(nullptr, server_);
+ ASSERT_NE(0, port);
+ server_address_ = absl::StrCat("0.0.0.0:", port);
+ server_thread_ = std::thread(&StatsPluginEnd2EndTest::RunServerLoop, this);
+
+ stub_ = EchoTestService::NewStub(::grpc::CreateChannel(
+ server_address_, ::grpc::InsecureChannelCredentials()));
+ }
+
+ void TearDown() {
+ server_->Shutdown();
+ server_thread_.join();
+ }
+
+ void RunServerLoop() { server_->Wait(); }
+
+ const std::string client_method_name_ = "grpc.testing.EchoTestService/Echo";
+ const std::string server_method_name_ = "grpc.testing.EchoTestService/Echo";
+
+ std::string server_address_;
+ EchoServer service_;
+ std::unique_ptr<grpc::Server> server_;
+ std::thread server_thread_;
+
+ std::unique_ptr<EchoTestService::Stub> stub_;
+};
+
+TEST_F(StatsPluginEnd2EndTest, ErrorCount) {
+ const auto client_method_descriptor =
+ ViewDescriptor()
+ .set_measure(kRpcClientRoundtripLatencyMeasureName)
+ .set_name("client_method")
+ .set_aggregation(Aggregation::Count())
+ .add_column(ClientMethodTagKey());
+ View client_method_view(client_method_descriptor);
+ const auto server_method_descriptor =
+ ViewDescriptor()
+ .set_measure(kRpcServerServerLatencyMeasureName)
+ .set_name("server_method")
+ .set_aggregation(Aggregation::Count())
+ .add_column(ServerMethodTagKey());
+ View server_method_view(server_method_descriptor);
+
+ const auto client_status_descriptor =
+ ViewDescriptor()
+ .set_measure(kRpcClientRoundtripLatencyMeasureName)
+ .set_name("client_status")
+ .set_aggregation(Aggregation::Count())
+ .add_column(ClientStatusTagKey());
+ View client_status_view(client_status_descriptor);
+ const auto server_status_descriptor =
+ ViewDescriptor()
+ .set_measure(kRpcServerServerLatencyMeasureName)
+ .set_name("server_status")
+ .set_aggregation(Aggregation::Count())
+ .add_column(ServerStatusTagKey());
+ View server_status_view(server_status_descriptor);
+
+ // Cover all valid statuses.
+ for (int i = 0; i <= 16; ++i) {
+ EchoRequest request;
+ request.set_message("foo");
+ request.mutable_param()->mutable_expected_error()->set_code(i);
+ EchoResponse response;
+ ::grpc::ClientContext context;
+ ::grpc::Status status = stub_->Echo(&context, request, &response);
+ }
+ absl::SleepFor(absl::Milliseconds(500));
+ TestUtils::Flush();
+
+ EXPECT_THAT(client_method_view.GetData().int_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(client_method_name_), 17)));
+ EXPECT_THAT(server_method_view.GetData().int_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(server_method_name_), 17)));
+
+ auto codes = {
+ ::testing::Pair(::testing::ElementsAre("OK"), 1),
+ ::testing::Pair(::testing::ElementsAre("CANCELLED"), 1),
+ ::testing::Pair(::testing::ElementsAre("UNKNOWN"), 1),
+ ::testing::Pair(::testing::ElementsAre("INVALID_ARGUMENT"), 1),
+ ::testing::Pair(::testing::ElementsAre("DEADLINE_EXCEEDED"), 1),
+ ::testing::Pair(::testing::ElementsAre("NOT_FOUND"), 1),
+ ::testing::Pair(::testing::ElementsAre("ALREADY_EXISTS"), 1),
+ ::testing::Pair(::testing::ElementsAre("PERMISSION_DENIED"), 1),
+ ::testing::Pair(::testing::ElementsAre("UNAUTHENTICATED"), 1),
+ ::testing::Pair(::testing::ElementsAre("RESOURCE_EXHAUSTED"), 1),
+ ::testing::Pair(::testing::ElementsAre("FAILED_PRECONDITION"), 1),
+ ::testing::Pair(::testing::ElementsAre("ABORTED"), 1),
+ ::testing::Pair(::testing::ElementsAre("OUT_OF_RANGE"), 1),
+ ::testing::Pair(::testing::ElementsAre("UNIMPLEMENTED"), 1),
+ ::testing::Pair(::testing::ElementsAre("INTERNAL"), 1),
+ ::testing::Pair(::testing::ElementsAre("UNAVAILABLE"), 1),
+ ::testing::Pair(::testing::ElementsAre("DATA_LOSS"), 1),
+ };
+
+ EXPECT_THAT(client_status_view.GetData().int_data(),
+ ::testing::UnorderedElementsAreArray(codes));
+ EXPECT_THAT(server_status_view.GetData().int_data(),
+ ::testing::UnorderedElementsAreArray(codes));
+}
+
+TEST_F(StatsPluginEnd2EndTest, RequestReceivedBytesPerRpc) {
+ View client_sent_bytes_per_rpc_view(ClientSentBytesPerRpcCumulative());
+ View client_received_bytes_per_rpc_view(
+ ClientReceivedBytesPerRpcCumulative());
+ View server_sent_bytes_per_rpc_view(ServerSentBytesPerRpcCumulative());
+ View server_received_bytes_per_rpc_view(
+ ServerReceivedBytesPerRpcCumulative());
+
+ {
+ EchoRequest request;
+ request.set_message("foo");
+ EchoResponse response;
+ ::grpc::ClientContext context;
+ ::grpc::Status status = stub_->Echo(&context, request, &response);
+ ASSERT_TRUE(status.ok());
+ EXPECT_EQ("foo", response.message());
+ }
+ absl::SleepFor(absl::Milliseconds(500));
+ TestUtils::Flush();
+
+ EXPECT_THAT(client_received_bytes_per_rpc_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(client_method_name_),
+ ::testing::AllOf(::testing::Property(&Distribution::count, 1),
+ ::testing::Property(&Distribution::mean,
+ ::testing::Gt(0.0))))));
+ EXPECT_THAT(client_sent_bytes_per_rpc_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(client_method_name_),
+ ::testing::AllOf(::testing::Property(&Distribution::count, 1),
+ ::testing::Property(&Distribution::mean,
+ ::testing::Gt(0.0))))));
+ EXPECT_THAT(server_received_bytes_per_rpc_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(server_method_name_),
+ ::testing::AllOf(::testing::Property(&Distribution::count, 1),
+ ::testing::Property(&Distribution::mean,
+ ::testing::Gt(0.0))))));
+ EXPECT_THAT(server_sent_bytes_per_rpc_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(server_method_name_),
+ ::testing::AllOf(::testing::Property(&Distribution::count, 1),
+ ::testing::Property(&Distribution::mean,
+ ::testing::Gt(0.0))))));
+}
+
+TEST_F(StatsPluginEnd2EndTest, Latency) {
+ View client_latency_view(ClientRoundtripLatencyCumulative());
+ View client_server_latency_view(ClientServerLatencyCumulative());
+ View server_server_latency_view(ServerServerLatencyCumulative());
+
+ const absl::Time start_time = absl::Now();
+ {
+ EchoRequest request;
+ request.set_message("foo");
+ EchoResponse response;
+ ::grpc::ClientContext context;
+ ::grpc::Status status = stub_->Echo(&context, request, &response);
+ ASSERT_TRUE(status.ok());
+ EXPECT_EQ("foo", response.message());
+ }
+ // We do not know exact latency/elapsed time, but we know it is less than the
+ // entire time spent making the RPC.
+ const double max_time = absl::ToDoubleMilliseconds(absl::Now() - start_time);
+
+ absl::SleepFor(absl::Milliseconds(500));
+ TestUtils::Flush();
+
+ EXPECT_THAT(
+ client_latency_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(client_method_name_),
+ ::testing::AllOf(
+ ::testing::Property(&Distribution::count, 1),
+ ::testing::Property(&Distribution::mean, ::testing::Gt(0.0)),
+ ::testing::Property(&Distribution::mean,
+ ::testing::Lt(max_time))))));
+
+ // Elapsed time is a subinterval of total latency.
+ const auto client_latency = client_latency_view.GetData()
+ .distribution_data()
+ .find({client_method_name_})
+ ->second.mean();
+ EXPECT_THAT(
+ client_server_latency_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(client_method_name_),
+ ::testing::AllOf(
+ ::testing::Property(&Distribution::count, 1),
+ ::testing::Property(&Distribution::mean, ::testing::Gt(0.0)),
+ ::testing::Property(&Distribution::mean,
+ ::testing::Lt(client_latency))))));
+
+ // client server elapsed time should be the same value propagated to the
+ // client.
+ const auto client_elapsed_time = client_server_latency_view.GetData()
+ .distribution_data()
+ .find({client_method_name_})
+ ->second.mean();
+ EXPECT_THAT(
+ server_server_latency_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(server_method_name_),
+ ::testing::AllOf(
+ ::testing::Property(&Distribution::count, 1),
+ ::testing::Property(&Distribution::mean,
+ ::testing::DoubleEq(client_elapsed_time))))));
+}
+
+TEST_F(StatsPluginEnd2EndTest, CompletedRpcs) {
+ View client_completed_rpcs_view(ClientCompletedRpcsCumulative());
+ View server_completed_rpcs_view(ServerCompletedRpcsCumulative());
+
+ EchoRequest request;
+ request.set_message("foo");
+ EchoResponse response;
+ const int count = 5;
+ for (int i = 0; i < count; ++i) {
+ {
+ ::grpc::ClientContext context;
+ ::grpc::Status status = stub_->Echo(&context, request, &response);
+ ASSERT_TRUE(status.ok());
+ EXPECT_EQ("foo", response.message());
+ }
+ absl::SleepFor(absl::Milliseconds(500));
+ TestUtils::Flush();
+
+ EXPECT_THAT(client_completed_rpcs_view.GetData().int_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(client_method_name_, "OK"), i + 1)));
+ EXPECT_THAT(server_completed_rpcs_view.GetData().int_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(server_method_name_, "OK"), i + 1)));
+ }
+}
+
+TEST_F(StatsPluginEnd2EndTest, RequestReceivedMessagesPerRpc) {
+ // TODO: Use streaming RPCs.
+ View client_received_messages_per_rpc_view(
+ ClientSentMessagesPerRpcCumulative());
+ View client_sent_messages_per_rpc_view(
+ ClientReceivedMessagesPerRpcCumulative());
+ View server_received_messages_per_rpc_view(
+ ServerSentMessagesPerRpcCumulative());
+ View server_sent_messages_per_rpc_view(
+ ServerReceivedMessagesPerRpcCumulative());
+
+ EchoRequest request;
+ request.set_message("foo");
+ EchoResponse response;
+ const int count = 5;
+ for (int i = 0; i < count; ++i) {
+ {
+ ::grpc::ClientContext context;
+ ::grpc::Status status = stub_->Echo(&context, request, &response);
+ ASSERT_TRUE(status.ok());
+ EXPECT_EQ("foo", response.message());
+ }
+ absl::SleepFor(absl::Milliseconds(500));
+ TestUtils::Flush();
+
+ EXPECT_THAT(
+ client_received_messages_per_rpc_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(client_method_name_),
+ ::testing::AllOf(::testing::Property(&Distribution::count, i + 1),
+ ::testing::Property(&Distribution::mean,
+ ::testing::DoubleEq(1.0))))));
+ EXPECT_THAT(
+ client_sent_messages_per_rpc_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(client_method_name_),
+ ::testing::AllOf(::testing::Property(&Distribution::count, i + 1),
+ ::testing::Property(&Distribution::mean,
+ ::testing::DoubleEq(1.0))))));
+ EXPECT_THAT(
+ server_received_messages_per_rpc_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(server_method_name_),
+ ::testing::AllOf(::testing::Property(&Distribution::count, i + 1),
+ ::testing::Property(&Distribution::mean,
+ ::testing::DoubleEq(1.0))))));
+ EXPECT_THAT(
+ server_sent_messages_per_rpc_view.GetData().distribution_data(),
+ ::testing::UnorderedElementsAre(::testing::Pair(
+ ::testing::ElementsAre(server_method_name_),
+ ::testing::AllOf(::testing::Property(&Distribution::count, i + 1),
+ ::testing::Property(&Distribution::mean,
+ ::testing::DoubleEq(1.0))))));
+ }
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index 3eb155ef95..a4b1a85f85 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -46,6 +46,7 @@ DEFINE_string(
"all : all test cases;\n"
"cancel_after_begin : cancel stream after starting it;\n"
"cancel_after_first_response: cancel on first response;\n"
+ "channel_soak: sends 'soak_iterations' rpcs, rebuilds channel each time;\n"
"client_compressed_streaming : compressed request streaming with "
"client_compressed_unary : single compressed request;\n"
"client_streaming : request streaming with single response;\n"
@@ -56,10 +57,12 @@ DEFINE_string(
"half_duplex : half-duplex streaming;\n"
"jwt_token_creds: large_unary with JWT token auth;\n"
"large_unary : single request and (large) response;\n"
+ "long_lived_channel: sends large_unary rpcs over a long-lived channel;\n"
"oauth2_auth_token: raw oauth2 access token auth;\n"
"per_rpc_creds: raw oauth2 access token on a single rpc;\n"
"ping_pong : full-duplex streaming;\n"
"response streaming;\n"
+ "rpc_soak: 'sends soak_iterations' large_unary rpcs;\n"
"server_compressed_streaming : single request with compressed "
"server_compressed_unary : single compressed response;\n"
"server_streaming : single request with response streaming;\n"
@@ -82,6 +85,12 @@ DEFINE_bool(do_not_abort_on_transient_failures, false,
"whether abort() is called or not. It does not control whether the "
"test is retried in case of transient failures (and currently the "
"interop tests are not retried even if this flag is set to true)");
+DEFINE_int32(soak_iterations, 1000,
+ "number of iterations to use for the two soak tests; rpc_soak and "
+ "channel_soak");
+DEFINE_int32(iteration_interval, 10,
+ "The interval in seconds between rpcs. This is used by "
+ "long_connection test");
using grpc::testing::CreateChannelForTestCase;
using grpc::testing::GetServiceAccountJsonKey;
@@ -91,8 +100,9 @@ int main(int argc, char** argv) {
grpc::testing::InitTest(&argc, &argv, true);
gpr_log(GPR_INFO, "Testing these cases: %s", FLAGS_test_case.c_str());
int ret = 0;
- grpc::testing::InteropClient client(CreateChannelForTestCase(FLAGS_test_case),
- true,
+ grpc::testing::ChannelCreationFunc channel_creation_func =
+ std::bind(&CreateChannelForTestCase, FLAGS_test_case);
+ grpc::testing::InteropClient client(channel_creation_func, true,
FLAGS_do_not_abort_on_transient_failures);
std::unordered_map<grpc::string, std::function<bool()>> actions;
@@ -151,6 +161,14 @@ int main(int argc, char** argv) {
std::bind(&grpc::testing::InteropClient::DoUnimplementedService, &client);
actions["cacheable_unary"] =
std::bind(&grpc::testing::InteropClient::DoCacheableUnary, &client);
+ actions["channel_soak"] =
+ std::bind(&grpc::testing::InteropClient::DoChannelSoakTest, &client,
+ FLAGS_soak_iterations);
+ actions["rpc_soak"] = std::bind(&grpc::testing::InteropClient::DoRpcSoakTest,
+ &client, FLAGS_soak_iterations);
+ actions["long_lived_channel"] =
+ std::bind(&grpc::testing::InteropClient::DoLongLivedChannelTest, &client,
+ FLAGS_soak_iterations, FLAGS_iteration_interval);
UpdateActions(&actions);
diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc
index 29b5a1ed6c..fb7b7bb7d0 100644
--- a/test/cpp/interop/client_helper.cc
+++ b/test/cpp/interop/client_helper.cc
@@ -88,20 +88,20 @@ std::shared_ptr<Channel> CreateChannelForTestCase(
std::shared_ptr<CallCredentials> creds;
if (test_case == "compute_engine_creds") {
- GPR_ASSERT(FLAGS_use_tls);
- creds = GoogleComputeEngineCredentials();
- GPR_ASSERT(creds);
+ creds = FLAGS_custom_credentials_type == "google_default_credentials"
+ ? nullptr
+ : GoogleComputeEngineCredentials();
} else if (test_case == "jwt_token_creds") {
- GPR_ASSERT(FLAGS_use_tls);
grpc::string json_key = GetServiceAccountJsonKey();
std::chrono::seconds token_lifetime = std::chrono::hours(1);
- creds =
- ServiceAccountJWTAccessCredentials(json_key, token_lifetime.count());
- GPR_ASSERT(creds);
+ creds = FLAGS_custom_credentials_type == "google_default_credentials"
+ ? nullptr
+ : ServiceAccountJWTAccessCredentials(json_key,
+ token_lifetime.count());
} else if (test_case == "oauth2_auth_token") {
- grpc::string raw_token = GetOauth2AccessToken();
- creds = AccessTokenCredentials(raw_token);
- GPR_ASSERT(creds);
+ creds = FLAGS_custom_credentials_type == "google_default_credentials"
+ ? nullptr
+ : AccessTokenCredentials(GetOauth2AccessToken());
}
if (FLAGS_custom_credentials_type.empty()) {
transport_security security_type =
diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc
index 543f159265..bc7f0f5edb 100644
--- a/test/cpp/interop/http2_client.cc
+++ b/test/cpp/interop/http2_client.cc
@@ -42,16 +42,16 @@ const int kLargeRequestSize = 271828;
const int kLargeResponseSize = 314159;
} // namespace
-Http2Client::ServiceStub::ServiceStub(std::shared_ptr<Channel> channel)
- : channel_(channel) {
+Http2Client::ServiceStub::ServiceStub(const std::shared_ptr<Channel>& channel)
+ : channel_(std::move(channel)) {
stub_ = TestService::NewStub(channel);
}
TestService::Stub* Http2Client::ServiceStub::Get() { return stub_.get(); }
-Http2Client::Http2Client(std::shared_ptr<Channel> channel)
+Http2Client::Http2Client(const std::shared_ptr<Channel>& channel)
: serviceStub_(channel),
- channel_(channel),
+ channel_(std::move(channel)),
defaultRequest_(BuildDefaultRequest()) {}
bool Http2Client::AssertStatusCode(const Status& s, StatusCode expected_code) {
@@ -140,7 +140,8 @@ bool Http2Client::DoPing() {
return true;
}
-void Http2Client::MaxStreamsWorker(std::shared_ptr<grpc::Channel> channel) {
+void Http2Client::MaxStreamsWorker(
+ const std::shared_ptr<grpc::Channel>& channel) {
SimpleResponse response;
AssertStatusCode(SendUnaryCall(&response), grpc::StatusCode::OK);
GPR_ASSERT(response.payload().body() ==
diff --git a/test/cpp/interop/http2_client.h b/test/cpp/interop/http2_client.h
index 2bcfdd69db..269d3b32e2 100644
--- a/test/cpp/interop/http2_client.h
+++ b/test/cpp/interop/http2_client.h
@@ -31,7 +31,7 @@ namespace testing {
class Http2Client {
public:
- explicit Http2Client(std::shared_ptr<Channel> channel);
+ explicit Http2Client(const std::shared_ptr<Channel>& channel);
~Http2Client() {}
bool DoRstAfterHeader();
@@ -44,7 +44,7 @@ class Http2Client {
private:
class ServiceStub {
public:
- ServiceStub(std::shared_ptr<Channel> channel);
+ ServiceStub(const std::shared_ptr<Channel>& channel);
TestService::Stub* Get();
@@ -53,7 +53,7 @@ class Http2Client {
std::shared_ptr<Channel> channel_;
};
- void MaxStreamsWorker(std::shared_ptr<grpc::Channel> channel);
+ void MaxStreamsWorker(const std::shared_ptr<grpc::Channel>& channel);
bool AssertStatusCode(const Status& s, StatusCode expected_code);
Status SendUnaryCall(SimpleResponse* response);
SimpleRequest BuildDefaultRequest();
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index 68bf1e6dc7..a99cf8122f 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -19,6 +19,7 @@
#include <cinttypes>
#include <fstream>
#include <memory>
+#include <utility>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
@@ -73,13 +74,15 @@ void UnaryCompressionChecks(const InteropClientContextInspector& inspector,
}
} // namespace
-InteropClient::ServiceStub::ServiceStub(std::shared_ptr<Channel> channel,
- bool new_stub_every_call)
- : channel_(channel), new_stub_every_call_(new_stub_every_call) {
+InteropClient::ServiceStub::ServiceStub(
+ ChannelCreationFunc channel_creation_func, bool new_stub_every_call)
+ : channel_creation_func_(channel_creation_func),
+ channel_(channel_creation_func_()),
+ new_stub_every_call_(new_stub_every_call) {
// If new_stub_every_call is false, then this is our chance to initialize
// stub_. (see Get())
if (!new_stub_every_call) {
- stub_ = TestService::NewStub(channel);
+ stub_ = TestService::NewStub(channel_);
}
}
@@ -99,26 +102,17 @@ InteropClient::ServiceStub::GetUnimplementedServiceStub() {
return unimplemented_service_stub_.get();
}
-void InteropClient::ServiceStub::Reset(std::shared_ptr<Channel> channel) {
- channel_ = channel;
-
- // Update stub_ as well. Note: If new_stub_every_call_ is true, we can reset
- // the stub_ since the next call to Get() will create a new stub
- if (new_stub_every_call_) {
- stub_.reset();
- } else {
- stub_ = TestService::NewStub(channel);
+void InteropClient::ServiceStub::ResetChannel() {
+ channel_ = channel_creation_func_();
+ if (!new_stub_every_call_) {
+ stub_ = TestService::NewStub(channel_);
}
}
-void InteropClient::Reset(std::shared_ptr<Channel> channel) {
- serviceStub_.Reset(channel);
-}
-
-InteropClient::InteropClient(std::shared_ptr<Channel> channel,
+InteropClient::InteropClient(ChannelCreationFunc channel_creation_func,
bool new_stub_every_test_case,
bool do_not_abort_on_transient_failures)
- : serviceStub_(channel, new_stub_every_test_case),
+ : serviceStub_(channel_creation_func, new_stub_every_test_case),
do_not_abort_on_transient_failures_(do_not_abort_on_transient_failures) {}
bool InteropClient::AssertStatusOk(const Status& s,
@@ -180,7 +174,7 @@ bool InteropClient::PerformLargeUnary(SimpleRequest* request,
bool InteropClient::PerformLargeUnary(SimpleRequest* request,
SimpleResponse* response,
- CheckerFn custom_checks_fn) {
+ const CheckerFn& custom_checks_fn) {
ClientContext context;
InteropClientContextInspector inspector(context);
request->set_response_size(kLargeResponseSize);
@@ -1026,6 +1020,66 @@ bool InteropClient::DoCustomMetadata() {
return true;
}
+bool InteropClient::DoRpcSoakTest(int32_t soak_iterations) {
+ gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations);
+ GPR_ASSERT(soak_iterations > 0);
+ SimpleRequest request;
+ SimpleResponse response;
+ for (int i = 0; i < soak_iterations; ++i) {
+ if (!PerformLargeUnary(&request, &response)) {
+ gpr_log(GPR_ERROR, "rpc_soak test failed on iteration %d", i);
+ return false;
+ }
+ }
+ gpr_log(GPR_DEBUG, "rpc_soak test done.");
+ return true;
+}
+
+bool InteropClient::DoChannelSoakTest(int32_t soak_iterations) {
+ gpr_log(GPR_DEBUG, "Sending %d RPCs, tearing down the channel each time...",
+ soak_iterations);
+ GPR_ASSERT(soak_iterations > 0);
+ SimpleRequest request;
+ SimpleResponse response;
+ for (int i = 0; i < soak_iterations; ++i) {
+ serviceStub_.ResetChannel();
+ if (!PerformLargeUnary(&request, &response)) {
+ gpr_log(GPR_ERROR, "channel_soak test failed on iteration %d", i);
+ return false;
+ }
+ }
+ gpr_log(GPR_DEBUG, "channel_soak test done.");
+ return true;
+}
+
+bool InteropClient::DoLongLivedChannelTest(int32_t soak_iterations,
+ int32_t iteration_interval) {
+ gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations);
+ GPR_ASSERT(soak_iterations > 0);
+ GPR_ASSERT(iteration_interval > 0);
+ SimpleRequest request;
+ SimpleResponse response;
+ int num_failures = 0;
+ for (int i = 0; i < soak_iterations; ++i) {
+ gpr_log(GPR_DEBUG, "Sending RPC number %d...", i);
+ if (!PerformLargeUnary(&request, &response)) {
+ gpr_log(GPR_ERROR, "Iteration %d failed.", i);
+ num_failures++;
+ }
+ gpr_sleep_until(
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(iteration_interval, GPR_TIMESPAN)));
+ }
+ if (num_failures == 0) {
+ gpr_log(GPR_DEBUG, "long_lived_channel test done.");
+ return true;
+ } else {
+ gpr_log(GPR_DEBUG, "long_lived_channel test failed with %d rpc failures.",
+ num_failures);
+ return false;
+ }
+}
+
bool InteropClient::DoUnimplementedService() {
gpr_log(GPR_DEBUG, "Sending a request for an unimplemented service...");
diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h
index 79ff24fc47..0ceff55c5c 100644
--- a/test/cpp/interop/interop_client.h
+++ b/test/cpp/interop/interop_client.h
@@ -34,18 +34,20 @@ typedef std::function<void(const InteropClientContextInspector&,
const SimpleRequest*, const SimpleResponse*)>
CheckerFn;
+typedef std::function<std::shared_ptr<Channel>(void)> ChannelCreationFunc;
+
class InteropClient {
public:
/// If new_stub_every_test_case is true, a new TestService::Stub object is
/// created for every test case
/// If do_not_abort_on_transient_failures is true, abort() is not called in
/// case of transient failures (like connection failures)
- explicit InteropClient(std::shared_ptr<Channel> channel,
+ explicit InteropClient(ChannelCreationFunc channel_creation_func,
bool new_stub_every_test_case,
bool do_not_abort_on_transient_failures);
~InteropClient() {}
- void Reset(std::shared_ptr<Channel> channel);
+ void Reset(const std::shared_ptr<Channel>& channel);
bool DoEmpty();
bool DoLargeUnary();
@@ -67,6 +69,16 @@ class InteropClient {
bool DoUnimplementedMethod();
bool DoUnimplementedService();
bool DoCacheableUnary();
+
+ // The following interop test are not yet part of the interop spec, and are
+ // not implemented cross-language. They are considered experimental for now,
+ // but at some point in the future, might be codified and implemented in all
+ // languages
+ bool DoChannelSoakTest(int32_t soak_iterations);
+ bool DoRpcSoakTest(int32_t soak_iterations);
+ bool DoLongLivedChannelTest(int32_t soak_iterations,
+ int32_t iteration_interval);
+
// Auth tests.
// username is a string containing the user email
bool DoJwtTokenCreds(const grpc::string& username);
@@ -83,14 +95,17 @@ class InteropClient {
public:
// If new_stub_every_call = true, pointer to a new instance of
// TestServce::Stub is returned by Get() everytime it is called
- ServiceStub(std::shared_ptr<Channel> channel, bool new_stub_every_call);
+ ServiceStub(ChannelCreationFunc channel_creation_func,
+ bool new_stub_every_call);
TestService::Stub* Get();
UnimplementedService::Stub* GetUnimplementedServiceStub();
- void Reset(std::shared_ptr<Channel> channel);
+ // forces channel to be recreated.
+ void ResetChannel();
private:
+ ChannelCreationFunc channel_creation_func_;
std::unique_ptr<TestService::Stub> stub_;
std::unique_ptr<UnimplementedService::Stub> unimplemented_service_stub_;
std::shared_ptr<Channel> channel_;
@@ -102,14 +117,14 @@ class InteropClient {
/// Run \a custom_check_fn as an additional check.
bool PerformLargeUnary(SimpleRequest* request, SimpleResponse* response,
- CheckerFn custom_checks_fn);
+ const CheckerFn& custom_checks_fn);
bool AssertStatusOk(const Status& s,
const grpc::string& optional_debug_string);
bool AssertStatusCode(const Status& s, StatusCode expected_code,
const grpc::string& optional_debug_string);
bool TransientFailureOrAbort();
- ServiceStub serviceStub_;
+ ServiceStub serviceStub_;
/// If true, abort() is not called for transient failures
bool do_not_abort_on_transient_failures_;
};
diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc
index f55d624b21..6570bbf969 100644
--- a/test/cpp/interop/interop_server.cc
+++ b/test/cpp/interop/interop_server.cc
@@ -317,25 +317,25 @@ class TestServiceImpl : public TestService::Service {
};
void grpc::testing::interop::RunServer(
- std::shared_ptr<ServerCredentials> creds) {
+ const std::shared_ptr<ServerCredentials>& creds) {
RunServer(creds, FLAGS_port, nullptr, nullptr);
}
void grpc::testing::interop::RunServer(
- std::shared_ptr<ServerCredentials> creds,
+ const std::shared_ptr<ServerCredentials>& creds,
std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>>
server_options) {
RunServer(creds, FLAGS_port, nullptr, std::move(server_options));
}
void grpc::testing::interop::RunServer(
- std::shared_ptr<ServerCredentials> creds, const int port,
+ const std::shared_ptr<ServerCredentials>& creds, const int port,
ServerStartedCondition* server_started_condition) {
RunServer(creds, port, server_started_condition, nullptr);
}
void grpc::testing::interop::RunServer(
- std::shared_ptr<ServerCredentials> creds, const int port,
+ const std::shared_ptr<ServerCredentials>& creds, const int port,
ServerStartedCondition* server_started_condition,
std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>>
server_options) {
diff --git a/test/cpp/interop/server_helper.h b/test/cpp/interop/server_helper.h
index 265874df70..1bfbf8e474 100644
--- a/test/cpp/interop/server_helper.h
+++ b/test/cpp/interop/server_helper.h
@@ -63,7 +63,7 @@ struct ServerStartedCondition {
/// Run gRPC interop server using port FLAGS_port.
///
/// \param creds The credentials associated with the server.
-void RunServer(std::shared_ptr<ServerCredentials> creds);
+void RunServer(const std::shared_ptr<ServerCredentials>& creds);
/// Run gRPC interop server.
///
@@ -71,7 +71,7 @@ void RunServer(std::shared_ptr<ServerCredentials> creds);
/// \param port Port to use for the server.
/// \param server_started_condition (optional) Struct holding mutex, condition
/// variable, and condition used to notify when the server has started.
-void RunServer(std::shared_ptr<ServerCredentials> creds, int port,
+void RunServer(const std::shared_ptr<ServerCredentials>& creds, int port,
ServerStartedCondition* server_started_condition);
/// Run gRPC interop server.
@@ -79,7 +79,7 @@ void RunServer(std::shared_ptr<ServerCredentials> creds, int port,
/// \param creds The credentials associated with the server.
/// \param server_options List of options to set when building the server.
void RunServer(
- std::shared_ptr<ServerCredentials> creds,
+ const std::shared_ptr<ServerCredentials>& creds,
std::unique_ptr<std::vector<std::unique_ptr<ServerBuilderOption>>>
server_options);
@@ -91,7 +91,7 @@ void RunServer(
/// \param server_started_condition (optional) Struct holding mutex, condition
// variable, and condition used to notify when the server has started.
void RunServer(
- std::shared_ptr<ServerCredentials> creds, const int port,
+ const std::shared_ptr<ServerCredentials>& creds, const int port,
ServerStartedCondition* server_started_condition,
std::unique_ptr<std::vector<std::unique_ptr<grpc::ServerBuilderOption>>>
server_options);
diff --git a/test/cpp/interop/stress_interop_client.cc b/test/cpp/interop/stress_interop_client.cc
index 30a8351cfe..7dc1956f78 100644
--- a/test/cpp/interop/stress_interop_client.cc
+++ b/test/cpp/interop/stress_interop_client.cc
@@ -68,19 +68,20 @@ TestCaseType WeightedRandomTestSelector::GetNextTest() const {
StressTestInteropClient::StressTestInteropClient(
int test_id, const grpc::string& server_address,
- std::shared_ptr<Channel> channel,
+ ChannelCreationFunc channel_creation_func,
const WeightedRandomTestSelector& test_selector, long test_duration_secs,
long sleep_duration_ms, bool do_not_abort_on_transient_failures)
: test_id_(test_id),
server_address_(server_address),
- channel_(channel),
- interop_client_(new InteropClient(channel, false,
+ channel_creation_func_(channel_creation_func),
+ interop_client_(new InteropClient(channel_creation_func_, false,
do_not_abort_on_transient_failures)),
test_selector_(test_selector),
test_duration_secs_(test_duration_secs),
sleep_duration_ms_(sleep_duration_ms) {}
-void StressTestInteropClient::MainLoop(std::shared_ptr<QpsGauge> qps_gauge) {
+void StressTestInteropClient::MainLoop(
+ const std::shared_ptr<QpsGauge>& qps_gauge) {
gpr_log(GPR_INFO, "Running test %d. ServerAddr: %s", test_id_,
server_address_.c_str());
diff --git a/test/cpp/interop/stress_interop_client.h b/test/cpp/interop/stress_interop_client.h
index a306dc3565..58680d8093 100644
--- a/test/cpp/interop/stress_interop_client.h
+++ b/test/cpp/interop/stress_interop_client.h
@@ -91,21 +91,21 @@ class WeightedRandomTestSelector {
class StressTestInteropClient {
public:
StressTestInteropClient(int test_id, const grpc::string& server_address,
- std::shared_ptr<Channel> channel,
+ ChannelCreationFunc channel_creation_func,
const WeightedRandomTestSelector& test_selector,
long test_duration_secs, long sleep_duration_ms,
bool do_not_abort_on_transient_failures);
// The main function. Use this as the thread entry point.
// qps_gauge is the QpsGauge to record the requests per second metric
- void MainLoop(std::shared_ptr<QpsGauge> qps_gauge);
+ void MainLoop(const std::shared_ptr<QpsGauge>& qps_gauge);
private:
bool RunTest(TestCaseType test_case);
int test_id_;
const grpc::string& server_address_;
- std::shared_ptr<Channel> channel_;
+ ChannelCreationFunc channel_creation_func_;
std::unique_ptr<InteropClient> interop_client_;
const WeightedRandomTestSelector& test_selector_;
long test_duration_secs_;
diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc
index 023e0c8f0b..ebbd14beba 100644
--- a/test/cpp/interop/stress_test.cc
+++ b/test/cpp/interop/stress_test.cc
@@ -283,15 +283,20 @@ int main(int argc, char** argv) {
channel_idx++) {
gpr_log(GPR_INFO, "Starting test with %s channel_idx=%d..", it->c_str(),
channel_idx);
- std::shared_ptr<grpc::Channel> channel = grpc::CreateTestChannel(
+ grpc::testing::ChannelCreationFunc channel_creation_func = std::bind(
+ static_cast<std::shared_ptr<grpc::Channel> (*)(
+ const grpc::string&, const grpc::string&,
+ grpc::testing::transport_security, bool)>(
+ grpc::CreateTestChannel),
*it, FLAGS_server_host_override, security_type, !FLAGS_use_test_ca);
// Create stub(s) for each channel
for (int stub_idx = 0; stub_idx < FLAGS_num_stubs_per_channel;
stub_idx++) {
clients.emplace_back(new StressTestInteropClient(
- ++thread_idx, *it, channel, test_selector, FLAGS_test_duration_secs,
- FLAGS_sleep_duration_ms, FLAGS_do_not_abort_on_transient_failures));
+ ++thread_idx, *it, channel_creation_func, test_selector,
+ FLAGS_test_duration_secs, FLAGS_sleep_duration_ms,
+ FLAGS_do_not_abort_on_transient_failures));
bool is_already_created = false;
// QpsGauge name
diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD
index 5dcfd94ed3..0c3b9ef816 100644
--- a/test/cpp/microbenchmarks/BUILD
+++ b/test/cpp/microbenchmarks/BUILD
@@ -24,6 +24,7 @@ grpc_cc_test(
external_deps = [
"benchmark",
],
+ deps = ["//test/core/util:gpr_test_util",]
)
grpc_cc_library(
@@ -54,6 +55,20 @@ grpc_cc_binary(
)
grpc_cc_binary(
+ name = "bm_arena",
+ testonly = 1,
+ srcs = ["bm_arena.cc"],
+ deps = [":helpers"],
+)
+
+grpc_cc_binary(
+ name = "bm_channel",
+ testonly = 1,
+ srcs = ["bm_channel.cc"],
+ deps = [":helpers"],
+)
+
+grpc_cc_binary(
name = "bm_cq",
testonly = 1,
srcs = ["bm_cq.cc"],
@@ -148,3 +163,15 @@ grpc_cc_binary(
srcs = ["bm_chttp2_hpack.cc"],
deps = [":helpers"],
)
+
+grpc_cc_binary(
+ name = "bm_opencensus_plugin",
+ testonly = 1,
+ srcs = ["bm_opencensus_plugin.cc"],
+ language = "C++",
+ deps = [
+ ":helpers",
+ "//:grpc_opencensus_plugin",
+ "//src/proto/grpc/testing:echo_proto",
+ ],
+)
diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc
index 831b29c506..9516b2e3e2 100644
--- a/test/cpp/microbenchmarks/bm_call_create.cc
+++ b/test/cpp/microbenchmarks/bm_call_create.cc
@@ -604,10 +604,13 @@ BENCHMARK_TEMPLATE(BM_IsolatedFilter, HttpServerFilter, SendEmptyMetadata);
typedef Fixture<&grpc_message_size_filter, CHECKS_NOT_LAST> MessageSizeFilter;
BENCHMARK_TEMPLATE(BM_IsolatedFilter, MessageSizeFilter, NoOp);
BENCHMARK_TEMPLATE(BM_IsolatedFilter, MessageSizeFilter, SendEmptyMetadata);
-typedef Fixture<&grpc_server_load_reporting_filter, CHECKS_NOT_LAST>
- LoadReportingFilter;
-BENCHMARK_TEMPLATE(BM_IsolatedFilter, LoadReportingFilter, NoOp);
-BENCHMARK_TEMPLATE(BM_IsolatedFilter, LoadReportingFilter, SendEmptyMetadata);
+// This cmake target is disabled for now because it depends on OpenCensus, which
+// is Bazel-only.
+// typedef Fixture<&grpc_server_load_reporting_filter, CHECKS_NOT_LAST>
+// LoadReportingFilter;
+// BENCHMARK_TEMPLATE(BM_IsolatedFilter, LoadReportingFilter, NoOp);
+// BENCHMARK_TEMPLATE(BM_IsolatedFilter, LoadReportingFilter,
+// SendEmptyMetadata);
////////////////////////////////////////////////////////////////////////////////
// Benchmarks isolating grpc_call
@@ -621,18 +624,26 @@ typedef struct {
static void StartTransportStreamOp(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
call_data* calld = static_cast<call_data*>(elem->call_data);
+ // Construct list of closures to return.
+ grpc_core::CallCombinerClosureList closures;
if (op->recv_initial_metadata) {
- GRPC_CALL_COMBINER_START(
- calld->call_combiner,
- op->payload->recv_initial_metadata.recv_initial_metadata_ready,
- GRPC_ERROR_NONE, "recv_initial_metadata");
+ closures.Add(op->payload->recv_initial_metadata.recv_initial_metadata_ready,
+ GRPC_ERROR_NONE, "recv_initial_metadata");
}
if (op->recv_message) {
- GRPC_CALL_COMBINER_START(calld->call_combiner,
- op->payload->recv_message.recv_message_ready,
- GRPC_ERROR_NONE, "recv_message");
+ closures.Add(op->payload->recv_message.recv_message_ready, GRPC_ERROR_NONE,
+ "recv_message");
}
- GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_NONE);
+ if (op->recv_trailing_metadata) {
+ closures.Add(
+ op->payload->recv_trailing_metadata.recv_trailing_metadata_ready,
+ GRPC_ERROR_NONE, "recv_trailing_metadata");
+ }
+ if (op->on_complete != nullptr) {
+ closures.Add(op->on_complete, GRPC_ERROR_NONE, "on_complete");
+ }
+ // Execute closures.
+ closures.RunClosures(calld->call_combiner);
}
static void StartTransportOp(grpc_channel_element* elem,
diff --git a/test/cpp/microbenchmarks/bm_channel.cc b/test/cpp/microbenchmarks/bm_channel.cc
new file mode 100644
index 0000000000..15ac997540
--- /dev/null
+++ b/test/cpp/microbenchmarks/bm_channel.cc
@@ -0,0 +1,90 @@
+/*
+ *
+ * Copyright 2017 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.
+ *
+ */
+
+/* Benchmark channel */
+
+#include <benchmark/benchmark.h>
+#include <grpc/grpc.h>
+#include "test/cpp/microbenchmarks/helpers.h"
+#include "test/cpp/util/test_config.h"
+
+auto& force_library_initialization = Library::get();
+
+class ChannelDestroyerFixture {
+ public:
+ ChannelDestroyerFixture() {}
+ virtual ~ChannelDestroyerFixture() {
+ if (channel_) {
+ grpc_channel_destroy(channel_);
+ }
+ }
+ virtual void Init() = 0;
+
+ protected:
+ grpc_channel* channel_ = nullptr;
+};
+
+class InsecureChannelFixture : public ChannelDestroyerFixture {
+ public:
+ InsecureChannelFixture() {}
+ void Init() override {
+ channel_ = grpc_insecure_channel_create("localhost:1234", nullptr, nullptr);
+ }
+};
+
+class LameChannelFixture : public ChannelDestroyerFixture {
+ public:
+ LameChannelFixture() {}
+ void Init() override {
+ channel_ = grpc_lame_client_channel_create(
+ "localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah");
+ }
+};
+
+template <class Fixture>
+static void BM_InsecureChannelCreateDestroy(benchmark::State& state) {
+ // In order to test if channel creation time is affected by the number of
+ // already existing channels, we create some initial channels here.
+ Fixture initial_channels[512];
+ for (int i = 0; i < state.range(0); i++) {
+ initial_channels[i].Init();
+ }
+ while (state.KeepRunning()) {
+ Fixture channel;
+ channel.Init();
+ }
+}
+BENCHMARK_TEMPLATE(BM_InsecureChannelCreateDestroy, InsecureChannelFixture)
+ ->Range(0, 512);
+;
+BENCHMARK_TEMPLATE(BM_InsecureChannelCreateDestroy, LameChannelFixture)
+ ->Range(0, 512);
+;
+
+// Some distros have RunSpecifiedBenchmarks under the benchmark namespace,
+// and others do not. This allows us to support both modes.
+namespace benchmark {
+void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); }
+} // namespace benchmark
+
+int main(int argc, char** argv) {
+ ::benchmark::Initialize(&argc, argv);
+ ::grpc::testing::InitTest(&argc, &argv, false);
+ benchmark::RunTheBenchmarksNamespaced();
+ return 0;
+}
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index 823c76f755..ba4b57ad22 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -27,6 +27,7 @@
#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
+#include "src/core/ext/transport/chttp2/transport/incoming_metadata.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/transport/static_metadata.h"
@@ -208,6 +209,7 @@ class SingleInternedBinaryElem {
private:
static grpc_slice MakeBytes() {
std::vector<char> v;
+ v.reserve(kLength);
for (int i = 0; i < kLength; i++) {
v.push_back(static_cast<char>(rand()));
}
@@ -246,6 +248,7 @@ class SingleNonInternedBinaryElem {
private:
static grpc_slice MakeBytes() {
std::vector<char> v;
+ v.reserve(kLength);
for (int i = 0; i < kLength; i++) {
v.push_back(static_cast<char>(rand()));
}
@@ -454,8 +457,9 @@ static void BM_HpackParserParseHeader(benchmark::State& state) {
std::vector<grpc_slice> benchmark_slices = Fixture::GetBenchmarkSlices();
grpc_chttp2_hpack_parser p;
grpc_chttp2_hpack_parser_init(&p);
+ const int kArenaSize = 4096 * 4096;
+ p.on_header_user_data = gpr_arena_create(kArenaSize);
p.on_header = OnHeader;
- p.on_header_user_data = nullptr;
for (auto slice : init_slices) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
}
@@ -464,7 +468,14 @@ static void BM_HpackParserParseHeader(benchmark::State& state) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
}
grpc_core::ExecCtx::Get()->Flush();
+ // Recreate arena every 4k iterations to avoid oom
+ if (0 == (state.iterations() & 0xfff)) {
+ gpr_arena_destroy((gpr_arena*)p.on_header_user_data);
+ p.on_header_user_data = gpr_arena_create(kArenaSize);
+ }
}
+ // Clean up
+ gpr_arena_destroy((gpr_arena*)p.on_header_user_data);
for (auto slice : init_slices) grpc_slice_unref(slice);
for (auto slice : benchmark_slices) grpc_slice_unref(slice);
grpc_chttp2_hpack_parser_destroy(&p);
@@ -764,8 +775,58 @@ class RepresentativeServerTrailingMetadata {
static void free_timeout(void* p) { gpr_free(p); }
-// New implementation.
-static void OnHeaderNew(void* user_data, grpc_mdelem md) {
+// Benchmark the current on_initial_header implementation
+static void OnInitialHeader(void* user_data, grpc_mdelem md) {
+ // Setup for benchmark. This will bloat the absolute values of this benchmark
+ grpc_chttp2_incoming_metadata_buffer buffer;
+ grpc_chttp2_incoming_metadata_buffer_init(&buffer, (gpr_arena*)user_data);
+ bool seen_error = false;
+
+ // Below here is the code we actually care about benchmarking
+ if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_STATUS) &&
+ !grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) {
+ seen_error = true;
+ }
+ if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) {
+ grpc_millis* cached_timeout =
+ static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
+ grpc_millis timeout;
+ if (cached_timeout != nullptr) {
+ timeout = *cached_timeout;
+ } else {
+ if (GPR_UNLIKELY(
+ !grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout))) {
+ char* val = grpc_slice_to_c_string(GRPC_MDVALUE(md));
+ gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val);
+ gpr_free(val);
+ timeout = GRPC_MILLIS_INF_FUTURE;
+ }
+ if (GRPC_MDELEM_IS_INTERNED(md)) {
+ /* not already parsed: parse it now, and store the
+ * result away */
+ cached_timeout =
+ static_cast<grpc_millis*>(gpr_malloc(sizeof(grpc_millis)));
+ *cached_timeout = timeout;
+ grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
+ }
+ }
+ benchmark::DoNotOptimize(timeout);
+ GRPC_MDELEM_UNREF(md);
+ } else {
+ const size_t new_size = buffer.size + GRPC_MDELEM_LENGTH(md);
+ if (!seen_error) {
+ buffer.size = new_size;
+ }
+ grpc_error* error = grpc_chttp2_incoming_metadata_buffer_add(&buffer, md);
+ if (error != GRPC_ERROR_NONE) {
+ GPR_ASSERT(0);
+ }
+ }
+ grpc_chttp2_incoming_metadata_buffer_destroy(&buffer);
+}
+
+// Benchmark timeout handling
+static void OnHeaderTimeout(void* user_data, grpc_mdelem md) {
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) {
grpc_millis* cached_timeout =
static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
@@ -851,8 +912,13 @@ BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
RepresentativeServerInitialMetadata, UnrefHeader);
BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
RepresentativeServerTrailingMetadata, UnrefHeader);
-
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, SameDeadline, OnHeaderNew);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
+ RepresentativeClientInitialMetadata, OnInitialHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
+ MoreRepresentativeClientInitialMetadata, OnInitialHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
+ RepresentativeServerInitialMetadata, OnInitialHeader);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, SameDeadline, OnHeaderTimeout);
} // namespace hpack_parser_fixtures
diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
index 1e9bd273aa..189923a841 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
@@ -96,7 +96,7 @@ class DummyEndpoint : public grpc_endpoint {
}
static void write(grpc_endpoint* ep, grpc_slice_buffer* slices,
- grpc_closure* cb) {
+ grpc_closure* cb, void* arg) {
GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
}
diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc
index 8bdc3b9385..74ca1ce3a4 100644
--- a/test/cpp/microbenchmarks/bm_closure.cc
+++ b/test/cpp/microbenchmarks/bm_closure.cc
@@ -385,7 +385,7 @@ static void BM_ClosureReschedOnExecCtx(benchmark::State& state) {
grpc_core::ExecCtx exec_ctx;
Rescheduler r(state, grpc_schedule_on_exec_ctx);
r.ScheduleFirst();
-
+ grpc_core::ExecCtx::Get()->Flush();
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnExecCtx);
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index da095c3e68..85767c8758 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -34,15 +34,15 @@ struct grpc_pollset {
gpr_mu mu;
};
+static gpr_mu g_mu;
+static gpr_cv g_cv;
+static int g_threads_active;
+static bool g_active;
+
namespace grpc {
namespace testing {
-
-auto& force_library_initialization = Library::get();
-
-static void* g_tag = (void*)static_cast<intptr_t>(10); // Some random number
static grpc_completion_queue* g_cq;
static grpc_event_engine_vtable g_vtable;
-static const grpc_event_engine_vtable* g_old_vtable;
static void pollset_shutdown(grpc_pollset* ps, grpc_closure* closure) {
GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
@@ -74,16 +74,18 @@ static grpc_error* pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker,
}
gpr_mu_unlock(&ps->mu);
- GPR_ASSERT(grpc_cq_begin_op(g_cq, g_tag));
+
+ void* tag = (void*)static_cast<intptr_t>(10); // Some random number
+ GPR_ASSERT(grpc_cq_begin_op(g_cq, tag));
grpc_cq_end_op(
- g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
+ g_cq, tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
static_cast<grpc_cq_completion*>(gpr_malloc(sizeof(grpc_cq_completion))));
grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&ps->mu);
return GRPC_ERROR_NONE;
}
-static void init_engine_vtable() {
+static const grpc_event_engine_vtable* init_engine_vtable(bool) {
memset(&g_vtable, 0, sizeof(g_vtable));
g_vtable.pollset_size = sizeof(grpc_pollset);
@@ -92,17 +94,23 @@ static void init_engine_vtable() {
g_vtable.pollset_destroy = pollset_destroy;
g_vtable.pollset_work = pollset_work;
g_vtable.pollset_kick = pollset_kick;
+ g_vtable.shutdown_engine = [] {};
+
+ return &g_vtable;
}
static void setup() {
- grpc_init();
+ // This test should only ever be run with a non or any polling engine
+ // Override the polling engine for the non-polling engine
+ // and add a custom polling engine
+ grpc_register_event_engine_factory("none", init_engine_vtable, false);
+ grpc_register_event_engine_factory("bm_cq_multiple_threads",
+ init_engine_vtable, true);
- /* Override the event engine with our test event engine (g_vtable); but before
- * that, save the current event engine in g_old_vtable. We will have to set
- * g_old_vtable back before calling grpc_shutdown() */
- init_engine_vtable();
- g_old_vtable = grpc_get_event_engine_test_only();
- grpc_set_event_engine_test_only(&g_vtable);
+ grpc_init();
+ GPR_ASSERT(strcmp(grpc_get_poll_strategy_name(), "none") == 0 ||
+ strcmp(grpc_get_poll_strategy_name(), "bm_cq_multiple_threads") ==
+ 0);
g_cq = grpc_completion_queue_create_for_next(nullptr);
}
@@ -118,9 +126,6 @@ static void teardown() {
}
grpc_completion_queue_destroy(g_cq);
-
- /* Restore the old event engine before calling grpc_shutdown */
- grpc_set_event_engine_test_only(g_old_vtable);
grpc_shutdown();
}
@@ -137,14 +142,33 @@ static void teardown() {
code (i.e the code between two successive calls of state.KeepRunning()) if
state.KeepRunning() returns false. So it is safe to do the teardown in one
of the threads after state.keepRunning() returns false.
+
+ However, our use requires synchronization because we do additional work at
+ each thread that requires specific ordering (TrackCounters must be constructed
+ after grpc_init because it needs the number of cores, initialized by grpc,
+ and its Finish call must take place before grpc_shutdown so that it can use
+ grpc_stats).
*/
static void BM_Cq_Throughput(benchmark::State& state) {
- TrackCounters track_counters;
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
+ auto thd_idx = state.thread_index;
- if (state.thread_index == 0) {
+ gpr_mu_lock(&g_mu);
+ g_threads_active++;
+ if (thd_idx == 0) {
setup();
+ g_active = true;
+ gpr_cv_broadcast(&g_cv);
+ } else {
+ while (!g_active) {
+ gpr_cv_wait(&g_cv, &g_mu, deadline);
+ }
}
+ gpr_mu_unlock(&g_mu);
+
+ // Use a TrackCounters object to monitor the gRPC performance statistics
+ // (optionally including low-level counters) before and after the test
+ TrackCounters track_counters;
while (state.KeepRunning()) {
GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, nullptr).type ==
@@ -152,12 +176,23 @@ static void BM_Cq_Throughput(benchmark::State& state) {
}
state.SetItemsProcessed(state.iterations());
+ track_counters.Finish(state);
- if (state.thread_index == 0) {
- teardown();
+ gpr_mu_lock(&g_mu);
+ g_threads_active--;
+ if (g_threads_active == 0) {
+ gpr_cv_broadcast(&g_cv);
+ } else {
+ while (g_threads_active > 0) {
+ gpr_cv_wait(&g_cv, &g_mu, deadline);
+ }
}
+ gpr_mu_unlock(&g_mu);
- track_counters.Finish(state);
+ if (thd_idx == 0) {
+ teardown();
+ g_active = false;
+ }
}
BENCHMARK(BM_Cq_Throughput)->ThreadRange(1, 16)->UseRealTime();
@@ -172,6 +207,8 @@ void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); }
} // namespace benchmark
int main(int argc, char** argv) {
+ gpr_mu_init(&g_mu);
+ gpr_cv_init(&g_cv);
::benchmark::Initialize(&argc, argv);
::grpc::testing::InitTest(&argc, &argv, false);
benchmark::RunTheBenchmarksNamespaced();
diff --git a/test/cpp/microbenchmarks/bm_opencensus_plugin.cc b/test/cpp/microbenchmarks/bm_opencensus_plugin.cc
new file mode 100644
index 0000000000..9d42eb891d
--- /dev/null
+++ b/test/cpp/microbenchmarks/bm_opencensus_plugin.cc
@@ -0,0 +1,118 @@
+/*
+ *
+ * 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 <benchmark/benchmark.h>
+#include <string>
+#include <thread> // NOLINT
+
+#include "absl/base/call_once.h"
+#include "absl/strings/str_cat.h"
+#include "include/grpc++/grpc++.h"
+#include "opencensus/stats/stats.h"
+#include "src/cpp/ext/filters/census/grpc_plugin.h"
+#include "src/proto/grpc/testing/echo.grpc.pb.h"
+#include "test/cpp/microbenchmarks/helpers.h"
+
+absl::once_flag once;
+void RegisterOnce() { absl::call_once(once, grpc::RegisterOpenCensusPlugin); }
+
+class EchoServer final : public grpc::testing::EchoTestService::Service {
+ grpc::Status Echo(grpc::ServerContext* context,
+ const grpc::testing::EchoRequest* request,
+ grpc::testing::EchoResponse* response) override {
+ if (request->param().expected_error().code() == 0) {
+ response->set_message(request->message());
+ return grpc::Status::OK;
+ } else {
+ return grpc::Status(static_cast<grpc::StatusCode>(
+ request->param().expected_error().code()),
+ "");
+ }
+ }
+};
+
+// An EchoServerThread object creates an EchoServer on a separate thread and
+// shuts down the server and thread when it goes out of scope.
+class EchoServerThread final {
+ public:
+ EchoServerThread() {
+ grpc::ServerBuilder builder;
+ int port;
+ builder.AddListeningPort("[::]:0", grpc::InsecureServerCredentials(),
+ &port);
+ builder.RegisterService(&service_);
+ server_ = builder.BuildAndStart();
+ if (server_ == nullptr || port == 0) {
+ std::abort();
+ }
+ server_address_ = absl::StrCat("[::]:", port);
+ server_thread_ = std::thread(&EchoServerThread::RunServerLoop, this);
+ }
+
+ ~EchoServerThread() {
+ server_->Shutdown();
+ server_thread_.join();
+ }
+
+ const std::string& address() { return server_address_; }
+
+ private:
+ void RunServerLoop() { server_->Wait(); }
+
+ std::string server_address_;
+ EchoServer service_;
+ std::unique_ptr<grpc::Server> server_;
+ std::thread server_thread_;
+};
+
+static void BM_E2eLatencyCensusDisabled(benchmark::State& state) {
+ EchoServerThread server;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub =
+ grpc::testing::EchoTestService::NewStub(grpc::CreateChannel(
+ server.address(), grpc::InsecureChannelCredentials()));
+
+ grpc::testing::EchoResponse response;
+ for (auto _ : state) {
+ grpc::testing::EchoRequest request;
+ grpc::ClientContext context;
+ grpc::Status status = stub->Echo(&context, request, &response);
+ }
+}
+BENCHMARK(BM_E2eLatencyCensusDisabled);
+
+static void BM_E2eLatencyCensusEnabled(benchmark::State& state) {
+ RegisterOnce();
+ // This we can safely repeat, and doing so clears accumulated data to avoid
+ // initialization costs varying between runs.
+ grpc::RegisterOpenCensusViewsForExport();
+
+ EchoServerThread server;
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub =
+ grpc::testing::EchoTestService::NewStub(grpc::CreateChannel(
+ server.address(), grpc::InsecureChannelCredentials()));
+
+ grpc::testing::EchoResponse response;
+ for (auto _ : state) {
+ grpc::testing::EchoRequest request;
+ grpc::ClientContext context;
+ grpc::Status status = stub->Echo(&context, request, &response);
+ }
+}
+BENCHMARK(BM_E2eLatencyCensusEnabled);
+
+BENCHMARK_MAIN();
diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc
index bcb68ff229..050c7f7c17 100644
--- a/test/cpp/microbenchmarks/bm_pollset.cc
+++ b/test/cpp/microbenchmarks/bm_pollset.cc
@@ -141,12 +141,12 @@ static void BM_PollAddFd(benchmark::State& state) {
grpc_wakeup_fd wakeup_fd;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd)));
- grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx");
+ grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx", false);
while (state.KeepRunning()) {
grpc_pollset_add_fd(ps, fd);
grpc_core::ExecCtx::Get()->Flush();
}
- grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */, "xxx");
+ grpc_fd_orphan(fd, nullptr, nullptr, "xxx");
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
@@ -222,7 +222,7 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
grpc_core::ExecCtx exec_ctx;
grpc_wakeup_fd wakeup_fd;
GRPC_ERROR_UNREF(grpc_wakeup_fd_init(&wakeup_fd));
- grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read");
+ grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read", false);
grpc_pollset_add_fd(ps, wakeup);
bool done = false;
Closure* continue_closure = MakeClosure(
@@ -242,7 +242,7 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
while (!done) {
GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, GRPC_MILLIS_INF_FUTURE));
}
- grpc_fd_orphan(wakeup, nullptr, nullptr, false /* already_closed */, "done");
+ grpc_fd_orphan(wakeup, nullptr, nullptr, "done");
wakeup_fd.read_fd = 0;
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index 9d70277fbc..d390ae08f6 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -48,6 +48,7 @@ namespace testing {
class FixtureConfiguration {
public:
+ virtual ~FixtureConfiguration() {}
virtual void ApplyCommonChannelArguments(ChannelArguments* c) const {
c->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX);
c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX);
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
index e4ba37e2d6..bce72985dc 100644
--- a/test/cpp/microbenchmarks/helpers.cc
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -38,6 +38,7 @@ void TrackCounters::AddLabel(const grpc::string& label) {
}
void TrackCounters::AddToLabel(std::ostream& out, benchmark::State& state) {
+#ifdef GRPC_COLLECT_STATS
grpc_stats_data stats_end;
grpc_stats_collect(&stats_end);
grpc_stats_data stats;
@@ -53,6 +54,7 @@ void TrackCounters::AddToLabel(std::ostream& out, benchmark::State& state) {
<< " " << grpc_stats_histogram_name[i] << "-99p:"
<< grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 99.0);
}
+#endif
#ifdef GPR_LOW_LEVEL_COUNTERS
grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();
out << " locks/iter:"
diff --git a/test/cpp/microbenchmarks/helpers.h b/test/cpp/microbenchmarks/helpers.h
index 4aabd4094a..25d34b5f87 100644
--- a/test/cpp/microbenchmarks/helpers.h
+++ b/test/cpp/microbenchmarks/helpers.h
@@ -63,6 +63,7 @@ extern gpr_atm gpr_now_call_count;
class TrackCounters {
public:
TrackCounters() { grpc_stats_collect(&stats_begin_); }
+ virtual ~TrackCounters() {}
virtual void Finish(benchmark::State& state);
virtual void AddLabel(const grpc::string& label);
virtual void AddToLabel(std::ostream& out, benchmark::State& state);
diff --git a/test/cpp/naming/BUILD b/test/cpp/naming/BUILD
index fa0b216f8f..2925e8fbcf 100644
--- a/test/cpp/naming/BUILD
+++ b/test/cpp/naming/BUILD
@@ -22,7 +22,7 @@ package(
licenses(["notice"]) # Apache v2
-load("//bazel:grpc_build_system.bzl", "grpc_py_binary")
+load("//bazel:grpc_build_system.bzl", "grpc_py_binary", "grpc_cc_test")
load(":generate_resolver_component_tests.bzl", "generate_resolver_component_tests")
@@ -35,4 +35,20 @@ grpc_py_binary(
testonly = True,
)
+grpc_cc_test(
+ name = "cancel_ares_query_test",
+ srcs = ["cancel_ares_query_test.cc"],
+ external_deps = ["gmock"],
+ deps = [
+ "//test/cpp/util:test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/core/util:gpr_test_util",
+ "//:grpc++",
+ "//:grpc",
+ "//:gpr",
+ "//test/cpp/util:test_config",
+ "//test/core/end2end:cq_verifier",
+ ],
+)
+
generate_resolver_component_tests()
diff --git a/test/cpp/naming/README.md b/test/cpp/naming/README.md
deleted file mode 100644
index e0dd208465..0000000000
--- a/test/cpp/naming/README.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# Resolver Tests
-
-This directory has tests and infrastructure for unit tests and GCE
-integration tests of gRPC resolver functionality.
-
-There are two different tests here:
-
-## Resolver unit tests (resolver "component" tests)
-
-These tests run per-change, along with the rest of the grpc unit tests.
-They query a local testing DNS server.
-
-## GCE integration tests
-
-These tests use the same test binary and the same test records
-as the unit tests, but they run against GCE DNS (this is done by
-running the test on a GCE instance and not specifying an authority
-in uris). These tests run in a background job, which needs to be
-actively monitored.
-
-## Making changes to test records
-
-After making a change to `resolver_test_record_groups.yaml`:
-
-1. Increment the "version number" in the `resolver_tests_common_zone_name`
- DNS zone (this is a yaml field at the top
- of `resolver_test_record_groups.yaml`).
-
-2. Regenerate projects.
-
-3. From the repo root, run:
-
-```
-$ test/cpp/naming/create_private_dns_zone.sh
-$ test/cpp/naming/private_dns_zone_init.sh
-```
-
-Note that these commands must be ran in environment that
-has access to the grpc-testing GCE project.
-
-If everything runs smoothly, then once the change is merged,
-the GCE DNS integration testing job will transition to the
-new records and continue passing.
diff --git a/test/cpp/naming/address_sorting_test.cc b/test/cpp/naming/address_sorting_test.cc
index a92e9e3b3e..fc6721d0ba 100644
--- a/test/cpp/naming/address_sorting_test.cc
+++ b/test/cpp/naming/address_sorting_test.cc
@@ -24,10 +24,8 @@
#include <grpc/support/time.h>
#include <string.h>
-#include <arpa/inet.h>
#include <gflags/gflags.h>
#include <gmock/gmock.h>
-#include <sys/socket.h>
#include <sys/types.h>
#include <vector>
@@ -51,6 +49,11 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
+#ifndef GPR_WINDOWS
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#endif
+
namespace {
struct TestAddress {
@@ -190,10 +193,18 @@ void VerifyLbAddrOutputs(grpc_lb_addresses* lb_addrs,
grpc_lb_addresses_destroy(lb_addrs);
}
-} // namespace
+/* We need to run each test case inside of its own
+ * isolated grpc_init/grpc_shutdown pair, so that
+ * the "address sorting source addr factory" can be
+ * restored to its default for each test case. */
+class AddressSortingTest : public ::testing::Test {
+ protected:
+ void SetUp() override { grpc_init(); }
+ void TearDown() override { grpc_shutdown(); }
+};
/* Tests for rule 1 */
-TEST(AddressSortingTest, TestDepriotizesUnreachableAddresses) {
+TEST_F(AddressSortingTest, TestDepriotizesUnreachableAddresses) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -205,14 +216,14 @@ TEST(AddressSortingTest, TestDepriotizesUnreachableAddresses) {
{"1.2.3.4:443", AF_INET},
{"5.6.7.8:443", AF_INET},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"1.2.3.4:443",
"5.6.7.8:443",
});
}
-TEST(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv6) {
+TEST_F(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv6) {
bool ipv4_supported = true;
bool ipv6_supported = false;
OverrideAddressSortingSourceAddrFactory(
@@ -224,14 +235,14 @@ TEST(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv6) {
{"[2607:f8b0:400a:801::1002]:443", AF_INET6},
{"1.2.3.4:443", AF_INET},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"1.2.3.4:443",
"[2607:f8b0:400a:801::1002]:443",
});
}
-TEST(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv4) {
+TEST_F(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv4) {
bool ipv4_supported = false;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -244,7 +255,7 @@ TEST(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv4) {
{"[2607:f8b0:400a:801::1002]:443", AF_INET6},
{"1.2.3.4:443", AF_INET},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[2607:f8b0:400a:801::1002]:443",
"1.2.3.4:443",
@@ -253,7 +264,7 @@ TEST(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv4) {
/* Tests for rule 2 */
-TEST(AddressSortingTest, TestDepriotizesNonMatchingScope) {
+TEST_F(AddressSortingTest, TestDepriotizesNonMatchingScope) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -268,7 +279,7 @@ TEST(AddressSortingTest, TestDepriotizesNonMatchingScope) {
{"[2000:f8b0:400a:801::1002]:443", AF_INET6},
{"[fec0::5000]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[fec0::5000]:443",
"[2000:f8b0:400a:801::1002]:443",
@@ -277,7 +288,7 @@ TEST(AddressSortingTest, TestDepriotizesNonMatchingScope) {
/* Tests for rule 5 */
-TEST(AddressSortingTest, TestUsesLabelFromDefaultTable) {
+TEST_F(AddressSortingTest, TestUsesLabelFromDefaultTable) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -291,7 +302,7 @@ TEST(AddressSortingTest, TestUsesLabelFromDefaultTable) {
{"[2002::5001]:443", AF_INET6},
{"[2001::5001]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[2001::5001]:443",
"[2002::5001]:443",
@@ -300,7 +311,7 @@ TEST(AddressSortingTest, TestUsesLabelFromDefaultTable) {
/* Flip the input on the test above to reorder the sort function's
* comparator's inputs. */
-TEST(AddressSortingTest, TestUsesLabelFromDefaultTableInputFlipped) {
+TEST_F(AddressSortingTest, TestUsesLabelFromDefaultTableInputFlipped) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -314,7 +325,7 @@ TEST(AddressSortingTest, TestUsesLabelFromDefaultTableInputFlipped) {
{"[2001::5001]:443", AF_INET6},
{"[2002::5001]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[2001::5001]:443",
"[2002::5001]:443",
@@ -323,8 +334,8 @@ TEST(AddressSortingTest, TestUsesLabelFromDefaultTableInputFlipped) {
/* Tests for rule 6 */
-TEST(AddressSortingTest,
- TestUsesDestinationWithHigherPrecedenceWithAnIpv4Address) {
+TEST_F(AddressSortingTest,
+ TestUsesDestinationWithHigherPrecedenceWithAnIpv4Address) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -337,7 +348,7 @@ TEST(AddressSortingTest,
{"[3ffe::5001]:443", AF_INET6},
{"1.2.3.4:443", AF_INET},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(
lb_addrs, {
// The AF_INET address should be IPv4-mapped by the sort,
@@ -348,8 +359,8 @@ TEST(AddressSortingTest,
});
}
-TEST(AddressSortingTest,
- TestUsesDestinationWithHigherPrecedenceWithV4CompatAndLocalhostAddress) {
+TEST_F(AddressSortingTest,
+ TestUsesDestinationWithHigherPrecedenceWithV4CompatAndLocalhostAddress) {
bool ipv4_supported = true;
bool ipv6_supported = true;
// Handle unique observed behavior of inet_ntop(v4-compatible-address) on OS X.
@@ -370,15 +381,15 @@ TEST(AddressSortingTest,
{v4_compat_dest, AF_INET6},
{"[::1]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[::1]:443",
v4_compat_dest,
});
}
-TEST(AddressSortingTest,
- TestUsesDestinationWithHigherPrecedenceWithCatchAllAndLocalhostAddress) {
+TEST_F(AddressSortingTest,
+ TestUsesDestinationWithHigherPrecedenceWithCatchAllAndLocalhostAddress) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -393,7 +404,7 @@ TEST(AddressSortingTest,
{"[1234::2]:443", AF_INET6},
{"[::1]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(
lb_addrs,
{
@@ -403,8 +414,8 @@ TEST(AddressSortingTest,
});
}
-TEST(AddressSortingTest,
- TestUsesDestinationWithHigherPrecedenceWith2000PrefixedAddress) {
+TEST_F(AddressSortingTest,
+ TestUsesDestinationWithHigherPrecedenceWith2000PrefixedAddress) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -417,7 +428,7 @@ TEST(AddressSortingTest,
{"[2001::1234]:443", AF_INET6},
{"[2000::5001]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(
lb_addrs, {
// The 2000::/16 address should match the ::/0 prefix rule
@@ -426,7 +437,7 @@ TEST(AddressSortingTest,
});
}
-TEST(
+TEST_F(
AddressSortingTest,
TestUsesDestinationWithHigherPrecedenceWith2000PrefixedAddressEnsurePrefixMatchHasNoEffect) {
bool ipv4_supported = true;
@@ -441,15 +452,15 @@ TEST(
{"[2001::1231]:443", AF_INET6},
{"[2000::5001]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[2000::5001]:443",
"[2001::1231]:443",
});
}
-TEST(AddressSortingTest,
- TestUsesDestinationWithHigherPrecedenceWithLinkAndSiteLocalAddresses) {
+TEST_F(AddressSortingTest,
+ TestUsesDestinationWithHigherPrecedenceWithLinkAndSiteLocalAddresses) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -462,40 +473,43 @@ TEST(AddressSortingTest,
{"[fec0::1234]:443", AF_INET6},
{"[fc00::5001]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[fc00::5001]:443",
"[fec0::1234]:443",
});
}
-TEST(
+TEST_F(
AddressSortingTest,
TestUsesDestinationWithHigherPrecedenceWithCatchAllAndAndV4MappedAddresses) {
bool ipv4_supported = true;
bool ipv6_supported = true;
+ // Use embedded ipv4 addresses with leading 1's instead of zero's to be
+ // compatible with inet_ntop implementations that can display such
+ // addresses with leading zero's as e.g.: "::ffff:0:2", as on windows.
OverrideAddressSortingSourceAddrFactory(
ipv4_supported, ipv6_supported,
{
- {"[::ffff:0.0.0.2]:443", {"[::ffff:0.0.0.3]:0", AF_INET6}},
+ {"[::ffff:1.1.1.2]:443", {"[::ffff:1.1.1.3]:0", AF_INET6}},
{"[1234::2]:443", {"[1234::3]:0", AF_INET6}},
});
grpc_lb_addresses* lb_addrs = BuildLbAddrInputs({
- {"[::ffff:0.0.0.2]:443", AF_INET6},
+ {"[::ffff:1.1.1.2]:443", AF_INET6},
{"[1234::2]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
// ::ffff:0:2 should match the v4-mapped
// precedence entry and be deprioritized.
"[1234::2]:443",
- "[::ffff:0.0.0.2]:443",
+ "[::ffff:1.1.1.2]:443",
});
}
/* Tests for rule 8 */
-TEST(AddressSortingTest, TestPrefersSmallerScope) {
+TEST_F(AddressSortingTest, TestPrefersSmallerScope) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -511,7 +525,7 @@ TEST(AddressSortingTest, TestPrefersSmallerScope) {
{"[3ffe::5001]:443", AF_INET6},
{"[fec0::1234]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[fec0::1234]:443",
"[3ffe::5001]:443",
@@ -520,7 +534,7 @@ TEST(AddressSortingTest, TestPrefersSmallerScope) {
/* Tests for rule 9 */
-TEST(AddressSortingTest, TestPrefersLongestMatchingSrcDstPrefix) {
+TEST_F(AddressSortingTest, TestPrefersLongestMatchingSrcDstPrefix) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -536,15 +550,15 @@ TEST(AddressSortingTest, TestPrefersLongestMatchingSrcDstPrefix) {
{"[3ffe:5001::]:443", AF_INET6},
{"[3ffe:1234::]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[3ffe:1234::]:443",
"[3ffe:5001::]:443",
});
}
-TEST(AddressSortingTest,
- TestPrefersLongestMatchingSrcDstPrefixMatchesWholeAddress) {
+TEST_F(AddressSortingTest,
+ TestPrefersLongestMatchingSrcDstPrefixMatchesWholeAddress) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -557,14 +571,14 @@ TEST(AddressSortingTest,
{"[3ffe::5001]:443", AF_INET6},
{"[3ffe::1234]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[3ffe::1234]:443",
"[3ffe::5001]:443",
});
}
-TEST(AddressSortingTest, TestPrefersLongestPrefixStressInnerBytePrefix) {
+TEST_F(AddressSortingTest, TestPrefersLongestPrefixStressInnerBytePrefix) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -577,14 +591,14 @@ TEST(AddressSortingTest, TestPrefersLongestPrefixStressInnerBytePrefix) {
{"[3ffe:8000::]:443", AF_INET6},
{"[3ffe:2000::]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[3ffe:2000::]:443",
"[3ffe:8000::]:443",
});
}
-TEST(AddressSortingTest, TestPrefersLongestPrefixDiffersOnHighestBitOfByte) {
+TEST_F(AddressSortingTest, TestPrefersLongestPrefixDiffersOnHighestBitOfByte) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -597,14 +611,14 @@ TEST(AddressSortingTest, TestPrefersLongestPrefixDiffersOnHighestBitOfByte) {
{"[3ffe:6::]:443", AF_INET6},
{"[3ffe:c::]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[3ffe:c::]:443",
"[3ffe:6::]:443",
});
}
-TEST(AddressSortingTest, TestPrefersLongestPrefixDiffersByLastBit) {
+TEST_F(AddressSortingTest, TestPrefersLongestPrefixDiffersByLastBit) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -619,7 +633,7 @@ TEST(AddressSortingTest, TestPrefersLongestPrefixDiffersByLastBit) {
{"[3ffe:1111:1111:1110::]:443", AF_INET6},
{"[3ffe:1111:1111:1111::]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[3ffe:1111:1111:1111::]:443",
"[3ffe:1111:1111:1110::]:443",
@@ -628,7 +642,7 @@ TEST(AddressSortingTest, TestPrefersLongestPrefixDiffersByLastBit) {
/* Tests for rule 10 */
-TEST(AddressSortingTest, TestStableSort) {
+TEST_F(AddressSortingTest, TestStableSort) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -641,14 +655,14 @@ TEST(AddressSortingTest, TestStableSort) {
{"[3ffe::1234]:443", AF_INET6},
{"[3ffe::1235]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[3ffe::1234]:443",
"[3ffe::1235]:443",
});
}
-TEST(AddressSortingTest, TestStableSortFiveElements) {
+TEST_F(AddressSortingTest, TestStableSortFiveElements) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(
@@ -667,7 +681,7 @@ TEST(AddressSortingTest, TestStableSortFiveElements) {
{"[3ffe::1234]:443", AF_INET6},
{"[3ffe::1235]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[3ffe::1231]:443",
"[3ffe::1232]:443",
@@ -677,7 +691,7 @@ TEST(AddressSortingTest, TestStableSortFiveElements) {
});
}
-TEST(AddressSortingTest, TestStableSortNoSrcAddrsExist) {
+TEST_F(AddressSortingTest, TestStableSortNoSrcAddrsExist) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(ipv4_supported, ipv6_supported, {});
@@ -688,7 +702,7 @@ TEST(AddressSortingTest, TestStableSortNoSrcAddrsExist) {
{"[3ffe::1234]:443", AF_INET6},
{"[3ffe::1235]:443", AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[3ffe::1231]:443",
"[3ffe::1232]:443",
@@ -698,7 +712,7 @@ TEST(AddressSortingTest, TestStableSortNoSrcAddrsExist) {
});
}
-TEST(AddressSortingTest, TestStableSortNoSrcAddrsExistWithIpv4) {
+TEST_F(AddressSortingTest, TestStableSortNoSrcAddrsExistWithIpv4) {
bool ipv4_supported = true;
bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(ipv4_supported, ipv6_supported, {});
@@ -706,14 +720,14 @@ TEST(AddressSortingTest, TestStableSortNoSrcAddrsExistWithIpv4) {
{"[::ffff:5.6.7.8]:443", AF_INET6},
{"1.2.3.4:443", AF_INET},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[::ffff:5.6.7.8]:443",
"1.2.3.4:443",
});
}
-TEST(AddressSortingTest, TestStableSortV4CompatAndSiteLocalAddresses) {
+TEST_F(AddressSortingTest, TestStableSortV4CompatAndSiteLocalAddresses) {
bool ipv4_supported = true;
bool ipv6_supported = true;
// Handle unique observed behavior of inet_ntop(v4-compatible-address) on OS X.
@@ -734,7 +748,7 @@ TEST(AddressSortingTest, TestStableSortV4CompatAndSiteLocalAddresses) {
{"[fec0::2000]:443", AF_INET6},
{v4_compat_dest, AF_INET6},
});
- grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs,
{
// The sort should be stable since
@@ -744,6 +758,78 @@ TEST(AddressSortingTest, TestStableSortV4CompatAndSiteLocalAddresses) {
});
}
+/* TestPrefersIpv6Loopback tests the actual "address probing" code
+ * for the current platform, without any mocks.
+ * This test relies on the assumption that the ipv6 loopback address is
+ * available in the hosts/containers that grpc C/C++ tests run on
+ * (whether ipv4 loopback is available or not, an available ipv6
+ * loopback should be preferred). */
+TEST_F(AddressSortingTest, TestPrefersIpv6Loopback) {
+ grpc_lb_addresses* lb_addrs = BuildLbAddrInputs({
+ {"[::1]:443", AF_INET6},
+ {"127.0.0.1:443", AF_INET},
+ });
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
+ VerifyLbAddrOutputs(lb_addrs, {
+ "[::1]:443",
+ "127.0.0.1:443",
+ });
+}
+
+/* Flip the order of the inputs above and expect the same output order
+ * (try to rule out influence of arbitrary qsort ordering) */
+TEST_F(AddressSortingTest, TestPrefersIpv6LoopbackInputsFlipped) {
+ grpc_lb_addresses* lb_addrs = BuildLbAddrInputs({
+ {"127.0.0.1:443", AF_INET},
+ {"[::1]:443", AF_INET6},
+ });
+ grpc_cares_wrapper_address_sorting_sort(lb_addrs);
+ VerifyLbAddrOutputs(lb_addrs, {
+ "[::1]:443",
+ "127.0.0.1:443",
+ });
+}
+
+/* Try to rule out false positives in the above two tests in which
+ * the sorter might think that neither ipv6 or ipv4 loopback is
+ * available, but ipv6 loopback is still preferred only due
+ * to precedance table lookups. */
+TEST_F(AddressSortingTest, TestSorterKnowsIpv6LoopbackIsAvailable) {
+ sockaddr_in6 ipv6_loopback;
+ memset(&ipv6_loopback, 0, sizeof(ipv6_loopback));
+ ipv6_loopback.sin6_family = AF_INET6;
+ ((char*)&ipv6_loopback.sin6_addr)[15] = 1;
+ ipv6_loopback.sin6_port = htons(443);
+ // Set up the source and destination parameters of
+ // address_sorting_get_source_addr
+ address_sorting_address sort_input_dest;
+ memcpy(&sort_input_dest.addr, &ipv6_loopback, sizeof(ipv6_loopback));
+ sort_input_dest.len = sizeof(ipv6_loopback);
+ address_sorting_address source_for_sort_input_dest;
+ memset(&source_for_sort_input_dest, 0, sizeof(source_for_sort_input_dest));
+ // address_sorting_get_source_addr returns true if a source address was found
+ // for the destination address, otherwise false.
+ EXPECT_TRUE(address_sorting_get_source_addr_for_testing(
+ &sort_input_dest, &source_for_sort_input_dest));
+ // Now also check that the source address was filled in correctly.
+ EXPECT_GT(source_for_sort_input_dest.len, 0u);
+ sockaddr_in6* source_addr_output =
+ (sockaddr_in6*)source_for_sort_input_dest.addr;
+ EXPECT_EQ(source_addr_output->sin6_family, AF_INET6);
+ char* buf = static_cast<char*>(gpr_zalloc(100));
+ EXPECT_NE(inet_ntop(AF_INET6, &source_addr_output->sin6_addr, buf, 100),
+ nullptr)
+ << "inet_ntop failed. Errno: " + std::to_string(errno);
+ std::string source_addr_str(buf);
+ gpr_free(buf);
+ // This test
+ // assumes that the source address for any loopback destination is also the
+ // loopback address.
+ EXPECT_EQ(source_addr_str, "::1");
+}
+
+} // namespace
+
int main(int argc, char** argv) {
char* resolver = gpr_getenv("GRPC_DNS_RESOLVER");
if (resolver == nullptr || strlen(resolver) == 0) {
@@ -754,9 +840,7 @@ int main(int argc, char** argv) {
gpr_free(resolver);
grpc_test_init(argc, argv);
::testing::InitGoogleTest(&argc, argv);
- grpc_init();
auto result = RUN_ALL_TESTS();
- grpc_shutdown();
// Test sequential and nested inits and shutdowns.
grpc_init();
grpc_init();
diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc
new file mode 100644
index 0000000000..dec7c171dc
--- /dev/null
+++ b/test/cpp/naming/cancel_ares_query_test.cc
@@ -0,0 +1,360 @@
+/*
+ *
+ * Copyright 2015 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 <stdio.h>
+#include <string.h>
+
+#include <gflags/gflags.h>
+#include <gmock/gmock.h>
+
+#include <grpc/byte_buffer.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/time.h>
+#include "include/grpc/support/string_util.h"
+#include "src/core/ext/filters/client_channel/resolver.h"
+#include "src/core/ext/filters/client_channel/resolver_registry.h"
+#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/debug/stats.h"
+#include "src/core/lib/gpr/env.h"
+#include "src/core/lib/gpr/host_port.h"
+#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/orphanable.h"
+#include "src/core/lib/gprpp/thd.h"
+#include "src/core/lib/iomgr/combiner.h"
+#include "src/core/lib/iomgr/pollset.h"
+#include "src/core/lib/iomgr/pollset_set.h"
+#include "test/core/end2end/cq_verifier.h"
+#include "test/core/util/cmdline.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+#ifdef GPR_WINDOWS
+#include "src/core/lib/iomgr/sockaddr_windows.h"
+#include "src/core/lib/iomgr/socket_windows.h"
+#define BAD_SOCKET_RETURN_VAL INVALID_SOCKET
+#else
+#include "src/core/lib/iomgr/sockaddr_posix.h"
+#define BAD_SOCKET_RETURN_VAL -1
+#endif
+
+namespace {
+
+void* Tag(intptr_t t) { return (void*)t; }
+
+gpr_timespec FiveSecondsFromNow(void) {
+ return grpc_timeout_seconds_to_deadline(5);
+}
+
+void DrainCq(grpc_completion_queue* cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, FiveSecondsFromNow(), nullptr);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+void EndTest(grpc_channel* client, grpc_completion_queue* cq) {
+ grpc_channel_destroy(client);
+ grpc_completion_queue_shutdown(cq);
+ DrainCq(cq);
+ grpc_completion_queue_destroy(cq);
+}
+
+class FakeNonResponsiveDNSServer {
+ public:
+ FakeNonResponsiveDNSServer(int port) {
+ socket_ = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (socket_ == BAD_SOCKET_RETURN_VAL) {
+ gpr_log(GPR_DEBUG, "Failed to create UDP ipv6 socket");
+ abort();
+ }
+ sockaddr_in6 addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.sin6_family = AF_INET6;
+ addr.sin6_port = htons(port);
+ ((char*)&addr.sin6_addr)[15] = 1;
+ if (bind(socket_, (const sockaddr*)&addr, sizeof(addr)) != 0) {
+ gpr_log(GPR_DEBUG, "Failed to bind UDP ipv6 socket to [::1]:%d", port);
+ abort();
+ }
+ }
+ ~FakeNonResponsiveDNSServer() {
+#ifdef GPR_WINDOWS
+ closesocket(socket_);
+#else
+ close(socket_);
+#endif
+ }
+
+ private:
+ int socket_;
+};
+
+struct ArgsStruct {
+ gpr_atm done_atm;
+ gpr_mu* mu;
+ grpc_pollset* pollset;
+ grpc_pollset_set* pollset_set;
+ grpc_combiner* lock;
+ grpc_channel_args* channel_args;
+};
+
+void ArgsInit(ArgsStruct* args) {
+ args->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset_init(args->pollset, &args->mu);
+ args->pollset_set = grpc_pollset_set_create();
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
+ args->lock = grpc_combiner_create();
+ gpr_atm_rel_store(&args->done_atm, 0);
+ args->channel_args = nullptr;
+}
+
+void DoNothing(void* arg, grpc_error* error) {}
+
+void ArgsFinish(ArgsStruct* args) {
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
+ grpc_closure DoNothing_cb;
+ GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, nullptr,
+ grpc_schedule_on_exec_ctx);
+ grpc_pollset_shutdown(args->pollset, &DoNothing_cb);
+ // exec_ctx needs to be flushed before calling grpc_pollset_destroy()
+ grpc_channel_args_destroy(args->channel_args);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
+ gpr_free(args->pollset);
+ GRPC_COMBINER_UNREF(args->lock, nullptr);
+}
+
+void PollPollsetUntilRequestDone(ArgsStruct* args) {
+ while (true) {
+ bool done = gpr_atm_acq_load(&args->done_atm) != 0;
+ if (done) {
+ break;
+ }
+ grpc_pollset_worker* worker = nullptr;
+ grpc_core::ExecCtx exec_ctx;
+ gpr_mu_lock(args->mu);
+ GRPC_LOG_IF_ERROR(
+ "pollset_work",
+ grpc_pollset_work(args->pollset, &worker,
+ grpc_timespec_to_millis_round_up(
+ gpr_inf_future(GPR_CLOCK_REALTIME))));
+ gpr_mu_unlock(args->mu);
+ }
+}
+
+void CheckResolverResultAssertFailureLocked(void* arg, grpc_error* error) {
+ EXPECT_NE(error, GRPC_ERROR_NONE);
+ ArgsStruct* args = static_cast<ArgsStruct*>(arg);
+ gpr_atm_rel_store(&args->done_atm, 1);
+ gpr_mu_lock(args->mu);
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
+ gpr_mu_unlock(args->mu);
+}
+
+void TestCancelActiveDNSQuery(ArgsStruct* args) {
+ int fake_dns_port = grpc_pick_unused_port_or_die();
+ FakeNonResponsiveDNSServer fake_dns_server(fake_dns_port);
+ char* client_target;
+ GPR_ASSERT(gpr_asprintf(
+ &client_target,
+ "dns://[::1]:%d/dont-care-since-wont-be-resolved.test.com:1234",
+ fake_dns_port));
+ // create resolver and resolve
+ grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
+ grpc_core::ResolverRegistry::CreateResolver(
+ client_target, nullptr, args->pollset_set, args->lock);
+ gpr_free(client_target);
+ grpc_closure on_resolver_result_changed;
+ GRPC_CLOSURE_INIT(&on_resolver_result_changed,
+ CheckResolverResultAssertFailureLocked, (void*)args,
+ grpc_combiner_scheduler(args->lock));
+ resolver->NextLocked(&args->channel_args, &on_resolver_result_changed);
+ // Without resetting and causing resolver shutdown, the
+ // PollPollsetUntilRequestDone call should never finish.
+ resolver.reset();
+ grpc_core::ExecCtx::Get()->Flush();
+ PollPollsetUntilRequestDone(args);
+ ArgsFinish(args);
+}
+
+TEST(CancelDuringAresQuery, TestCancelActiveDNSQuery) {
+ grpc_core::ExecCtx exec_ctx;
+ ArgsStruct args;
+ ArgsInit(&args);
+ TestCancelActiveDNSQuery(&args);
+}
+
+#ifdef GPR_WINDOWS
+
+void MaybePollArbitraryPollsetTwice() {
+ grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ gpr_mu* mu;
+ grpc_pollset_init(pollset, &mu);
+ grpc_pollset_worker* worker = nullptr;
+ // Make a zero timeout poll
+ gpr_mu_lock(mu);
+ GRPC_LOG_IF_ERROR(
+ "pollset_work",
+ grpc_pollset_work(pollset, &worker, grpc_core::ExecCtx::Get()->Now()));
+ gpr_mu_unlock(mu);
+ grpc_core::ExecCtx::Get()->Flush();
+ // Make a second zero-timeout poll (in case the first one
+ // short-circuited by picking up a previous "kick")
+ gpr_mu_lock(mu);
+ GRPC_LOG_IF_ERROR(
+ "pollset_work",
+ grpc_pollset_work(pollset, &worker, grpc_core::ExecCtx::Get()->Now()));
+ gpr_mu_unlock(mu);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(pollset);
+ gpr_free(pollset);
+}
+
+#else
+
+void MaybePollArbitraryPollsetTwice() {}
+
+#endif
+
+TEST(CancelDuringAresQuery, TestFdsAreDeletedFromPollsetSet) {
+ grpc_core::ExecCtx exec_ctx;
+ ArgsStruct args;
+ ArgsInit(&args);
+ // Add fake_other_pollset_set into the mix to test
+ // that we're explicitly deleting fd's from their pollset.
+ // If we aren't doing so, then the remaining presence of
+ // "fake_other_pollset_set" after the request is done and the resolver
+ // pollset set is destroyed should keep the resolver's fd alive and
+ // fail the test.
+ grpc_pollset_set* fake_other_pollset_set = grpc_pollset_set_create();
+ grpc_pollset_set_add_pollset_set(fake_other_pollset_set, args.pollset_set);
+ // Note that running the cancellation c-ares test is somewhat irrelevant for
+ // this test. This test only cares about what happens to fd's that c-ares
+ // opens.
+ TestCancelActiveDNSQuery(&args);
+ // This test relies on the assumption that cancelling a c-ares query
+ // will flush out all callbacks on the current exec ctx, which is true
+ // on posix platforms but not on Windows, because fd shutdown on Windows
+ // requires a trip through the polling loop to schedule the callback.
+ // So we need to do extra polling work on Windows to free things up.
+ MaybePollArbitraryPollsetTwice();
+ EXPECT_EQ(grpc_iomgr_count_objects_for_testing(), 0u);
+ grpc_pollset_set_destroy(fake_other_pollset_set);
+}
+
+TEST(CancelDuringAresQuery,
+ TestHitDeadlineAndDestroyChannelDuringAresResolutionIsGraceful) {
+ // Start up fake non responsive DNS server
+ int fake_dns_port = grpc_pick_unused_port_or_die();
+ FakeNonResponsiveDNSServer fake_dns_server(fake_dns_port);
+ // Create a call that will try to use the fake DNS server
+ char* client_target = nullptr;
+ GPR_ASSERT(gpr_asprintf(
+ &client_target,
+ "dns://[::1]:%d/dont-care-since-wont-be-resolved.test.com:1234",
+ fake_dns_port));
+ grpc_channel* client =
+ grpc_insecure_channel_create(client_target,
+ /* client_args */ nullptr, nullptr);
+ gpr_free(client_target);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
+ cq_verifier* cqv = cq_verifier_create(cq);
+ gpr_timespec deadline = grpc_timeout_milliseconds_to_deadline(10);
+ grpc_call* call = grpc_channel_create_call(
+ client, nullptr, GRPC_PROPAGATE_DEFAULTS, cq,
+ grpc_slice_from_static_string("/foo"), nullptr, deadline, nullptr);
+ GPR_ASSERT(call);
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details call_details;
+ grpc_call_details_init(&call_details);
+ grpc_status_code status;
+ const char* error_string;
+ grpc_slice details;
+ // Set ops for client the request
+ grpc_op ops_base[6];
+ memset(ops_base, 0, sizeof(ops_base));
+ grpc_op* op = ops_base;
+ 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_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op->data.recv_status_on_client.error_string = &error_string;
+ op->flags = 0;
+ op->reserved = nullptr;
+ op++;
+ // Run the call and sanity check it failed as expected
+ grpc_call_error error = grpc_call_start_batch(
+ call, ops_base, static_cast<size_t>(op - ops_base), Tag(1), nullptr);
+ EXPECT_EQ(GRPC_CALL_OK, error);
+ CQ_EXPECT_COMPLETION(cqv, Tag(1), 1);
+ cq_verify(cqv);
+ EXPECT_EQ(status, GRPC_STATUS_DEADLINE_EXCEEDED);
+ // Teardown
+ grpc_slice_unref(details);
+ gpr_free((void*)error_string);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+ grpc_call_unref(call);
+ cq_verifier_destroy(cqv);
+ EndTest(client, cq);
+}
+
+} // namespace
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ gpr_setenv("GRPC_DNS_RESOLVER", "ares");
+ // Sanity check the time that it takes to run the test
+ // including the teardown time (the teardown
+ // part of the test involves cancelling the DNS query,
+ // which is the main point of interest for this test).
+ gpr_timespec overall_deadline = grpc_timeout_seconds_to_deadline(4);
+ grpc_init();
+ auto result = RUN_ALL_TESTS();
+ grpc_shutdown();
+ if (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), overall_deadline) > 0) {
+ gpr_log(GPR_ERROR, "Test took too long");
+ abort();
+ }
+ return result;
+}
diff --git a/test/cpp/naming/gen_build_yaml.py b/test/cpp/naming/gen_build_yaml.py
index 493713ff0e..1c9d0676b8 100755
--- a/test/cpp/naming/gen_build_yaml.py
+++ b/test/cpp/naming/gen_build_yaml.py
@@ -24,12 +24,6 @@ import json
_LOCAL_DNS_SERVER_ADDRESS = '127.0.0.1:15353'
-_TARGET_RECORDS_TO_SKIP_AGAINST_GCE = [
- # TODO: enable this once able to upload the very large TXT record
- # in this group to GCE DNS.
- 'ipv4-config-causing-fallback-to-tcp',
-]
-
def _append_zone_name(name, zone_name):
return '%s.%s' % (name, zone_name)
@@ -39,86 +33,9 @@ def _build_expected_addrs_cmd_arg(expected_addrs):
out.append('%s,%s' % (addr['address'], str(addr['is_balancer'])))
return ';'.join(out)
-def _data_for_type(r_type, r_data, common_zone_name):
- if r_type in ['A', 'AAAA']:
- return ' '.join(map(lambda x: '\"%s\"' % x, r_data))
- if r_type == 'SRV':
- assert len(r_data) == 1
- target = r_data[0].split(' ')[3]
- uploadable_target = '%s.%s' % (target, common_zone_name)
- uploadable = r_data[0].split(' ')
- uploadable[3] = uploadable_target
- return '\"%s\"' % ' '.join(uploadable)
- if r_type == 'TXT':
- assert len(r_data) == 1
- chunks = []
- all_data = r_data[0]
- cur = 0
- # Split TXT records that span more than 255 characters (the single
- # string length-limit in DNS) into multiple strings. Each string
- # needs to be wrapped with double-quotes, and all inner double-quotes
- # are escaped. The wrapping double-quotes and inner backslashes can be
- # counted towards the 255 character length limit (as observed with gcloud),
- # so make sure all strings fit within that limit.
- while len(all_data[cur:]) > 0:
- next_chunk = '\"'
- while len(next_chunk) < 254 and len(all_data[cur:]) > 0:
- if all_data[cur] == '\"':
- if len(next_chunk) < 253:
- next_chunk += '\\\"'
- else:
- break
- else:
- next_chunk += all_data[cur]
- cur += 1
- next_chunk += '\"'
- if len(next_chunk) > 255:
- raise Exception('Bug: next chunk is too long.')
- chunks.append(next_chunk)
- # Wrap the whole record in single quotes to make sure all strings
- # are associated with the same TXT record (to make it one bash token for
- # gcloud)
- return '\'%s\'' % ' '.join(chunks)
-
-# Convert DNS records from their "within a test group" format
-# of the yaml file to an easier form for the templates to use.
-def _gcloud_uploadable_form(test_cases, common_zone_name):
- out = []
- for group in test_cases:
- if group['record_to_resolve'] in _TARGET_RECORDS_TO_SKIP_AGAINST_GCE:
- continue
- for record_name in group['records'].keys():
- r_ttl = None
- all_r_data = {}
- for r_data in group['records'][record_name]:
- # enforce records have the same TTL only for simplicity
- if r_ttl is None:
- r_ttl = r_data['TTL']
- assert r_ttl == r_data['TTL'], '%s and %s differ' % (r_ttl, r_data['TTL'])
- r_type = r_data['type']
- if all_r_data.get(r_type) is None:
- all_r_data[r_type] = []
- all_r_data[r_type].append(r_data['data'])
- for r_type in all_r_data.keys():
- for r in out:
- assert r['name'] != record_name or r['type'] != r_type, 'attempt to add a duplicate record'
- out.append({
- 'name': record_name,
- 'ttl': r_ttl,
- 'type': r_type,
- 'data': _data_for_type(r_type, all_r_data[r_type], common_zone_name)
- })
- return out
-
-def _gce_dns_zone_id(resolver_component_data):
- dns_name = resolver_component_data['resolver_tests_common_zone_name']
- return dns_name.replace('.', '-') + 'zone-id'
-
-def _resolver_test_cases(resolver_component_data, records_to_skip):
+def _resolver_test_cases(resolver_component_data):
out = []
for test_case in resolver_component_data['resolver_component_tests']:
- if test_case['record_to_resolve'] in records_to_skip:
- continue
target_name = _append_zone_name(
test_case['record_to_resolve'],
resolver_component_data['resolver_tests_common_zone_name'])
@@ -142,11 +59,7 @@ def main():
json = {
'resolver_tests_common_zone_name': resolver_component_data['resolver_tests_common_zone_name'],
- 'resolver_gce_integration_tests_zone_id': _gce_dns_zone_id(resolver_component_data),
- 'all_integration_test_records': _gcloud_uploadable_form(resolver_component_data['resolver_component_tests'],
- resolver_component_data['resolver_tests_common_zone_name']),
- 'resolver_gce_integration_test_cases': _resolver_test_cases(resolver_component_data, _TARGET_RECORDS_TO_SKIP_AGAINST_GCE),
- 'resolver_component_test_cases': _resolver_test_cases(resolver_component_data, []),
+ 'resolver_component_test_cases': _resolver_test_cases(resolver_component_data),
'targets': [
{
'name': 'resolver_component_test' + unsecure_build_config_suffix,
@@ -155,7 +68,7 @@ def main():
'gtest': False,
'run': False,
'src': ['test/cpp/naming/resolver_component_test.cc'],
- 'platforms': ['linux', 'posix', 'mac'],
+ 'platforms': ['linux', 'posix', 'mac', 'windows'],
'deps': [
'grpc++_test_util' + unsecure_build_config_suffix,
'grpc_test_util' + unsecure_build_config_suffix,
@@ -197,7 +110,7 @@ def main():
'gtest': True,
'run': True,
'src': ['test/cpp/naming/address_sorting_test.cc'],
- 'platforms': ['linux', 'posix', 'mac'],
+ 'platforms': ['linux', 'posix', 'mac', 'windows'],
'deps': [
'grpc++_test_util' + unsecure_build_config_suffix,
'grpc_test_util' + unsecure_build_config_suffix,
@@ -208,6 +121,25 @@ def main():
'grpc++_test_config',
],
} for unsecure_build_config_suffix in ['_unsecure', '']
+ ] + [
+ {
+ 'name': 'cancel_ares_query_test',
+ 'build': 'test',
+ 'language': 'c++',
+ 'gtest': True,
+ 'run': True,
+ 'src': ['test/cpp/naming/cancel_ares_query_test.cc'],
+ 'platforms': ['linux', 'posix', 'mac', 'windows'],
+ 'deps': [
+ 'grpc++_test_util',
+ 'grpc_test_util',
+ 'gpr_test_util',
+ 'grpc++',
+ 'grpc',
+ 'gpr',
+ 'grpc++_test_config',
+ ],
+ },
]
}
diff --git a/test/cpp/naming/manual_run_resolver_component_test.py b/test/cpp/naming/manual_run_resolver_component_test.py
new file mode 100644
index 0000000000..fb2157741a
--- /dev/null
+++ b/test/cpp/naming/manual_run_resolver_component_test.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# Copyright 2015 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.
+
+import os
+import subprocess
+import sys
+
+# The c-ares test suite doesn't get ran regularly on Windows, but
+# this script provides a way to run a lot of the tests manually.
+_MSBUILD_CONFIG = os.environ['CONFIG']
+os.chdir(os.path.join('..', '..', os.getcwd()))
+# This port is arbitrary, but it needs to be available.
+_DNS_SERVER_PORT = 15353
+
+subprocess.call([
+ sys.executable,
+ 'test\\cpp\\naming\\resolver_component_tests_runner.py',
+ '--test_bin_path', 'cmake\\build\\%s\\resolver_component_test.exe' % _MSBUILD_CONFIG,
+ '--dns_server_bin_path', 'test\\cpp\\naming\\utils\\dns_server.py',
+ '--records_config_path', 'test\\cpp\\naming\\resolver_test_record_groups.yaml',
+ '--dns_server_port', str(_DNS_SERVER_PORT),
+ '--dns_resolver_bin_path', 'test\\cpp\\naming\\utils\\dns_resolver.py',
+ '--tcp_connect_bin_path', 'test\\cpp\\naming\\utils\\tcp_connect.py',
+])
diff --git a/test/cpp/naming/private_dns_zone_init.sh b/test/cpp/naming/private_dns_zone_init.sh
deleted file mode 100755
index fba8a005cc..0000000000
--- a/test/cpp/naming/private_dns_zone_init.sh
+++ /dev/null
@@ -1,215 +0,0 @@
-#!/bin/bash
-# Copyright 2015 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.
-
-# This file is auto-generated
-
-set -ex
-
-cd "$(dirname "$0")/../../.."
-
-gcloud dns record-sets transaction start -z=resolver-tests-version-4-grpctestingexp-zone-id
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp. \
- --type=SRV \
- --ttl=2100 \
- "0 0 1234 ipv4-single-target.resolver-tests-version-4.grpctestingexp."
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv4-single-target.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.4"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp. \
- --type=SRV \
- --ttl=2100 \
- "0 0 1234 ipv4-multi-target.resolver-tests-version-4.grpctestingexp."
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv4-multi-target.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.5" "1.2.3.6" "1.2.3.7"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp. \
- --type=SRV \
- --ttl=2100 \
- "0 0 1234 ipv6-single-target.resolver-tests-version-4.grpctestingexp."
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv6-single-target.resolver-tests-version-4.grpctestingexp. \
- --type=AAAA \
- --ttl=2100 \
- "2607:f8b0:400a:801::1001"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp. \
- --type=SRV \
- --ttl=2100 \
- "0 0 1234 ipv6-multi-target.resolver-tests-version-4.grpctestingexp."
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv6-multi-target.resolver-tests-version-4.grpctestingexp. \
- --type=AAAA \
- --ttl=2100 \
- "2607:f8b0:400a:801::1002" "2607:f8b0:400a:801::1003" "2607:f8b0:400a:801::1004"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpc_config.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. \
- --type=TXT \
- --ttl=2100 \
- '"grpc_config=[{\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"SimpleService\",\"waitForReady\":true}]}]}}]"'
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. \
- --type=SRV \
- --ttl=2100 \
- "0 0 1234 ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp."
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.4"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.4"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpc_config.ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. \
- --type=TXT \
- --ttl=2100 \
- '"grpc_config=[{\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"NoSrvSimpleService\",\"waitForReady\":true}]}]}}]"'
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpc_config.ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. \
- --type=TXT \
- --ttl=2100 \
- '"grpc_config=[{\"clientLanguage\":[\"python\"],\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"PythonService\",\"waitForReady\":true}]}]}}]"'
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.4"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.4"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpc_config.ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. \
- --type=TXT \
- --ttl=2100 \
- '"grpc_config=[{\"percentage\":0,\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"CppService\",\"waitForReady\":true}]}]}}]"'
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpc_config.ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. \
- --type=TXT \
- --ttl=2100 \
- '"grpc_config=[{\"clientLanguage\":[\"go\"],\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"GoService\",\"waitForReady\":true}]}]}},{\"clientLanguage\":[\"c++\"],\"serviceConfig\":{" "\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"CppService\",\"waitForReady\":true}]}]}}]"'
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.4"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.4"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpc_config.ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. \
- --type=TXT \
- --ttl=2100 \
- '"grpc_config=[{\"percentage\":0,\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"NeverPickedService\",\"waitForReady\":true}]}]}},{\"percentage\":100,\"serviceConfig\":{\"loadBalanc" "ingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"AlwaysPickedService\",\"waitForReady\":true}]}]}}]"'
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
- --type=SRV \
- --ttl=2100 \
- "0 0 1234 balancer-for-ipv4-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp."
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=balancer-for-ipv4-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.4"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
- --type=A \
- --ttl=2100 \
- "1.2.3.4"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
- --type=SRV \
- --ttl=2100 \
- "0 0 1234 balancer-for-ipv6-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp."
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=balancer-for-ipv6-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
- --type=AAAA \
- --ttl=2100 \
- "2607:f8b0:400a:801::1002"
-
-gcloud dns record-sets transaction add \
- -z=resolver-tests-version-4-grpctestingexp-zone-id \
- --name=srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. \
- --type=AAAA \
- --ttl=2100 \
- "2607:f8b0:400a:801::1002"
-
-gcloud dns record-sets transaction describe -z=resolver-tests-version-4-grpctestingexp-zone-id
-gcloud dns record-sets transaction execute -z=resolver-tests-version-4-grpctestingexp-zone-id
-gcloud dns record-sets list -z=resolver-tests-version-4-grpctestingexp-zone-id
diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc
index f4be064305..3dc6e7178c 100644
--- a/test/cpp/naming/resolver_component_test.cc
+++ b/test/cpp/naming/resolver_component_test.cc
@@ -16,16 +16,22 @@
*
*/
+#include <grpc/support/port_platform.h>
+
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
+
#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
#include <gflags/gflags.h>
#include <gmock/gmock.h>
+#include <thread>
#include <vector>
#include "test/cpp/util/subprocess.h"
@@ -48,6 +54,19 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
+// TODO: pull in different headers when enabling this
+// test on windows. Also set BAD_SOCKET_RETURN_VAL
+// to INVALID_SOCKET on windows.
+#ifdef GPR_WINDOWS
+#include "src/core/lib/iomgr/sockaddr_windows.h"
+#include "src/core/lib/iomgr/socket_windows.h"
+#include "src/core/lib/iomgr/tcp_windows.h"
+#define BAD_SOCKET_RETURN_VAL INVALID_SOCKET
+#else
+#include "src/core/lib/iomgr/sockaddr_posix.h"
+#define BAD_SOCKET_RETURN_VAL -1
+#endif
+
using grpc::SubProcess;
using std::vector;
using testing::UnorderedElementsAreArray;
@@ -80,7 +99,7 @@ namespace {
class GrpcLBAddress final {
public:
GrpcLBAddress(std::string address, bool is_balancer)
- : is_balancer(is_balancer), address(address) {}
+ : is_balancer(is_balancer), address(std::move(address)) {}
bool operator==(const GrpcLBAddress& other) const {
return this->is_balancer == other.is_balancer &&
@@ -99,7 +118,7 @@ vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) {
std::vector<GrpcLBAddress> out;
while (expected_addrs.size() != 0) {
// get the next <ip>,<port> (v4 or v6)
- size_t next_comma = expected_addrs.find(",");
+ size_t next_comma = expected_addrs.find(',');
if (next_comma == std::string::npos) {
gpr_log(GPR_ERROR,
"Missing ','. Expected_addrs arg should be a semicolon-separated "
@@ -110,7 +129,7 @@ vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) {
std::string next_addr = expected_addrs.substr(0, next_comma);
expected_addrs = expected_addrs.substr(next_comma + 1, std::string::npos);
// get the next is_balancer 'bool' associated with this address
- size_t next_semicolon = expected_addrs.find(";");
+ size_t next_semicolon = expected_addrs.find(';');
bool is_balancer =
gpr_is_true(expected_addrs.substr(0, next_semicolon).c_str());
out.emplace_back(GrpcLBAddress(next_addr, is_balancer));
@@ -231,7 +250,136 @@ void CheckLBPolicyResultLocked(grpc_channel_args* channel_args,
}
}
+#ifdef GPR_WINDOWS
+void OpenAndCloseSocketsStressLoop(int dummy_port, gpr_event* done_ev) {
+ sockaddr_in6 addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.sin6_family = AF_INET6;
+ addr.sin6_port = htons(dummy_port);
+ ((char*)&addr.sin6_addr)[15] = 1;
+ for (;;) {
+ if (gpr_event_get(done_ev)) {
+ return;
+ }
+ std::vector<int> sockets;
+ for (size_t i = 0; i < 50; i++) {
+ SOCKET s = WSASocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP, nullptr, 0,
+ WSA_FLAG_OVERLAPPED);
+ ASSERT_TRUE(s != BAD_SOCKET_RETURN_VAL)
+ << "Failed to create TCP ipv6 socket";
+ gpr_log(GPR_DEBUG, "Opened socket: %d", s);
+ char val = 1;
+ ASSERT_TRUE(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) !=
+ SOCKET_ERROR)
+ << "Failed to set socketopt reuseaddr. WSA error: " +
+ std::to_string(WSAGetLastError());
+ ASSERT_TRUE(grpc_tcp_set_non_block(s) == GRPC_ERROR_NONE)
+ << "Failed to set socket non-blocking";
+ ASSERT_TRUE(bind(s, (const sockaddr*)&addr, sizeof(addr)) != SOCKET_ERROR)
+ << "Failed to bind socket " + std::to_string(s) +
+ " to [::1]:" + std::to_string(dummy_port) +
+ ". WSA error: " + std::to_string(WSAGetLastError());
+ ASSERT_TRUE(listen(s, 1) != SOCKET_ERROR)
+ << "Failed to listen on socket " + std::to_string(s) +
+ ". WSA error: " + std::to_string(WSAGetLastError());
+ sockets.push_back(s);
+ }
+ // Do a non-blocking accept followed by a close on all of those sockets.
+ // Do this in a separate loop to try to induce a time window to hit races.
+ for (size_t i = 0; i < sockets.size(); i++) {
+ gpr_log(GPR_DEBUG, "non-blocking accept then close on %d", sockets[i]);
+ ASSERT_TRUE(accept(sockets[i], nullptr, nullptr) == INVALID_SOCKET)
+ << "Accept on dummy socket unexpectedly accepted actual connection.";
+ ASSERT_TRUE(WSAGetLastError() == WSAEWOULDBLOCK)
+ << "OpenAndCloseSocketsStressLoop accept on socket " +
+ std::to_string(sockets[i]) +
+ " failed in "
+ "an unexpected way. "
+ "WSA error: " +
+ std::to_string(WSAGetLastError()) +
+ ". Socket use-after-close bugs are likely.";
+ ASSERT_TRUE(closesocket(sockets[i]) != SOCKET_ERROR)
+ << "Failed to close socket: " + std::to_string(sockets[i]) +
+ ". WSA error: " + std::to_string(WSAGetLastError());
+ }
+ }
+ return;
+}
+#else
+void OpenAndCloseSocketsStressLoop(int dummy_port, gpr_event* done_ev) {
+ // The goal of this loop is to catch socket
+ // "use after close" bugs within the c-ares resolver by acting
+ // like some separate thread doing I/O.
+ // It's goal is to try to hit race conditions whereby:
+ // 1) The c-ares resolver closes a socket.
+ // 2) This loop opens a socket with (coincidentally) the same handle.
+ // 3) the c-ares resolver mistakenly uses that same socket without
+ // realizing that its closed.
+ // 4) This loop performs an operation on that socket that should
+ // succeed but instead fails because of what the c-ares
+ // resolver did in the meantime.
+ sockaddr_in6 addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.sin6_family = AF_INET6;
+ addr.sin6_port = htons(dummy_port);
+ ((char*)&addr.sin6_addr)[15] = 1;
+ for (;;) {
+ if (gpr_event_get(done_ev)) {
+ return;
+ }
+ std::vector<int> sockets;
+ // First open a bunch of sockets, bind and listen
+ // '50' is an arbitrary number that, experimentally,
+ // has a good chance of catching bugs.
+ for (size_t i = 0; i < 50; i++) {
+ int s = socket(AF_INET6, SOCK_STREAM, 0);
+ int val = 1;
+ ASSERT_TRUE(setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val)) ==
+ 0)
+ << "Failed to set socketopt reuseport";
+ ASSERT_TRUE(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) ==
+ 0)
+ << "Failed to set socket reuseaddr";
+ ASSERT_TRUE(fcntl(s, F_SETFL, O_NONBLOCK) == 0)
+ << "Failed to set socket non-blocking";
+ ASSERT_TRUE(s != BAD_SOCKET_RETURN_VAL)
+ << "Failed to create TCP ipv6 socket";
+ gpr_log(GPR_DEBUG, "Opened fd: %d", s);
+ ASSERT_TRUE(bind(s, (const sockaddr*)&addr, sizeof(addr)) == 0)
+ << "Failed to bind socket " + std::to_string(s) +
+ " to [::1]:" + std::to_string(dummy_port) +
+ ". errno: " + std::to_string(errno);
+ ASSERT_TRUE(listen(s, 1) == 0) << "Failed to listen on socket " +
+ std::to_string(s) +
+ ". errno: " + std::to_string(errno);
+ sockets.push_back(s);
+ }
+ // Do a non-blocking accept followed by a close on all of those sockets.
+ // Do this in a separate loop to try to induce a time window to hit races.
+ for (size_t i = 0; i < sockets.size(); i++) {
+ gpr_log(GPR_DEBUG, "non-blocking accept then close on %d", sockets[i]);
+ if (accept(sockets[i], nullptr, nullptr)) {
+ // If e.g. a "shutdown" was called on this fd from another thread,
+ // then this accept call should fail with an unexpected error.
+ ASSERT_TRUE(errno == EAGAIN || errno == EWOULDBLOCK)
+ << "OpenAndCloseSocketsStressLoop accept on socket " +
+ std::to_string(sockets[i]) +
+ " failed in "
+ "an unexpected way. "
+ "errno: " +
+ std::to_string(errno) +
+ ". Socket use-after-close bugs are likely.";
+ }
+ ASSERT_TRUE(close(sockets[i]) == 0)
+ << "Failed to close socket: " + std::to_string(sockets[i]) +
+ ". errno: " + std::to_string(errno);
+ }
+ }
+}
+#endif
+
void CheckResolverResultLocked(void* argsp, grpc_error* err) {
+ EXPECT_EQ(err, GRPC_ERROR_NONE);
ArgsStruct* args = (ArgsStruct*)argsp;
grpc_channel_args* channel_args = args->channel_args;
const grpc_arg* channel_arg =
@@ -271,7 +419,17 @@ void CheckResolverResultLocked(void* argsp, grpc_error* err) {
gpr_mu_unlock(args->mu);
}
-TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
+void CheckResolvedWithoutErrorLocked(void* argsp, grpc_error* err) {
+ EXPECT_EQ(err, GRPC_ERROR_NONE);
+ ArgsStruct* args = (ArgsStruct*)argsp;
+ gpr_atm_rel_store(&args->done_atm, 1);
+ gpr_mu_lock(args->mu);
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
+ gpr_mu_unlock(args->mu);
+}
+
+void RunResolvesRelevantRecordsTest(void (*OnDoneLocked)(void* arg,
+ grpc_error* error)) {
grpc_core::ExecCtx exec_ctx;
ArgsStruct args;
ArgsInit(&args);
@@ -280,23 +438,41 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
args.expected_lb_policy = FLAGS_expected_lb_policy;
// maybe build the address with an authority
char* whole_uri = nullptr;
- GPR_ASSERT(asprintf(&whole_uri, "dns://%s/%s",
- FLAGS_local_dns_server_address.c_str(),
- FLAGS_target_name.c_str()));
+ GPR_ASSERT(gpr_asprintf(&whole_uri, "dns://%s/%s",
+ FLAGS_local_dns_server_address.c_str(),
+ FLAGS_target_name.c_str()));
// create resolver and resolve
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
grpc_core::ResolverRegistry::CreateResolver(whole_uri, nullptr,
args.pollset_set, args.lock);
gpr_free(whole_uri);
grpc_closure on_resolver_result_changed;
- GRPC_CLOSURE_INIT(&on_resolver_result_changed, CheckResolverResultLocked,
- (void*)&args, grpc_combiner_scheduler(args.lock));
+ GRPC_CLOSURE_INIT(&on_resolver_result_changed, OnDoneLocked, (void*)&args,
+ grpc_combiner_scheduler(args.lock));
resolver->NextLocked(&args.channel_args, &on_resolver_result_changed);
grpc_core::ExecCtx::Get()->Flush();
PollPollsetUntilRequestDone(&args);
ArgsFinish(&args);
}
+TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
+ RunResolvesRelevantRecordsTest(CheckResolverResultLocked);
+}
+
+TEST(ResolverComponentTest, TestResolvesRelevantRecordsWithConcurrentFdStress) {
+ // Start up background stress thread
+ int dummy_port = grpc_pick_unused_port_or_die();
+ gpr_event done_ev;
+ gpr_event_init(&done_ev);
+ std::thread socket_stress_thread(OpenAndCloseSocketsStressLoop, dummy_port,
+ &done_ev);
+ // Run the resolver test
+ RunResolvesRelevantRecordsTest(CheckResolvedWithoutErrorLocked);
+ // Shutdown and join stress thread
+ gpr_event_set(&done_ev, (void*)1);
+ socket_stress_thread.join();
+}
+
} // namespace
int main(int argc, char** argv) {
diff --git a/test/cpp/naming/resolver_component_tests_runner.py b/test/cpp/naming/resolver_component_tests_runner.py
index 69386ebeb0..1873eec35b 100755
--- a/test/cpp/naming/resolver_component_tests_runner.py
+++ b/test/cpp/naming/resolver_component_tests_runner.py
@@ -22,6 +22,7 @@ import tempfile
import os
import time
import signal
+import platform
argp = argparse.ArgumentParser(description='Run c-ares resolver tests')
@@ -43,6 +44,11 @@ args = argp.parse_args()
def test_runner_log(msg):
sys.stderr.write('\n%s: %s\n' % (__file__, msg))
+def python_args(arg_list):
+ if platform.system() == 'Windows':
+ return [sys.executable] + arg_list
+ return arg_list
+
cur_resolver = os.environ.get('GRPC_DNS_RESOLVER')
if cur_resolver and cur_resolver != 'ares':
test_runner_log(('WARNING: cur resolver set to %s. This set of tests '
@@ -50,26 +56,27 @@ if cur_resolver and cur_resolver != 'ares':
test_runner_log('Exit 1 without running tests.')
sys.exit(1)
os.environ.update({'GRPC_DNS_RESOLVER': 'ares'})
+os.environ.update({'GRPC_TRACE': 'cares_resolver'})
def wait_until_dns_server_is_up(args,
dns_server_subprocess,
dns_server_subprocess_output):
for i in range(0, 30):
test_runner_log('Health check: attempt to connect to DNS server over TCP.')
- tcp_connect_subprocess = subprocess.Popen([
+ tcp_connect_subprocess = subprocess.Popen(python_args([
args.tcp_connect_bin_path,
'--server_host', '127.0.0.1',
'--server_port', str(args.dns_server_port),
- '--timeout', str(1)])
+ '--timeout', str(1)]))
tcp_connect_subprocess.communicate()
if tcp_connect_subprocess.returncode == 0:
test_runner_log(('Health check: attempt to make an A-record '
'query to DNS server.'))
- dns_resolver_subprocess = subprocess.Popen([
+ dns_resolver_subprocess = subprocess.Popen(python_args([
args.dns_resolver_bin_path,
'--qname', 'health-check-local-dns-server-is-alive.resolver-tests.grpctestingexp',
'--server_host', '127.0.0.1',
- '--server_port', str(args.dns_server_port)],
+ '--server_port', str(args.dns_server_port)]),
stdout=subprocess.PIPE)
dns_resolver_stdout, _ = dns_resolver_subprocess.communicate()
if dns_resolver_subprocess.returncode == 0:
@@ -91,10 +98,10 @@ def wait_until_dns_server_is_up(args,
dns_server_subprocess_output = tempfile.mktemp()
with open(dns_server_subprocess_output, 'w') as l:
- dns_server_subprocess = subprocess.Popen([
+ dns_server_subprocess = subprocess.Popen(python_args([
args.dns_server_bin_path,
'--port', str(args.dns_server_port),
- '--records_config_path', args.records_config_path],
+ '--records_config_path', args.records_config_path]),
stdin=subprocess.PIPE,
stdout=l,
stderr=l)
@@ -112,6 +119,18 @@ wait_until_dns_server_is_up(args,
dns_server_subprocess_output)
num_test_failures = 0
+test_runner_log('Run test with target: %s' % 'no-srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.')
+current_test_subprocess = subprocess.Popen([
+ args.test_bin_path,
+ '--target_name', 'no-srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.',
+ '--expected_addrs', '5.5.5.5:443,False',
+ '--expected_chosen_service_config', '',
+ '--expected_lb_policy', '',
+ '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port])
+current_test_subprocess.communicate()
+if current_test_subprocess.returncode != 0:
+ num_test_failures += 1
+
test_runner_log('Run test with target: %s' % 'srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.')
current_test_subprocess = subprocess.Popen([
args.test_bin_path,
diff --git a/test/cpp/naming/resolver_component_tests_runner_invoker.cc b/test/cpp/naming/resolver_component_tests_runner_invoker.cc
index 45c1029caa..68be00a67d 100644
--- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc
+++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc
@@ -99,21 +99,21 @@ namespace grpc {
namespace testing {
-void InvokeResolverComponentTestsRunner(std::string test_runner_bin_path,
- std::string test_bin_path,
- std::string dns_server_bin_path,
- std::string records_config_path,
- std::string dns_resolver_bin_path,
- std::string tcp_connect_bin_path) {
+void InvokeResolverComponentTestsRunner(
+ std::string test_runner_bin_path, const std::string& test_bin_path,
+ const std::string& dns_server_bin_path,
+ const std::string& records_config_path,
+ const std::string& dns_resolver_bin_path,
+ const std::string& tcp_connect_bin_path) {
int dns_server_port = grpc_pick_unused_port_or_die();
- SubProcess* test_driver =
- new SubProcess({test_runner_bin_path, "--test_bin_path=" + test_bin_path,
- "--dns_server_bin_path=" + dns_server_bin_path,
- "--records_config_path=" + records_config_path,
- "--dns_server_port=" + std::to_string(dns_server_port),
- "--dns_resolver_bin_path=" + dns_resolver_bin_path,
- "--tcp_connect_bin_path=" + tcp_connect_bin_path});
+ SubProcess* test_driver = new SubProcess(
+ {std::move(test_runner_bin_path), "--test_bin_path=" + test_bin_path,
+ "--dns_server_bin_path=" + dns_server_bin_path,
+ "--records_config_path=" + records_config_path,
+ "--dns_server_port=" + std::to_string(dns_server_port),
+ "--dns_resolver_bin_path=" + dns_resolver_bin_path,
+ "--tcp_connect_bin_path=" + tcp_connect_bin_path});
gpr_mu test_driver_mu;
gpr_mu_init(&test_driver_mu);
gpr_cv test_driver_cv;
diff --git a/test/cpp/naming/resolver_gce_integration_tests_runner.sh b/test/cpp/naming/resolver_gce_integration_tests_runner.sh
deleted file mode 100755
index 2f673a59fd..0000000000
--- a/test/cpp/naming/resolver_gce_integration_tests_runner.sh
+++ /dev/null
@@ -1,359 +0,0 @@
-#!/bin/bash
-# Copyright 2015 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.
-
-# This file is auto-generated
-
-set -ex
-
-if [[ "$GRPC_DNS_RESOLVER" == "" ]]; then
- export GRPC_DNS_RESOLVER=ares
-elif [[ "$GRPC_DNS_RESOLVER" != ares ]]; then
- echo "Unexpected: GRPC_DNS_RESOLVER=$GRPC_DNS_RESOLVER. This test only works with c-ares resolver"
- exit 1
-fi
-
-cd "$(dirname "$0")/../../.."
-
-if [[ "$CONFIG" == "" ]]; then
- export CONFIG=opt
-fi
-make resolver_component_test
-echo "Sanity check DNS records are resolveable with dig:"
-EXIT_CODE=0
-
-ONE_FAILED=0
-dig SRV _grpclb._tcp.srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A ipv4-single-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A ipv4-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig SRV _grpclb._tcp.srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A ipv4-multi-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A ipv4-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig SRV _grpclb._tcp.srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig AAAA ipv6-single-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig AAAA ipv6-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig SRV _grpclb._tcp.srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig AAAA ipv6-multi-target.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig AAAA ipv6-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig TXT _grpc_config.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig TXT _grpc_config.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig SRV _grpclb._tcp.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig TXT _grpc_config.ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig TXT _grpc_config.ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig TXT _grpc_config.ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig TXT _grpc_config.ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig TXT _grpc_config.ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig TXT _grpc_config.ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig TXT _grpc_config.ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig TXT _grpc_config.ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig TXT _grpc_config.ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig TXT _grpc_config.ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig SRV _grpclb._tcp.srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A balancer-for-ipv4-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A balancer-for-ipv4-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig A srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig A srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig SRV _grpclb._tcp.srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig SRV _grpclb._tcp.srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig AAAA balancer-for-ipv6-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig AAAA balancer-for-ipv6-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-ONE_FAILED=0
-dig AAAA srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Sanity check: dig AAAA srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
- exit 1
-fi
-
-echo "Sanity check PASSED. Run resolver tests:"
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='1.2.3.4:1234,True' \
- --expected_chosen_service_config='' \
- --expected_lb_policy='' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='1.2.3.5:1234,True;1.2.3.6:1234,True;1.2.3.7:1234,True' \
- --expected_chosen_service_config='' \
- --expected_lb_policy='' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='[2607:f8b0:400a:801::1001]:1234,True' \
- --expected_chosen_service_config='' \
- --expected_lb_policy='' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1003]:1234,True;[2607:f8b0:400a:801::1004]:1234,True' \
- --expected_chosen_service_config='' \
- --expected_lb_policy='' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='1.2.3.4:1234,True' \
- --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}' \
- --expected_lb_policy='round_robin' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='1.2.3.4:443,False' \
- --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService","waitForReady":true}]}]}' \
- --expected_lb_policy='round_robin' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='1.2.3.4:443,False' \
- --expected_chosen_service_config='' \
- --expected_lb_policy='' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='1.2.3.4:443,False' \
- --expected_chosen_service_config='' \
- --expected_lb_policy='' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='1.2.3.4:443,False' \
- --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}' \
- --expected_lb_policy='round_robin' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='1.2.3.4:443,False' \
- --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService","waitForReady":true}]}]}' \
- --expected_lb_policy='round_robin' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='1.2.3.4:1234,True;1.2.3.4:443,False' \
- --expected_chosen_service_config='' \
- --expected_lb_policy='' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-ONE_FAILED=0
-bins/$CONFIG/resolver_component_test \
- --target_name='srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.' \
- --expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1002]:443,False' \
- --expected_chosen_service_config='' \
- --expected_lb_policy='' || ONE_FAILED=1
-if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
- EXIT_CODE=1
-fi
-
-exit $EXIT_CODE
diff --git a/test/cpp/naming/resolver_test_record_groups.yaml b/test/cpp/naming/resolver_test_record_groups.yaml
index 6c4f89d09b..3c51a00c7b 100644
--- a/test/cpp/naming/resolver_test_record_groups.yaml
+++ b/test/cpp/naming/resolver_test_record_groups.yaml
@@ -1,6 +1,14 @@
resolver_tests_common_zone_name: resolver-tests-version-4.grpctestingexp.
resolver_component_tests:
- expected_addrs:
+ - {address: '5.5.5.5:443', is_balancer: false}
+ expected_chosen_service_config: null
+ expected_lb_policy: null
+ record_to_resolve: no-srv-ipv4-single-target
+ records:
+ no-srv-ipv4-single-target:
+ - {TTL: '2100', data: 5.5.5.5, type: A}
+- expected_addrs:
- {address: '1.2.3.4:1234', is_balancer: true}
expected_chosen_service_config: null
expected_lb_policy: null
diff --git a/test/cpp/qps/BUILD b/test/cpp/qps/BUILD
index a348b88079..483b29b1b3 100644
--- a/test/cpp/qps/BUILD
+++ b/test/cpp/qps/BUILD
@@ -15,6 +15,7 @@
licenses(["notice"]) # Apache v2
load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_cc_library", "grpc_cc_binary", "grpc_package")
+load("//test/cpp/qps:qps_benchmark_script.bzl", "qps_json_driver_batch", "json_run_localhost_batch")
grpc_package(name = "test/cpp/qps")
@@ -22,8 +23,8 @@ grpc_cc_library(
name = "parse_json",
srcs = ["parse_json.cc"],
hdrs = ["parse_json.h"],
- deps = ["//:grpc++"],
external_deps = ["protobuf"],
+ deps = ["//:grpc++"],
)
grpc_cc_library(
@@ -31,15 +32,20 @@ grpc_cc_library(
srcs = [
"client_async.cc",
"client_sync.cc",
+ "qps_server_builder.cc",
"qps_worker.cc",
"server_async.cc",
"server_sync.cc",
],
hdrs = [
"client.h",
+ "qps_server_builder.h",
"qps_worker.h",
"server.h",
],
+ external_deps = [
+ "gflags",
+ ],
deps = [
":histogram",
":interarrival",
@@ -54,6 +60,7 @@ grpc_cc_library(
"//test/core/end2end:ssl_test_data",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_config",
"//test/cpp/util:test_util",
],
)
@@ -91,15 +98,15 @@ grpc_cc_library(
hdrs = [
"benchmark_config.h",
],
+ external_deps = [
+ "gflags",
+ ],
deps = [
":driver_impl",
":histogram",
"//:grpc++",
"//src/proto/grpc/testing:control_proto",
],
- external_deps = [
- "gflags",
- ],
)
grpc_cc_library(
@@ -111,6 +118,21 @@ grpc_cc_library(
deps = ["//test/core/util:grpc_test_util"],
)
+grpc_cc_binary(
+ name = "qps_json_driver",
+ srcs = ["qps_json_driver.cc"],
+ external_deps = [
+ "gflags",
+ ],
+ deps = [
+ ":benchmark_config",
+ ":driver_impl",
+ "//:grpc++",
+ "//test/cpp/util:test_config",
+ "//test/cpp/util:test_util",
+ ],
+)
+
grpc_cc_test(
name = "inproc_sync_unary_ping_pong_test",
srcs = ["inproc_sync_unary_ping_pong_test.cc"],
@@ -129,17 +151,9 @@ grpc_cc_library(
deps = ["//:grpc++"],
)
-grpc_cc_binary(
- name = "json_run_localhost",
- srcs = ["json_run_localhost.cc"],
- deps = [
- "//:gpr",
- "//test/core/util:gpr_test_util",
- "//test/core/util:grpc_test_util",
- "//test/cpp/util:test_config",
- "//test/cpp/util:test_util",
- ],
-)
+qps_json_driver_batch()
+
+json_run_localhost_batch()
grpc_cc_test(
name = "qps_interarrival_test",
@@ -151,24 +165,10 @@ grpc_cc_test(
],
)
-grpc_cc_binary(
- name = "qps_json_driver",
- srcs = ["qps_json_driver.cc"],
- deps = [
- ":benchmark_config",
- ":driver_impl",
- "//:grpc++",
- "//test/cpp/util:test_config",
- "//test/cpp/util:test_util",
- ],
- external_deps = [
- "gflags",
- ],
-)
-
grpc_cc_test(
name = "qps_openloop_test",
srcs = ["qps_openloop_test.cc"],
+ data = ["//third_party/toolchains:RBE_USE_MACHINE_TYPE_LARGE"],
deps = [
":benchmark_config",
":driver_impl",
diff --git a/test/cpp/qps/benchmark_config.cc b/test/cpp/qps/benchmark_config.cc
index a4fd9de820..5fd0f00038 100644
--- a/test/cpp/qps/benchmark_config.cc
+++ b/test/cpp/qps/benchmark_config.cc
@@ -22,6 +22,8 @@
#include <grpcpp/create_channel.h>
#include <grpcpp/security/credentials.h>
+#include "test/cpp/util/test_credentials_provider.h"
+
DEFINE_bool(enable_log_reporter, true,
"Enable reporting of benchmark results through GprLog");
@@ -44,6 +46,10 @@ DEFINE_string(rpc_reporter_server_address, "",
DEFINE_bool(enable_rpc_reporter, false, "Enable use of RPC reporter");
+DEFINE_string(
+ rpc_reporter_credential_type, grpc::testing::kInsecureCredentialsType,
+ "Credential type for communication to the QPS benchmark report server");
+
// In some distros, gflags is in the namespace google, and in some others,
// in gflags. This hack is enabling us to find both.
namespace google {}
@@ -65,11 +71,14 @@ static std::shared_ptr<Reporter> InitBenchmarkReporters() {
new JsonReporter("JsonReporter", FLAGS_scenario_result_file)));
}
if (FLAGS_enable_rpc_reporter) {
+ ChannelArguments channel_args;
+ std::shared_ptr<ChannelCredentials> channel_creds =
+ testing::GetCredentialsProvider()->GetChannelCredentials(
+ FLAGS_rpc_reporter_credential_type, &channel_args);
GPR_ASSERT(!FLAGS_rpc_reporter_server_address.empty());
composite_reporter->add(std::unique_ptr<Reporter>(new RpcReporter(
- "RpcReporter",
- grpc::CreateChannel(FLAGS_rpc_reporter_server_address,
- grpc::InsecureChannelCredentials()))));
+ "RpcReporter", grpc::CreateChannel(FLAGS_rpc_reporter_server_address,
+ channel_creds))));
}
return std::shared_ptr<Reporter>(composite_reporter);
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index 31ae6ca1fb..0b4b2ff0a9 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -19,6 +19,8 @@
#ifndef TEST_QPS_CLIENT_H
#define TEST_QPS_CLIENT_H
+#include <stdlib.h>
+
#include <condition_variable>
#include <mutex>
#include <unordered_map>
@@ -34,6 +36,7 @@
#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
#include "src/proto/grpc/testing/payloads.pb.h"
+#include "src/core/lib/gpr/env.h"
#include "src/cpp/util/core_stats.h"
#include "test/cpp/qps/histogram.h"
#include "test/cpp/qps/interarrival.h"
@@ -177,6 +180,19 @@ class Client {
timer_result = timer_->Mark();
}
+ // Print the median latency per interval for one thread.
+ // If the number of warmup seconds is x, then the first x + 1 numbers in the
+ // vector are from the warmup period and should be discarded.
+ if (median_latency_collection_interval_seconds_ > 0) {
+ std::vector<double> medians_per_interval =
+ threads_[0]->GetMedianPerIntervalList();
+ gpr_log(GPR_INFO, "Num threads: %ld", threads_.size());
+ gpr_log(GPR_INFO, "Number of medians: %ld", medians_per_interval.size());
+ for (size_t j = 0; j < medians_per_interval.size(); j++) {
+ gpr_log(GPR_INFO, "%f", medians_per_interval[j]);
+ }
+ }
+
grpc_stats_data core_stats;
grpc_stats_collect(&core_stats);
@@ -207,6 +223,12 @@ class Client {
}
}
+ // Returns the interval (in seconds) between collecting latency medians. If 0,
+ // no periodic median latencies will be collected.
+ double GetLatencyCollectionIntervalInSeconds() {
+ return median_latency_collection_interval_seconds_;
+ }
+
virtual int GetPollCount() {
// For sync client.
return 0;
@@ -215,6 +237,7 @@ class Client {
protected:
bool closed_loop_;
gpr_atm thread_pool_done_;
+ double median_latency_collection_interval_seconds_; // In seconds
void StartThreads(size_t num_threads) {
gpr_atm_rel_store(&thread_pool_done_, static_cast<gpr_atm>(false));
@@ -296,10 +319,27 @@ class Client {
MergeStatusHistogram(statuses_, s);
}
+ std::vector<double> GetMedianPerIntervalList() {
+ return medians_each_interval_list_;
+ }
+
void UpdateHistogram(HistogramEntry* entry) {
std::lock_guard<std::mutex> g(mu_);
if (entry->value_used()) {
histogram_.Add(entry->value());
+ if (client_->GetLatencyCollectionIntervalInSeconds() > 0) {
+ histogram_per_interval_.Add(entry->value());
+ double now = UsageTimer::Now();
+ if ((now - interval_start_time_) >=
+ client_->GetLatencyCollectionIntervalInSeconds()) {
+ // Record the median latency of requests from the last interval.
+ // Divide by 1e3 to get microseconds.
+ medians_each_interval_list_.push_back(
+ histogram_per_interval_.Percentile(50) / 1e3);
+ histogram_per_interval_.Reset();
+ interval_start_time_ = now;
+ }
+ }
}
if (entry->status_used()) {
statuses_[entry->status()]++;
@@ -331,6 +371,11 @@ class Client {
Client* client_;
const size_t idx_;
std::thread impl_;
+ // The following are used only if
+ // median_latency_collection_interval_seconds_ is greater than 0
+ Histogram histogram_per_interval_;
+ std::vector<double> medians_each_interval_list_;
+ double interval_start_time_;
};
bool ThreadCompleted() {
@@ -389,7 +434,8 @@ class ClientImpl : public Client {
for (auto& t : connecting_threads) {
t->join();
}
-
+ median_latency_collection_interval_seconds_ =
+ config.median_latency_collection_interval_millis() / 1e3;
ClientRequestCreator<RequestType> create_req(&request_,
config.payload_config());
}
@@ -441,16 +487,31 @@ class ClientImpl : public Client {
std::unique_ptr<std::thread> WaitForReady() {
return std::unique_ptr<std::thread>(new std::thread([this]() {
if (!is_inproc_) {
- GPR_ASSERT(channel_->WaitForConnected(
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_seconds(10, GPR_TIMESPAN))));
+ int connect_deadline = 10;
+ /* Allow optionally overriding connect_deadline in order
+ * to deal with benchmark environments in which the server
+ * can take a long time to become ready. */
+ char* channel_connect_timeout_str =
+ gpr_getenv("QPS_WORKER_CHANNEL_CONNECT_TIMEOUT");
+ if (channel_connect_timeout_str != nullptr &&
+ strcmp(channel_connect_timeout_str, "") != 0) {
+ connect_deadline = atoi(channel_connect_timeout_str);
+ }
+ gpr_log(GPR_INFO,
+ "Waiting for up to %d seconds for the channel %p to connect",
+ connect_deadline, channel_.get());
+ gpr_free(channel_connect_timeout_str);
+ GPR_ASSERT(channel_->WaitForConnected(gpr_time_add(
+ gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_seconds(connect_deadline, GPR_TIMESPAN))));
+ gpr_log(GPR_INFO, "Channel %p connected!", channel_.get());
}
}));
}
private:
void set_channel_args(const ClientConfig& config, ChannelArguments* args) {
- for (auto channel_arg : config.channel_args()) {
+ for (const auto& channel_arg : config.channel_args()) {
if (channel_arg.value_case() == ChannelArg::kStrValue) {
args->SetString(channel_arg.name(), channel_arg.str_value());
} else if (channel_arg.value_case() == ChannelArg::kIntValue) {
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index c79a10d1b4..bad24cf04a 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -24,6 +24,7 @@
#include <sstream>
#include <string>
#include <thread>
+#include <utility>
#include <vector>
#include <grpc/grpc.h>
@@ -78,7 +79,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
response_(),
next_state_(State::READY),
callback_(on_done),
- next_issue_(next_issue),
+ next_issue_(std::move(next_issue)),
prepare_req_(prepare_req) {}
~ClientRpcContextUnaryImpl() override {}
void Start(CompletionQueue* cq, const ClientConfig& config) override {
@@ -298,7 +299,7 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
};
static std::unique_ptr<BenchmarkService::Stub> BenchmarkStubCreator(
- std::shared_ptr<Channel> ch) {
+ const std::shared_ptr<Channel>& ch) {
return BenchmarkService::NewStub(ch);
}
@@ -313,7 +314,7 @@ class AsyncUnaryClient final
~AsyncUnaryClient() override {}
private:
- static void CheckDone(grpc::Status s, SimpleResponse* response,
+ static void CheckDone(const grpc::Status& s, SimpleResponse* response,
HistogramEntry* entry) {
entry->set_status(s.error_code());
}
@@ -326,7 +327,7 @@ class AsyncUnaryClient final
std::function<gpr_timespec()> next_issue,
const SimpleRequest& req) {
return new ClientRpcContextUnaryImpl<SimpleRequest, SimpleResponse>(
- stub, req, next_issue, AsyncUnaryClient::PrepareReq,
+ stub, req, std::move(next_issue), AsyncUnaryClient::PrepareReq,
AsyncUnaryClient::CheckDone);
}
};
@@ -349,7 +350,7 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext {
response_(),
next_state_(State::INVALID),
callback_(on_done),
- next_issue_(next_issue),
+ next_issue_(std::move(next_issue)),
prepare_req_(prepare_req),
coalesce_(false) {}
~ClientRpcContextStreamingPingPongImpl() override {}
@@ -497,7 +498,7 @@ class AsyncStreamingPingPongClient final
~AsyncStreamingPingPongClient() override {}
private:
- static void CheckDone(grpc::Status s, SimpleResponse* response) {}
+ static void CheckDone(const grpc::Status& s, SimpleResponse* response) {}
static std::unique_ptr<
grpc::ClientAsyncReaderWriter<SimpleRequest, SimpleResponse>>
PrepareReq(BenchmarkService::Stub* stub, grpc::ClientContext* ctx,
@@ -510,7 +511,8 @@ class AsyncStreamingPingPongClient final
const SimpleRequest& req) {
return new ClientRpcContextStreamingPingPongImpl<SimpleRequest,
SimpleResponse>(
- stub, req, next_issue, AsyncStreamingPingPongClient::PrepareReq,
+ stub, req, std::move(next_issue),
+ AsyncStreamingPingPongClient::PrepareReq,
AsyncStreamingPingPongClient::CheckDone);
}
};
@@ -533,7 +535,7 @@ class ClientRpcContextStreamingFromClientImpl : public ClientRpcContext {
response_(),
next_state_(State::INVALID),
callback_(on_done),
- next_issue_(next_issue),
+ next_issue_(std::move(next_issue)),
prepare_req_(prepare_req) {}
~ClientRpcContextStreamingFromClientImpl() override {}
void Start(CompletionQueue* cq, const ClientConfig& config) override {
@@ -628,7 +630,7 @@ class AsyncStreamingFromClientClient final
~AsyncStreamingFromClientClient() override {}
private:
- static void CheckDone(grpc::Status s, SimpleResponse* response) {}
+ static void CheckDone(const grpc::Status& s, SimpleResponse* response) {}
static std::unique_ptr<grpc::ClientAsyncWriter<SimpleRequest>> PrepareReq(
BenchmarkService::Stub* stub, grpc::ClientContext* ctx,
SimpleResponse* resp, CompletionQueue* cq) {
@@ -640,7 +642,8 @@ class AsyncStreamingFromClientClient final
const SimpleRequest& req) {
return new ClientRpcContextStreamingFromClientImpl<SimpleRequest,
SimpleResponse>(
- stub, req, next_issue, AsyncStreamingFromClientClient::PrepareReq,
+ stub, req, std::move(next_issue),
+ AsyncStreamingFromClientClient::PrepareReq,
AsyncStreamingFromClientClient::CheckDone);
}
};
@@ -663,7 +666,7 @@ class ClientRpcContextStreamingFromServerImpl : public ClientRpcContext {
response_(),
next_state_(State::INVALID),
callback_(on_done),
- next_issue_(next_issue),
+ next_issue_(std::move(next_issue)),
prepare_req_(prepare_req) {}
~ClientRpcContextStreamingFromServerImpl() override {}
void Start(CompletionQueue* cq, const ClientConfig& config) override {
@@ -742,7 +745,7 @@ class AsyncStreamingFromServerClient final
~AsyncStreamingFromServerClient() override {}
private:
- static void CheckDone(grpc::Status s, SimpleResponse* response) {}
+ static void CheckDone(const grpc::Status& s, SimpleResponse* response) {}
static std::unique_ptr<grpc::ClientAsyncReader<SimpleResponse>> PrepareReq(
BenchmarkService::Stub* stub, grpc::ClientContext* ctx,
const SimpleRequest& req, CompletionQueue* cq) {
@@ -754,7 +757,8 @@ class AsyncStreamingFromServerClient final
const SimpleRequest& req) {
return new ClientRpcContextStreamingFromServerImpl<SimpleRequest,
SimpleResponse>(
- stub, req, next_issue, AsyncStreamingFromServerClient::PrepareReq,
+ stub, req, std::move(next_issue),
+ AsyncStreamingFromServerClient::PrepareReq,
AsyncStreamingFromServerClient::CheckDone);
}
};
@@ -775,9 +779,9 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext {
req_(req),
response_(),
next_state_(State::INVALID),
- callback_(on_done),
- next_issue_(next_issue),
- prepare_req_(prepare_req) {}
+ callback_(std::move(on_done)),
+ next_issue_(std::move(next_issue)),
+ prepare_req_(std::move(prepare_req)) {}
~ClientRpcContextGenericStreamingImpl() override {}
void Start(CompletionQueue* cq, const ClientConfig& config) override {
GPR_ASSERT(!config.use_coalesce_api()); // not supported yet.
@@ -891,7 +895,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext {
};
static std::unique_ptr<grpc::GenericStub> GenericStubCreator(
- std::shared_ptr<Channel> ch) {
+ const std::shared_ptr<Channel>& ch) {
return std::unique_ptr<grpc::GenericStub>(new grpc::GenericStub(ch));
}
@@ -907,7 +911,7 @@ class GenericAsyncStreamingClient final
~GenericAsyncStreamingClient() override {}
private:
- static void CheckDone(grpc::Status s, ByteBuffer* response) {}
+ static void CheckDone(const grpc::Status& s, ByteBuffer* response) {}
static std::unique_ptr<grpc::GenericClientAsyncReaderWriter> PrepareReq(
grpc::GenericStub* stub, grpc::ClientContext* ctx,
const grpc::string& method_name, CompletionQueue* cq) {
@@ -918,7 +922,8 @@ class GenericAsyncStreamingClient final
std::function<gpr_timespec()> next_issue,
const ByteBuffer& req) {
return new ClientRpcContextGenericStreamingImpl(
- stub, req, next_issue, GenericAsyncStreamingClient::PrepareReq,
+ stub, req, std::move(next_issue),
+ GenericAsyncStreamingClient::PrepareReq,
GenericAsyncStreamingClient::CheckDone);
}
};
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index e65e3b43f3..668d9abf5c 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -44,7 +44,7 @@ namespace grpc {
namespace testing {
static std::unique_ptr<BenchmarkService::Stub> BenchmarkStubCreator(
- std::shared_ptr<Channel> ch) {
+ const std::shared_ptr<Channel>& ch) {
return BenchmarkService::NewStub(ch);
}
@@ -192,7 +192,7 @@ class SynchronousStreamingClient : public SynchronousClient {
new (&context_[thread_idx]) ClientContext();
}
- void CleanupAllStreams(std::function<void(size_t)> cleaner) {
+ void CleanupAllStreams(const std::function<void(size_t)>& cleaner) {
std::vector<std::thread> cleanup_threads;
for (size_t i = 0; i < num_threads_; i++) {
cleanup_threads.emplace_back([this, i, cleaner] {
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index 34f1291576..11cfb4aa05 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -96,16 +96,20 @@ static deque<string> get_workers(const string& env_name) {
}
// helpers for postprocess_scenario_result
-static double WallTime(ClientStats s) { return s.time_elapsed(); }
-static double SystemTime(ClientStats s) { return s.time_system(); }
-static double UserTime(ClientStats s) { return s.time_user(); }
-static double CliPollCount(ClientStats s) { return s.cq_poll_count(); }
-static double SvrPollCount(ServerStats s) { return s.cq_poll_count(); }
-static double ServerWallTime(ServerStats s) { return s.time_elapsed(); }
-static double ServerSystemTime(ServerStats s) { return s.time_system(); }
-static double ServerUserTime(ServerStats s) { return s.time_user(); }
-static double ServerTotalCpuTime(ServerStats s) { return s.total_cpu_time(); }
-static double ServerIdleCpuTime(ServerStats s) { return s.idle_cpu_time(); }
+static double WallTime(const ClientStats& s) { return s.time_elapsed(); }
+static double SystemTime(const ClientStats& s) { return s.time_system(); }
+static double UserTime(const ClientStats& s) { return s.time_user(); }
+static double CliPollCount(const ClientStats& s) { return s.cq_poll_count(); }
+static double SvrPollCount(const ServerStats& s) { return s.cq_poll_count(); }
+static double ServerWallTime(const ServerStats& s) { return s.time_elapsed(); }
+static double ServerSystemTime(const ServerStats& s) { return s.time_system(); }
+static double ServerUserTime(const ServerStats& s) { return s.time_user(); }
+static double ServerTotalCpuTime(const ServerStats& s) {
+ return s.total_cpu_time();
+}
+static double ServerIdleCpuTime(const ServerStats& s) {
+ return s.idle_cpu_time();
+}
static int Cores(int n) { return n; }
// Postprocess ScenarioResult and populate result summary.
@@ -156,7 +160,7 @@ static void postprocess_scenario_result(ScenarioResult* result) {
int64_t successes = 0;
int64_t failures = 0;
for (int i = 0; i < result->request_results_size(); i++) {
- RequestResultCount rrc = result->request_results(i);
+ const RequestResultCount& rrc = result->request_results(i);
if (rrc.status_code() == 0) {
successes += rrc.count();
} else {
@@ -194,7 +198,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
const ServerConfig& initial_server_config, size_t num_servers,
int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count,
const grpc::string& qps_server_target_override,
- const grpc::string& credential_type, bool run_inproc) {
+ const grpc::string& credential_type, bool run_inproc,
+ int32_t median_latency_collection_interval_millis) {
if (run_inproc) {
g_inproc_servers = new std::vector<grpc::testing::Server*>;
}
@@ -213,7 +218,6 @@ std::unique_ptr<ScenarioResult> RunScenario(
// To be added to the result, containing the final configuration used for
// client and config (including host, etc.)
ClientConfig result_client_config;
- const ServerConfig result_server_config = initial_server_config;
// Get client, server lists; ignore if inproc test
auto workers = (!run_inproc) ? get_workers("QPS_WORKERS") : deque<string>();
@@ -280,7 +284,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
local_workers[i]->InProcessChannel(channel_args));
}
- ServerConfig server_config = initial_server_config;
+ const ServerConfig& server_config = initial_server_config;
if (server_config.core_limit() != 0) {
gpr_log(GPR_ERROR,
"server config core limit is set but ignored by driver");
@@ -314,6 +318,9 @@ std::unique_ptr<ScenarioResult> RunScenario(
}
}
+ client_config.set_median_latency_collection_interval_millis(
+ median_latency_collection_interval_millis);
+
// Targets are all set by now
result_client_config = client_config;
// Start clients
diff --git a/test/cpp/qps/driver.h b/test/cpp/qps/driver.h
index fede4d8045..cda89f7ddf 100644
--- a/test/cpp/qps/driver.h
+++ b/test/cpp/qps/driver.h
@@ -32,7 +32,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
const grpc::testing::ServerConfig& server_config, size_t num_servers,
int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count,
const grpc::string& qps_server_target_override,
- const grpc::string& credential_type, bool run_inproc);
+ const grpc::string& credential_type, bool run_inproc,
+ int32_t median_latency_collection_interval_millis);
bool RunQuit(const grpc::string& credential_type);
} // namespace testing
diff --git a/test/cpp/qps/gen_build_yaml.py b/test/cpp/qps/gen_build_yaml.py
index 776283c25a..fb2caf5486 100755
--- a/test/cpp/qps/gen_build_yaml.py
+++ b/test/cpp/qps/gen_build_yaml.py
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import print_function
import json
import pipes
import shutil
@@ -68,62 +69,66 @@ def maybe_exclude_gcov(scenario_json):
return ['gcov']
return []
-print yaml.dump({
- 'tests': [
- {
- 'name': 'json_run_localhost',
- 'shortname': 'json_run_localhost:%s' % scenario_json['name'],
- 'args': ['--scenarios_json', _scenario_json_string(scenario_json, False)],
- 'ci_platforms': ['linux'],
- 'platforms': ['linux'],
- 'flaky': False,
- 'language': 'c++',
- 'boringssl': True,
- 'defaults': 'boringssl',
- 'cpu_cost': guess_cpu(scenario_json, False),
- 'exclude_configs': ['tsan', 'asan'] + maybe_exclude_gcov(scenario_json),
- 'timeout_seconds': 2*60,
- 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []),
- 'auto_timeout_scaling': False
- }
- for scenario_json in scenario_config.CXXLanguage().scenarios()
- if 'scalable' in scenario_json.get('CATEGORIES', [])
- ] + [
- {
- 'name': 'qps_json_driver',
- 'shortname': 'qps_json_driver:inproc_%s' % scenario_json['name'],
- 'args': ['--run_inproc', '--scenarios_json', _scenario_json_string(scenario_json, False)],
- 'ci_platforms': ['linux'],
- 'platforms': ['linux'],
- 'flaky': False,
- 'language': 'c++',
- 'boringssl': True,
- 'defaults': 'boringssl',
- 'cpu_cost': guess_cpu(scenario_json, False),
- 'exclude_configs': ['tsan', 'asan'],
- 'timeout_seconds': 6*60,
- 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', [])
- }
- for scenario_json in scenario_config.CXXLanguage().scenarios()
- if 'inproc' in scenario_json.get('CATEGORIES', [])
- ] + [
- {
- 'name': 'json_run_localhost',
- 'shortname': 'json_run_localhost:%s_low_thread_count' % scenario_json['name'],
- 'args': ['--scenarios_json', _scenario_json_string(scenario_json, True)],
- 'ci_platforms': ['linux'],
- 'platforms': ['linux'],
- 'flaky': False,
- 'language': 'c++',
- 'boringssl': True,
- 'defaults': 'boringssl',
- 'cpu_cost': guess_cpu(scenario_json, True),
- 'exclude_configs': sorted(c for c in configs_from_yaml if c not in ('tsan', 'asan')),
- 'timeout_seconds': 10*60,
- 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []),
- 'auto_timeout_scaling': False
- }
- for scenario_json in scenario_config.CXXLanguage().scenarios()
- if 'scalable' in scenario_json.get('CATEGORIES', [])
- ]
-})
+def generate_yaml():
+ return {
+ 'tests': [
+ {
+ 'name': 'json_run_localhost',
+ 'shortname': 'json_run_localhost:%s' % scenario_json['name'],
+ 'args': ['--scenarios_json', _scenario_json_string(scenario_json, False)],
+ 'ci_platforms': ['linux'],
+ 'platforms': ['linux'],
+ 'flaky': False,
+ 'language': 'c++',
+ 'boringssl': True,
+ 'defaults': 'boringssl',
+ 'cpu_cost': guess_cpu(scenario_json, False),
+ 'exclude_configs': ['tsan', 'asan'] + maybe_exclude_gcov(scenario_json),
+ 'timeout_seconds': 2*60,
+ 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []),
+ 'auto_timeout_scaling': False
+ }
+ for scenario_json in scenario_config.CXXLanguage().scenarios()
+ if 'scalable' in scenario_json.get('CATEGORIES', [])
+ ] + [
+ {
+ 'name': 'qps_json_driver',
+ 'shortname': 'qps_json_driver:inproc_%s' % scenario_json['name'],
+ 'args': ['--run_inproc', '--scenarios_json', _scenario_json_string(scenario_json, False)],
+ 'ci_platforms': ['linux'],
+ 'platforms': ['linux'],
+ 'flaky': False,
+ 'language': 'c++',
+ 'boringssl': True,
+ 'defaults': 'boringssl',
+ 'cpu_cost': guess_cpu(scenario_json, False),
+ 'exclude_configs': ['tsan', 'asan'],
+ 'timeout_seconds': 6*60,
+ 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', [])
+ }
+ for scenario_json in scenario_config.CXXLanguage().scenarios()
+ if 'inproc' in scenario_json.get('CATEGORIES', [])
+ ] + [
+ {
+ 'name': 'json_run_localhost',
+ 'shortname': 'json_run_localhost:%s_low_thread_count' % scenario_json['name'],
+ 'args': ['--scenarios_json', _scenario_json_string(scenario_json, True)],
+ 'ci_platforms': ['linux'],
+ 'platforms': ['linux'],
+ 'flaky': False,
+ 'language': 'c++',
+ 'boringssl': True,
+ 'defaults': 'boringssl',
+ 'cpu_cost': guess_cpu(scenario_json, True),
+ 'exclude_configs': sorted(c for c in configs_from_yaml if c not in ('tsan', 'asan')),
+ 'timeout_seconds': 10*60,
+ 'excluded_poll_engines': scenario_json.get('EXCLUDED_POLL_ENGINES', []),
+ 'auto_timeout_scaling': False
+ }
+ for scenario_json in scenario_config.CXXLanguage().scenarios()
+ if 'scalable' in scenario_json.get('CATEGORIES', [])
+ ]
+ }
+
+
+print(yaml.dump(generate_yaml())) \ No newline at end of file
diff --git a/test/cpp/qps/histogram.h b/test/cpp/qps/histogram.h
index ba72b5b332..6275128f34 100644
--- a/test/cpp/qps/histogram.h
+++ b/test/cpp/qps/histogram.h
@@ -34,6 +34,11 @@ class Histogram {
~Histogram() {
if (impl_) grpc_histogram_destroy(impl_);
}
+ void Reset() {
+ if (impl_) grpc_histogram_destroy(impl_);
+ impl_ = grpc_histogram_create(default_resolution(), default_max_possible());
+ }
+
Histogram(Histogram&& other) : impl_(other.impl_) { other.impl_ = nullptr; }
void Merge(const Histogram& h) { grpc_histogram_merge(impl_, h.impl_); }
diff --git a/test/cpp/qps/inproc_sync_unary_ping_pong_test.cc b/test/cpp/qps/inproc_sync_unary_ping_pong_test.cc
index f2e977d48b..56d1730252 100644
--- a/test/cpp/qps/inproc_sync_unary_ping_pong_test.cc
+++ b/test/cpp/qps/inproc_sync_unary_ping_pong_test.cc
@@ -48,7 +48,7 @@ static void RunSynchronousUnaryPingPong() {
const auto result =
RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2, "",
- kInsecureCredentialsType, true);
+ kInsecureCredentialsType, true, 0);
GetReporter()->ReportQPS(*result);
GetReporter()->ReportLatency(*result);
diff --git a/test/cpp/qps/json_run_localhost_scenario_gen.py b/test/cpp/qps/json_run_localhost_scenario_gen.py
new file mode 100755
index 0000000000..ab14f0e4a5
--- /dev/null
+++ b/test/cpp/qps/json_run_localhost_scenario_gen.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python2.7
+
+# 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.
+
+import gen_build_yaml as gen
+import json
+
+def generate_args():
+ all_scenario_set = gen.generate_yaml()
+ all_scenario_set = all_scenario_set['tests']
+ json_run_localhost_scenarios = \
+ [item for item in all_scenario_set if item['name'] == 'json_run_localhost']
+ json_run_localhost_arg_set = \
+ [item['args'][1] for item in json_run_localhost_scenarios \
+ if 'args' in item and len(item['args']) > 1]
+ deserialized_scenarios = [json.loads(item)['scenarios'][0] \
+ for item in json_run_localhost_arg_set]
+ all_scenarios = {scenario['name'].encode('ascii', 'ignore'): \
+ '\'{\'scenarios\' : [' + json.dumps(scenario) + ']}\'' \
+ for scenario in deserialized_scenarios}
+
+ serialized_scenarios_str = str(all_scenarios).encode('ascii', 'ignore')
+ with open('json_run_localhost_scenarios.bzl', 'wb') as f:
+ f.write('"""Scenarios run on localhost."""\n\n')
+ f.write('JSON_RUN_LOCALHOST_SCENARIOS = ' + serialized_scenarios_str + '\n')
+
+generate_args()
diff --git a/test/cpp/qps/json_run_localhost_scenarios.bzl b/test/cpp/qps/json_run_localhost_scenarios.bzl
new file mode 100644
index 0000000000..5bfb0bca76
--- /dev/null
+++ b/test/cpp/qps/json_run_localhost_scenarios.bzl
@@ -0,0 +1,3 @@
+"""Scenarios run on localhost."""
+
+JSON_RUN_LOCALHOST_SCENARIOS = {'cpp_protobuf_async_unary_75Kqps_600channel_60Krpcs_300Breq_50Bresp': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_75Kqps_600channel_60Krpcs_300Breq_50Bresp", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 16, "threads_per_cq": 1, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"poisson": {"offered_load": 37500}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 50, "req_size": 300}}, "client_channels": 300, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_from_client_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_client_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 1000000, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 1000000}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_client_ping_pong_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_client_ping_pong_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_generic_async_streaming_qps_1channel_1MBmsg_secure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_1channel_1MBmsg_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 1048576, "req_size": 1048576}}, "threads_per_cq": 0}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_server_ping_pong_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_server_ping_pong_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_1mps_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1mps_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 1, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_64KBmsg_secure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_64KBmsg_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 65536, "req_size": 65536}}, "threads_per_cq": 0}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 65536, "req_size": 65536}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_1mps_secure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_1mps_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 1, "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_1cq_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1cq_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 1000000, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 1000000}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_10mps_secure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_10mps_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 10, "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_ping_pong_insecure_1MB': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_ping_pong_insecure_1MB", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_generic_async_streaming_qps_one_server_core_secure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_one_server_core_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 1, "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "messages_per_stream": 10, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 2, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 2}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_secure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 2}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 2}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_ping_pong_secure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_ping_pong_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 1, "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_sync_streaming_from_server_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_server_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_qps_unconstrained_10mps_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_10mps_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "messages_per_stream": 10, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_unary_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_unary_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_from_client_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_client_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_from_client_ping_pong_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_client_ping_pong_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 2, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 2}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_1cq_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_1cq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 1000000}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 1000000}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 10, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 65536, "req_size": 65536}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 65536, "req_size": 65536}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_server_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_server_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 8388608, "req_size": 128}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_streaming_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_sync_streaming_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_client_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_client_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_streaming_from_client_1channel_1MB': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_client_1channel_1MB", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_unary_1channel_100rpcs_1MB': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_1channel_100rpcs_1MB", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 1048576, "req_size": 1048576}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_1mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_1mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 1, "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 2, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 2}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_ping_pong_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_ping_pong_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 10, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 8388608, "req_size": 128}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_generic_async_streaming_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 1, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_sync_streaming_from_server_ping_pong_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_server_ping_pong_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_unary_qps_unconstrained_1cq_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_qps_unconstrained_1cq_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 1000000, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 1000000}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_unary_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_unary_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 10, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_one_server_core_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_one_server_core_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 1, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 10, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_server_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_server_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 2}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 2}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "messages_per_stream": 1, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_unary_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_unary_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_ping_pong_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_ping_pong_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 2, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 2}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_unary_ping_pong_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_unary_ping_pong_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_unary_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_from_server_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_server_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 10, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_1cq_secure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_1cq_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 1000000}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 1000000}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_10mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_10mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 10, "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_10mps_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_10mps_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 10, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_ping_pong_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_ping_pong_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 1, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_streaming_from_client_qps_unconstrained_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_client_qps_unconstrained_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 1000000, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 1000000}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_qps_unconstrained_1mps_secure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_1mps_secure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "messages_per_stream": 1, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 1, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_ping_pong_secure_1MB': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_ping_pong_secure_1MB", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": {"use_test_ca": true, "server_host_override": "foo.test.google.fr"}, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\''}
diff --git a/test/cpp/qps/qps_benchmark_script.bzl b/test/cpp/qps/qps_benchmark_script.bzl
new file mode 100644
index 0000000000..b2b67d988c
--- /dev/null
+++ b/test/cpp/qps/qps_benchmark_script.bzl
@@ -0,0 +1,80 @@
+# 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.
+
+#
+# This is for the gRPC build system. This isn't intended to be used outsite of
+# the BUILD file for gRPC. It contains the mapping for the template system we
+# use to generate other platform's build system files.
+#
+# Please consider that there should be a high bar for additions and changes to
+# this file.
+# Each rule listed must be re-written for Google's internal build system, and
+# each change must be ported from one to the other.
+#
+
+"""Script to run qps benchmark."""
+
+load("//bazel:grpc_build_system.bzl", "grpc_cc_test")
+load("//test/cpp/qps:qps_json_driver_scenarios.bzl", "QPS_JSON_DRIVER_SCENARIOS")
+load("//test/cpp/qps:json_run_localhost_scenarios.bzl", "JSON_RUN_LOCALHOST_SCENARIOS")
+
+def qps_json_driver_batch():
+ for scenario in QPS_JSON_DRIVER_SCENARIOS:
+ grpc_cc_test(
+ name = "qps_json_driver_test_%s" % scenario,
+ srcs = ["qps_json_driver.cc"],
+ args = [
+ "--run_inproc",
+ "--scenarios_json",
+ QPS_JSON_DRIVER_SCENARIOS[scenario],
+ ],
+ external_deps = [
+ "gflags",
+ ],
+ deps = [
+ ":benchmark_config",
+ ":driver_impl",
+ "//:grpc++",
+ "//test/cpp/util:test_config",
+ "//test/cpp/util:test_util",
+ ],
+ tags = [
+ "qps_json_driver",
+ ],
+ )
+
+def json_run_localhost_batch():
+ for scenario in JSON_RUN_LOCALHOST_SCENARIOS:
+ grpc_cc_test(
+ name = "json_run_localhost_%s" % scenario,
+ srcs = ["json_run_localhost.cc"],
+ args = [
+ "--scenarios_json",
+ JSON_RUN_LOCALHOST_SCENARIOS[scenario],
+ ],
+ data = [
+ "//test/cpp/qps:qps_json_driver",
+ "//test/cpp/qps:qps_worker",
+ ],
+ deps = [
+ "//:gpr",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ "//test/cpp/util:test_config",
+ "//test/cpp/util:test_util",
+ ],
+ tags = [
+ "json_run_localhost",
+ ],
+ )
diff --git a/test/cpp/qps/qps_interarrival_test.cc b/test/cpp/qps/qps_interarrival_test.cc
index 625b7db426..2cc22e9985 100644
--- a/test/cpp/qps/qps_interarrival_test.cc
+++ b/test/cpp/qps/qps_interarrival_test.cc
@@ -28,7 +28,8 @@
using grpc::testing::InterarrivalTimer;
using grpc::testing::RandomDistInterface;
-static void RunTest(RandomDistInterface&& r, int threads, std::string title) {
+static void RunTest(RandomDistInterface&& r, int threads,
+ const std::string& title) {
InterarrivalTimer timer;
timer.init(r, threads);
grpc_histogram* h(grpc_histogram_create(0.01, 60e9));
diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc
index 0ff692255c..eaa0dd992c 100644
--- a/test/cpp/qps/qps_json_driver.cc
+++ b/test/cpp/qps/qps_json_driver.cc
@@ -66,6 +66,11 @@ DEFINE_string(json_file_out, "", "File to write the JSON output to.");
DEFINE_string(credential_type, grpc::testing::kInsecureCredentialsType,
"Credential type for communication with workers");
DEFINE_bool(run_inproc, false, "Perform an in-process transport test");
+DEFINE_int32(
+ median_latency_collection_interval_millis, 0,
+ "Specifies the period between gathering latency medians in "
+ "milliseconds. The medians will be logged out on the client at the "
+ "end of the benchmark run. If 0, this periodic collection is disabled.");
namespace grpc {
namespace testing {
@@ -73,13 +78,13 @@ namespace testing {
static std::unique_ptr<ScenarioResult> RunAndReport(const Scenario& scenario,
bool* success) {
std::cerr << "RUNNING SCENARIO: " << scenario.name() << "\n";
- auto result =
- RunScenario(scenario.client_config(), scenario.num_clients(),
- scenario.server_config(), scenario.num_servers(),
- scenario.warmup_seconds(), scenario.benchmark_seconds(),
- !FLAGS_run_inproc ? scenario.spawn_local_worker_count() : -2,
- FLAGS_qps_server_target_override, FLAGS_credential_type,
- FLAGS_run_inproc);
+ auto result = RunScenario(
+ scenario.client_config(), scenario.num_clients(),
+ scenario.server_config(), scenario.num_servers(),
+ scenario.warmup_seconds(), scenario.benchmark_seconds(),
+ !FLAGS_run_inproc ? scenario.spawn_local_worker_count() : -2,
+ FLAGS_qps_server_target_override, FLAGS_credential_type, FLAGS_run_inproc,
+ FLAGS_median_latency_collection_interval_millis);
// Amend the result with scenario config. Eventually we should adjust
// RunScenario contract so we don't need to touch the result here.
diff --git a/test/cpp/qps/qps_json_driver_scenario_gen.py b/test/cpp/qps/qps_json_driver_scenario_gen.py
new file mode 100755
index 0000000000..2b66c69d8a
--- /dev/null
+++ b/test/cpp/qps/qps_json_driver_scenario_gen.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python2.7
+
+# 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.
+
+import gen_build_yaml as gen
+import json
+
+def generate_args():
+ all_scenario_set = gen.generate_yaml()
+ all_scenario_set = all_scenario_set['tests']
+ qps_json_driver_scenario_set = \
+ [item for item in all_scenario_set if item['name'] == 'qps_json_driver']
+ qps_json_driver_arg_set = \
+ [item['args'][2] for item in qps_json_driver_scenario_set \
+ if 'args' in item and len(item['args']) > 2]
+ deserialized_scenarios = [json.loads(item)['scenarios'][0] \
+ for item in qps_json_driver_arg_set]
+ all_scenarios = {scenario['name'].encode('ascii', 'ignore'): \
+ '\'{\'scenarios\' : [' + json.dumps(scenario) + ']}\'' \
+ for scenario in deserialized_scenarios}
+
+ serialized_scenarios_str = str(all_scenarios).encode('ascii', 'ignore')
+ with open('qps_json_driver_scenarios.bzl', 'w') as f:
+ f.write('"""Scenarios of qps driver."""\n\n')
+ f.write('QPS_JSON_DRIVER_SCENARIOS = ' + serialized_scenarios_str + '\n')
+
+generate_args()
diff --git a/test/cpp/qps/qps_json_driver_scenarios.bzl b/test/cpp/qps/qps_json_driver_scenarios.bzl
new file mode 100644
index 0000000000..95b4911325
--- /dev/null
+++ b/test/cpp/qps/qps_json_driver_scenarios.bzl
@@ -0,0 +1,3 @@
+"""Scenarios of qps driver."""
+
+QPS_JSON_DRIVER_SCENARIOS = {'cpp_protobuf_sync_streaming_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 16, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_1mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 16, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "messages_per_stream": 1, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_ping_pong_insecure_1MB': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_ping_pong_insecure_1MB", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_qps_unconstrained_10mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 16, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "messages_per_stream": 10, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_qps_unconstrained_2waysharedcq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 2, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 2}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_qps_unconstrained_1cq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 1000000, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 1000000}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_2waysharedcq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 2, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 2}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_1cq_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_1cq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 1000000}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 1000000}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_10mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 10, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_64KBmsg_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 65536, "req_size": 65536}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 65536, "req_size": 65536}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1cq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 1000000, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 13, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 1000000}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_server_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_client_1channel_1MB': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_client_1channel_1MB", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_unary_1channel_100rpcs_1MB': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_1channel_100rpcs_1MB", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_1channel_1MBmsg_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 1048576, "req_size": 1048576}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 1048576, "req_size": 1048576}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_1mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_1mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 1, "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_client_sync_server_unary_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_client_unary_1channel_64wide_128Breq_8MBresp_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 8388608, "req_size": 128}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_client_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 16, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_client_sync_server_streaming_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_from_client_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING_FROM_CLIENT", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_2waysharedcq_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 2}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 2}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_unary_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_unary_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 16, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_sync_streaming_from_server_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "SYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 16, "rpc_type": "STREAMING_FROM_SERVER", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "SYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_protobuf_async_unary_qps_unconstrained_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_unary_qps_unconstrained_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 3, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "UNARY", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 3}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_qps_unconstrained_10mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_qps_unconstrained_10mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 0, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 10, "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\'', 'cpp_generic_async_streaming_ping_pong_insecure': '\'{\'scenarios\' : [{"name": "cpp_generic_async_streaming_ping_pong_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"async_server_threads": 1, "security_params": null, "server_type": "ASYNC_GENERIC_SERVER", "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "threads_per_cq": 0}, "client_config": {"security_params": null, "channel_args": [{"str_value": "latency", "name": "grpc.optimization_target"}], "async_client_threads": 1, "outstanding_rpcs_per_channel": 1, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "payload_config": {"bytebuf_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 1, "threads_per_cq": 0}, "num_clients": 1}]}\'', 'cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure': '\'{\'scenarios\' : [{"name": "cpp_protobuf_async_streaming_qps_unconstrained_1mps_insecure", "warmup_seconds": 0, "benchmark_seconds": 1, "num_servers": 1, "server_config": {"security_params": null, "server_type": "ASYNC_SERVER", "async_server_threads": 0, "threads_per_cq": 0, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}]}, "client_config": {"security_params": null, "channel_args": [{"str_value": "throughput", "name": "grpc.optimization_target"}, {"int_value": 1, "name": "grpc.minimal_stack"}], "async_client_threads": 0, "outstanding_rpcs_per_channel": 100, "rpc_type": "STREAMING", "load_params": {"closed_loop": {}}, "histogram_params": {"resolution": 0.01, "max_possible": 60000000000.0}, "client_type": "ASYNC_CLIENT", "messages_per_stream": 1, "payload_config": {"simple_params": {"resp_size": 0, "req_size": 0}}, "client_channels": 64, "threads_per_cq": 0}, "num_clients": 0}]}\''}
diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc
index df929b9811..6044f4265a 100644
--- a/test/cpp/qps/qps_openloop_test.cc
+++ b/test/cpp/qps/qps_openloop_test.cc
@@ -52,7 +52,7 @@ static void RunQPS() {
const auto result =
RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2, "",
- kInsecureCredentialsType, false);
+ kInsecureCredentialsType, false, 0);
GetReporter()->ReportQPSPerCore(*result);
GetReporter()->ReportLatency(*result);
diff --git a/test/cpp/qps/qps_server_builder.cc b/test/cpp/qps/qps_server_builder.cc
new file mode 100644
index 0000000000..5fbc682b75
--- /dev/null
+++ b/test/cpp/qps/qps_server_builder.cc
@@ -0,0 +1,45 @@
+/*
+ *
+ * Copyright 2016 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 "qps_server_builder.h"
+
+using grpc::ServerBuilder;
+
+namespace grpc {
+namespace testing {
+
+namespace {
+std::unique_ptr<ServerBuilder> DefaultCreateQpsServerBuilder() {
+ return std::unique_ptr<ServerBuilder>(new ServerBuilder());
+}
+
+std::function<std::unique_ptr<ServerBuilder>()> g_create_qps_server_builder =
+ DefaultCreateQpsServerBuilder;
+} // namespace
+
+std::unique_ptr<ServerBuilder> CreateQpsServerBuilder() {
+ return g_create_qps_server_builder();
+}
+
+void SetCreateQpsServerBuilderFunc(
+ std::function<std::unique_ptr<ServerBuilder>()> create_qps_server_builder) {
+ g_create_qps_server_builder = std::move(create_qps_server_builder);
+}
+
+} // namespace testing
+} // namespace grpc
diff --git a/test/cpp/qps/qps_server_builder.h b/test/cpp/qps/qps_server_builder.h
new file mode 100644
index 0000000000..98f9fa72e9
--- /dev/null
+++ b/test/cpp/qps/qps_server_builder.h
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright 2016 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.
+ *
+ */
+
+#ifndef GRPC_QPS_SERVER_BUILDER_H
+#define GRPC_QPS_SERVER_BUILDER_H
+
+#include <functional>
+#include <memory>
+
+#include <grpcpp/server_builder.h>
+
+namespace grpc {
+namespace testing {
+
+// CreateQpsServerBuilder creates a new ServerBuilder.
+// This uses the "create ServerBuilder" func that was set
+// in SetCreateQpsServerBuilderFunc if one has been set,
+// otherwise, this defaults to creating a new ServerBuilder
+// with only its default constructor.
+std::unique_ptr<ServerBuilder> CreateQpsServerBuilder();
+
+// SetCreateQpsServerBuilderFunc sets a function to use to create new
+// ServerBuilders in "CreateQpsServerBuilder". It can be used to modify options
+// that the server is built with.
+void SetCreateQpsServerBuilderFunc(
+ std::function<std::unique_ptr<ServerBuilder>()>);
+
+} // namespace testing
+} // namespace grpc
+
+#endif // GRPC_QPS_SERVER_BUILDER_H
diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc
index d3f0380474..7ddf3c1cf3 100644
--- a/test/cpp/qps/qps_worker.cc
+++ b/test/cpp/qps/qps_worker.cc
@@ -39,6 +39,7 @@
#include "test/core/util/grpc_profiler.h"
#include "test/core/util/histogram.h"
#include "test/cpp/qps/client.h"
+#include "test/cpp/qps/qps_server_builder.h"
#include "test/cpp/qps/server.h"
#include "test/cpp/util/create_test_channel.h"
#include "test/cpp/util/test_credentials_provider.h"
@@ -272,18 +273,18 @@ QpsWorker::QpsWorker(int driver_port, int server_port,
impl_.reset(new WorkerServiceImpl(server_port, this));
gpr_atm_rel_store(&done_, static_cast<gpr_atm>(0));
- ServerBuilder builder;
+ std::unique_ptr<ServerBuilder> builder = CreateQpsServerBuilder();
if (driver_port >= 0) {
char* server_address = nullptr;
gpr_join_host_port(&server_address, "::", driver_port);
- builder.AddListeningPort(
+ builder->AddListeningPort(
server_address,
GetCredentialsProvider()->GetServerCredentials(credential_type));
gpr_free(server_address);
}
- builder.RegisterService(impl_.get());
+ builder->RegisterService(impl_.get());
- server_ = builder.BuildAndStart();
+ server_ = builder->BuildAndStart();
}
QpsWorker::~QpsWorker() {}
diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h
index 8e62f4f449..b00b0a311f 100644
--- a/test/cpp/qps/report.h
+++ b/test/cpp/qps/report.h
@@ -129,7 +129,7 @@ class JsonReporter : public Reporter {
class RpcReporter : public Reporter {
public:
- RpcReporter(const string& name, std::shared_ptr<grpc::Channel> channel)
+ RpcReporter(const string& name, const std::shared_ptr<grpc::Channel>& channel)
: Reporter(name), stub_(ReportQpsScenarioService::NewStub(channel)) {}
private:
diff --git a/test/cpp/qps/secure_sync_unary_ping_pong_test.cc b/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
index bb415e9d63..a559c82cc8 100644
--- a/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
+++ b/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
@@ -55,7 +55,7 @@ static void RunSynchronousUnaryPingPong() {
const auto result =
RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2, "",
- kInsecureCredentialsType, false);
+ kInsecureCredentialsType, false, 0);
GetReporter()->ReportQPS(*result);
GetReporter()->ReportLatency(*result);
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 1dfef6cfc1..5cd975cf74 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -38,6 +38,7 @@
#include "src/core/lib/surface/completion_queue.h"
#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
#include "test/core/util/test_config.h"
+#include "test/cpp/qps/qps_server_builder.h"
#include "test/cpp/qps/server.h"
namespace grpc {
@@ -74,19 +75,19 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
ResponseType*)>
process_rpc)
: Server(config) {
- ServerBuilder builder;
+ std::unique_ptr<ServerBuilder> builder = CreateQpsServerBuilder();
auto port_num = port();
// Negative port number means inproc server, so no listen port needed
if (port_num >= 0) {
char* server_address = nullptr;
gpr_join_host_port(&server_address, "::", port_num);
- builder.AddListeningPort(server_address,
- Server::CreateServerCredentials(config));
+ builder->AddListeningPort(server_address,
+ Server::CreateServerCredentials(config));
gpr_free(server_address);
}
- register_service(&builder, &async_service_);
+ register_service(builder.get(), &async_service_);
int num_threads = config.async_server_threads();
if (num_threads <= 0) { // dynamic sizing
@@ -97,15 +98,15 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
int tpc = std::max(1, config.threads_per_cq()); // 1 if unspecified
int num_cqs = (num_threads + tpc - 1) / tpc; // ceiling operator
for (int i = 0; i < num_cqs; i++) {
- srv_cqs_.emplace_back(builder.AddCompletionQueue());
+ srv_cqs_.emplace_back(builder->AddCompletionQueue());
}
for (int i = 0; i < num_threads; i++) {
cq_.emplace_back(i % srv_cqs_.size());
}
- ApplyConfigToBuilder(config, &builder);
+ ApplyConfigToBuilder(config, builder.get());
- server_ = builder.BuildAndStart();
+ server_ = builder->BuildAndStart();
auto process_rpc_bound =
std::bind(process_rpc, config.payload_config(), std::placeholders::_1,
diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc
index 82a9186989..2e63f5ec86 100644
--- a/test/cpp/qps/server_sync.cc
+++ b/test/cpp/qps/server_sync.cc
@@ -27,6 +27,7 @@
#include "src/core/lib/gpr/host_port.h"
#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
+#include "test/cpp/qps/qps_server_builder.h"
#include "test/cpp/qps/server.h"
#include "test/cpp/qps/usage_timer.h"
@@ -129,7 +130,7 @@ class BenchmarkServiceImpl final : public BenchmarkService::Service {
template <class W>
static Status ServerPush(ServerContext* context, W* stream,
const SimpleResponse& response,
- std::function<bool()> done) {
+ const std::function<bool()>& done) {
while ((done == nullptr) || !done()) {
// TODO(vjpai): Add potential for rate-pacing on this
if (!stream->Write(response)) {
@@ -154,23 +155,23 @@ class BenchmarkServiceImpl final : public BenchmarkService::Service {
class SynchronousServer final : public grpc::testing::Server {
public:
explicit SynchronousServer(const ServerConfig& config) : Server(config) {
- ServerBuilder builder;
+ std::unique_ptr<ServerBuilder> builder = CreateQpsServerBuilder();
auto port_num = port();
// Negative port number means inproc server, so no listen port needed
if (port_num >= 0) {
char* server_address = nullptr;
gpr_join_host_port(&server_address, "::", port_num);
- builder.AddListeningPort(server_address,
- Server::CreateServerCredentials(config));
+ builder->AddListeningPort(server_address,
+ Server::CreateServerCredentials(config));
gpr_free(server_address);
}
- ApplyConfigToBuilder(config, &builder);
+ ApplyConfigToBuilder(config, builder.get());
- builder.RegisterService(&service_);
+ builder->RegisterService(&service_);
- impl_ = builder.BuildAndStart();
+ impl_ = builder->BuildAndStart();
}
std::shared_ptr<Channel> InProcessChannel(
diff --git a/test/cpp/server/load_reporter/BUILD b/test/cpp/server/load_reporter/BUILD
index 5cb3a00f82..b7c4d29d71 100644
--- a/test/cpp/server/load_reporter/BUILD
+++ b/test/cpp/server/load_reporter/BUILD
@@ -14,7 +14,7 @@
licenses(["notice"]) # Apache v2
-load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_cc_library", "grpc_cc_binary", "grpc_package")
+load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_cc_test", "grpc_package")
grpc_package(name = "test/cpp/server/load_reporter")
@@ -29,3 +29,36 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
],
)
+
+grpc_cc_test(
+ name = "lb_load_reporter_test",
+ srcs = ["load_reporter_test.cc"],
+ external_deps = [
+ "gtest",
+ "gmock",
+ "opencensus-stats-test",
+ ],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:lb_load_reporter",
+ "//:lb_server_load_reporting_filter",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "lb_get_cpu_stats_test",
+ srcs = ["get_cpu_stats_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//:lb_get_cpu_stats",
+ "//test/core/util:gpr_test_util",
+ "//test/core/util:grpc_test_util",
+ ],
+)
diff --git a/test/cpp/server/load_reporter/get_cpu_stats_test.cc b/test/cpp/server/load_reporter/get_cpu_stats_test.cc
new file mode 100644
index 0000000000..5b1d5fa3a4
--- /dev/null
+++ b/test/cpp/server/load_reporter/get_cpu_stats_test.cc
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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 <grpc/impl/codegen/port_platform.h>
+
+#include <grpc/grpc.h>
+#include <gtest/gtest.h>
+
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+#include "src/cpp/server/load_reporter/get_cpu_stats.h"
+
+namespace grpc {
+namespace testing {
+namespace {
+
+TEST(GetCpuStatsTest, ReadOnce) { ::grpc::load_reporter::GetCpuStatsImpl(); }
+
+TEST(GetCpuStatsTest, BusyNoLargerThanTotal) {
+ auto p = ::grpc::load_reporter::GetCpuStatsImpl();
+ uint64_t busy = p.first;
+ uint64_t total = p.second;
+ ASSERT_LE(busy, total);
+}
+
+TEST(GetCpuStatsTest, Ascending) {
+ const size_t kRuns = 100;
+ auto prev = ::grpc::load_reporter::GetCpuStatsImpl();
+ for (size_t i = 0; i < kRuns; ++i) {
+ auto cur = ::grpc::load_reporter::GetCpuStatsImpl();
+ ASSERT_LE(prev.first, cur.first);
+ ASSERT_LE(prev.second, cur.second);
+ prev = cur;
+ }
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/server/load_reporter/load_data_store_test.cc b/test/cpp/server/load_reporter/load_data_store_test.cc
index 8280dee6a4..c92c407e4f 100644
--- a/test/cpp/server/load_reporter/load_data_store_test.cc
+++ b/test/cpp/server/load_reporter/load_data_store_test.cc
@@ -50,8 +50,8 @@ class LoadDataStoreTest : public ::testing::Test {
bool PerBalancerStoresContains(
const LoadDataStore& load_data_store,
const std::set<PerBalancerStore*>* per_balancer_stores,
- const grpc::string hostname, const grpc::string lb_id,
- const grpc::string load_key) {
+ const grpc::string& hostname, const grpc::string& lb_id,
+ const grpc::string& load_key) {
auto original_per_balancer_store =
load_data_store.FindPerBalancerStore(hostname, lb_id);
EXPECT_NE(original_per_balancer_store, nullptr);
@@ -155,7 +155,7 @@ TEST_F(LoadDataStoreTest, OrphanAssignmentIsSticky) {
active_lb_ids.erase(orphaned_lb_id);
// Find which LB is assigned the orphaned store.
grpc::string assigned_lb_id = "";
- for (auto lb_id : active_lb_ids) {
+ for (const auto& lb_id : active_lb_ids) {
if (PerBalancerStoresContains(
load_data_store,
load_data_store.GetAssignedStores(kHostname1, lb_id), kHostname1,
@@ -169,7 +169,7 @@ TEST_F(LoadDataStoreTest, OrphanAssignmentIsSticky) {
// orphaned_lb_id shouldn't change.
for (size_t _ = 0; _ < 10; ++_) {
grpc::string lb_id_to_close = "";
- for (auto lb_id : active_lb_ids) {
+ for (const auto& lb_id : active_lb_ids) {
if (lb_id != assigned_lb_id) {
lb_id_to_close = lb_id;
break;
@@ -187,7 +187,7 @@ TEST_F(LoadDataStoreTest, OrphanAssignmentIsSticky) {
load_data_store.ReportStreamClosed(kHostname1, assigned_lb_id);
active_lb_ids.erase(assigned_lb_id);
size_t orphaned_lb_id_occurences = 0;
- for (auto lb_id : active_lb_ids) {
+ for (const auto& lb_id : active_lb_ids) {
if (PerBalancerStoresContains(
load_data_store,
load_data_store.GetAssignedStores(kHostname1, lb_id), kHostname1,
@@ -393,9 +393,9 @@ TEST_F(PerBalancerStoreTest, Suspend) {
TEST_F(PerBalancerStoreTest, DataAggregation) {
PerBalancerStore per_balancer_store(kLbId1, kLoadKey1);
// Construct some Values.
- LoadRecordValue v1(992, 34, 13, 234.0, 164.0, 173467.38);
+ LoadRecordValue v1(992, 34, 13, 234, 164, 173467);
v1.InsertCallMetric(kMetric1, CallMetricValue(3, 2773.2));
- LoadRecordValue v2(4842, 213, 9, 393.0, 974.0, 1345.2398);
+ LoadRecordValue v2(4842, 213, 9, 393, 974, 1345);
v2.InsertCallMetric(kMetric1, CallMetricValue(7, 25.234));
v2.InsertCallMetric(kMetric2, CallMetricValue(2, 387.08));
// v3 doesn't change the number of in-progress RPCs.
diff --git a/test/cpp/server/load_reporter/load_reporter_test.cc b/test/cpp/server/load_reporter/load_reporter_test.cc
new file mode 100644
index 0000000000..0d56cdf431
--- /dev/null
+++ b/test/cpp/server/load_reporter/load_reporter_test.cc
@@ -0,0 +1,507 @@
+/*
+ *
+ * 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 <grpc/impl/codegen/port_platform.h>
+
+#include <set>
+#include <vector>
+
+#include <gmock/gmock.h>
+#include <grpc/grpc.h>
+#include <gtest/gtest.h>
+
+#include "src/core/ext/filters/load_reporting/registered_opencensus_objects.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/cpp/server/load_reporter/constants.h"
+#include "src/cpp/server/load_reporter/load_reporter.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+#include "opencensus/stats/testing/test_utils.h"
+
+namespace grpc {
+namespace testing {
+namespace {
+
+using ::grpc::lb::v1::LoadBalancingFeedback;
+using ::grpc::load_reporter::CensusViewProvider;
+using ::grpc::load_reporter::CpuStatsProvider;
+using ::grpc::load_reporter::LoadReporter;
+using ::opencensus::stats::View;
+using ::opencensus::stats::ViewData;
+using ::opencensus::stats::ViewDataImpl;
+using ::opencensus::stats::ViewDescriptor;
+using ::testing::DoubleNear;
+using ::testing::Return;
+
+constexpr uint64_t kFeedbackSampleWindowSeconds = 5;
+constexpr uint64_t kFetchAndSampleIntervalSeconds = 1;
+constexpr uint64_t kNumFeedbackSamplesInWindow =
+ kFeedbackSampleWindowSeconds / kFetchAndSampleIntervalSeconds;
+
+class MockCensusViewProvider : public CensusViewProvider {
+ public:
+ MOCK_METHOD0(FetchViewData, CensusViewProvider::ViewDataMap());
+
+ const ::opencensus::stats::ViewDescriptor& FindViewDescriptor(
+ const grpc::string& view_name) {
+ auto it = view_descriptor_map().find(view_name);
+ GPR_ASSERT(it != view_descriptor_map().end());
+ return it->second;
+ }
+};
+
+class MockCpuStatsProvider : public CpuStatsProvider {
+ public:
+ MOCK_METHOD0(GetCpuStats, CpuStatsProvider::CpuStatsSample());
+};
+
+class LoadReporterTest : public ::testing::Test {
+ public:
+ LoadReporterTest() {}
+
+ MockCensusViewProvider* mock_census_view_provider() {
+ return static_cast<MockCensusViewProvider*>(
+ load_reporter_->census_view_provider());
+ }
+
+ void PrepareCpuExpectation(size_t call_num) {
+ auto mock_cpu_stats_provider = static_cast<MockCpuStatsProvider*>(
+ load_reporter_->cpu_stats_provider());
+ ::testing::InSequence s;
+ for (size_t i = 0; i < call_num; ++i) {
+ EXPECT_CALL(*mock_cpu_stats_provider, GetCpuStats())
+ .WillOnce(Return(kCpuStatsSamples[i]))
+ .RetiresOnSaturation();
+ }
+ }
+
+ CpuStatsProvider::CpuStatsSample initial_cpu_stats_{2, 20};
+ const std::vector<CpuStatsProvider::CpuStatsSample> kCpuStatsSamples = {
+ {13, 53}, {64, 96}, {245, 345}, {314, 785},
+ {874, 1230}, {1236, 2145}, {1864, 2974}};
+
+ std::unique_ptr<LoadReporter> load_reporter_;
+
+ const grpc::string kHostname1 = "kHostname1";
+ const grpc::string kHostname2 = "kHostname2";
+ const grpc::string kHostname3 = "kHostname3";
+ // Pad to the length of a valid LB ID.
+ const grpc::string kLbId1 = "kLbId111";
+ const grpc::string kLbId2 = "kLbId222";
+ const grpc::string kLbId3 = "kLbId333";
+ const grpc::string kLbId4 = "kLbId444";
+ const grpc::string kLoadKey1 = "kLoadKey1";
+ const grpc::string kLoadKey2 = "kLoadKey2";
+ const grpc::string kLoadKey3 = "kLoadKey3";
+ const grpc::string kLbTag1 = "kLbTag1";
+ const grpc::string kLbTag2 = "kLbTag2";
+ const grpc::string kLbToken1 = "kLbId111kLbTag1";
+ const grpc::string kLbToken2 = "kLbId222kLbTag2";
+ const grpc::string kUser1 = "kUser1";
+ const grpc::string kUser2 = "kUser2";
+ const grpc::string kUser3 = "kUser3";
+ const grpc::string kClientIp0 = "00";
+ const grpc::string kClientIp1 = "0800000001";
+ const grpc::string kClientIp2 = "3200000000000000000000000000000002";
+ const grpc::string kMetric1 = "kMetric1";
+ const grpc::string kMetric2 = "kMetric2";
+
+ private:
+ void SetUp() override {
+ // Access the measures to make them valid.
+ ::grpc::load_reporter::MeasureStartCount();
+ ::grpc::load_reporter::MeasureEndCount();
+ ::grpc::load_reporter::MeasureEndBytesSent();
+ ::grpc::load_reporter::MeasureEndBytesReceived();
+ ::grpc::load_reporter::MeasureEndLatencyMs();
+ ::grpc::load_reporter::MeasureOtherCallMetric();
+ // Set up the load reporter.
+ auto mock_cpu = new MockCpuStatsProvider();
+ auto mock_census = new MockCensusViewProvider();
+ // Prepare the initial CPU stats data. Note that the expectation should be
+ // set up before the load reporter is initialized, because CPU stats is
+ // sampled at that point.
+ EXPECT_CALL(*mock_cpu, GetCpuStats())
+ .WillOnce(Return(initial_cpu_stats_))
+ .RetiresOnSaturation();
+ load_reporter_ = std::unique_ptr<LoadReporter>(
+ new LoadReporter(kFeedbackSampleWindowSeconds,
+ std::unique_ptr<CensusViewProvider>(mock_census),
+ std::unique_ptr<CpuStatsProvider>(mock_cpu)));
+ }
+};
+
+class LbFeedbackTest : public LoadReporterTest {
+ public:
+ // Note that [start, start + count) of the fake samples (maybe plus the
+ // initial record) are in the window now.
+ void VerifyLbFeedback(const LoadBalancingFeedback& lb_feedback, size_t start,
+ size_t count) {
+ const CpuStatsProvider::CpuStatsSample* base =
+ start == 0 ? &initial_cpu_stats_ : &kCpuStatsSamples[start - 1];
+ double expected_cpu_util =
+ static_cast<double>(kCpuStatsSamples[start + count - 1].first -
+ base->first) /
+ static_cast<double>(kCpuStatsSamples[start + count - 1].second -
+ base->second);
+ ASSERT_THAT(static_cast<double>(lb_feedback.server_utilization()),
+ DoubleNear(expected_cpu_util, 0.00001));
+ double qps_sum = 0, eps_sum = 0;
+ for (size_t i = 0; i < count; ++i) {
+ qps_sum += kQpsEpsSamples[start + i].first;
+ eps_sum += kQpsEpsSamples[start + i].second;
+ }
+ double expected_qps = qps_sum / count;
+ double expected_eps = eps_sum / count;
+ // TODO(juanlishen): The error is big because we use sleep(). It should be
+ // much smaller when we use fake clock.
+ ASSERT_THAT(static_cast<double>(lb_feedback.calls_per_second()),
+ DoubleNear(expected_qps, expected_qps * 0.05));
+ ASSERT_THAT(static_cast<double>(lb_feedback.errors_per_second()),
+ DoubleNear(expected_eps, expected_eps * 0.05));
+ gpr_log(GPR_INFO,
+ "Verified LB feedback matches the samples of index [%lu, %lu).",
+ start, start + count);
+ }
+
+ const std::vector<std::pair<double, double>> kQpsEpsSamples = {
+ {546.1, 153.1}, {62.1, 54.1}, {578.1, 154.2}, {978.1, 645.1},
+ {1132.1, 846.4}, {531.5, 315.4}, {874.1, 324.9}};
+};
+
+TEST_F(LbFeedbackTest, ZeroDuration) {
+ PrepareCpuExpectation(kCpuStatsSamples.size());
+ EXPECT_CALL(*mock_census_view_provider(), FetchViewData())
+ .WillRepeatedly(
+ Return(::grpc::load_reporter::CensusViewProvider::ViewDataMap()));
+ // Verify that divide-by-zero exception doesn't happen.
+ for (size_t i = 0; i < kCpuStatsSamples.size(); ++i) {
+ load_reporter_->FetchAndSample();
+ }
+ load_reporter_->GenerateLoadBalancingFeedback();
+}
+
+TEST_F(LbFeedbackTest, Normal) {
+ // Prepare view data list using the <QPS, EPS> samples.
+ std::vector<CensusViewProvider::ViewDataMap> view_data_map_list;
+ for (const auto& p : LbFeedbackTest::kQpsEpsSamples) {
+ double qps = p.first;
+ double eps = p.second;
+ double ok_count = (qps - eps) * kFetchAndSampleIntervalSeconds;
+ double error_count = eps * kFetchAndSampleIntervalSeconds;
+ double ok_count_1 = ok_count / 3.0;
+ double ok_count_2 = ok_count - ok_count_1;
+ auto end_count_vd = ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndCount),
+ {{{kClientIp0 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ ok_count_1},
+ {{kClientIp0 + kLbToken1, kHostname1, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ ok_count_2},
+ {{kClientIp0 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusClientError},
+ error_count}});
+ // Values for other view data don't matter.
+ auto end_bytes_sent_vd =
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndBytesSent),
+ {{{kClientIp0 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 0},
+ {{kClientIp0 + kLbToken1, kHostname1, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 0},
+ {{kClientIp0 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 0}});
+ auto end_bytes_received_vd =
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndBytesReceived),
+ {{{kClientIp0 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 0},
+ {{kClientIp0 + kLbToken1, kHostname1, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 0},
+ {{kClientIp0 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 0}});
+ auto end_latency_vd = ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndLatencyMs),
+ {{{kClientIp0 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 0},
+ {{kClientIp0 + kLbToken1, kHostname1, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 0},
+ {{kClientIp0 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 0}});
+ view_data_map_list.push_back(
+ {{::grpc::load_reporter::kViewEndCount, end_count_vd},
+ {::grpc::load_reporter::kViewEndBytesSent, end_bytes_sent_vd},
+ {::grpc::load_reporter::kViewEndBytesReceived, end_bytes_received_vd},
+ {::grpc::load_reporter::kViewEndLatencyMs, end_latency_vd}});
+ }
+ {
+ ::testing::InSequence s;
+ for (size_t i = 0; i < view_data_map_list.size(); ++i) {
+ EXPECT_CALL(*mock_census_view_provider(), FetchViewData())
+ .WillOnce(Return(view_data_map_list[i]))
+ .RetiresOnSaturation();
+ }
+ }
+ PrepareCpuExpectation(kNumFeedbackSamplesInWindow + 2);
+ // When the load reporter is created, a trivial LB feedback record is added.
+ // But that's not enough for generating an LB feedback.
+ // Fetch some view data so that non-trivial LB feedback can be generated.
+ for (size_t i = 0; i < kNumFeedbackSamplesInWindow / 2; ++i) {
+ // TODO(juanlishen): Find some fake clock to speed up testing.
+ sleep(1);
+ load_reporter_->FetchAndSample();
+ }
+ VerifyLbFeedback(load_reporter_->GenerateLoadBalancingFeedback(), 0,
+ kNumFeedbackSamplesInWindow / 2);
+ // Fetch more view data so that the feedback record window is just full (the
+ // initial record just falls out of the window).
+ for (size_t i = 0; i < (kNumFeedbackSamplesInWindow + 1) / 2; ++i) {
+ sleep(1);
+ load_reporter_->FetchAndSample();
+ }
+ VerifyLbFeedback(load_reporter_->GenerateLoadBalancingFeedback(), 0,
+ kNumFeedbackSamplesInWindow);
+ // Further fetching will cause the old records to fall out of the window.
+ for (size_t i = 0; i < 2; ++i) {
+ sleep(1);
+ load_reporter_->FetchAndSample();
+ }
+ VerifyLbFeedback(load_reporter_->GenerateLoadBalancingFeedback(), 2,
+ kNumFeedbackSamplesInWindow);
+}
+
+using LoadReportTest = LoadReporterTest;
+
+TEST_F(LoadReportTest, BasicReport) {
+ // Make up the first view data map.
+ CensusViewProvider::ViewDataMap vdm1;
+ vdm1.emplace(
+ ::grpc::load_reporter::kViewStartCount,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewStartCount),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser1}, 1234},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser1}, 1225},
+ {{kClientIp0 + kLbToken1, kHostname1, kUser1}, 10},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser2}, 464},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3}, 101},
+ {{kClientIp1 + kLbToken2, kHostname2, kUser3}, 17},
+ {{kClientIp2 + kLbId3 + kLbTag2, kHostname2, kUser3}, 23}}));
+ vdm1.emplace(::grpc::load_reporter::kViewEndCount,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndCount),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 641},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 272},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 996},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 34},
+ {{kClientIp1 + kLbToken2, kHostname2, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 18}}));
+ vdm1.emplace(::grpc::load_reporter::kViewEndBytesSent,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndBytesSent),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 8977},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 266},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 1276},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 77823},
+ {{kClientIp1 + kLbToken2, kHostname2, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 48}}));
+ vdm1.emplace(::grpc::load_reporter::kViewEndBytesReceived,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndBytesReceived),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 2341},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 466},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 518},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 81},
+ {{kClientIp1 + kLbToken2, kHostname2, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 27}}));
+ vdm1.emplace(::grpc::load_reporter::kViewEndLatencyMs,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndLatencyMs),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 3.14},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 5.26},
+ {{kClientIp2 + kLbToken1, kHostname1, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 45.4},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 4.4},
+ {{kClientIp1 + kLbToken2, kHostname2, kUser2,
+ ::grpc::load_reporter::kCallStatusOk},
+ 2348.0}}));
+ vdm1.emplace(
+ ::grpc::load_reporter::kViewOtherCallMetricCount,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewOtherCallMetricCount),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser2, kMetric1}, 1},
+ {{kClientIp1 + kLbToken1, kHostname1, kUser2, kMetric1}, 1},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3, kMetric2},
+ 1}}));
+ vdm1.emplace(
+ ::grpc::load_reporter::kViewOtherCallMetricValue,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewOtherCallMetricValue),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser2, kMetric1}, 1.2},
+ {{kClientIp1 + kLbToken1, kHostname1, kUser2, kMetric1}, 1.2},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3, kMetric2},
+ 3.2}}));
+ // Make up the second view data map.
+ CensusViewProvider::ViewDataMap vdm2;
+ vdm2.emplace(
+ ::grpc::load_reporter::kViewStartCount,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewStartCount),
+ {{{kClientIp2 + kLbToken1, kHostname1, kUser1}, 3},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3}, 778}}));
+ vdm2.emplace(::grpc::load_reporter::kViewEndCount,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndCount),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 24},
+ {{kClientIp1 + kLbToken2, kHostname2, kUser3,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 546}}));
+ vdm2.emplace(::grpc::load_reporter::kViewEndBytesSent,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndBytesSent),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 747},
+ {{kClientIp1 + kLbToken2, kHostname2, kUser3,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 229}}));
+ vdm2.emplace(::grpc::load_reporter::kViewEndBytesReceived,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndBytesReceived),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 173},
+ {{kClientIp1 + kLbToken2, kHostname2, kUser3,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 438}}));
+ vdm2.emplace(::grpc::load_reporter::kViewEndLatencyMs,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewEndLatencyMs),
+ {{{kClientIp1 + kLbToken1, kHostname1, kUser1,
+ ::grpc::load_reporter::kCallStatusOk},
+ 187},
+ {{kClientIp1 + kLbToken2, kHostname2, kUser3,
+ ::grpc::load_reporter::kCallStatusClientError},
+ 34}}));
+ vdm2.emplace(
+ ::grpc::load_reporter::kViewOtherCallMetricCount,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewOtherCallMetricCount),
+ {{{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3, kMetric1}, 1},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3, kMetric2},
+ 1}}));
+ vdm2.emplace(
+ ::grpc::load_reporter::kViewOtherCallMetricValue,
+ ::opencensus::stats::testing::TestUtils::MakeViewData(
+ mock_census_view_provider()->FindViewDescriptor(
+ ::grpc::load_reporter::kViewOtherCallMetricValue),
+ {{{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3, kMetric1}, 9.6},
+ {{kClientIp1 + kLbId2 + kLbTag1, kHostname2, kUser3, kMetric2},
+ 5.7}}));
+ // Set up mock expectation.
+ EXPECT_CALL(*mock_census_view_provider(), FetchViewData())
+ .WillOnce(Return(vdm1))
+ .WillOnce(Return(vdm2));
+ PrepareCpuExpectation(2);
+ // Start testing.
+ load_reporter_->ReportStreamCreated(kHostname1, kLbId1, kLoadKey1);
+ load_reporter_->ReportStreamCreated(kHostname2, kLbId2, kLoadKey2);
+ load_reporter_->ReportStreamCreated(kHostname2, kLbId3, kLoadKey3);
+ // First fetch.
+ load_reporter_->FetchAndSample();
+ load_reporter_->GenerateLoads(kHostname1, kLbId1);
+ gpr_log(GPR_INFO, "First load generated.");
+ // Second fetch.
+ load_reporter_->FetchAndSample();
+ load_reporter_->GenerateLoads(kHostname2, kLbId2);
+ gpr_log(GPR_INFO, "Second load generated.");
+ // TODO(juanlishen): Verify the data.
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc
index 7a95a9f17d..99de5a3e01 100644
--- a/test/cpp/thread_manager/thread_manager_test.cc
+++ b/test/cpp/thread_manager/thread_manager_test.cc
@@ -30,30 +30,44 @@
#include "test/cpp/util/test_config.h"
namespace grpc {
+
+struct ThreadManagerTestSettings {
+ // The min number of pollers that SHOULD be active in ThreadManager
+ int min_pollers;
+ // The max number of pollers that could be active in ThreadManager
+ int max_pollers;
+ // The sleep duration in PollForWork() function to simulate "polling"
+ int poll_duration_ms;
+ // The sleep duration in DoWork() function to simulate "work"
+ int work_duration_ms;
+ // Max number of times PollForWork() is called before shutting down
+ int max_poll_calls;
+};
+
class ThreadManagerTest final : public grpc::ThreadManager {
public:
- ThreadManagerTest()
- : ThreadManager(kMinPollers, kMaxPollers),
+ ThreadManagerTest(const char* name, grpc_resource_quota* rq,
+ const ThreadManagerTestSettings& settings)
+ : ThreadManager(name, rq, settings.min_pollers, settings.max_pollers),
+ settings_(settings),
num_do_work_(0),
num_poll_for_work_(0),
num_work_found_(0) {}
grpc::ThreadManager::WorkStatus PollForWork(void** tag, bool* ok) override;
- void DoWork(void* tag, bool ok) override;
- void PerformTest();
+ void DoWork(void* tag, bool ok, bool resources) override;
+
+ // Get number of times PollForWork() returned WORK_FOUND
+ int GetNumWorkFound();
+ // Get number of times DoWork() was called
+ int GetNumDoWork();
private:
void SleepForMs(int sleep_time_ms);
- static const int kMinPollers = 2;
- static const int kMaxPollers = 10;
-
- static const int kPollingTimeoutMsec = 10;
- static const int kDoWorkDurationMsec = 1;
-
- // PollForWork will return SHUTDOWN after these many number of invocations
- static const int kMaxNumPollForWork = 50;
+ ThreadManagerTestSettings settings_;
+ // Counters
gpr_atm num_do_work_; // Number of calls to DoWork
gpr_atm num_poll_for_work_; // Number of calls to PollForWork
gpr_atm num_work_found_; // Number of times WORK_FOUND was returned
@@ -69,54 +83,117 @@ void ThreadManagerTest::SleepForMs(int duration_ms) {
grpc::ThreadManager::WorkStatus ThreadManagerTest::PollForWork(void** tag,
bool* ok) {
int call_num = gpr_atm_no_barrier_fetch_add(&num_poll_for_work_, 1);
-
- if (call_num >= kMaxNumPollForWork) {
+ if (call_num >= settings_.max_poll_calls) {
Shutdown();
return SHUTDOWN;
}
- // Simulate "polling for work" by sleeping for sometime
- SleepForMs(kPollingTimeoutMsec);
-
+ SleepForMs(settings_.poll_duration_ms); // Simulate "polling" duration
*tag = nullptr;
*ok = true;
- // Return timeout roughly 1 out of every 3 calls
+ // Return timeout roughly 1 out of every 3 calls just to make the test a bit
+ // more interesting
if (call_num % 3 == 0) {
return TIMEOUT;
- } else {
- gpr_atm_no_barrier_fetch_add(&num_work_found_, 1);
- return WORK_FOUND;
}
+
+ gpr_atm_no_barrier_fetch_add(&num_work_found_, 1);
+ return WORK_FOUND;
}
-void ThreadManagerTest::DoWork(void* tag, bool ok) {
+void ThreadManagerTest::DoWork(void* tag, bool ok, bool resources) {
gpr_atm_no_barrier_fetch_add(&num_do_work_, 1);
- SleepForMs(kDoWorkDurationMsec); // Simulate doing work by sleeping
+ SleepForMs(settings_.work_duration_ms); // Simulate work by sleeping
}
-void ThreadManagerTest::PerformTest() {
- // Initialize() starts the ThreadManager
- Initialize();
-
- // Wait for all the threads to gracefully terminate
- Wait();
+int ThreadManagerTest::GetNumWorkFound() {
+ return static_cast<int>(gpr_atm_no_barrier_load(&num_work_found_));
+}
- // The number of times DoWork() was called is equal to the number of times
- // WORK_FOUND was returned
- gpr_log(GPR_DEBUG, "DoWork() called %" PRIdPTR " times",
- gpr_atm_no_barrier_load(&num_do_work_));
- GPR_ASSERT(gpr_atm_no_barrier_load(&num_do_work_) ==
- gpr_atm_no_barrier_load(&num_work_found_));
+int ThreadManagerTest::GetNumDoWork() {
+ return static_cast<int>(gpr_atm_no_barrier_load(&num_do_work_));
}
} // namespace grpc
+// Test that the number of times DoWork() is called is equal to the number of
+// times PollForWork() returned WORK_FOUND
+static void TestPollAndWork() {
+ grpc_resource_quota* rq = grpc_resource_quota_create("Test-poll-and-work");
+ grpc::ThreadManagerTestSettings settings = {
+ 2 /* min_pollers */, 10 /* max_pollers */, 10 /* poll_duration_ms */,
+ 1 /* work_duration_ms */, 50 /* max_poll_calls */};
+
+ grpc::ThreadManagerTest test_thread_mgr("TestThreadManager", rq, settings);
+ grpc_resource_quota_unref(rq);
+
+ test_thread_mgr.Initialize(); // Start the thread manager
+ test_thread_mgr.Wait(); // Wait for all threads to finish
+
+ // Verify that The number of times DoWork() was called is equal to the number
+ // of times WORK_FOUND was returned
+ gpr_log(GPR_DEBUG, "DoWork() called %d times",
+ test_thread_mgr.GetNumDoWork());
+ GPR_ASSERT(test_thread_mgr.GetNumDoWork() ==
+ test_thread_mgr.GetNumWorkFound());
+}
+
+static void TestThreadQuota() {
+ const int kMaxNumThreads = 3;
+ grpc_resource_quota* rq = grpc_resource_quota_create("Test-thread-quota");
+ grpc_resource_quota_set_max_threads(rq, kMaxNumThreads);
+
+ // Set work_duration_ms to be much greater than poll_duration_ms. This way,
+ // the thread manager will be forced to create more 'polling' threads to
+ // honor the min_pollers guarantee
+ grpc::ThreadManagerTestSettings settings = {
+ 1 /* min_pollers */, 1 /* max_pollers */, 1 /* poll_duration_ms */,
+ 10 /* work_duration_ms */, 50 /* max_poll_calls */};
+
+ // Create two thread managers (but with same resource quota). This means
+ // that the max number of active threads across BOTH the thread managers
+ // cannot be greater than kMaxNumthreads
+ grpc::ThreadManagerTest test_thread_mgr_1("TestThreadManager-1", rq,
+ settings);
+ grpc::ThreadManagerTest test_thread_mgr_2("TestThreadManager-2", rq,
+ settings);
+ // It is ok to unref resource quota before starting thread managers.
+ grpc_resource_quota_unref(rq);
+
+ // Start both thread managers
+ test_thread_mgr_1.Initialize();
+ test_thread_mgr_2.Initialize();
+
+ // Wait for both to finish
+ test_thread_mgr_1.Wait();
+ test_thread_mgr_2.Wait();
+
+ // Now verify that the total number of active threads in either thread manager
+ // never exceeds kMaxNumThreads
+ //
+ // NOTE: Actually the total active threads across *both* thread managers at
+ // any point of time never exceeds kMaxNumThreads but unfortunately there is
+ // no easy way to verify it (i.e we can't just do (max1 + max2 <= k))
+ // Its okay to not test this case here. The resource quota c-core tests
+ // provide enough coverage to resource quota object with multiple resource
+ // users
+ int max1 = test_thread_mgr_1.GetMaxActiveThreadsSoFar();
+ int max2 = test_thread_mgr_2.GetMaxActiveThreadsSoFar();
+ gpr_log(
+ GPR_DEBUG,
+ "MaxActiveThreads in TestThreadManager_1: %d, TestThreadManager_2: %d",
+ max1, max2);
+ GPR_ASSERT(max1 <= kMaxNumThreads && max2 <= kMaxNumThreads);
+}
+
int main(int argc, char** argv) {
std::srand(std::time(nullptr));
-
grpc::testing::InitTest(&argc, &argv, true);
- grpc::ThreadManagerTest test_rpc_manager;
- test_rpc_manager.PerformTest();
+ grpc_init();
+
+ TestPollAndWork();
+ TestThreadQuota();
+ grpc_shutdown();
return 0;
}
diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD
index b1153d2df3..477862a0ee 100644
--- a/test/cpp/util/BUILD
+++ b/test/cpp/util/BUILD
@@ -177,6 +177,7 @@ grpc_cc_test(
"//:grpc++_reflection",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
+ "//test/core/end2end:ssl_test_data",
"//test/core/util:grpc_test_util",
],
)
@@ -217,6 +218,7 @@ grpc_cc_test(
],
deps = [
"//:grpc++",
+ "//test/core/util:gpr_test_util",
],
)
@@ -260,33 +262,22 @@ grpc_cc_test(
deps = [
"//:grpc++_error_details",
"//src/proto/grpc/testing:echo_messages_proto",
+ "//test/core/util:gpr_test_util",
],
)
grpc_cc_binary(
name = "grpc_cli",
srcs = [
- "cli_call.cc",
- "cli_call.h",
- "cli_credentials.cc",
- "cli_credentials.h",
- "config_grpc_cli.h",
"grpc_cli.cc",
- "grpc_tool.cc",
- "grpc_tool.h",
- "proto_file_parser.cc",
- "proto_file_parser.h",
- "proto_reflection_descriptor_database.cc",
- "proto_reflection_descriptor_database.h",
- "service_describer.cc",
- "service_describer.h",
- "test_config.h",
- "test_config_cc.cc",
],
external_deps = [
"gflags",
],
deps = [
+ ":grpc_cli_libs",
+ ":grpc++_proto_reflection_desc_db",
+ ":test_config",
"//:grpc++",
"//src/proto/grpc/reflection/v1alpha:reflection_proto",
],
diff --git a/test/cpp/util/byte_buffer_proto_helper.cc b/test/cpp/util/byte_buffer_proto_helper.cc
index bb5162f86e..37098955d4 100644
--- a/test/cpp/util/byte_buffer_proto_helper.cc
+++ b/test/cpp/util/byte_buffer_proto_helper.cc
@@ -40,5 +40,18 @@ std::unique_ptr<ByteBuffer> SerializeToByteBuffer(
return std::unique_ptr<ByteBuffer>(new ByteBuffer(&slice, 1));
}
+bool SerializeToByteBufferInPlace(grpc::protobuf::Message* message,
+ ByteBuffer* buffer) {
+ grpc::string buf;
+ if (!message->SerializeToString(&buf)) {
+ return false;
+ }
+ buffer->Clear();
+ Slice slice(buf);
+ ByteBuffer tmp(&slice, 1);
+ buffer->Swap(&tmp);
+ return true;
+}
+
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/util/byte_buffer_proto_helper.h b/test/cpp/util/byte_buffer_proto_helper.h
index 94603db110..eb923eccb5 100644
--- a/test/cpp/util/byte_buffer_proto_helper.h
+++ b/test/cpp/util/byte_buffer_proto_helper.h
@@ -32,6 +32,9 @@ bool ParseFromByteBuffer(ByteBuffer* buffer, grpc::protobuf::Message* message);
std::unique_ptr<ByteBuffer> SerializeToByteBuffer(
grpc::protobuf::Message* message);
+bool SerializeToByteBufferInPlace(grpc::protobuf::Message* message,
+ ByteBuffer* buffer);
+
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc
index 47a5b7f03a..9bffbf7ac1 100644
--- a/test/cpp/util/byte_buffer_test.cc
+++ b/test/cpp/util/byte_buffer_test.cc
@@ -38,6 +38,13 @@ const char* kContent2 = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy world";
class ByteBufferTest : public ::testing::Test {};
+TEST_F(ByteBufferTest, CopyCtor) {
+ ByteBuffer buffer1;
+ EXPECT_FALSE(buffer1.Valid());
+ const ByteBuffer& buffer2 = buffer1;
+ EXPECT_FALSE(buffer2.Valid());
+}
+
TEST_F(ByteBufferTest, CreateFromSingleSlice) {
Slice s(kContent1);
ByteBuffer buffer(&s, 1);
diff --git a/test/cpp/util/channel_trace_proto_helper.cc b/test/cpp/util/channel_trace_proto_helper.cc
index fbc9f1501c..42a436d49b 100644
--- a/test/cpp/util/channel_trace_proto_helper.cc
+++ b/test/cpp/util/channel_trace_proto_helper.cc
@@ -30,26 +30,69 @@
namespace grpc {
namespace testing {
-void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str) {
- std::string tracer_json_str(tracer_json_c_str);
- grpc::channelz::ChannelTrace channel_trace;
+namespace {
+
+// Generic helper that takes in a json string, converts it to a proto, and
+// then back to json. This ensures that the json string was correctly formatted
+// according to https://developers.google.com/protocol-buffers/docs/proto3#json
+template <typename Message>
+void VaidateProtoJsonTranslation(char* json_c_str) {
+ std::string json_str(json_c_str);
+ Message msg;
google::protobuf::util::JsonParseOptions parse_options;
// If the following line is failing, then uncomment the last line of the
// comment, and uncomment the lines that print the two strings. You can
// then compare the output, and determine what fields are missing.
//
- // options.ignore_unknown_fields = true;
- ASSERT_EQ(google::protobuf::util::JsonStringToMessage(
- tracer_json_str, &channel_trace, parse_options),
+ // parse_options.ignore_unknown_fields = true;
+ EXPECT_EQ(google::protobuf::util::JsonStringToMessage(json_str, &msg,
+ parse_options),
google::protobuf::util::Status::OK);
std::string proto_json_str;
- ASSERT_EQ(google::protobuf::util::MessageToJsonString(channel_trace,
- &proto_json_str),
+ google::protobuf::util::JsonPrintOptions print_options;
+ // We usually do not want this to be true, however it can be helpful to
+ // uncomment and see the output produced then all fields are printed.
+ // print_options.always_print_primitive_fields = true;
+ EXPECT_EQ(google::protobuf::util::MessageToJsonString(msg, &proto_json_str,
+ print_options),
google::protobuf::util::Status::OK);
// uncomment these to compare the the json strings.
- // gpr_log(GPR_ERROR, "tracer json: %s", tracer_json_str.c_str());
+ // gpr_log(GPR_ERROR, "tracer json: %s", json_str.c_str());
// gpr_log(GPR_ERROR, "proto json: %s", proto_json_str.c_str());
- ASSERT_EQ(tracer_json_str, proto_json_str);
+ EXPECT_EQ(json_str, proto_json_str);
+}
+
+} // namespace
+
+void ValidateChannelTraceProtoJsonTranslation(char* json_c_str) {
+ VaidateProtoJsonTranslation<grpc::channelz::v1::ChannelTrace>(json_c_str);
+}
+
+void ValidateChannelProtoJsonTranslation(char* json_c_str) {
+ VaidateProtoJsonTranslation<grpc::channelz::v1::Channel>(json_c_str);
+}
+
+void ValidateGetTopChannelsResponseProtoJsonTranslation(char* json_c_str) {
+ VaidateProtoJsonTranslation<grpc::channelz::v1::GetTopChannelsResponse>(
+ json_c_str);
+}
+
+void ValidateGetChannelResponseProtoJsonTranslation(char* json_c_str) {
+ VaidateProtoJsonTranslation<grpc::channelz::v1::GetChannelResponse>(
+ json_c_str);
+}
+
+void ValidateSubchannelProtoJsonTranslation(char* json_c_str) {
+ VaidateProtoJsonTranslation<grpc::channelz::v1::Subchannel>(json_c_str);
+}
+
+void ValidateServerProtoJsonTranslation(char* json_c_str) {
+ VaidateProtoJsonTranslation<grpc::channelz::v1::Server>(json_c_str);
+}
+
+void ValidateGetServersResponseProtoJsonTranslation(char* json_c_str) {
+ VaidateProtoJsonTranslation<grpc::channelz::v1::GetServersResponse>(
+ json_c_str);
}
} // namespace testing
diff --git a/test/cpp/util/channel_trace_proto_helper.h b/test/cpp/util/channel_trace_proto_helper.h
index d7043d9f06..67c363e89b 100644
--- a/test/cpp/util/channel_trace_proto_helper.h
+++ b/test/cpp/util/channel_trace_proto_helper.h
@@ -22,7 +22,13 @@
namespace grpc {
namespace testing {
-void ValidateChannelTraceProtoJsonTranslation(char* tracer_json_c_str);
+void ValidateChannelTraceProtoJsonTranslation(char* json_c_str);
+void ValidateChannelProtoJsonTranslation(char* json_c_str);
+void ValidateGetTopChannelsResponseProtoJsonTranslation(char* json_c_str);
+void ValidateGetChannelResponseProtoJsonTranslation(char* json_c_str);
+void ValidateSubchannelProtoJsonTranslation(char* json_c_str);
+void ValidateServerProtoJsonTranslation(char* json_c_str);
+void ValidateGetServersResponseProtoJsonTranslation(char* json_c_str);
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc
index a3992ab278..c258bde908 100644
--- a/test/cpp/util/cli_call.cc
+++ b/test/cpp/util/cli_call.cc
@@ -19,6 +19,7 @@
#include "test/cpp/util/cli_call.h"
#include <iostream>
+#include <utility>
#include <grpc/grpc.h>
#include <grpc/slice.h>
@@ -39,7 +40,7 @@ Status CliCall::Call(std::shared_ptr<grpc::Channel> channel,
const OutgoingMetadataContainer& metadata,
IncomingMetadataContainer* server_initial_metadata,
IncomingMetadataContainer* server_trailing_metadata) {
- CliCall call(channel, method, metadata);
+ CliCall call(std::move(channel), method, metadata);
call.Write(request);
call.WritesDone();
if (!call.Read(response, server_initial_metadata)) {
@@ -48,7 +49,7 @@ Status CliCall::Call(std::shared_ptr<grpc::Channel> channel,
return call.Finish(server_trailing_metadata);
}
-CliCall::CliCall(std::shared_ptr<grpc::Channel> channel,
+CliCall::CliCall(const std::shared_ptr<grpc::Channel>& channel,
const grpc::string& method,
const OutgoingMetadataContainer& metadata)
: stub_(new grpc::GenericStub(channel)) {
diff --git a/test/cpp/util/cli_call.h b/test/cpp/util/cli_call.h
index 51ffafd29f..3f279095a4 100644
--- a/test/cpp/util/cli_call.h
+++ b/test/cpp/util/cli_call.h
@@ -42,7 +42,8 @@ class CliCall final {
typedef std::multimap<grpc::string_ref, grpc::string_ref>
IncomingMetadataContainer;
- CliCall(std::shared_ptr<grpc::Channel> channel, const grpc::string& method,
+ CliCall(const std::shared_ptr<grpc::Channel>& channel,
+ const grpc::string& method,
const OutgoingMetadataContainer& metadata);
~CliCall();
diff --git a/test/cpp/util/cli_credentials.cc b/test/cpp/util/cli_credentials.cc
index aa4eafb756..1125b2d945 100644
--- a/test/cpp/util/cli_credentials.cc
+++ b/test/cpp/util/cli_credentials.cc
@@ -19,46 +19,210 @@
#include "test/cpp/util/cli_credentials.h"
#include <gflags/gflags.h>
+#include <grpc/slice.h>
+#include <grpc/support/log.h>
+#include <grpcpp/impl/codegen/slice.h>
-DEFINE_bool(enable_ssl, false, "Whether to use ssl/tls.");
-DEFINE_bool(use_auth, false, "Whether to create default google credentials.");
+#include "src/core/lib/iomgr/load_file.h"
+
+DEFINE_bool(
+ enable_ssl, false,
+ "Whether to use ssl/tls. Deprecated. Use --channel_creds_type=ssl.");
+DEFINE_bool(use_auth, false,
+ "Whether to create default google credentials. Deprecated. Use "
+ "--channel_creds_type=gdc.");
DEFINE_string(
access_token, "",
- "The access token that will be sent to the server to authenticate RPCs.");
+ "The access token that will be sent to the server to authenticate RPCs. "
+ "Deprecated. Use --call_creds=access_token=<token>.");
+DEFINE_string(
+ ssl_target, "",
+ "If not empty, treat the server host name as this for ssl/tls certificate "
+ "validation.");
+DEFINE_string(
+ ssl_client_cert, "",
+ "If not empty, load this PEM formated client certificate file. Requires "
+ "use of --ssl_client_key.");
+DEFINE_string(
+ ssl_client_key, "",
+ "If not empty, load this PEM formated private key. Requires use of "
+ "--ssl_client_cert");
+DEFINE_string(
+ channel_creds_type, "",
+ "The channel creds type: insecure, ssl, gdc (Google Default Credentials) "
+ "or alts.");
+DEFINE_string(
+ call_creds, "",
+ "Call credentials to use: none (default), or access_token=<token>. If "
+ "provided, the call creds are composited on top of channel creds.");
namespace grpc {
namespace testing {
-std::shared_ptr<grpc::ChannelCredentials> CliCredentials::GetCredentials()
- const {
- if (!FLAGS_access_token.empty()) {
- if (FLAGS_use_auth) {
- fprintf(stderr,
- "warning: use_auth is ignored when access_token is provided.");
- }
+namespace {
- return grpc::CompositeChannelCredentials(
- grpc::SslCredentials(grpc::SslCredentialsOptions()),
- grpc::AccessTokenCredentials(FLAGS_access_token));
+const char ACCESS_TOKEN_PREFIX[] = "access_token=";
+constexpr int ACCESS_TOKEN_PREFIX_LEN =
+ sizeof(ACCESS_TOKEN_PREFIX) / sizeof(*ACCESS_TOKEN_PREFIX) - 1;
+
+bool IsAccessToken(const grpc::string& auth) {
+ return auth.length() > ACCESS_TOKEN_PREFIX_LEN &&
+ auth.compare(0, ACCESS_TOKEN_PREFIX_LEN, ACCESS_TOKEN_PREFIX) == 0;
+}
+
+grpc::string AccessToken(const grpc::string& auth) {
+ if (!IsAccessToken(auth)) {
+ return "";
+ }
+ return grpc::string(auth, ACCESS_TOKEN_PREFIX_LEN);
+}
+
+} // namespace
+
+grpc::string CliCredentials::GetDefaultChannelCredsType() const {
+ // Compatibility logic for --enable_ssl.
+ if (FLAGS_enable_ssl) {
+ fprintf(stderr,
+ "warning: --enable_ssl is deprecated. Use "
+ "--channel_creds_type=ssl.\n");
+ return "ssl";
}
+ // Compatibility logic for --use_auth.
+ if (FLAGS_access_token.empty() && FLAGS_use_auth) {
+ fprintf(stderr,
+ "warning: --use_auth is deprecated. Use "
+ "--channel_creds_type=gdc.\n");
+ return "gdc";
+ }
+ return "insecure";
+}
- if (FLAGS_use_auth) {
+grpc::string CliCredentials::GetDefaultCallCreds() const {
+ if (!FLAGS_access_token.empty()) {
+ fprintf(stderr,
+ "warning: --access_token is deprecated. Use "
+ "--call_creds=access_token=<token>.\n");
+ return grpc::string("access_token=") + FLAGS_access_token;
+ }
+ return "none";
+}
+
+std::shared_ptr<grpc::ChannelCredentials>
+CliCredentials::GetChannelCredentials() const {
+ if (FLAGS_channel_creds_type.compare("insecure") == 0) {
+ return grpc::InsecureChannelCredentials();
+ } else if (FLAGS_channel_creds_type.compare("ssl") == 0) {
+ grpc::SslCredentialsOptions ssl_creds_options;
+ // TODO(@Capstan): This won't affect Google Default Credentials using SSL.
+ if (!FLAGS_ssl_client_cert.empty()) {
+ grpc_slice cert_slice = grpc_empty_slice();
+ GRPC_LOG_IF_ERROR(
+ "load_file",
+ grpc_load_file(FLAGS_ssl_client_cert.c_str(), 1, &cert_slice));
+ ssl_creds_options.pem_cert_chain =
+ grpc::StringFromCopiedSlice(cert_slice);
+ grpc_slice_unref(cert_slice);
+ }
+ if (!FLAGS_ssl_client_key.empty()) {
+ grpc_slice key_slice = grpc_empty_slice();
+ GRPC_LOG_IF_ERROR(
+ "load_file",
+ grpc_load_file(FLAGS_ssl_client_key.c_str(), 1, &key_slice));
+ ssl_creds_options.pem_private_key =
+ grpc::StringFromCopiedSlice(key_slice);
+ grpc_slice_unref(key_slice);
+ }
+ return grpc::SslCredentials(ssl_creds_options);
+ } else if (FLAGS_channel_creds_type.compare("gdc") == 0) {
return grpc::GoogleDefaultCredentials();
+ } else if (FLAGS_channel_creds_type.compare("alts") == 0) {
+ return grpc::experimental::AltsCredentials(
+ grpc::experimental::AltsCredentialsOptions());
}
+ fprintf(stderr,
+ "--channel_creds_type=%s invalid; must be insecure, ssl, gdc or "
+ "alts.\n",
+ FLAGS_channel_creds_type.c_str());
+ return std::shared_ptr<grpc::ChannelCredentials>();
+}
- if (FLAGS_enable_ssl) {
- return grpc::SslCredentials(grpc::SslCredentialsOptions());
+std::shared_ptr<grpc::CallCredentials> CliCredentials::GetCallCredentials()
+ const {
+ if (IsAccessToken(FLAGS_call_creds)) {
+ return grpc::AccessTokenCredentials(AccessToken(FLAGS_call_creds));
+ }
+ if (FLAGS_call_creds.compare("none") != 0) {
+ // Nothing to do; creds, if any, are baked into the channel.
+ return std::shared_ptr<grpc::CallCredentials>();
}
+ fprintf(stderr,
+ "--call_creds=%s invalid; must be none "
+ "or access_token=<token>.\n",
+ FLAGS_call_creds.c_str());
+ return std::shared_ptr<grpc::CallCredentials>();
+}
- return grpc::InsecureChannelCredentials();
+std::shared_ptr<grpc::ChannelCredentials> CliCredentials::GetCredentials()
+ const {
+ if (FLAGS_call_creds.empty()) {
+ FLAGS_call_creds = GetDefaultCallCreds();
+ } else if (!FLAGS_access_token.empty() && !IsAccessToken(FLAGS_call_creds)) {
+ fprintf(stderr,
+ "warning: ignoring --access_token because --call_creds "
+ "already set to %s.\n",
+ FLAGS_call_creds.c_str());
+ }
+ if (FLAGS_channel_creds_type.empty()) {
+ FLAGS_channel_creds_type = GetDefaultChannelCredsType();
+ } else if (FLAGS_enable_ssl && FLAGS_channel_creds_type.compare("ssl") != 0) {
+ fprintf(stderr,
+ "warning: ignoring --enable_ssl because "
+ "--channel_creds_type already set to %s.\n",
+ FLAGS_channel_creds_type.c_str());
+ } else if (FLAGS_use_auth && FLAGS_channel_creds_type.compare("gdc") != 0) {
+ fprintf(stderr,
+ "warning: ignoring --use_auth because "
+ "--channel_creds_type already set to %s.\n",
+ FLAGS_channel_creds_type.c_str());
+ }
+ // Legacy transport upgrade logic for insecure requests.
+ if (IsAccessToken(FLAGS_call_creds) &&
+ FLAGS_channel_creds_type.compare("insecure") == 0) {
+ fprintf(stderr,
+ "warning: --channel_creds_type=insecure upgraded to ssl because "
+ "an access token was provided.\n");
+ FLAGS_channel_creds_type = "ssl";
+ }
+ std::shared_ptr<grpc::ChannelCredentials> channel_creds =
+ GetChannelCredentials();
+ // Composite any call-type credentials on top of the base channel.
+ std::shared_ptr<grpc::CallCredentials> call_creds = GetCallCredentials();
+ return (channel_creds == nullptr || call_creds == nullptr)
+ ? channel_creds
+ : grpc::CompositeChannelCredentials(channel_creds, call_creds);
}
const grpc::string CliCredentials::GetCredentialUsage() const {
- return " --enable_ssl ; Set whether to use tls\n"
+ return " --enable_ssl ; Set whether to use ssl (deprecated)\n"
" --use_auth ; Set whether to create default google"
" credentials\n"
+ " ; (deprecated)\n"
" --access_token ; Set the access token in metadata,"
- " overrides --use_auth\n";
+ " overrides --use_auth\n"
+ " ; (deprecated)\n"
+ " --ssl_target ; Set server host for ssl validation\n"
+ " --ssl_client_cert ; Client cert for ssl\n"
+ " --ssl_client_key ; Client private key for ssl\n"
+ " --channel_creds_type ; Set to insecure, ssl, gdc, or alts\n"
+ " --call_creds ; Set to none, or"
+ " access_token=<token>\n";
+}
+
+const grpc::string CliCredentials::GetSslTargetNameOverride() const {
+ bool use_ssl = FLAGS_channel_creds_type.compare("ssl") == 0 ||
+ FLAGS_channel_creds_type.compare("gdc") == 0;
+ return use_ssl ? FLAGS_ssl_target : "";
}
+
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/util/cli_credentials.h b/test/cpp/util/cli_credentials.h
index b1358e77d8..472c7abef2 100644
--- a/test/cpp/util/cli_credentials.h
+++ b/test/cpp/util/cli_credentials.h
@@ -28,8 +28,25 @@ namespace testing {
class CliCredentials {
public:
virtual ~CliCredentials() {}
- virtual std::shared_ptr<grpc::ChannelCredentials> GetCredentials() const;
+ std::shared_ptr<grpc::ChannelCredentials> GetCredentials() const;
virtual const grpc::string GetCredentialUsage() const;
+ virtual const grpc::string GetSslTargetNameOverride() const;
+
+ protected:
+ // Returns the appropriate channel_creds_type value for the set of legacy
+ // flag arguments.
+ virtual grpc::string GetDefaultChannelCredsType() const;
+ // Returns the appropriate call_creds value for the set of legacy flag
+ // arguments.
+ virtual grpc::string GetDefaultCallCreds() const;
+ // Returns the base transport channel credentials. Child classes can override
+ // to support additional channel_creds_types unknown to this base class.
+ virtual std::shared_ptr<grpc::ChannelCredentials> GetChannelCredentials()
+ const;
+ // Returns call credentials to composite onto the base transport channel
+ // credentials. Child classes can override to support additional
+ // authentication flags unknown to this base class.
+ virtual std::shared_ptr<grpc::CallCredentials> GetCallCredentials() const;
};
} // namespace testing
diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc
index 195b6bd304..ccc60cca27 100644
--- a/test/cpp/util/grpc_tool.cc
+++ b/test/cpp/util/grpc_tool.cc
@@ -206,6 +206,15 @@ void ReadResponse(CliCall* call, const grpc::string& method_name,
}
}
+std::shared_ptr<grpc::Channel> CreateCliChannel(
+ const grpc::string& server_address, const CliCredentials& cred) {
+ grpc::ChannelArguments args;
+ if (!cred.GetSslTargetNameOverride().empty()) {
+ args.SetSslTargetNameOverride(cred.GetSslTargetNameOverride());
+ }
+ return grpc::CreateCustomChannel(server_address, cred.GetCredentials(), args);
+}
+
struct Command {
const char* command;
std::function<bool(GrpcTool*, int, const char**, const CliCredentials&,
@@ -324,7 +333,7 @@ bool GrpcTool::ListServices(int argc, const char** argv,
grpc::string server_address(argv[0]);
std::shared_ptr<grpc::Channel> channel =
- grpc::CreateChannel(server_address, cred.GetCredentials());
+ CreateCliChannel(server_address, cred);
grpc::ProtoReflectionDescriptorDatabase desc_db(channel);
grpc::protobuf::DescriptorPool desc_pool(&desc_db);
@@ -422,7 +431,7 @@ bool GrpcTool::PrintType(int argc, const char** argv,
grpc::string server_address(argv[0]);
std::shared_ptr<grpc::Channel> channel =
- grpc::CreateChannel(server_address, cred.GetCredentials());
+ CreateCliChannel(server_address, cred);
grpc::ProtoReflectionDescriptorDatabase desc_db(channel);
grpc::protobuf::DescriptorPool desc_pool(&desc_db);
@@ -469,19 +478,28 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
bool print_mode = false;
std::shared_ptr<grpc::Channel> channel =
- grpc::CreateChannel(server_address, cred.GetCredentials());
+ CreateCliChannel(server_address, cred);
- parser.reset(new grpc::testing::ProtoFileParser(
- FLAGS_remotedb ? channel : nullptr, FLAGS_proto_path, FLAGS_protofiles));
+ if (!FLAGS_binary_input || !FLAGS_binary_output) {
+ parser.reset(
+ new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
+ FLAGS_proto_path, FLAGS_protofiles));
+ if (parser->HasError()) {
+ fprintf(
+ stderr,
+ "Failed to find remote reflection service and local proto files.\n");
+ return false;
+ }
+ }
if (FLAGS_binary_input) {
formatted_method_name = method_name;
} else {
formatted_method_name = parser->GetFormattedMethodName(method_name);
- }
-
- if (parser->HasError()) {
- return false;
+ if (parser->HasError()) {
+ fprintf(stderr, "Failed to find method %s in proto files.\n",
+ method_name.c_str());
+ }
}
if (argc == 3) {
@@ -711,6 +729,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
serialized_request_proto = parser->GetSerializedProtoFromMethod(
method_name, request_text, true /* is_request */);
if (parser->HasError()) {
+ fprintf(stderr, "Failed to parse request.\n");
return false;
}
}
@@ -735,6 +754,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
serialized_response_proto = parser->GetTextFormatFromMethod(
method_name, serialized_response_proto, false /* is_request */);
if (parser->HasError()) {
+ fprintf(stderr, "Failed to parse response.\n");
return false;
}
}
@@ -809,11 +829,14 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
if (!FLAGS_binary_input || !FLAGS_binary_output) {
std::shared_ptr<grpc::Channel> channel =
- grpc::CreateChannel(server_address, cred.GetCredentials());
+ CreateCliChannel(server_address, cred);
parser.reset(
new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
FLAGS_proto_path, FLAGS_protofiles));
if (parser->HasError()) {
+ fprintf(
+ stderr,
+ "Failed to find remote reflection service and local proto files.\n");
return false;
}
}
@@ -824,6 +847,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
serialized_request_proto =
parser->GetSerializedProtoFromMessageType(type_name, message_text);
if (parser->HasError()) {
+ fprintf(stderr, "Failed to serialize the message.\n");
return false;
}
}
@@ -834,6 +858,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
grpc::string output_text = parser->GetTextFormatFromMessageType(
type_name, serialized_request_proto);
if (parser->HasError()) {
+ fprintf(stderr, "Failed to deserialize the message.\n");
return false;
}
output_ss << output_text << std::endl;
diff --git a/test/cpp/util/grpc_tool_test.cc b/test/cpp/util/grpc_tool_test.cc
index 6574d1bb44..3aae090e81 100644
--- a/test/cpp/util/grpc_tool_test.cc
+++ b/test/cpp/util/grpc_tool_test.cc
@@ -35,6 +35,7 @@
#include "src/core/lib/gpr/env.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "src/proto/grpc/testing/echo.pb.h"
+#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#include "test/cpp/util/cli_credentials.h"
@@ -80,6 +81,9 @@ using grpc::testing::EchoResponse;
" peer: \"peer\"\n" \
"}\n\n"
+DECLARE_string(channel_creds_type);
+DECLARE_string(ssl_target);
+
namespace grpc {
namespace testing {
@@ -97,10 +101,19 @@ const int kServerDefaultResponseStreamsToSend = 3;
class TestCliCredentials final : public grpc::testing::CliCredentials {
public:
- std::shared_ptr<grpc::ChannelCredentials> GetCredentials() const override {
- return InsecureChannelCredentials();
+ TestCliCredentials(bool secure = false) : secure_(secure) {}
+ std::shared_ptr<grpc::ChannelCredentials> GetChannelCredentials()
+ const override {
+ if (!secure_) {
+ return InsecureChannelCredentials();
+ }
+ SslCredentialsOptions ssl_opts = {test_root_cert, "", ""};
+ return SslCredentials(grpc::SslCredentialsOptions(ssl_opts));
}
const grpc::string GetCredentialUsage() const override { return ""; }
+
+ private:
+ const bool secure_;
};
bool PrintStream(std::stringstream* ss, const grpc::string& output) {
@@ -206,13 +219,24 @@ class GrpcToolTest : public ::testing::Test {
// SetUpServer cannot be used with EXPECT_EXIT. grpc_pick_unused_port_or_die()
// uses atexit() to free chosen ports, and it will spawn a new thread in
// resolve_address_posix.c:192 at exit time.
- const grpc::string SetUpServer() {
+ const grpc::string SetUpServer(bool secure = false) {
std::ostringstream server_address;
int port = grpc_pick_unused_port_or_die();
server_address << "localhost:" << port;
// Setup server
ServerBuilder builder;
- builder.AddListeningPort(server_address.str(), InsecureServerCredentials());
+ std::shared_ptr<grpc::ServerCredentials> creds;
+ if (secure) {
+ SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key,
+ test_server1_cert};
+ SslServerCredentialsOptions ssl_opts;
+ ssl_opts.pem_root_certs = "";
+ ssl_opts.pem_key_cert_pairs.push_back(pkcp);
+ creds = SslServerCredentials(ssl_opts);
+ } else {
+ creds = InsecureServerCredentials();
+ }
+ builder.AddListeningPort(server_address.str(), creds);
builder.RegisterService(&service_);
server_ = builder.BuildAndStart();
return server_address.str();
@@ -743,6 +767,29 @@ TEST_F(GrpcToolTest, CallCommandWithBadMetadata) {
gpr_free(test_srcdir);
}
+TEST_F(GrpcToolTest, ListCommand_OverrideSslHostName) {
+ const grpc::string server_address = SetUpServer(true);
+
+ // Test input "grpc_cli ls localhost:<port> --channel_creds_type=ssl
+ // --ssl_target=z.test.google.fr"
+ std::stringstream output_stream;
+ const char* argv[] = {"grpc_cli", "ls", server_address.c_str()};
+ FLAGS_l = false;
+ FLAGS_channel_creds_type = "ssl";
+ FLAGS_ssl_target = "z.test.google.fr";
+ EXPECT_TRUE(
+ 0 == GrpcToolMainLib(
+ ArraySize(argv), argv, TestCliCredentials(true),
+ std::bind(PrintStream, &output_stream, std::placeholders::_1)));
+ EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
+ "grpc.testing.EchoTestService\n"
+ "grpc.reflection.v1alpha.ServerReflection\n"));
+
+ FLAGS_channel_creds_type = "";
+ FLAGS_ssl_target = "";
+ ShutdownServer();
+}
+
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/util/proto_file_parser.cc b/test/cpp/util/proto_file_parser.cc
index 3fc96f38ae..a530ed1ffc 100644
--- a/test/cpp/util/proto_file_parser.cc
+++ b/test/cpp/util/proto_file_parser.cc
@@ -63,7 +63,7 @@ class ErrorPrinter : public protobuf::compiler::MultiFileErrorCollector {
ProtoFileParser* parser_; // not owned
};
-ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel,
+ProtoFileParser::ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
const grpc::string& proto_path,
const grpc::string& protofiles)
: has_error_(false),
diff --git a/test/cpp/util/proto_file_parser.h b/test/cpp/util/proto_file_parser.h
index 2236b59451..eb1d793c2b 100644
--- a/test/cpp/util/proto_file_parser.h
+++ b/test/cpp/util/proto_file_parser.h
@@ -36,7 +36,7 @@ class ProtoFileParser {
// The parser will search proto files using the server reflection service
// provided on the given channel. The given protofiles in a source tree rooted
// from proto_path will also be searched.
- ProtoFileParser(std::shared_ptr<grpc::Channel> channel,
+ ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
const grpc::string& proto_path,
const grpc::string& protofiles);
diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc
index 0adbf20ce6..119272ca42 100644
--- a/test/cpp/util/proto_reflection_descriptor_database.cc
+++ b/test/cpp/util/proto_reflection_descriptor_database.cc
@@ -35,7 +35,7 @@ ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase(
: stub_(std::move(stub)) {}
ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase(
- std::shared_ptr<grpc::Channel> channel)
+ const std::shared_ptr<grpc::Channel>& channel)
: stub_(ServerReflection::NewStub(channel)) {}
ProtoReflectionDescriptorDatabase::~ProtoReflectionDescriptorDatabase() {
@@ -79,7 +79,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileByName(
AddFileFromResponse(response.file_descriptor_response());
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindFileByName(%s)",
filename.c_str());
@@ -126,7 +126,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol(
AddFileFromResponse(response.file_descriptor_response());
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
missing_symbols_.insert(symbol_name);
gpr_log(GPR_INFO,
@@ -182,7 +182,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension(
AddFileFromResponse(response.file_descriptor_response());
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
if (missing_extensions_.find(containing_type) ==
missing_extensions_.end()) {
@@ -238,7 +238,7 @@ bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers(
return true;
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindAllExtensionNumbers(%s)",
extendee_type.c_str());
@@ -265,14 +265,14 @@ bool ProtoReflectionDescriptorDatabase::GetServices(
if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kListServicesResponse) {
- const ListServiceResponse ls_response = response.list_services_response();
+ const ListServiceResponse& ls_response = response.list_services_response();
for (int i = 0; i < ls_response.service_size(); ++i) {
(*output).push_back(ls_response.service(i).name());
}
return true;
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse error = response.error_response();
+ const ErrorResponse& error = response.error_response();
gpr_log(GPR_INFO,
"Error on GetServices()\n\tError code: %d\n"
"\tError Message: %s",
diff --git a/test/cpp/util/proto_reflection_descriptor_database.h b/test/cpp/util/proto_reflection_descriptor_database.h
index e4cf2f207e..46190b3217 100644
--- a/test/cpp/util/proto_reflection_descriptor_database.h
+++ b/test/cpp/util/proto_reflection_descriptor_database.h
@@ -38,7 +38,7 @@ class ProtoReflectionDescriptorDatabase : public protobuf::DescriptorDatabase {
std::unique_ptr<reflection::v1alpha::ServerReflection::Stub> stub);
explicit ProtoReflectionDescriptorDatabase(
- std::shared_ptr<grpc::Channel> channel);
+ const std::shared_ptr<grpc::Channel>& channel);
virtual ~ProtoReflectionDescriptorDatabase();
diff --git a/test/cpp/util/string_ref_test.cc b/test/cpp/util/string_ref_test.cc
index 8f7986e64e..031ec33241 100644
--- a/test/cpp/util/string_ref_test.cc
+++ b/test/cpp/util/string_ref_test.cc
@@ -60,7 +60,7 @@ TEST_F(StringRefTest, FromString) {
TEST_F(StringRefTest, CopyConstructor) {
string_ref s1(kTestString);
;
- string_ref s2(s1);
+ const string_ref& s2(s1);
EXPECT_EQ(s1.length(), s2.length());
EXPECT_EQ(s1.data(), s2.data());
}
diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc
index c8b0ac73f4..0cf75f1e5f 100644
--- a/test/cpp/util/test_credentials_provider.cc
+++ b/test/cpp/util/test_credentials_provider.cc
@@ -63,6 +63,8 @@ class DefaultCredentialsProvider : public CredentialsProvider {
SslCredentialsOptions ssl_opts = {test_root_cert, "", ""};
args->SetSslTargetNameOverride("foo.test.google.fr");
return SslCredentials(ssl_opts);
+ } else if (type == grpc::testing::kGoogleDefaultCredentialsType) {
+ return grpc::GoogleDefaultCredentials();
} else {
std::unique_lock<std::mutex> lock(mu_);
auto it(std::find(added_secure_type_names_.begin(),
diff --git a/test/cpp/util/test_credentials_provider.h b/test/cpp/util/test_credentials_provider.h
index b1d69e893d..0bc910dbc0 100644
--- a/test/cpp/util/test_credentials_provider.h
+++ b/test/cpp/util/test_credentials_provider.h
@@ -33,6 +33,7 @@ const char kInsecureCredentialsType[] = "INSECURE_CREDENTIALS";
// property "transport_security_type".
const char kTlsCredentialsType[] = "ssl";
const char kAltsCredentialsType[] = "alts";
+const char kGoogleDefaultCredentialsType[] = "google_default_credentials";
// Provide test credentials of a particular type.
class CredentialTypeProvider {
diff --git a/test/distrib/cpp/run_distrib_test_cmake.bat b/test/distrib/cpp/run_distrib_test_cmake.bat
index 8eb3b201b1..7658156be1 100644
--- a/test/distrib/cpp/run_distrib_test_cmake.bat
+++ b/test/distrib/cpp/run_distrib_test_cmake.bat
@@ -39,7 +39,7 @@ cd ../../..
cd third_party/protobuf/cmake
mkdir build
cd build
-cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF ..
+cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DZLIB_ROOT=%INSTALL_DIR% -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF ..
cmake --build . --config Release --target install || goto :error
cd ../../../..
diff --git a/test/distrib/cpp/run_distrib_test_routeguide.sh b/test/distrib/cpp/run_distrib_test_routeguide.sh
index dc69ab8377..a81692d920 100755
--- a/test/distrib/cpp/run_distrib_test_routeguide.sh
+++ b/test/distrib/cpp/run_distrib_test_routeguide.sh
@@ -19,7 +19,7 @@ set -ex
cd "$(dirname "$0")/../../.."
cd third_party/protobuf && ./autogen.sh && \
-./configure && make -j4 && make check && make install && ldconfig
+./configure && make -j4 && make install && ldconfig
cd ../.. && make -j4 && make install
diff --git a/test/distrib/csharp/DistribTest/packages.config b/test/distrib/csharp/DistribTest/packages.config
index 84be8f76b5..3cb2c46bcf 100644
--- a/test/distrib/csharp/DistribTest/packages.config
+++ b/test/distrib/csharp/DistribTest/packages.config
@@ -6,6 +6,7 @@
<package id="Grpc" version="__GRPC_NUGET_VERSION__" targetFramework="net45" />
<package id="Grpc.Auth" version="__GRPC_NUGET_VERSION__" targetFramework="net45" />
<package id="Grpc.Core" version="__GRPC_NUGET_VERSION__" targetFramework="net45" />
+ <package id="Grpc.Tools" version="__GRPC_NUGET_VERSION__" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/test/distrib/csharp/run_distrib_test.sh b/test/distrib/csharp/run_distrib_test.sh
index eee24d0e57..61924b91df 100755
--- a/test/distrib/csharp/run_distrib_test.sh
+++ b/test/distrib/csharp/run_distrib_test.sh
@@ -21,8 +21,12 @@ unzip -o "$EXTERNAL_GIT_ROOT/input_artifacts/csharp_nugets_windows_dotnetcli.zip
./update_version.sh auto
-nuget restore
+# Retry "nuget restore" to work around https://github.com/grpc/grpc/issues/16312
+nuget restore || nuget restore || nuget restore
xbuild DistribTest.sln
mono DistribTest/bin/Debug/DistribTest.exe
+
+# test that codegen work
+test_codegen/test_codegen.sh
diff --git a/test/distrib/csharp/test_codegen/test_codegen.sh b/test/distrib/csharp/test_codegen/test_codegen.sh
new file mode 100755
index 0000000000..fa101889f6
--- /dev/null
+++ b/test/distrib/csharp/test_codegen/test_codegen.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# Copyright 2018 The 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.
+
+set -ex
+
+cd "$(dirname "$0")"
+
+ls -lR "../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools"
+
+PLATFORM_ARCH=linux_x64
+if [ "$(uname)" == "Darwin" ]
+then
+ PLATFORM_ARCH=macosx_x64
+elif [ "$(getconf LONG_BIT)" == "32" ]
+then
+ PLATFORM_ARCH=linux_x86
+fi
+
+PROTOC=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/protoc
+PLUGIN=../packages/Grpc.Tools.__GRPC_NUGET_VERSION__/tools/${PLATFORM_ARCH}/grpc_csharp_plugin
+
+"${PROTOC}" --plugin="protoc-gen-grpc=${PLUGIN}" --csharp_out=. --grpc_out=. -I . testcodegen.proto
+
+ls ./*.cs
+
+echo 'Code generation works.'
diff --git a/test/distrib/csharp/test_codegen/testcodegen.proto b/test/distrib/csharp/test_codegen/testcodegen.proto
new file mode 100644
index 0000000000..5c228b81db
--- /dev/null
+++ b/test/distrib/csharp/test_codegen/testcodegen.proto
@@ -0,0 +1,29 @@
+// Copyright 2018 The 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.
+
+syntax = "proto3";
+
+package testcodegen;
+
+service Greeter {
+ rpc SayHello (HelloRequest) returns (HelloReply) {}
+}
+
+message HelloRequest {
+ string name = 1;
+}
+
+message HelloReply {
+ string message = 1;
+}
diff --git a/test/distrib/csharp/update_version.sh b/test/distrib/csharp/update_version.sh
index 9759cc5648..0e47ed3abd 100755
--- a/test/distrib/csharp/update_version.sh
+++ b/test/distrib/csharp/update_version.sh
@@ -28,4 +28,4 @@ then
fi
# Replaces version placeholder with value provided as first argument.
-sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj
+sed -ibak "s/__GRPC_NUGET_VERSION__/${CSHARP_VERSION}/g" DistribTest/packages.config DistribTest/DistribTest.csproj DistribTest/DistribTestDotNet.csproj test_codegen/test_codegen.sh
diff --git a/test/distrib/python/test_packages.sh b/test/distrib/python/test_packages.sh
index 6bf49d45b9..755daa1021 100755
--- a/test/distrib/python/test_packages.sh
+++ b/test/distrib/python/test_packages.sh
@@ -28,10 +28,12 @@ else
echo "Testing Python source distribution"
ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-[0-9]*.tar.gz)
TOOLS_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-tools-[0-9]*.tar.gz)
- HEALTH_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-health-checking-[0-9]*.tar.gz)
- REFLECTION_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-reflection-[0-9]*.tar.gz)
fi
+HEALTH_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-health-checking-[0-9]*.tar.gz)
+REFLECTION_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-reflection-[0-9]*.tar.gz)
+TESTING_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-testing-[0-9]*.tar.gz)
+
VIRTUAL_ENV=$(mktemp -d)
virtualenv "$VIRTUAL_ENV"
PYTHON=$VIRTUAL_ENV/bin/python
@@ -53,13 +55,9 @@ function at_least_one_installs() {
at_least_one_installs "${ARCHIVES[@]}"
at_least_one_installs "${TOOLS_ARCHIVES[@]}"
-
-if [[ "$1" == "source" ]]
-then
- echo "Testing Python health and reflection packages"
- at_least_one_installs "${HEALTH_ARCHIVES[@]}"
- at_least_one_installs "${REFLECTION_ARCHIVES[@]}"
-fi
+at_least_one_installs "${HEALTH_ARCHIVES[@]}"
+at_least_one_installs "${REFLECTION_ARCHIVES[@]}"
+at_least_one_installs "${TESTING_ARCHIVES[@]}"
#