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 16POLLERS = ['epollex', 'epollsig', 'epoll1', 'poll', 'poll-cv'] 17 18load("//bazel:grpc_build_system.bzl", "grpc_sh_test", "grpc_cc_binary", "grpc_cc_library") 19 20"""Generates the appropriate build.json data for all the end2end tests.""" 21 22 23def fixture_options(fullstack=True, includes_proxy=False, dns_resolver=True, 24 name_resolution=True, secure=True, tracing=False, 25 platforms=['windows', 'linux', 'mac', 'posix'], 26 is_inproc=False, is_http2=True, supports_proxy_auth=False, 27 supports_write_buffering=True, client_channel=True): 28 return struct( 29 fullstack=fullstack, 30 includes_proxy=includes_proxy, 31 dns_resolver=dns_resolver, 32 name_resolution=name_resolution, 33 secure=secure, 34 tracing=tracing, 35 is_inproc=is_inproc, 36 is_http2=is_http2, 37 supports_proxy_auth=supports_proxy_auth, 38 supports_write_buffering=supports_write_buffering, 39 client_channel=client_channel, 40 #platforms=platforms, 41 ) 42 43 44# maps fixture name to whether it requires the security library 45END2END_FIXTURES = { 46 'h2_compress': fixture_options(), 47 'h2_census': fixture_options(), 48 # TODO(juanlishen): This is disabled for now, but should be considered to re-enable once we have 49 # decided how the load reporting service should be enabled. 50 #'h2_load_reporting': fixture_options(), 51 'h2_fakesec': fixture_options(), 52 'h2_fd': fixture_options(dns_resolver=False, fullstack=False, 53 client_channel=False, 54 platforms=['linux', 'mac', 'posix']), 55 'h2_full': fixture_options(), 56 'h2_full+pipe': fixture_options(platforms=['linux']), 57 'h2_full+trace': fixture_options(tracing=True), 58 'h2_full+workarounds': fixture_options(), 59 'h2_http_proxy': fixture_options(supports_proxy_auth=True), 60 'h2_oauth2': fixture_options(), 61 'h2_proxy': fixture_options(includes_proxy=True), 62 'h2_sockpair_1byte': fixture_options(fullstack=False, dns_resolver=False, 63 client_channel=False), 64 'h2_sockpair': fixture_options(fullstack=False, dns_resolver=False, 65 client_channel=False), 66 'h2_sockpair+trace': fixture_options(fullstack=False, dns_resolver=False, 67 tracing=True, client_channel=False), 68 'h2_ssl': fixture_options(secure=True), 69 'h2_local': fixture_options(secure=True, dns_resolver=False, platforms=['linux', 'mac', 'posix']), 70 'h2_ssl_proxy': fixture_options(includes_proxy=True, secure=True), 71 'h2_uds': fixture_options(dns_resolver=False, 72 platforms=['linux', 'mac', 'posix']), 73 'inproc': fixture_options(fullstack=False, dns_resolver=False, 74 name_resolution=False, is_inproc=True, 75 is_http2=False, supports_write_buffering=False, 76 client_channel=False), 77} 78 79 80def test_options(needs_fullstack=False, needs_dns=False, needs_names=False, 81 proxyable=True, secure=False, traceable=False, 82 exclude_inproc=False, needs_http2=False, 83 needs_proxy_auth=False, needs_write_buffering=False, 84 needs_client_channel=False): 85 return struct( 86 needs_fullstack=needs_fullstack, 87 needs_dns=needs_dns, 88 needs_names=needs_names, 89 proxyable=proxyable, 90 secure=secure, 91 traceable=traceable, 92 exclude_inproc=exclude_inproc, 93 needs_http2=needs_http2, 94 needs_proxy_auth=needs_proxy_auth, 95 needs_write_buffering=needs_write_buffering, 96 needs_client_channel=needs_client_channel, 97 ) 98 99 100# maps test names to options 101END2END_TESTS = { 102 'bad_hostname': test_options(needs_names=True), 103 'bad_ping': test_options(needs_fullstack=True,proxyable=False), 104 'binary_metadata': test_options(), 105 'resource_quota_server': test_options(proxyable=False), 106 'call_creds': test_options(secure=True), 107 'call_host_override': test_options(needs_fullstack=True, needs_dns=True, 108 needs_names=True), 109 'cancel_after_accept': test_options(), 110 'cancel_after_client_done': test_options(), 111 'cancel_after_invoke': test_options(), 112 'cancel_after_round_trip': test_options(), 113 'cancel_before_invoke': test_options(), 114 'cancel_in_a_vacuum': test_options(), 115 'cancel_with_status': test_options(), 116 'compressed_payload': test_options(proxyable=False, exclude_inproc=True), 117 'connectivity': test_options(needs_fullstack=True, needs_names=True, 118 proxyable=False), 119 'channelz': test_options(), 120 'default_host': test_options(needs_fullstack=True, needs_dns=True, 121 needs_names=True), 122 'disappearing_server': test_options(needs_fullstack=True,needs_names=True), 123 'empty_batch': test_options(), 124 'filter_causes_close': test_options(), 125 'filter_call_init_fails': test_options(), 126 'graceful_server_shutdown': test_options(exclude_inproc=True), 127 'hpack_size': test_options(proxyable=False, traceable=False, 128 exclude_inproc=True), 129 'high_initial_seqno': test_options(), 130 'idempotent_request': test_options(), 131 'invoke_large_request': test_options(), 132 'keepalive_timeout': test_options(proxyable=False, needs_http2=True), 133 'large_metadata': test_options(), 134 'max_concurrent_streams': test_options(proxyable=False, 135 exclude_inproc=True), 136 'max_connection_age': test_options(exclude_inproc=True), 137 'max_connection_idle': test_options(needs_fullstack=True, proxyable=False), 138 'max_message_length': test_options(), 139 'negative_deadline': test_options(), 140 'network_status_change': test_options(), 141 'no_error_on_hotpath': test_options(proxyable=False), 142 'no_logging': test_options(traceable=False), 143 'no_op': test_options(), 144 'payload': test_options(), 145 # TODO(juanlishen): This is disabled for now because it depends on some generated functions in 146 # end2end_tests.cc, which are not generated because they would depend on OpenCensus while 147 # OpenCensus can only be built via Bazel so far. 148 # 'load_reporting_hook': test_options(), 149 'ping_pong_streaming': test_options(), 150 'ping': test_options(needs_fullstack=True, proxyable=False), 151 'proxy_auth': test_options(needs_proxy_auth=True), 152 'registered_call': test_options(), 153 'request_with_flags': test_options(proxyable=False), 154 'request_with_payload': test_options(), 155 # TODO(roth): Remove proxyable=False for all retry tests once we 156 # have a way for the proxy to propagate the fact that trailing 157 # metadata is available when initial metadata is returned. 158 # See https://github.com/grpc/grpc/issues/14467 for context. 159 'retry': test_options(needs_client_channel=True, proxyable=False), 160 'retry_cancellation': test_options(needs_client_channel=True, 161 proxyable=False), 162 'retry_disabled': test_options(needs_client_channel=True, proxyable=False), 163 'retry_exceeds_buffer_size_in_initial_batch': test_options( 164 needs_client_channel=True, proxyable=False), 165 'retry_exceeds_buffer_size_in_subsequent_batch': test_options( 166 needs_client_channel=True, proxyable=False), 167 'retry_non_retriable_status': test_options(needs_client_channel=True, 168 proxyable=False), 169 'retry_non_retriable_status_before_recv_trailing_metadata_started': 170 test_options(needs_client_channel=True, proxyable=False), 171 'retry_recv_initial_metadata': test_options(needs_client_channel=True, 172 proxyable=False), 173 'retry_recv_message': test_options(needs_client_channel=True, 174 proxyable=False), 175 'retry_server_pushback_delay': test_options(needs_client_channel=True, 176 proxyable=False), 177 'retry_server_pushback_disabled': test_options(needs_client_channel=True, 178 proxyable=False), 179 'retry_streaming': test_options(needs_client_channel=True, proxyable=False), 180 'retry_streaming_after_commit': test_options(needs_client_channel=True, 181 proxyable=False), 182 'retry_streaming_succeeds_before_replay_finished': test_options( 183 needs_client_channel=True, proxyable=False), 184 'retry_throttled': test_options(needs_client_channel=True, 185 proxyable=False), 186 'retry_too_many_attempts': test_options(needs_client_channel=True, 187 proxyable=False), 188 'server_finishes_request': test_options(), 189 'shutdown_finishes_calls': test_options(), 190 'shutdown_finishes_tags': test_options(), 191 'simple_cacheable_request': test_options(), 192 'simple_delayed_request': test_options(needs_fullstack=True), 193 'simple_metadata': test_options(), 194 'simple_request': test_options(), 195 'streaming_error_response': test_options(), 196 'stream_compression_compressed_payload': test_options(proxyable=False, 197 exclude_inproc=True), 198 'stream_compression_payload': test_options(exclude_inproc=True), 199 'stream_compression_ping_pong_streaming': test_options(exclude_inproc=True), 200 'trailing_metadata': test_options(), 201 'authority_not_supported': test_options(), 202 'filter_latency': test_options(), 203 'filter_status_code': test_options(), 204 'workaround_cronet_compression': test_options(), 205 'write_buffering': test_options(needs_write_buffering=True), 206 'write_buffering_at_end': test_options(needs_write_buffering=True), 207} 208 209 210def compatible(fopt, topt): 211 if topt.needs_fullstack: 212 if not fopt.fullstack: 213 return False 214 if topt.needs_dns: 215 if not fopt.dns_resolver: 216 return False 217 if topt.needs_names: 218 if not fopt.name_resolution: 219 return False 220 if not topt.proxyable: 221 if fopt.includes_proxy: 222 return False 223 if not topt.traceable: 224 if fopt.tracing: 225 return False 226 if topt.exclude_inproc: 227 if fopt.is_inproc: 228 return False 229 if topt.needs_http2: 230 if not fopt.is_http2: 231 return False 232 if topt.needs_proxy_auth: 233 if not fopt.supports_proxy_auth: 234 return False 235 if topt.needs_write_buffering: 236 if not fopt.supports_write_buffering: 237 return False 238 if topt.needs_client_channel: 239 if not fopt.client_channel: 240 return False 241 return True 242 243 244def grpc_end2end_tests(): 245 grpc_cc_library( 246 name = 'end2end_tests', 247 srcs = ['end2end_tests.cc', 'end2end_test_utils.cc'] + [ 248 'tests/%s.cc' % t 249 for t in sorted(END2END_TESTS.keys())], 250 hdrs = [ 251 'tests/cancel_test_helpers.h', 252 'end2end_tests.h' 253 ], 254 language = "C++", 255 deps = [ 256 ':cq_verifier', 257 ':ssl_test_data', 258 ':http_proxy', 259 ':proxy', 260 ] 261 ) 262 263 for f, fopt in END2END_FIXTURES.items(): 264 grpc_cc_binary( 265 name = '%s_test' % f, 266 srcs = ['fixtures/%s.cc' % f], 267 language = "C++", 268 deps = [ 269 ':end2end_tests', 270 '//test/core/util:grpc_test_util', 271 '//:grpc', 272 '//test/core/util:gpr_test_util', 273 '//:gpr', 274 ], 275 ) 276 for t, topt in END2END_TESTS.items(): 277 #print(compatible(fopt, topt), f, t, fopt, topt) 278 if not compatible(fopt, topt): continue 279 for poller in POLLERS: 280 native.sh_test( 281 name = '%s_test@%s@poller=%s' % (f, t, poller), 282 data = [':%s_test' % f], 283 srcs = ['end2end_test.sh'], 284 args = [ 285 '$(location %s_test)' % f, 286 t, 287 poller, 288 ], 289 ) 290