diff options
Diffstat (limited to 'test/core/end2end')
-rw-r--r-- | test/core/end2end/BUILD | 19 | ||||
-rw-r--r-- | test/core/end2end/fuzzers/api_fuzzer.cc | 5 | ||||
-rw-r--r-- | test/core/end2end/fuzzers/hpack.dictionary | 1 | ||||
-rwxr-xr-x | test/core/end2end/gen_build_yaml.py | 2 | ||||
-rwxr-xr-x | test/core/end2end/generate_tests.bzl | 104 | ||||
-rw-r--r-- | test/core/end2end/goaway_server_test.cc | 10 | ||||
-rw-r--r-- | test/core/end2end/tests/channelz.cc | 39 | ||||
-rw-r--r-- | test/core/end2end/tests/retry_streaming.cc | 64 | ||||
-rw-r--r-- | test/core/end2end/tests/simple_request.cc | 13 |
9 files changed, 209 insertions, 48 deletions
diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD index 37999a98d1..398e8a2d9a 100644 --- a/test/core/end2end/BUILD +++ b/test/core/end2end/BUILD @@ -18,7 +18,7 @@ licenses(["notice"]) # Apache v2 grpc_package(name = "test/core/end2end") -load(":generate_tests.bzl", "grpc_end2end_tests") +load(":generate_tests.bzl", "grpc_end2end_tests", "grpc_end2end_nosec_tests") grpc_cc_library( name = "cq_verifier", @@ -46,7 +46,6 @@ grpc_cc_library( visibility = ["//test:__subpackages__"], ) - grpc_cc_library( name = "http_proxy", srcs = ["fixtures/http_proxy_fixture.cc"], @@ -128,7 +127,7 @@ grpc_cc_test( srcs = ["inproc_callback_test.cc"], language = "C++", deps = [ - ':end2end_tests', + ":end2end_tests", "//:gpr", "//:grpc", "//test/core/util:gpr_test_util", @@ -177,6 +176,8 @@ grpc_cc_test( grpc_end2end_tests() +grpc_end2end_nosec_tests() + grpc_cc_test( name = "h2_ssl_session_reuse_test", srcs = ["h2_ssl_session_reuse_test.cc"], @@ -185,11 +186,11 @@ grpc_cc_test( ], language = "C++", deps = [ - ':end2end_tests', - '//:gpr', - '//:grpc', - '//:tsi', - '//test/core/util:gpr_test_util', - '//test/core/util:grpc_test_util', + ":end2end_tests", + "//:gpr", + "//:grpc", + "//:tsi", + "//test/core/util:gpr_test_util", + "//test/core/util:grpc_test_util", ], ) diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index 9544adb912..e97a544e12 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -390,6 +390,10 @@ grpc_ares_request* my_dns_lookup_ares_locked( return nullptr; } +static void my_cancel_ares_request_locked(grpc_ares_request* request) { + GPR_ASSERT(request == nullptr); +} + //////////////////////////////////////////////////////////////////////////////// // client connection @@ -705,6 +709,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { } grpc_set_resolver_impl(&fuzzer_resolver); grpc_dns_lookup_ares_locked = my_dns_lookup_ares_locked; + grpc_cancel_ares_request_locked = my_cancel_ares_request_locked; GPR_ASSERT(g_channel == nullptr); GPR_ASSERT(g_server == nullptr); diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index 569e744a6b..a79fe5ad95 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -34,6 +34,7 @@ "\x1Egrpc.max_request_message_bytes" "\x1Fgrpc.max_response_message_bytes" "$/grpc.lb.v1.LoadBalancer/BalanceLoad" +"\x1C/grpc.health.v1.Health/Watch" "\x07deflate" "\x04gzip" "\x0Bstream/gzip" diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index 39b9ba4a19..601d3bac38 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -41,7 +41,7 @@ local_fixture_options = default_secure_fixture_options._replace( fd_unsecure_fixture_options = default_unsecure_fixture_options._replace( dns_resolver=False, fullstack=False, platforms=['linux', 'mac', 'posix'], exclude_iomgrs=['uv'], client_channel=False) -inproc_fixture_options = default_unsecure_fixture_options._replace( +inproc_fixture_options = default_secure_fixture_options._replace( dns_resolver=False, fullstack=False, name_resolution=False, supports_compression=False, is_inproc=True, is_http2=False, supports_write_buffering=False, client_channel=False) diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl index 6d9ffcfb91..81956db841 100755 --- a/test/core/end2end/generate_tests.bzl +++ b/test/core/end2end/generate_tests.bzl @@ -92,6 +92,7 @@ END2END_FIXTURES = { _platforms = ["linux", "mac", "posix"], ), "inproc": _fixture_options( + secure = True, fullstack = False, dns_resolver = False, name_resolution = False, @@ -102,6 +103,55 @@ END2END_FIXTURES = { ), } +# maps fixture name to whether it requires the security library +END2END_NOSEC_FIXTURES = { + "h2_compress": _fixture_options(secure = False), + "h2_census": _fixture_options(secure = False), + # 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, + secure = False, + _platforms = ["linux", "mac", "posix"], + ), + "h2_full": _fixture_options(secure = False), + "h2_full+pipe": _fixture_options(secure = False, _platforms = ["linux"]), + "h2_full+trace": _fixture_options(secure = False, tracing = True), + "h2_full+workarounds": _fixture_options(secure = False), + "h2_http_proxy": _fixture_options(secure = False, supports_proxy_auth = True), + "h2_proxy": _fixture_options(secure = False, includes_proxy = True), + "h2_sockpair_1byte": _fixture_options( + fullstack = False, + dns_resolver = False, + client_channel = False, + secure = False, + ), + "h2_sockpair": _fixture_options( + fullstack = False, + dns_resolver = False, + client_channel = False, + secure = False, + ), + "h2_sockpair+trace": _fixture_options( + fullstack = False, + dns_resolver = False, + tracing = True, + secure = False, + client_channel = False, + ), + "h2_ssl": _fixture_options(secure = False), + "h2_ssl_proxy": _fixture_options(includes_proxy = True, secure = False), + "h2_uds": _fixture_options( + dns_resolver = False, + _platforms = ["linux", "mac", "posix"], + secure = False, + ), +} + def _test_options( needs_fullstack = False, needs_dns = False, @@ -357,3 +407,57 @@ def grpc_end2end_tests(): poller, ], ) + +def grpc_end2end_nosec_tests(): + grpc_cc_library( + name = "end2end_nosec_tests", + srcs = ["end2end_nosec_tests.cc", "end2end_test_utils.cc"] + [ + "tests/%s.cc" % t + for t in sorted(END2END_TESTS.keys()) + if not END2END_TESTS[t].secure + ], + 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_NOSEC_FIXTURES.items(): + if fopt.secure: + continue + grpc_cc_binary( + name = "%s_nosec_test" % f, + srcs = ["fixtures/%s.cc" % f], + language = "C++", + deps = [ + ":end2end_nosec_tests", + "//test/core/util:grpc_test_util_unsecure", + "//:grpc_unsecure", + "//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 + if topt.secure: + continue + for poller in POLLERS: + native.sh_test( + name = "%s_nosec_test@%s@poller=%s" % (f, t, poller), + data = [":%s_nosec_test" % f], + srcs = ["end2end_test.sh"], + args = [ + "$(location %s_nosec_test)" % f, + t, + poller, + ], + ) diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc index 8904c3d325..3f1c5596ad 100644 --- a/test/core/end2end/goaway_server_test.cc +++ b/test/core/end2end/goaway_server_test.cc @@ -50,6 +50,8 @@ static grpc_ares_request* (*iomgr_dns_lookup_ares_locked)( grpc_lb_addresses** addresses, bool check_grpclb, char** service_config_json, grpc_combiner* combiner); +static void (*iomgr_cancel_ares_request_locked)(grpc_ares_request* request); + static void set_resolve_port(int port) { gpr_mu_lock(&g_mu); g_resolve_port = port; @@ -130,6 +132,12 @@ static grpc_ares_request* my_dns_lookup_ares_locked( return nullptr; } +static void my_cancel_ares_request_locked(grpc_ares_request* request) { + if (request != nullptr) { + iomgr_cancel_ares_request_locked(request); + } +} + int main(int argc, char** argv) { grpc_completion_queue* cq; cq_verifier* cqv; @@ -143,7 +151,9 @@ int main(int argc, char** argv) { default_resolver = grpc_resolve_address_impl; grpc_set_resolver_impl(&test_resolver); iomgr_dns_lookup_ares_locked = grpc_dns_lookup_ares_locked; + iomgr_cancel_ares_request_locked = grpc_cancel_ares_request_locked; grpc_dns_lookup_ares_locked = my_dns_lookup_ares_locked; + grpc_cancel_ares_request_locked = my_cancel_ares_request_locked; int was_cancelled1; int was_cancelled2; diff --git a/test/core/end2end/tests/channelz.cc b/test/core/end2end/tests/channelz.cc index 41549190e3..922783aa0d 100644 --- a/test/core/end2end/tests/channelz.cc +++ b/test/core/end2end/tests/channelz.cc @@ -29,6 +29,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> +#include "src/core/lib/channel/channelz_registry.h" #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" @@ -199,9 +200,13 @@ static void run_one_request(grpc_end2end_test_config config, static void test_channelz(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - grpc_arg arg = grpc_channel_arg_integer_create( - const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true); - grpc_channel_args args = {1, &arg}; + grpc_arg arg[] = { + grpc_channel_arg_integer_create( + const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), + 0), + grpc_channel_arg_integer_create( + const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true)}; + grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg}; f = begin_test(config, "test_channelz", &args, &args); grpc_core::channelz::ChannelNode* channelz_channel = @@ -234,7 +239,6 @@ static void test_channelz(grpc_end2end_test_config config) { 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\"")); @@ -246,7 +250,6 @@ static void test_channelz(grpc_end2end_test_config config) { 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\"")); @@ -267,12 +270,12 @@ static void test_channelz(grpc_end2end_test_config config) { static void test_channelz_with_channel_trace(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - grpc_arg arg[2]; - arg[0] = grpc_channel_arg_integer_create( - const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), - 1024 * 1024); - arg[1] = grpc_channel_arg_integer_create( - const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true); + grpc_arg arg[] = { + grpc_channel_arg_integer_create( + const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), + 1024 * 1024), + grpc_channel_arg_integer_create( + const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true)}; grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg}; f = begin_test(config, "test_channelz_with_channel_trace", &args, &args); @@ -284,9 +287,10 @@ static void test_channelz_with_channel_trace(grpc_end2end_test_config config) { grpc_server_get_channelz_node(f.server); GPR_ASSERT(channelz_server != nullptr); + run_one_request(config, f, true); + 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\"")); @@ -294,7 +298,6 @@ static void test_channelz_with_channel_trace(grpc_end2end_test_config config) { 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\"")); @@ -307,7 +310,15 @@ static void test_channelz_with_channel_trace(grpc_end2end_test_config config) { 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_arg arg[] = { + grpc_channel_arg_integer_create( + const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), + 0), + grpc_channel_arg_integer_create( + const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), false)}; + grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg}; + + f = begin_test(config, "test_channelz_disabled", &args, &args); grpc_core::channelz::ChannelNode* channelz_channel = grpc_channel_get_channelz_node(f.client); GPR_ASSERT(channelz_channel == nullptr); diff --git a/test/core/end2end/tests/retry_streaming.cc b/test/core/end2end/tests/retry_streaming.cc index d06d124ca4..94a27faf7b 100644 --- a/test/core/end2end/tests/retry_streaming.cc +++ b/test/core/end2end/tests/retry_streaming.cc @@ -28,6 +28,9 @@ #include <grpc/support/string_util.h> #include <grpc/support/time.h> +#include "src/core/lib/surface/channel.h" +#include "src/core/lib/surface/server.h" + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" @@ -133,25 +136,30 @@ static void test_retry_streaming(grpc_end2end_test_config config) { int was_cancelled = 2; char* peer; - grpc_arg arg; - arg.type = GRPC_ARG_STRING; - arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG); - arg.value.string = const_cast<char*>( - "{\n" - " \"methodConfig\": [ {\n" - " \"name\": [\n" - " { \"service\": \"service\", \"method\": \"method\" }\n" - " ],\n" - " \"retryPolicy\": {\n" - " \"maxAttempts\": 3,\n" - " \"initialBackoff\": \"1s\",\n" - " \"maxBackoff\": \"120s\",\n" - " \"backoffMultiplier\": 1.6,\n" - " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" - " }\n" - " } ]\n" - "}"); - grpc_channel_args client_args = {1, &arg}; + grpc_arg args[] = { + grpc_channel_arg_integer_create( + const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), + 1024 * 8), + grpc_channel_arg_integer_create( + const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true), + grpc_channel_arg_string_create( + const_cast<char*>(GRPC_ARG_SERVICE_CONFIG), + const_cast<char*>( + "{\n" + " \"methodConfig\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"retryPolicy\": {\n" + " \"maxAttempts\": 3,\n" + " \"initialBackoff\": \"1s\",\n" + " \"maxBackoff\": \"120s\",\n" + " \"backoffMultiplier\": 1.6,\n" + " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" + " }\n" + " } ]\n" + "}"))}; + grpc_channel_args client_args = {GPR_ARRAY_SIZE(args), args}; grpc_end2end_test_fixture f = begin_test(config, "retry_streaming", &client_args, nullptr); @@ -161,6 +169,9 @@ static void test_retry_streaming(grpc_end2end_test_config config) { c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq, grpc_slice_from_static_string("/service/method"), nullptr, deadline, nullptr); + grpc_core::channelz::ChannelNode* channelz_channel = + grpc_channel_get_channelz_node(f.client); + GPR_ASSERT(c); peer = grpc_call_get_peer(c); @@ -384,6 +395,20 @@ static void test_retry_streaming(grpc_end2end_test_config config) { GPR_ASSERT(0 == call_details.flags); GPR_ASSERT(was_cancelled == 1); + GPR_ASSERT(channelz_channel != 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_ASSERT(nullptr != strstr(json, "Resolution event")); + GPR_ASSERT(nullptr != strstr(json, "Created new LB policy")); + GPR_ASSERT(nullptr != strstr(json, "Service config changed")); + GPR_ASSERT(nullptr != strstr(json, "Address list became non-empty")); + GPR_ASSERT(nullptr != strstr(json, "Channel state change to CONNECTING")); + gpr_free(json); + grpc_slice_unref(details); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); @@ -414,6 +439,7 @@ static void test_retry_streaming(grpc_end2end_test_config config) { void retry_streaming(grpc_end2end_test_config config) { GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL); + test_retry_streaming(config); } diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index 941d9ae319..9c018962f8 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -108,7 +108,9 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_stats_data* after = static_cast<grpc_stats_data*>(gpr_malloc(sizeof(grpc_stats_data))); +#if defined(GRPC_COLLECT_STATS) || !defined(NDEBUG) grpc_stats_collect(before); +#endif /* defined(GRPC_COLLECT_STATS) || !defined(NDEBUG) */ gpr_timespec deadline = five_seconds_from_now(); c = grpc_channel_create_call(f.client, nullptr, GRPC_PROPAGATE_DEFAULTS, f.cq, @@ -225,17 +227,18 @@ static void simple_request_body(grpc_end2end_test_config config, cq_verifier_destroy(cqv); + int expected_calls = 1; + if (config.feature_mask & FEATURE_MASK_SUPPORTS_REQUEST_PROXYING) { + expected_calls *= 2; + } +#if defined(GRPC_COLLECT_STATS) || !defined(NDEBUG) + grpc_stats_collect(after); char* stats = grpc_stats_data_as_json(after); gpr_log(GPR_DEBUG, "%s", stats); gpr_free(stats); - int expected_calls = 1; - 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); |