1# Copyright 2016 gRPC authors. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15""" 16Generate one e2e test & associated fuzzer 17""" 18 19load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test") 20load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer") 21 22END2END_TEST_DATA = [ 23 "//src/core/tsi/test_creds:ca.pem", 24 "//src/core/tsi/test_creds:server1.key", 25 "//src/core/tsi/test_creds:server1.pem", 26] 27 28def grpc_core_end2end_test(name, shard_count = 10, tags = []): 29 """Generate one core end2end test 30 31 Args: 32 name: name of the test, must correspond to a "test/name.cc" file 33 shard_count: per bazel 34 tags: per bazel 35 """ 36 37 if len(name) > 60: 38 fail("test name %s too long" % name) 39 40 grpc_cc_library( 41 name = "%s_library" % name, 42 testonly = 1, 43 srcs = [ 44 "tests/%s.cc" % name, 45 ], 46 deps = [ 47 "cq_verifier", 48 "end2end_test_lib", 49 "fixture_support", 50 "http_proxy", 51 "proxy", 52 "//:channel_stack_builder", 53 "//:config", 54 "//:config_vars", 55 "//:debug_location", 56 "//:exec_ctx", 57 "//:gpr", 58 "//:grpc_authorization_provider", 59 "//:grpc_public_hdrs", 60 "//:grpc_security_base", 61 "//:grpc_trace", 62 "//:grpc_unsecure", 63 "//:legacy_context", 64 "//:orphanable", 65 "//:promise", 66 "//:ref_counted_ptr", 67 "//:stats", 68 "//src/core:arena_promise", 69 "//src/core:bitset", 70 "//src/core:channel_args", 71 "//src/core:channel_fwd", 72 "//src/core:channel_init", 73 "//src/core:channel_stack_type", 74 "//src/core:closure", 75 "//src/core:error", 76 "//src/core:experiments", 77 "//src/core:grpc_authorization_base", 78 "//src/core:grpc_fake_credentials", 79 "//src/core:iomgr_port", 80 "//src/core:json", 81 "//src/core:lb_policy", 82 "//src/core:lb_policy_factory", 83 "//src/core:no_destruct", 84 "//src/core:notification", 85 "//src/core:slice", 86 "//src/core:stats_data", 87 "//src/core:status_helper", 88 "//src/core:time", 89 "//test/core/util:fake_stats_plugin", 90 "//test/core/util:grpc_test_util", 91 "//test/core/util:test_lb_policies", 92 ], 93 ) 94 95 grpc_cc_test( 96 name = "%s_test" % name, 97 shard_count = shard_count, 98 data = END2END_TEST_DATA, 99 external_deps = [ 100 "absl/functional:any_invocable", 101 "absl/status", 102 "absl/status:statusor", 103 "absl/strings", 104 "absl/strings:str_format", 105 "absl/types:optional", 106 "gtest", 107 ], 108 deps = [ 109 "end2end_test_main", 110 "%s_library" % name, 111 ], 112 tags = ["core_end2end_test"] + tags, 113 ) 114 115 grpc_proto_fuzzer( 116 name = "%s_fuzzer" % name, 117 srcs = [ 118 "end2end_test_fuzzer_main.cc", 119 ], 120 corpus = "end2end_test_corpus/%s" % name, 121 data = END2END_TEST_DATA, 122 external_deps = [ 123 "absl/functional:any_invocable", 124 "absl/status", 125 "absl/status:statusor", 126 "absl/strings", 127 "absl/strings:str_format", 128 "absl/types:optional", 129 "gtest", 130 ], 131 language = "C++", 132 proto = None, 133 tags = [ 134 "no_mac", 135 "no_windows", 136 ], 137 uses_event_engine = False, 138 uses_polling = False, 139 deps = [ 140 "%s_library" % name, 141 "end2end_test_fuzzer", 142 ], 143 ) 144