The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

487 lines
12 KiB

# 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.
8 years ago
load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package", "grpc_proto_library")
licenses(["notice"])
8 years ago
grpc_package(
name = "test/core/util",
visibility = "public",
)
grpc_cc_library(
name = "grpc_suppressions",
data = [
"lsan_suppressions.txt",
"tsan_suppressions.txt",
"ubsan_suppressions.txt",
],
)
TEST_UTILS_THAT_USE_GRPC_H_SOURCES = [
"port.cc",
"port_isolated_runtime_environment.cc",
"port_server_client.cc",
"reconnect_server.cc",
"test_config.cc",
"test_tcp_server.cc",
]
TEST_UTILS_THAT_USE_GRPC_H_HEADERS = [
"port.h",
"reconnect_server.h",
"port_server_client.h",
"test_config.h",
"test_tcp_server.h",
]
grpc_cc_library(
name = "grpc_test_util_base",
srcs = [
"cmdline.cc",
7 years ago
"fuzzer_util.cc",
"grpc_profiler.cc",
"histogram.cc",
"mock_endpoint.cc",
"parse_hexstring.cc",
"passthru_endpoint.cc",
"resolve_localhost_ip46.cc",
"slice_splitter.cc",
"tracer_util.cc",
8 years ago
],
hdrs = [
"cmdline.h",
"evaluate_args_test_util.h",
7 years ago
"fuzzer_util.h",
8 years ago
"grpc_profiler.h",
"histogram.h",
"mock_authorization_endpoint.h",
8 years ago
"mock_endpoint.h",
"parse_hexstring.h",
"passthru_endpoint.h",
"resolve_localhost_ip46.h",
8 years ago
"slice_splitter.h",
"tracer_util.h",
8 years ago
],
external_deps = [
"absl/status:statusor",
"absl/strings",
"absl/strings:str_format",
"absl/types:span",
],
language = "C++",
tags = ["nofixdeps"],
deps = [
"//:debug_location",
"//:gpr",
"//:grpc_base",
"//:grpc_security_base",
"//:grpc_trace",
"//:iomgr_timer",
"//:ref_counted_ptr",
"//src/core:arena",
"//src/core:closure",
"//src/core:grpc_authorization_base",
"//src/core:grpc_sockaddr",
"//src/core:iomgr_fwd",
"//src/core:memory_quota",
"//src/core:resolved_address",
"//src/core:resource_quota",
"//src/core:slice",
"//src/core:slice_refcount",
"//src/core:time",
"//src/core:useful",
],
)
grpc_cc_library(
name = "grpc_test_util",
srcs = TEST_UTILS_THAT_USE_GRPC_H_SOURCES + ["tls_utils.cc"],
hdrs = TEST_UTILS_THAT_USE_GRPC_H_HEADERS + ["tls_utils.h"],
external_deps = [
"absl/base:core_headers",
"absl/debugging:failure_signal_handler",
"absl/status",
"absl/status:statusor",
"absl/strings",
"absl/strings:str_format",
],
language = "C++",
deps = [
"build",
"stack_tracer",
"//:config",
"//:exec_ctx",
"//:gpr",
"//:grpc",
"//:grpc_public_hdrs",
"//:grpc_security_base",
"//:httpcli",
"//:orphanable",
"//:ref_counted_ptr",
"//:tsi_ssl_credentials",
"//:uri_parser",
"//src/core:channel_args_endpoint_config",
"//src/core:channel_args_preconditioning",
"//src/core:closure",
"//src/core:error",
"//src/core:gpr_atm",
"//src/core:grpc_sockaddr",
"//src/core:iomgr_fwd",
"//src/core:iomgr_port",
"//src/core:resolved_address",
"//src/core:slice",
"//src/core:slice_refcount",
"//src/core:status_helper",
"//src/core:time",
"//test/core/event_engine:test_init",
],
alwayslink = 1,
)
grpc_cc_library(
name = "grpc_test_util_unsecure",
srcs = TEST_UTILS_THAT_USE_GRPC_H_SOURCES,
hdrs = TEST_UTILS_THAT_USE_GRPC_H_HEADERS,
external_deps = [
"absl/debugging:failure_signal_handler",
"absl/status",
"absl/status:statusor",
"absl/strings",
"absl/strings:str_format",
],
language = "C++",
deps = [
"build",
"stack_tracer",
"//:config",
"//:exec_ctx",
"//:gpr",
"//:grpc_security_base",
"//:grpc_unsecure",
"//:httpcli",
"//:orphanable",
"//:ref_counted_ptr",
"//:uri_parser",
"//src/core:channel_args_endpoint_config",
"//src/core:channel_args_preconditioning",
"//src/core:closure",
"//src/core:error",
"//src/core:gpr_atm",
"//src/core:grpc_sockaddr",
"//src/core:iomgr_fwd",
"//src/core:iomgr_port",
"//src/core:resolved_address",
"//src/core:status_helper",
"//src/core:time",
"//test/core/event_engine:test_init",
],
alwayslink = 1,
)
grpc_cc_test(
name = "cmdline_test",
srcs = ["cmdline_test.cc"],
external_deps = ["gtest"],
language = "C++",
uses_event_engine = False,
uses_polling = False,
deps = [
"grpc_test_util",
"grpc_test_util_base",
"//:gpr",
"//src/core:useful",
],
)
grpc_cc_library(
name = "fuzzer_corpus_test",
testonly = 1,
srcs = ["fuzzer_corpus_test.cc"],
external_deps = [
"absl/flags:flag",
"gtest",
],
linkstatic = True,
tags = [
"no_windows",
"nofixdeps",
],
deps = [
":grpc_test_util",
"//:grpc",
"//test/cpp/util:test_config",
],
)
grpc_cc_test(
name = "histogram_test",
srcs = ["histogram_test.cc"],
external_deps = ["gtest"],
language = "C++",
tags = ["nofixdeps"],
uses_event_engine = False,
uses_polling = False,
deps = [
"grpc_test_util",
"grpc_test_util_base",
"//:gpr",
],
8 years ago
)
sh_library(
name = "fuzzer_one_entry_runner",
srcs = ["fuzzer_one_entry_runner.sh"],
)
grpc_cc_library(
name = "stack_tracer",
srcs = [
"stack_tracer.cc",
],
hdrs = [
"stack_tracer.h",
],
external_deps = [
"absl/debugging:stacktrace",
"absl/debugging:symbolize",
],
language = "C++",
deps = [
"//:gpr_platform",
"//src/core:examine_stack",
],
)
grpc_cc_test(
name = "stack_tracer_test",
srcs = [
"stack_tracer_test.cc",
],
external_deps = [
"absl/strings",
"gtest",
],
language = "C++",
# TODO(https://github.com/grpc/grpc/issues/24627): Disable this on Windows
tags = ["no_windows"],
uses_event_engine = False,
uses_polling = False,
deps = [
"grpc_test_util",
"stack_tracer",
"//:gpr",
],
)
grpc_cc_library(
name = "test_lb_policies",
testonly = 1,
srcs = ["test_lb_policies.cc"],
hdrs = ["test_lb_policies.h"],
external_deps = [
"absl/status",
"absl/status:statusor",
"absl/strings",
"absl/types:variant",
],
deps = [
"//:config",
"//:gpr",
"//:grpc",
"//:grpc_client_channel",
"//:orphanable",
[EventEngine] Modify iomgr to allow creation of event engine clients and client side endpoints (#31661) * [WIP] EventEngine iomgr endpoint shims * [WIP] EventEngine::Endpoint iomgr shims for the PosixEventEngine * Util functions to help with posix engine listener implementation * sanity * update comments in posix_engine_listener_utils.h * review comments * iwyu * revert prev commit * iwyu * update build * update * regenerate projects * regenerate projects * minor fixes * update BUILD * sanity * update build * regenerate projects * fix unused parameter * sanity * update * sanity * regenerate_projects * remove unused variable * start * update * regenerate_projects * sanity * update * fixes * update * regenerate_projects * update * fix sanity and msan failure * more fixes * build failure * update * fix * sanity * fixes * update * regenerate projects * fix sanity * review comments * An EventEngine subclass to be implemented by all posix based event engines * sanity * comments * update * review comments * re-word * fix * update * review comments * regenerate projects * syntax fix * add lock free event benchmark * releasable mutex lock * fix build isue * update * start * regenerate projects * update * fix * windows build * update * windows portability issue * update * update * update * update * format * update * update * update * update * update * fix sanity * regenerate projects * update * iwyu * Fix resolved address length related bugs in tcp_socket_utils and listener_utils * iwyu * cleanup src/core/lib/event_engine/tcp_socket_utils.cc * iwyu * fix * regenerate projects * fix sanity * re-write endpoint shim * more re-write * cleanup * update * review comments * build issue * more build issue fixes plus adding event_engine_trace * even more build issue fixes * iwyu * add static_cast * update * remove redundant code * update * deduplicate * iwyu * Fix review comments and regenerate_projects * sanity * review comments * fix include guards Co-authored-by: AJ Heller <hork@google.com>
2 years ago
"//:parse_address",
"//:ref_counted_ptr",
"//:server_address",
"//:uri_parser",
"//src/core:channel_args",
"//src/core:delegating_helper",
"//src/core:error",
"//src/core:grpc_backend_metric_data",
"//src/core:json",
"//src/core:json_util",
"//src/core:lb_policy",
"//src/core:lb_policy_factory",
"//src/core:lb_policy_registry",
"//src/core:pollset_set",
"//src/core:resolved_address",
"//src/core:status_helper",
"//src/core:subchannel_interface",
"//src/core:time",
],
)
grpc_cc_library(
name = "fake_udp_and_tcp_server",
srcs = ["fake_udp_and_tcp_server.cc"],
hdrs = ["fake_udp_and_tcp_server.h"],
external_deps = [
"absl/status:statusor",
"absl/strings",
],
language = "C++",
deps = [
"grpc_test_util",
"//:gpr",
"//:grpc",
"//:sockaddr_utils",
"//src/core:resolved_address",
],
)
grpc_cc_library(
name = "fake_udp_and_tcp_server_unsecure",
srcs = ["fake_udp_and_tcp_server.cc"],
hdrs = ["fake_udp_and_tcp_server.h"],
external_deps = [
"absl/status:statusor",
"absl/strings",
],
language = "C++",
deps = [
"grpc_test_util_unsecure",
"//:gpr",
"//:grpc",
"//:sockaddr_utils",
"//src/core:resolved_address",
],
)
grpc_cc_library(
name = "socket_use_after_close_detector",
testonly = True,
srcs = ["socket_use_after_close_detector.cc"],
hdrs = ["socket_use_after_close_detector.h"],
external_deps = ["gtest"],
language = "C++",
deps = [
"grpc_test_util",
"//:gpr",
"//:grpc",
"//src/core:grpc_sockaddr",
],
)
grpc_cc_library(
name = "socket_use_after_close_detector_unsecure",
testonly = True,
srcs = ["socket_use_after_close_detector.cc"],
hdrs = ["socket_use_after_close_detector.h"],
external_deps = ["gtest"],
language = "C++",
deps = [
"grpc_test_util_unsecure",
"//:gpr",
"//:grpc",
"//src/core:grpc_sockaddr",
],
)
grpc_cc_library(
name = "build",
srcs = ["build.cc"],
hdrs = ["build.h"],
)
xDS cluster resource type: use ValidationErrors and add unit test (#31025) * XdsBootstrap: move two more methods out of the interface * Automated change: Fix sanity tests * XdsClient: add unit test * Automated change: Fix sanity tests * fix memory leaks * add helper method * add unsubscription * add test for multiple subscriptions * clang-format * fix build * fix flakiness * add checking for other node fields * add v2 test * add response builder * add test for update from server * add test for update containing only changed resources * clang-format * fix build * add test for resource not existing upon subscription * add test for stream closed by server * add test for multiple watchers for the same resource * add test for connection failure * clang-format * add test for resources wrapped in Resource wrapper message * add test for resource validation failure * add test for multiple invalid resources, and fix a case in XdsClient * add test for validation failure for already-cached resource * add test for server not resending resources after stream disconnect * clang-format * fix XdsClient to report channel errors to newly started watchers * fix XdsClient to send cached errors/does-not-exists to newly started watchers * fix watcher to ensure events arrive in the expected order * fix tests * clang-format * add test for multiple resource types * fix xds_cluster_e2e_test * Automated change: Fix sanity tests * cleanup * add federation tests * clang-format * remove now-unnecessary XdsCertificateProviderPluginMapInterface * code review comments * simplify XdsResourceType::Decode() API * XdsClient: add unit tests for XdsClusterResourceType * add XdsClient with gRPC bootstrap config * add LB policy tests * started adding CertificateProvider tests * update for recent API changes * fix merge bugs * xDS resource validation: identify extensions by type_url instead of name * fix build * migrate to ValidationErrors * add xds_common_types_test * finish TLS tests and add LRS tests * move ScopedExperimentalEnvVar to its own library and remove redundant e2e tests * add circuit breaking and outlier detection tests * add validation to outlier detection LB policy parsing * clang-format * Automated change: Fix sanity tests * fix signedness * fix sanity * fix sanity * iwyu * update code for XdsResourceTypeImpl changes Co-authored-by: markdroth <markdroth@users.noreply.github.com>
2 years ago
[fuzz] Turn core end2end tests into fuzzers (#33013) Add a new binary that runs all core end2end tests in fuzzing mode. In this mode FuzzingEventEngine is substituted for the default event engine. This means that time is simulated, as is IO. The FEE gets control of callback delays also. In our tests the `Step()` function becomes, instead of a single call to `completion_queue_next`, a series of calls to that function and `FuzzingEventEngine::Tick`, driving forward the event loop until progress can be made. PR guide: --- **New binaries** `core_end2end_test_fuzzer` - the new fuzzer itself `seed_end2end_corpus` - a tool that produces an interesting seed corpus **Config changes for safe fuzzing** The implementation tries to use the config fuzzing work we've previously deployed in api_fuzzer to fuzz across experiments. Since some experiments are far too experimental to be safe in such fuzzing (and this will always be the case): - a new flag is added to experiments to opt-out of this fuzzing - a new hook is added to the config system to allow variables to re-write their inputs before setting them during the fuzz **Event manager/IO changes** Changes are made to the event engine shims so that tcp_server_posix can run with a non-FD carrying EventEngine. These are in my mind a bit clunky, but they work and they're in code that we expect to delete in the medium term, so I think overall the approach is good. **Changes to time** A small tweak is made to fix a bug initializing time for fuzzers in time.cc - we were previously failing to initialize `g_process_epoch_cycles` **Changes to `Crash`** A version that prints to stdio is added so that we can reliably print a crash from the fuzzer. **Changes to CqVerifier** Hooks are added to allow the top level loop to hook the verification functions with a function that steps time between CQ polls. **Changes to end2end fixtures** State machinery moves from the fixture to the test infra, to keep the customizations for fuzzing or not in one place. This means that fixtures are now just client/server factories, which is overall nice. It did necessitate moving some bespoke machinery into h2_ssl_cert_test.cc - this file is beginning to be problematic in borrowing parts but not all of the e2e test machinery. Some future PR needs to solve this. A cq arg is added to the Make functions since the cq is now owned by the test and not the fixture. **Changes to test registration** `TEST_P` is replaced by `CORE_END2END_TEST` and our own test registry is used as a first depot for test information. The gtest version of these tests: queries that registry to manually register tests with gtest. This ultimately changes the name of our tests again (I think for the last time) - the new names are shorter and more readable, so I don't count this as a regression. The fuzzer version of these tests: constructs a database of fuzzable tests that it can consult to look up a particular suite/test/config combination specified by the fuzzer to fuzz against. This gives us a single fuzzer that can test all 3k-ish fuzzing ready tests and cross polinate configuration between them. **Changes to test config** The zero size registry stuff was causing some problems with the event engine feature macros, so instead I've removed those and used GTEST_SKIP in the problematic tests. I think that's the approach we move towards in the future. **Which tests are included** Configs that are compatible - those that do not do fd manipulation directly (these are incompatible with FuzzingEventEngine), and those that do not join threads on their shutdown path (as these are incompatible with our cq wait methodology). Each we can talk about in the future - fd manipulation would be a significant expansion of FuzzingEventEngine, and is probably not worth it, however many uses of background threads now should probably evolve to be EventEngine::Run calls in the future, and then would be trivially enabled in the fuzzers. Some tests currently fail in the fuzzing environment, a `SKIP_IF_FUZZING` macro is used for these few to disable them if in the fuzzing environment. We'll burn these down in the future. **Changes to fuzzing_event_engine** Changes are made to time: an exponential sweep forward is used now - this catches small time precision things early, but makes decade long timers (we have them) able to be used right now. In the future we'll just skip time forward to the next scheduled timer, but that approach doesn't yet work due to legacy timer system interactions. Changes to port assignment: we ensure that ports are legal numbers before assigning them via `grpc_pick_port_or_die`. A race condition between time checking and io is fixed. --------- Co-authored-by: ctiller <ctiller@users.noreply.github.com>
2 years ago
grpc_cc_library(
name = "osa_distance",
srcs = ["osa_distance.cc"],
hdrs = ["osa_distance.h"],
external_deps = ["absl/strings"],
)
grpc_cc_test(
name = "osa_distance_test",
srcs = ["osa_distance_test.cc"],
external_deps = ["gtest"],
deps = ["osa_distance"],
)
xDS cluster resource type: use ValidationErrors and add unit test (#31025) * XdsBootstrap: move two more methods out of the interface * Automated change: Fix sanity tests * XdsClient: add unit test * Automated change: Fix sanity tests * fix memory leaks * add helper method * add unsubscription * add test for multiple subscriptions * clang-format * fix build * fix flakiness * add checking for other node fields * add v2 test * add response builder * add test for update from server * add test for update containing only changed resources * clang-format * fix build * add test for resource not existing upon subscription * add test for stream closed by server * add test for multiple watchers for the same resource * add test for connection failure * clang-format * add test for resources wrapped in Resource wrapper message * add test for resource validation failure * add test for multiple invalid resources, and fix a case in XdsClient * add test for validation failure for already-cached resource * add test for server not resending resources after stream disconnect * clang-format * fix XdsClient to report channel errors to newly started watchers * fix XdsClient to send cached errors/does-not-exists to newly started watchers * fix watcher to ensure events arrive in the expected order * fix tests * clang-format * add test for multiple resource types * fix xds_cluster_e2e_test * Automated change: Fix sanity tests * cleanup * add federation tests * clang-format * remove now-unnecessary XdsCertificateProviderPluginMapInterface * code review comments * simplify XdsResourceType::Decode() API * XdsClient: add unit tests for XdsClusterResourceType * add XdsClient with gRPC bootstrap config * add LB policy tests * started adding CertificateProvider tests * update for recent API changes * fix merge bugs * xDS resource validation: identify extensions by type_url instead of name * fix build * migrate to ValidationErrors * add xds_common_types_test * finish TLS tests and add LRS tests * move ScopedExperimentalEnvVar to its own library and remove redundant e2e tests * add circuit breaking and outlier detection tests * add validation to outlier detection LB policy parsing * clang-format * Automated change: Fix sanity tests * fix signedness * fix sanity * fix sanity * iwyu * update code for XdsResourceTypeImpl changes Co-authored-by: markdroth <markdroth@users.noreply.github.com>
2 years ago
grpc_cc_library(
name = "scoped_env_var",
testonly = True,
hdrs = ["scoped_env_var.h"],
deps = [
"//:gpr_platform",
"//src/core:env",
xDS cluster resource type: use ValidationErrors and add unit test (#31025) * XdsBootstrap: move two more methods out of the interface * Automated change: Fix sanity tests * XdsClient: add unit test * Automated change: Fix sanity tests * fix memory leaks * add helper method * add unsubscription * add test for multiple subscriptions * clang-format * fix build * fix flakiness * add checking for other node fields * add v2 test * add response builder * add test for update from server * add test for update containing only changed resources * clang-format * fix build * add test for resource not existing upon subscription * add test for stream closed by server * add test for multiple watchers for the same resource * add test for connection failure * clang-format * add test for resources wrapped in Resource wrapper message * add test for resource validation failure * add test for multiple invalid resources, and fix a case in XdsClient * add test for validation failure for already-cached resource * add test for server not resending resources after stream disconnect * clang-format * fix XdsClient to report channel errors to newly started watchers * fix XdsClient to send cached errors/does-not-exists to newly started watchers * fix watcher to ensure events arrive in the expected order * fix tests * clang-format * add test for multiple resource types * fix xds_cluster_e2e_test * Automated change: Fix sanity tests * cleanup * add federation tests * clang-format * remove now-unnecessary XdsCertificateProviderPluginMapInterface * code review comments * simplify XdsResourceType::Decode() API * XdsClient: add unit tests for XdsClusterResourceType * add XdsClient with gRPC bootstrap config * add LB policy tests * started adding CertificateProvider tests * update for recent API changes * fix merge bugs * xDS resource validation: identify extensions by type_url instead of name * fix build * migrate to ValidationErrors * add xds_common_types_test * finish TLS tests and add LRS tests * move ScopedExperimentalEnvVar to its own library and remove redundant e2e tests * add circuit breaking and outlier detection tests * add validation to outlier detection LB policy parsing * clang-format * Automated change: Fix sanity tests * fix signedness * fix sanity * fix sanity * iwyu * update code for XdsResourceTypeImpl changes Co-authored-by: markdroth <markdroth@users.noreply.github.com>
2 years ago
],
)
grpc_proto_library(
name = "fuzz_config_vars_proto",
srcs = ["fuzz_config_vars.proto"],
has_services = False,
)
grpc_cc_library(
name = "fuzz_config_vars",
srcs = ["fuzz_config_vars.cc"],
hdrs = ["fuzz_config_vars.h"],
external_deps = ["absl/types:optional"],
deps = [
[fuzz] Turn core end2end tests into fuzzers (#33013) Add a new binary that runs all core end2end tests in fuzzing mode. In this mode FuzzingEventEngine is substituted for the default event engine. This means that time is simulated, as is IO. The FEE gets control of callback delays also. In our tests the `Step()` function becomes, instead of a single call to `completion_queue_next`, a series of calls to that function and `FuzzingEventEngine::Tick`, driving forward the event loop until progress can be made. PR guide: --- **New binaries** `core_end2end_test_fuzzer` - the new fuzzer itself `seed_end2end_corpus` - a tool that produces an interesting seed corpus **Config changes for safe fuzzing** The implementation tries to use the config fuzzing work we've previously deployed in api_fuzzer to fuzz across experiments. Since some experiments are far too experimental to be safe in such fuzzing (and this will always be the case): - a new flag is added to experiments to opt-out of this fuzzing - a new hook is added to the config system to allow variables to re-write their inputs before setting them during the fuzz **Event manager/IO changes** Changes are made to the event engine shims so that tcp_server_posix can run with a non-FD carrying EventEngine. These are in my mind a bit clunky, but they work and they're in code that we expect to delete in the medium term, so I think overall the approach is good. **Changes to time** A small tweak is made to fix a bug initializing time for fuzzers in time.cc - we were previously failing to initialize `g_process_epoch_cycles` **Changes to `Crash`** A version that prints to stdio is added so that we can reliably print a crash from the fuzzer. **Changes to CqVerifier** Hooks are added to allow the top level loop to hook the verification functions with a function that steps time between CQ polls. **Changes to end2end fixtures** State machinery moves from the fixture to the test infra, to keep the customizations for fuzzing or not in one place. This means that fixtures are now just client/server factories, which is overall nice. It did necessitate moving some bespoke machinery into h2_ssl_cert_test.cc - this file is beginning to be problematic in borrowing parts but not all of the e2e test machinery. Some future PR needs to solve this. A cq arg is added to the Make functions since the cq is now owned by the test and not the fixture. **Changes to test registration** `TEST_P` is replaced by `CORE_END2END_TEST` and our own test registry is used as a first depot for test information. The gtest version of these tests: queries that registry to manually register tests with gtest. This ultimately changes the name of our tests again (I think for the last time) - the new names are shorter and more readable, so I don't count this as a regression. The fuzzer version of these tests: constructs a database of fuzzable tests that it can consult to look up a particular suite/test/config combination specified by the fuzzer to fuzz against. This gives us a single fuzzer that can test all 3k-ish fuzzing ready tests and cross polinate configuration between them. **Changes to test config** The zero size registry stuff was causing some problems with the event engine feature macros, so instead I've removed those and used GTEST_SKIP in the problematic tests. I think that's the approach we move towards in the future. **Which tests are included** Configs that are compatible - those that do not do fd manipulation directly (these are incompatible with FuzzingEventEngine), and those that do not join threads on their shutdown path (as these are incompatible with our cq wait methodology). Each we can talk about in the future - fd manipulation would be a significant expansion of FuzzingEventEngine, and is probably not worth it, however many uses of background threads now should probably evolve to be EventEngine::Run calls in the future, and then would be trivially enabled in the fuzzers. Some tests currently fail in the fuzzing environment, a `SKIP_IF_FUZZING` macro is used for these few to disable them if in the fuzzing environment. We'll burn these down in the future. **Changes to fuzzing_event_engine** Changes are made to time: an exponential sweep forward is used now - this catches small time precision things early, but makes decade long timers (we have them) able to be used right now. In the future we'll just skip time forward to the next scheduled timer, but that approach doesn't yet work due to legacy timer system interactions. Changes to port assignment: we ensure that ports are legal numbers before assigning them via `grpc_pick_port_or_die`. A race condition between time checking and io is fixed. --------- Co-authored-by: ctiller <ctiller@users.noreply.github.com>
2 years ago
"fuzz_config_vars_helpers",
"fuzz_config_vars_proto",
"//:config_vars",
"//:gpr_platform",
],
)
[fuzz] Turn core end2end tests into fuzzers (#33013) Add a new binary that runs all core end2end tests in fuzzing mode. In this mode FuzzingEventEngine is substituted for the default event engine. This means that time is simulated, as is IO. The FEE gets control of callback delays also. In our tests the `Step()` function becomes, instead of a single call to `completion_queue_next`, a series of calls to that function and `FuzzingEventEngine::Tick`, driving forward the event loop until progress can be made. PR guide: --- **New binaries** `core_end2end_test_fuzzer` - the new fuzzer itself `seed_end2end_corpus` - a tool that produces an interesting seed corpus **Config changes for safe fuzzing** The implementation tries to use the config fuzzing work we've previously deployed in api_fuzzer to fuzz across experiments. Since some experiments are far too experimental to be safe in such fuzzing (and this will always be the case): - a new flag is added to experiments to opt-out of this fuzzing - a new hook is added to the config system to allow variables to re-write their inputs before setting them during the fuzz **Event manager/IO changes** Changes are made to the event engine shims so that tcp_server_posix can run with a non-FD carrying EventEngine. These are in my mind a bit clunky, but they work and they're in code that we expect to delete in the medium term, so I think overall the approach is good. **Changes to time** A small tweak is made to fix a bug initializing time for fuzzers in time.cc - we were previously failing to initialize `g_process_epoch_cycles` **Changes to `Crash`** A version that prints to stdio is added so that we can reliably print a crash from the fuzzer. **Changes to CqVerifier** Hooks are added to allow the top level loop to hook the verification functions with a function that steps time between CQ polls. **Changes to end2end fixtures** State machinery moves from the fixture to the test infra, to keep the customizations for fuzzing or not in one place. This means that fixtures are now just client/server factories, which is overall nice. It did necessitate moving some bespoke machinery into h2_ssl_cert_test.cc - this file is beginning to be problematic in borrowing parts but not all of the e2e test machinery. Some future PR needs to solve this. A cq arg is added to the Make functions since the cq is now owned by the test and not the fixture. **Changes to test registration** `TEST_P` is replaced by `CORE_END2END_TEST` and our own test registry is used as a first depot for test information. The gtest version of these tests: queries that registry to manually register tests with gtest. This ultimately changes the name of our tests again (I think for the last time) - the new names are shorter and more readable, so I don't count this as a regression. The fuzzer version of these tests: constructs a database of fuzzable tests that it can consult to look up a particular suite/test/config combination specified by the fuzzer to fuzz against. This gives us a single fuzzer that can test all 3k-ish fuzzing ready tests and cross polinate configuration between them. **Changes to test config** The zero size registry stuff was causing some problems with the event engine feature macros, so instead I've removed those and used GTEST_SKIP in the problematic tests. I think that's the approach we move towards in the future. **Which tests are included** Configs that are compatible - those that do not do fd manipulation directly (these are incompatible with FuzzingEventEngine), and those that do not join threads on their shutdown path (as these are incompatible with our cq wait methodology). Each we can talk about in the future - fd manipulation would be a significant expansion of FuzzingEventEngine, and is probably not worth it, however many uses of background threads now should probably evolve to be EventEngine::Run calls in the future, and then would be trivially enabled in the fuzzers. Some tests currently fail in the fuzzing environment, a `SKIP_IF_FUZZING` macro is used for these few to disable them if in the fuzzing environment. We'll burn these down in the future. **Changes to fuzzing_event_engine** Changes are made to time: an exponential sweep forward is used now - this catches small time precision things early, but makes decade long timers (we have them) able to be used right now. In the future we'll just skip time forward to the next scheduled timer, but that approach doesn't yet work due to legacy timer system interactions. Changes to port assignment: we ensure that ports are legal numbers before assigning them via `grpc_pick_port_or_die`. A race condition between time checking and io is fixed. --------- Co-authored-by: ctiller <ctiller@users.noreply.github.com>
2 years ago
grpc_cc_library(
name = "fuzz_config_vars_helpers",
srcs = ["fuzz_config_vars_helpers.cc"],
hdrs = ["fuzz_config_vars_helpers.h"],
external_deps = ["absl/strings"],
deps = [
"//:gpr_platform",
"//src/core:experiments",
],
)
grpc_cc_library(
name = "audit_logging_utils",
srcs = ["audit_logging_utils.cc"],
hdrs = ["audit_logging_utils.h"],
external_deps = [
"absl/status:statusor",
"absl/strings",
],
deps = [
"//:gpr",
"//:gpr_platform",
"//:grpc",
"//src/core:json_writer",
],
)
grpc_proto_library(
name = "fuzzing_channel_args_proto",
srcs = ["fuzzing_channel_args.proto"],
has_services = False,
)
grpc_cc_library(
name = "fuzzing_channel_args",
srcs = ["fuzzing_channel_args.cc"],
hdrs = ["fuzzing_channel_args.h"],
deps = [
"fuzzing_channel_args_proto",
"//:gpr_platform",
"//:ref_counted_ptr",
"//src/core:channel_args",
"//src/core:resource_quota",
],
)