• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16"""Generates the appropriate build.json data for all the end2end tests."""
17
18load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library")
19
20POLLERS = ["epollex", "epoll1", "poll"]
21
22def _fixture_options(
23        fullstack = True,
24        includes_proxy = False,
25        dns_resolver = True,
26        name_resolution = True,
27        secure = True,
28        tracing = False,
29        _platforms = ["windows", "linux", "mac", "posix"],
30        is_inproc = False,
31        is_http2 = True,
32        supports_proxy_auth = False,
33        supports_write_buffering = True,
34        client_channel = True,
35        supports_msvc = True,
36        flaky_tests = []):
37    return struct(
38        fullstack = fullstack,
39        includes_proxy = includes_proxy,
40        dns_resolver = dns_resolver,
41        name_resolution = name_resolution,
42        secure = secure,
43        tracing = tracing,
44        is_inproc = is_inproc,
45        is_http2 = is_http2,
46        supports_proxy_auth = supports_proxy_auth,
47        supports_write_buffering = supports_write_buffering,
48        client_channel = client_channel,
49        supports_msvc = supports_msvc,
50        _platforms = _platforms,
51        flaky_tests = flaky_tests,
52    )
53
54# maps fixture name to whether it requires the security library
55END2END_FIXTURES = {
56    "h2_compress": _fixture_options(),
57    "h2_census": _fixture_options(),
58    # TODO(juanlishen): This is disabled for now, but should be considered to re-enable once we have
59    # decided how the load reporting service should be enabled.
60    #'h2_load_reporting': _fixture_options(),
61    "h2_fakesec": _fixture_options(),
62    "h2_fd": _fixture_options(
63        dns_resolver = False,
64        fullstack = False,
65        client_channel = False,
66        _platforms = ["linux", "mac", "posix"],
67    ),
68    "h2_full": _fixture_options(),
69    "h2_full+pipe": _fixture_options(_platforms = ["linux"]),
70    "h2_full+trace": _fixture_options(tracing = True),
71    "h2_full+workarounds": _fixture_options(),
72    "h2_http_proxy": _fixture_options(supports_proxy_auth = True),
73    "h2_oauth2": _fixture_options(),
74    "h2_proxy": _fixture_options(includes_proxy = True),
75    "h2_sockpair_1byte": _fixture_options(
76        fullstack = False,
77        dns_resolver = False,
78        client_channel = False,
79    ),
80    "h2_sockpair": _fixture_options(
81        fullstack = False,
82        dns_resolver = False,
83        client_channel = False,
84    ),
85    "h2_sockpair+trace": _fixture_options(
86        fullstack = False,
87        dns_resolver = False,
88        tracing = True,
89        client_channel = False,
90    ),
91    "h2_ssl": _fixture_options(secure = True),
92    "h2_ssl_cred_reload": _fixture_options(secure = True),
93    "h2_tls": _fixture_options(secure = True),
94    "h2_local_uds": _fixture_options(
95        secure = True,
96        dns_resolver = False,
97        _platforms = ["linux", "mac", "posix"],
98    ),
99    "h2_local_ipv4": _fixture_options(secure = True, dns_resolver = False, _platforms = ["linux", "mac", "posix"]),
100    "h2_local_ipv6": _fixture_options(secure = True, dns_resolver = False, _platforms = ["linux", "mac", "posix"]),
101    "h2_ssl_proxy": _fixture_options(includes_proxy = True, secure = True),
102    "h2_uds": _fixture_options(
103        dns_resolver = False,
104        _platforms = ["linux", "mac", "posix"],
105    ),
106    "inproc": _fixture_options(
107        secure = True,
108        fullstack = False,
109        dns_resolver = False,
110        name_resolution = False,
111        is_inproc = True,
112        is_http2 = False,
113        supports_write_buffering = False,
114        client_channel = False,
115    ),
116}
117
118# maps fixture name to whether it requires the security library
119END2END_NOSEC_FIXTURES = {
120    "h2_compress": _fixture_options(secure = False),
121    "h2_census": _fixture_options(secure = False),
122    # TODO(juanlishen): This is disabled for now, but should be considered to re-enable once we have
123    # decided how the load reporting service should be enabled.
124    #'h2_load_reporting': _fixture_options(),
125    "h2_fakesec": _fixture_options(),
126    "h2_fd": _fixture_options(
127        dns_resolver = False,
128        fullstack = False,
129        client_channel = False,
130        secure = False,
131        _platforms = ["linux", "mac", "posix"],
132        supports_msvc = False,
133    ),
134    "h2_full": _fixture_options(secure = False),
135    "h2_full+pipe": _fixture_options(secure = False, _platforms = ["linux"], supports_msvc = False),
136    "h2_full+trace": _fixture_options(secure = False, tracing = True, supports_msvc = False),
137    "h2_full+workarounds": _fixture_options(secure = False),
138    "h2_http_proxy": _fixture_options(secure = False, supports_proxy_auth = True),
139    "h2_proxy": _fixture_options(secure = False, includes_proxy = True),
140    "h2_sockpair_1byte": _fixture_options(
141        fullstack = False,
142        dns_resolver = False,
143        client_channel = False,
144        secure = False,
145    ),
146    "h2_sockpair": _fixture_options(
147        fullstack = False,
148        dns_resolver = False,
149        client_channel = False,
150        secure = False,
151    ),
152    "h2_sockpair+trace": _fixture_options(
153        fullstack = False,
154        dns_resolver = False,
155        tracing = True,
156        secure = False,
157        client_channel = False,
158    ),
159    "h2_ssl": _fixture_options(secure = False),
160    "h2_ssl_cred_reload": _fixture_options(secure = False),
161    "h2_ssl_proxy": _fixture_options(includes_proxy = True, secure = False),
162    "h2_uds": _fixture_options(
163        dns_resolver = False,
164        _platforms = ["linux", "mac", "posix"],
165        secure = False,
166        supports_msvc = False,
167    ),
168}
169
170def _test_options(
171        needs_fullstack = False,
172        needs_dns = False,
173        needs_names = False,
174        proxyable = True,
175        secure = False,
176        traceable = False,
177        exclude_inproc = False,
178        needs_http2 = False,
179        needs_proxy_auth = False,
180        needs_write_buffering = False,
181        needs_client_channel = False,
182        short_name = None,
183        exclude_pollers = []):
184    return struct(
185        needs_fullstack = needs_fullstack,
186        needs_dns = needs_dns,
187        needs_names = needs_names,
188        proxyable = proxyable,
189        secure = secure,
190        traceable = traceable,
191        exclude_inproc = exclude_inproc,
192        needs_http2 = needs_http2,
193        needs_proxy_auth = needs_proxy_auth,
194        needs_write_buffering = needs_write_buffering,
195        needs_client_channel = needs_client_channel,
196        short_name = short_name,
197        exclude_pollers = exclude_pollers,
198    )
199
200# maps test names to options
201END2END_TESTS = {
202    "bad_hostname": _test_options(needs_names = True),
203    "bad_ping": _test_options(needs_fullstack = True, proxyable = False),
204    "binary_metadata": _test_options(),
205    "resource_quota_server": _test_options(
206        proxyable = False,
207        # TODO(b/151212019): Test case known to be flaky under epoll1.
208        exclude_pollers = ["epoll1"],
209    ),
210    "call_creds": _test_options(secure = True),
211    "call_host_override": _test_options(
212        needs_fullstack = True,
213        needs_dns = True,
214        needs_names = True,
215    ),
216    "cancel_after_accept": _test_options(),
217    "cancel_after_client_done": _test_options(),
218    "cancel_after_invoke": _test_options(),
219    "cancel_after_round_trip": _test_options(),
220    "cancel_before_invoke": _test_options(),
221    "cancel_in_a_vacuum": _test_options(),
222    "cancel_with_status": _test_options(),
223    "client_streaming": _test_options(),
224    "compressed_payload": _test_options(proxyable = False, exclude_inproc = True),
225    "connectivity": _test_options(
226        needs_fullstack = True,
227        needs_names = True,
228        proxyable = False,
229    ),
230    "channelz": _test_options(),
231    "default_host": _test_options(
232        needs_fullstack = True,
233        needs_dns = True,
234        needs_names = True,
235    ),
236    "disappearing_server": _test_options(needs_fullstack = True, needs_names = True),
237    "empty_batch": _test_options(),
238    "filter_causes_close": _test_options(),
239    "filter_call_init_fails": _test_options(),
240    "filter_context": _test_options(),
241    "graceful_server_shutdown": _test_options(exclude_inproc = True),
242    "hpack_size": _test_options(
243        proxyable = False,
244        traceable = False,
245        exclude_inproc = True,
246    ),
247    "high_initial_seqno": _test_options(),
248    "idempotent_request": _test_options(),
249    "invoke_large_request": _test_options(),
250    "keepalive_timeout": _test_options(proxyable = False, needs_http2 = True),
251    "large_metadata": _test_options(),
252    "max_concurrent_streams": _test_options(
253        proxyable = False,
254        exclude_inproc = True,
255    ),
256    "max_connection_age": _test_options(exclude_inproc = True),
257    "max_connection_idle": _test_options(needs_fullstack = True, proxyable = False),
258    "max_message_length": _test_options(),
259    "negative_deadline": _test_options(),
260    "no_error_on_hotpath": _test_options(proxyable = False),
261    "no_logging": _test_options(traceable = False),
262    "no_op": _test_options(),
263    "payload": _test_options(),
264    # TODO(juanlishen): This is disabled for now because it depends on some generated functions in
265    # end2end_tests.cc, which are not generated because they would depend on OpenCensus while
266    # OpenCensus can only be built via Bazel so far.
267    # 'load_reporting_hook': _test_options(),
268    "ping_pong_streaming": _test_options(),
269    "ping": _test_options(needs_fullstack = True, proxyable = False),
270    "proxy_auth": _test_options(needs_proxy_auth = True),
271    "registered_call": _test_options(),
272    "request_with_flags": _test_options(proxyable = False),
273    "request_with_payload": _test_options(),
274    # TODO(roth): Remove proxyable=False for all retry tests once we
275    # have a way for the proxy to propagate the fact that trailing
276    # metadata is available when initial metadata is returned.
277    # See https://github.com/grpc/grpc/issues/14467 for context.
278    "retry": _test_options(needs_client_channel = True, proxyable = False),
279    "retry_cancellation": _test_options(
280        needs_client_channel = True,
281        proxyable = False,
282    ),
283    "retry_disabled": _test_options(needs_client_channel = True, proxyable = False),
284    "retry_exceeds_buffer_size_in_initial_batch": _test_options(
285        needs_client_channel = True,
286        proxyable = False,
287        # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
288        # See b/151617965
289        short_name = "retry_exceeds_buffer_size_in_init",
290    ),
291    "retry_exceeds_buffer_size_in_subsequent_batch": _test_options(
292        needs_client_channel = True,
293        proxyable = False,
294        # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
295        # See b/151617965
296        short_name = "retry_exceeds_buffer_size_in_subseq",
297    ),
298    "retry_non_retriable_status": _test_options(
299        needs_client_channel = True,
300        proxyable = False,
301    ),
302    "retry_non_retriable_status_before_recv_trailing_metadata_started": _test_options(
303        needs_client_channel = True,
304        proxyable = False,
305        # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
306        # See b/151617965
307        short_name = "retry_non_retriable_status2",
308    ),
309    "retry_recv_initial_metadata": _test_options(
310        needs_client_channel = True,
311        proxyable = False,
312    ),
313    "retry_recv_message": _test_options(
314        needs_client_channel = True,
315        proxyable = False,
316    ),
317    "retry_server_pushback_delay": _test_options(
318        needs_client_channel = True,
319        proxyable = False,
320    ),
321    "retry_server_pushback_disabled": _test_options(
322        needs_client_channel = True,
323        proxyable = False,
324    ),
325    "retry_streaming": _test_options(needs_client_channel = True, proxyable = False),
326    "retry_streaming_after_commit": _test_options(
327        needs_client_channel = True,
328        proxyable = False,
329    ),
330    "retry_streaming_succeeds_before_replay_finished": _test_options(
331        needs_client_channel = True,
332        proxyable = False,
333        # TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE
334        # See b/151617965
335        short_name = "retry_streaming2",
336    ),
337    "retry_throttled": _test_options(
338        needs_client_channel = True,
339        proxyable = False,
340    ),
341    "retry_too_many_attempts": _test_options(
342        needs_client_channel = True,
343        proxyable = False,
344    ),
345    "server_finishes_request": _test_options(),
346    "shutdown_finishes_calls": _test_options(),
347    "shutdown_finishes_tags": _test_options(),
348    "simple_cacheable_request": _test_options(),
349    "simple_delayed_request": _test_options(needs_fullstack = True),
350    "simple_metadata": _test_options(),
351    "simple_request": _test_options(),
352    "streaming_error_response": _test_options(),
353    "stream_compression_compressed_payload": _test_options(
354        proxyable = False,
355        exclude_inproc = True,
356    ),
357    "stream_compression_payload": _test_options(exclude_inproc = True),
358    "stream_compression_ping_pong_streaming": _test_options(exclude_inproc = True),
359    "trailing_metadata": _test_options(),
360    "authority_not_supported": _test_options(),
361    "filter_latency": _test_options(),
362    "filter_status_code": _test_options(),
363    "workaround_cronet_compression": _test_options(),
364    "write_buffering": _test_options(needs_write_buffering = True),
365    "write_buffering_at_end": _test_options(needs_write_buffering = True),
366}
367
368def _compatible(fopt, topt):
369    if topt.needs_fullstack:
370        if not fopt.fullstack:
371            return False
372    if topt.needs_dns:
373        if not fopt.dns_resolver:
374            return False
375    if topt.needs_names:
376        if not fopt.name_resolution:
377            return False
378    if not topt.proxyable:
379        if fopt.includes_proxy:
380            return False
381    if not topt.traceable:
382        if fopt.tracing:
383            return False
384    if topt.exclude_inproc:
385        if fopt.is_inproc:
386            return False
387    if topt.needs_http2:
388        if not fopt.is_http2:
389            return False
390    if topt.needs_proxy_auth:
391        if not fopt.supports_proxy_auth:
392            return False
393    if topt.needs_write_buffering:
394        if not fopt.supports_write_buffering:
395            return False
396    if topt.needs_client_channel:
397        if not fopt.client_channel:
398            return False
399    return True
400
401def _platform_support_tags(fopt):
402    result = []
403    if not "windows" in fopt._platforms:
404        result += ["no_windows"]
405    if not "mac" in fopt._platforms:
406        result += ["no_mac"]
407    if not "linux" in fopt._platforms:
408        result += ["no_linux"]
409    return result
410
411def grpc_end2end_tests():
412    grpc_cc_library(
413        name = "end2end_tests",
414        srcs = ["end2end_tests.cc", "end2end_test_utils.cc"] + [
415            "tests/%s.cc" % t
416            for t in sorted(END2END_TESTS.keys())
417        ],
418        hdrs = [
419            "tests/cancel_test_helpers.h",
420            "end2end_tests.h",
421        ],
422        language = "C++",
423        deps = [
424            ":cq_verifier",
425            ":ssl_test_data",
426            ":http_proxy",
427            ":proxy",
428            ":local_util",
429        ],
430    )
431
432    for f, fopt in END2END_FIXTURES.items():
433        grpc_cc_binary(
434            name = "%s_test" % f,
435            srcs = ["fixtures/%s.cc" % f],
436            language = "C++",
437            data = [
438                "//src/core/tsi/test_creds:ca.pem",
439                "//src/core/tsi/test_creds:server1.key",
440                "//src/core/tsi/test_creds:server1.pem",
441            ],
442            deps = [
443                ":end2end_tests",
444                "//test/core/util:grpc_test_util",
445                "//:grpc",
446                "//:gpr",
447            ],
448            tags = _platform_support_tags(fopt),
449        )
450
451        for t, topt in END2END_TESTS.items():
452            #print(_compatible(fopt, topt), f, t, fopt, topt)
453            if not _compatible(fopt, topt):
454                continue
455
456            test_short_name = str(t) if not topt.short_name else topt.short_name
457            native.sh_test(
458                name = "%s_test@%s" % (f, test_short_name),
459                data = [":%s_test" % f],
460                srcs = ["end2end_test.sh"],
461                args = [
462                    "$(location %s_test)" % f,
463                    t,
464                ],
465                tags = ["no_linux"] + _platform_support_tags(fopt),
466                flaky = t in fopt.flaky_tests,
467            )
468
469            for poller in POLLERS:
470                if poller in topt.exclude_pollers:
471                    continue
472                native.sh_test(
473                    name = "%s_test@%s@poller=%s" % (f, test_short_name, poller),
474                    data = [":%s_test" % f],
475                    srcs = ["end2end_test.sh"],
476                    args = [
477                        "$(location %s_test)" % f,
478                        t,
479                        poller,
480                    ],
481                    tags = ["no_mac", "no_windows"],
482                    flaky = t in fopt.flaky_tests,
483                )
484
485def grpc_end2end_nosec_tests():
486    grpc_cc_library(
487        name = "end2end_nosec_tests",
488        srcs = ["end2end_nosec_tests.cc", "end2end_test_utils.cc"] + [
489            "tests/%s.cc" % t
490            for t in sorted(END2END_TESTS.keys())
491            if not END2END_TESTS[t].secure
492        ],
493        hdrs = [
494            "tests/cancel_test_helpers.h",
495            "end2end_tests.h",
496        ],
497        language = "C++",
498        deps = [
499            ":cq_verifier",
500            ":ssl_test_data",
501            ":http_proxy",
502            ":proxy",
503            ":local_util",
504        ],
505    )
506
507    for f, fopt in END2END_NOSEC_FIXTURES.items():
508        if fopt.secure:
509            continue
510        grpc_cc_binary(
511            name = "%s_nosec_test" % f,
512            srcs = ["fixtures/%s.cc" % f],
513            language = "C++",
514            data = [
515                "//src/core/tsi/test_creds:ca.pem",
516                "//src/core/tsi/test_creds:server1.key",
517                "//src/core/tsi/test_creds:server1.pem",
518            ],
519            deps = [
520                ":end2end_nosec_tests",
521                "//test/core/util:grpc_test_util_unsecure",
522                "//:grpc_unsecure",
523                "//:gpr",
524            ],
525            tags = _platform_support_tags(fopt),
526        )
527        for t, topt in END2END_TESTS.items():
528            #print(_compatible(fopt, topt), f, t, fopt, topt)
529            if not _compatible(fopt, topt):
530                continue
531            if topt.secure:
532                continue
533
534            test_short_name = str(t) if not topt.short_name else topt.short_name
535            native.sh_test(
536                name = "%s_nosec_test@%s" % (f, test_short_name),
537                data = [":%s_nosec_test" % f],
538                srcs = ["end2end_test.sh"],
539                args = [
540                    "$(location %s_nosec_test)" % f,
541                    t,
542                ],
543                tags = ["no_linux"] + _platform_support_tags(fopt),
544                flaky = t in fopt.flaky_tests,
545            )
546
547            for poller in POLLERS:
548                if poller in topt.exclude_pollers:
549                    continue
550                native.sh_test(
551                    name = "%s_nosec_test@%s@poller=%s" % (f, test_short_name, poller),
552                    data = [":%s_nosec_test" % f],
553                    srcs = ["end2end_test.sh"],
554                    args = [
555                        "$(location %s_nosec_test)" % f,
556                        t,
557                        poller,
558                    ],
559                    tags = ["no_mac", "no_windows"],
560                    flaky = t in fopt.flaky_tests,
561                )
562