Debian Codegraph @

test/core/end2end/generate_tests.bzl

raw
1 #!/usr/bin/env python2.7
2 # Copyright 2015 gRPC authors.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 """Generates the appropriate build.json data for all the end2end tests."""
16
17 load(
18 "//bazel:grpc_build_system.bzl",
19 "grpc_cc_binary",
20 "grpc_cc_library",
21 "grpc_sh_test",
22 )
23 load("flaky.bzl", "FLAKY_TESTS")
24
25 def _fixture_options(
26 fullstack = True,
27 includes_proxy = False,
28 dns_resolver = True,
29 name_resolution = True,
30 secure = True,
31 tracing = False,
32 _platforms = ["windows", "linux", "mac", "posix"],
33 is_inproc = False,
34 is_1byte = False,
35 is_http2 = True,
36 is_minstack = False,
37 supports_proxy_auth = False,
38 supports_write_buffering = True,
39 client_channel = True,
40 supports_msvc = True,
41 supports_retry = None,
42 tags = []):
43 if supports_retry == None:
44 supports_retry = client_channel
45 return struct(
46 fullstack = fullstack,
47 includes_proxy = includes_proxy,
48 dns_resolver = dns_resolver,
49 name_resolution = name_resolution,
50 secure = secure,
51 tracing = tracing,
52 is_inproc = is_inproc,
53 is_1byte = is_1byte,
54 is_http2 = is_http2,
55 is_minstack = is_minstack,
56 supports_proxy_auth = supports_proxy_auth,
57 supports_write_buffering = supports_write_buffering,
58 client_channel = client_channel,
59 supports_msvc = supports_msvc,
60 _platforms = _platforms,
61 supports_retry = supports_retry,
62 tags = tags,
63 )
64
65 # maps fixture name to whether it requires the security library
66 END2END_FIXTURES = {
67 "h2_compress": _fixture_options(),
68 "h2_census": _fixture_options(),
69 # TODO(juanlishen): This is disabled for now, but should be considered to re-enable once we have
70 # decided how the load reporting service should be enabled.
71 #'h2_load_reporting': _fixture_options(),
72 "h2_fakesec": _fixture_options(),
73 "h2_fd": _fixture_options(
74 dns_resolver = False,
75 fullstack = False,
76 client_channel = False,
77 _platforms = ["linux", "mac", "posix"],
78 tags = ["no_test_ios"],
79 ),
80 "h2_full": _fixture_options(),
81 "h2_full_no_retry": _fixture_options(supports_retry = False),
82 "h2_full+pipe": _fixture_options(_platforms = ["linux"]),
83 "h2_full+trace": _fixture_options(tracing = True),
84 "h2_http_proxy": _fixture_options(supports_proxy_auth = True),
85 "h2_insecure": _fixture_options(secure = True),
86 "h2_oauth2_tls12": _fixture_options(),
87 "h2_oauth2_tls13": _fixture_options(),
88 "h2_proxy": _fixture_options(includes_proxy = True),
89 "h2_sockpair_1byte": _fixture_options(
90 fullstack = False,
91 dns_resolver = False,
92 client_channel = False,
93 is_1byte = True,
94 ),
95 "h2_sockpair": _fixture_options(
96 fullstack = False,
97 dns_resolver = False,
98 client_channel = False,
99 ),
100 "h2_sockpair_with_minstack": _fixture_options(
101 fullstack = False,
102 dns_resolver = False,
103 client_channel = False,
104 is_minstack = True,
105 ),
106 "h2_sockpair+trace": _fixture_options(
107 fullstack = False,
108 dns_resolver = False,
109 tracing = True,
110 client_channel = False,
111 ),
112 "h2_ssl_tls12": _fixture_options(secure = True),
113 "h2_ssl_tls13": _fixture_options(secure = True),
114 "h2_ssl_cred_reload_tls12": _fixture_options(secure = True),
115 "h2_ssl_cred_reload_tls13": _fixture_options(secure = True),
116 "h2_tls_simple": _fixture_options(secure = True),
117 "h2_tls_static_async_tls1_3": _fixture_options(secure = True),
118 "h2_tls_certwatch_sync_tls1_2": _fixture_options(secure = True),
119 "h2_tls_certwatch_async_tls1_3": _fixture_options(secure = True),
120 "h2_local_abstract_uds_percent_encoded": _fixture_options(
121 secure = True,
122 dns_resolver = False,
123 _platforms = ["linux", "posix"],
124 ),
125 "h2_local_uds": _fixture_options(
126 secure = True,
127 dns_resolver = False,
128 _platforms = ["linux", "mac", "posix"],
129 ),
130 "h2_local_uds_percent_encoded": _fixture_options(
131 secure = True,
132 dns_resolver = False,
133 _platforms = ["linux", "mac", "posix"],
134 ),
135 "h2_local_ipv4": _fixture_options(
136 secure = True,
137 dns_resolver = False,
138 _platforms = ["linux", "mac", "posix"],
139 tags = ["requires-net:ipv4", "requires-net:loopback", "event_engine_client"],
140 ),
141 "h2_local_ipv6": _fixture_options(
142 secure = True,
143 dns_resolver = False,
144 _platforms = ["linux", "mac", "posix"],
145 ),
146 "h2_ssl_proxy": _fixture_options(includes_proxy = True, secure = True),
147 "h2_uds": _fixture_options(
148 dns_resolver = False,
149 _platforms = ["linux", "mac", "posix"],
150 ),
151 "h2_uds_abstract": _fixture_options(
152 dns_resolver = False,
153 _platforms = ["linux", "posix"],
154 ),
155 "inproc": _fixture_options(
156 secure = True,
157 fullstack = False,
158 dns_resolver = False,
159 name_resolution = False,
160 is_inproc = True,
161 is_http2 = False,
162 supports_write_buffering = False,
163 client_channel = False,
164 ),
165 }
166
167 def _test_options(
168 needs_fullstack = False,
169 needs_dns = False,
170 needs_names = False,
171 proxyable = True,
172 secure = False,
173 traceable = False,
174 exclude_inproc = False,
175 exclude_1byte = False,
176 exclude_minstack = False,
177 needs_http2 = False,
178 needs_proxy_auth = False,
179 needs_write_buffering = False,
180 needs_client_channel = False,
181 needs_retry = False,
182 short_name = None,
183 tags = [],
184 exclude_pollers = []):
185 return struct(
186 needs_fullstack = needs_fullstack,
187 needs_dns = needs_dns,
188 needs_names = needs_names,
189 proxyable = proxyable,
190 secure = secure,
191 traceable = traceable,
192 exclude_inproc = exclude_inproc,
193 exclude_1byte = exclude_1byte,
194 exclude_minstack = exclude_minstack,
195 needs_http2 = needs_http2,
196 needs_proxy_auth = needs_proxy_auth,
197 needs_write_buffering = needs_write_buffering,
198 needs_client_channel = needs_client_channel,
199 needs_retry = needs_retry,
200 short_name = short_name,
201 tags = tags,
202 exclude_pollers = exclude_pollers,
203 )
204
205 # maps test names to options
206 END2END_TESTS = {
207 "bad_hostname": _test_options(needs_names = True),
208 "bad_ping": _test_options(needs_fullstack = True, proxyable = False),
209 "binary_metadata": _test_options(),
210 "resource_quota_server": _test_options(
211 proxyable = False,
212 # TODO(b/151212019): Test case known to be flaky under epoll1.
213 exclude_pollers = ["epoll1"],
214 exclude_1byte = True,
215 ),
216 "call_creds": _test_options(secure = True),
217 "call_host_override": _test_options(
218 needs_fullstack = True,
219 needs_dns = True,
220 needs_names = True,
221 ),
222 "cancel_after_accept": _test_options(),
223 "cancel_after_client_done": _test_options(),
224 "cancel_after_invoke": _test_options(),
225 "cancel_after_round_trip": _test_options(),
226 "cancel_before_invoke": _test_options(),
227 "cancel_in_a_vacuum": _test_options(),
228 "cancel_with_status": _test_options(),
229 "client_streaming": _test_options(),
230 "compressed_payload": _test_options(proxyable = False, exclude_inproc = True, exclude_minstack = True),
231 "connectivity": _test_options(
232 needs_fullstack = True,
233 needs_names = True,
234 proxyable = False,
235 ),
236 "channelz": _test_options(),
237 "default_host": _test_options(
238 needs_fullstack = True,
239 needs_dns = True,
240 needs_names = True,
241 ),
242 "disappearing_server": _test_options(needs_fullstack = True, needs_names = True),
243 "empty_batch": _test_options(),
244 "filter_causes_close": _test_options(),
245 "filter_init_fails": _test_options(),
246 "filter_context": _test_options(),
247 "filtered_metadata": _test_options(),
248 "graceful_server_shutdown": _test_options(exclude_inproc = True),
249 "grpc_authz": _test_options(secure = True),
250 "hpack_size": _test_options(
251 proxyable = False,
252 traceable = False,
253 exclude_inproc = True,
254 ),
255 "high_initial_seqno": _test_options(),
256 "invoke_large_request": _test_options(exclude_1byte = True, tags = ["flow_control_test"]),
257 "keepalive_timeout": _test_options(proxyable = False, needs_http2 = True),
258 "large_metadata": _test_options(exclude_1byte = True),
259 "max_concurrent_streams": _test_options(
260 proxyable = False,
261 exclude_inproc = True,
262 exclude_minstack = True,
263 ),
264 "max_connection_age": _test_options(exclude_inproc = True),
265 "max_connection_idle": _test_options(needs_fullstack = True, proxyable = False),
266 "max_message_length": _test_options(exclude_minstack = True),
267 "negative_deadline": _test_options(exclude_minstack = True),
268 "no_logging": _test_options(traceable = False),
269 "no_op": _test_options(),
270 "payload": _test_options(exclude_1byte = True),
271 # TODO(juanlishen): This is disabled for now because it depends on some generated functions in
272 # end2end_tests.cc, which are not generated because they would depend on OpenCensus while
273 # OpenCensus can only be built via Bazel so far.
274 # 'load_reporting_hook': _test_options(),
275 "ping_pong_streaming": _test_options(tags = ["flow_control_test"]),
276 "ping": _test_options(needs_fullstack = True, proxyable = False),
277 "proxy_auth": _test_options(needs_proxy_auth = True),
278 "registered_call": _test_options(),
279 "request_with_flags": _test_options(proxyable = False),
280 "request_with_payload": _test_options(),
281 "retry": _test_options(needs_client_channel = True, needs_retry = True),
282 "retry_cancellation": _test_options(needs_client_channel = True, needs_retry = True),
283 "retry_cancel_during_delay": _test_options(needs_client_channel = True, needs_retry = True),
284 "retry_cancel_with_multiple_send_batches": _test_options(
285 # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
286 # See b/151617965
287 short_name = "retry_cancel3",
288 needs_client_channel = True,
289 needs_retry = True,
290 ),
291 "retry_cancel_after_first_attempt_starts": _test_options(
292 # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
293 # See b/151617965
294 short_name = "retry_cancel4",
295 needs_client_channel = True,
296 needs_retry = True,
297 ),
298 "retry_disabled": _test_options(needs_client_channel = True, needs_retry = True),
299 "retry_exceeds_buffer_size_in_delay": _test_options(needs_client_channel = True, needs_retry = True),
300 "retry_exceeds_buffer_size_in_initial_batch": _test_options(
301 needs_client_channel = True,
302 # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
303 # See b/151617965
304 short_name = "retry_exceeds_buffer_size_in_init",
305 needs_retry = True,
306 ),
307 "retry_exceeds_buffer_size_in_subsequent_batch": _test_options(
308 needs_client_channel = True,
309 # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
310 # See b/151617965
311 short_name = "retry_exceeds_buffer_size_in_subseq",
312 needs_retry = True,
313 ),
314 "retry_lb_drop": _test_options(needs_client_channel = True, needs_retry = True),
315 "retry_lb_fail": _test_options(needs_client_channel = True, needs_retry = True),
316 "retry_non_retriable_status": _test_options(needs_client_channel = True, needs_retry = True),
317 "retry_non_retriable_status_before_recv_trailing_metadata_started": _test_options(
318 needs_client_channel = True,
319 # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
320 # See b/151617965
321 short_name = "retry_non_retriable_status2",
322 needs_retry = True,
323 ),
324 "retry_per_attempt_recv_timeout": _test_options(needs_client_channel = True, needs_retry = True),
325 "retry_per_attempt_recv_timeout_on_last_attempt": _test_options(
326 needs_client_channel = True,
327 # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
328 # See b/151617965
329 short_name = "retry_per_attempt_recv_timeout2",
330 needs_retry = True,
331 ),
332 "retry_recv_initial_metadata": _test_options(needs_client_channel = True, needs_retry = True),
333 "retry_recv_message": _test_options(needs_client_channel = True, needs_retry = True),
334 "retry_recv_message_replay": _test_options(needs_client_channel = True, needs_retry = True),
335 "retry_recv_trailing_metadata_error": _test_options(needs_client_channel = True, needs_retry = True),
336 "retry_send_initial_metadata_refs": _test_options(needs_client_channel = True, needs_retry = True),
337 "retry_send_op_fails": _test_options(needs_client_channel = True, needs_retry = True),
338 "retry_send_recv_batch": _test_options(needs_client_channel = True, needs_retry = True),
339 "retry_server_pushback_delay": _test_options(needs_client_channel = True, needs_retry = True),
340 "retry_server_pushback_disabled": _test_options(needs_client_channel = True, needs_retry = True),
341 "retry_streaming": _test_options(needs_client_channel = True, needs_retry = True),
342 "retry_streaming_after_commit": _test_options(needs_client_channel = True, needs_retry = True),
343 "retry_streaming_succeeds_before_replay_finished": _test_options(
344 needs_client_channel = True,
345 # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
346 # See b/151617965
347 short_name = "retry_streaming2",
348 needs_retry = True,
349 ),
350 "retry_throttled": _test_options(needs_client_channel = True, needs_retry = True),
351 "retry_too_many_attempts": _test_options(needs_client_channel = True, needs_retry = True),
352 "retry_transparent_goaway": _test_options(needs_client_channel = True, needs_retry = True),
353 "retry_transparent_not_sent_on_wire": _test_options(needs_client_channel = True, needs_retry = True),
354 "retry_transparent_max_concurrent_streams": _test_options(
355 needs_client_channel = True,
356 proxyable = False,
357 # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
358 # See b/151617965
359 short_name = "retry_transparent_mcs",
360 needs_retry = True,
361 ),
362 "retry_unref_before_finish": _test_options(needs_client_channel = True, needs_retry = True),
363 "retry_unref_before_recv": _test_options(needs_client_channel = True, needs_retry = True),
364 "server_finishes_request": _test_options(),
365 "server_streaming": _test_options(needs_http2 = True),
366 "shutdown_finishes_calls": _test_options(),
367 "shutdown_finishes_tags": _test_options(),
368 "simple_delayed_request": _test_options(needs_fullstack = True),
369 "simple_metadata": _test_options(),
370 "simple_request": _test_options(),
371 "streaming_error_response": _test_options(),
372 "trailing_metadata": _test_options(),
373 "authority_not_supported": _test_options(),
374 "filter_latency": _test_options(),
375 "filter_status_code": _test_options(),
376 "write_buffering": _test_options(needs_write_buffering = True),
377 "write_buffering_at_end": _test_options(needs_write_buffering = True),
378 }
379
380 def _compatible(fopt, topt):
381 if topt.needs_fullstack:
382 if not fopt.fullstack:
383 return False
384 if topt.needs_dns:
385 if not fopt.dns_resolver:
386 return False
387 if topt.needs_names:
388 if not fopt.name_resolution:
389 return False
390 if not topt.proxyable:
391 if fopt.includes_proxy:
392 return False
393 if not topt.traceable:
394 if fopt.tracing:
395 return False
396 if topt.exclude_inproc:
397 if fopt.is_inproc:
398 return False
399 if topt.exclude_1byte:
400 if fopt.is_1byte:
401 return False
402 if topt.exclude_minstack:
403 if fopt.is_minstack:
404 return False
405 if topt.needs_http2:
406 if not fopt.is_http2:
407 return False
408 if topt.needs_proxy_auth:
409 if not fopt.supports_proxy_auth:
410 return False
411 if topt.needs_write_buffering:
412 if not fopt.supports_write_buffering:
413 return False
414 if topt.needs_client_channel:
415 if not fopt.client_channel:
416 return False
417 if topt.needs_retry:
418 if not fopt.supports_retry:
419 return False
420 return True
421
422 def _platform_support_tags(fopt):
423 result = []
424 if not "windows" in fopt._platforms:
425 result.append("no_windows")
426 if not "mac" in fopt._platforms:
427 result.append("no_mac")
428 if not "linux" in fopt._platforms:
429 result.append("no_linux")
430 return result
431
432 # buildifier: disable=unnamed-macro
433 def grpc_end2end_tests():
434 """Instantiates the gRPC end2end tests."""
435 grpc_cc_library(
436 name = "end2end_tests",
437 srcs = ["end2end_tests.cc", "end2end_test_utils.cc"] +
438 ["tests/%s.cc" % t for t in sorted(END2END_TESTS.keys())],
439 hdrs = [
440 "tests/cancel_test_helpers.h",
441 "end2end_tests.h",
442 ],
443 language = "C++",
444 testonly = 1,
445 deps = [
446 ":cq_verifier",
447 ":ssl_test_data",
448 ":http_proxy",
449 ":proxy",
450 ":local_util",
451 "//test/core/util:test_lb_policies",
452 "//:grpc_authorization_provider",
453 "//test/core/compression:args_utils",
454 "//:grpc_http_filters",
455 "//src/core:event_log",
456 ],
457 visibility = [
458 "//src/objective-c/tests:__subpackages__",
459 ],
460 )
461 for f, fopt in END2END_FIXTURES.items():
462 bin_name = "%s_test" % f
463 grpc_cc_binary(
464 name = bin_name,
465 srcs = ["fixtures/%s.cc" % f, "fixtures/h2_tls_common.h"],
466 language = "C++",
467 testonly = 1,
468 data = [
469 "//src/core/tsi/test_creds:ca.pem",
470 "//src/core/tsi/test_creds:server1.key",
471 "//src/core/tsi/test_creds:server1.pem",
472 ],
473 deps = [
474 ":end2end_tests",
475 "//test/core/util:grpc_test_util",
476 "//:grpc",
477 "//:gpr",
478 "//test/core/compression:args_utils",
479 "//:grpc_http_filters",
480 ],
481 tags = _platform_support_tags(fopt) + fopt.tags,
482 )
483 for t, topt in END2END_TESTS.items():
484 if not _compatible(fopt, topt):
485 continue
486 test_short_name = str(t) if not topt.short_name else topt.short_name
487 name = "%s_test@%s" % (f, test_short_name)
488 grpc_sh_test(
489 name = name,
490 srcs = ["run.sh"],
491 data = [":" + bin_name],
492 args = ["$(location %s)" % bin_name, t],
493 tags = _platform_support_tags(fopt) + fopt.tags + topt.tags + [
494 "no_test_ios",
495 "core_end2end_test",
496 ],
497 flaky = name in FLAKY_TESTS,
498 exclude_pollers = topt.exclude_pollers,
499 )