diff options
author | Eric Gribkoff <ericgribkoff@google.com> | 2017-03-13 13:13:30 -0700 |
---|---|---|
committer | Eric Gribkoff <ericgribkoff@google.com> | 2017-03-17 00:46:01 -0700 |
commit | 61335ec086b9c40c5c0d099f53dde1b602db5955 (patch) | |
tree | 06fdbde6f4c07fbd84d513fdaac7d381ccda9469 /tools | |
parent | 95f48c154b1073393fae4d412f4c905194e7f96c (diff) |
use docker port mapping for http2 server
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/run_tests/run_interop_tests.py | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 29d5a9aaa0..f51088e237 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -636,10 +636,7 @@ def cloud_to_cloud_jobspec(language, test_case, server_name, server_host, '--server_host=%s' % server_host, ] if test_case in _HTTP2_BADSERVER_TEST_CASES: - # We are running the http2_badserver_interop test. Adjust command line accordingly. - offset = sorted(_HTTP2_BADSERVER_TEST_CASES).index(test_case) - client_options = common_options + ['--server_port=%s' % - (int(server_port)+offset)] + client_options = common_options + ['--server_port=%s' % server_port] cmdline = bash_cmdline(language.client_cmd_http2interop(client_options)) cwd = language.http2_cwd else: @@ -685,18 +682,11 @@ def server_jobspec(language, docker_image, insecure=False, manual_cmd_log=None): if language.safename == 'http2': # we are running the http2 interop server. Open next N ports beginning # with the server port. These ports are used for http2 interop test - # (one test case per port). We also attach the docker container running - # the server to local network, so we don't have to mess with port mapping - port_args = [ - '-p', str(_DEFAULT_SERVER_PORT+0), - '-p', str(_DEFAULT_SERVER_PORT+1), - '-p', str(_DEFAULT_SERVER_PORT+2), - '-p', str(_DEFAULT_SERVER_PORT+3), - '-p', str(_DEFAULT_SERVER_PORT+4), - '-p', str(_DEFAULT_SERVER_PORT+5), - '-p', str(_DEFAULT_SERVER_PORT+6), - '--net=host', - ] + # (one test case per port). + port_args = list( + itertools.chain.from_iterable(('-p', str(_DEFAULT_SERVER_PORT + i)) + for i in range( + len(_HTTP2_BADSERVER_TEST_CASES)))) else: port_args = ['-p', str(_DEFAULT_SERVER_PORT)] @@ -936,6 +926,7 @@ client_manual_cmd_log = [] if args.manual_run else None # Start interop servers. server_jobs = {} server_addresses = {} +http2_badserver_ports = () try: for s in servers: lang = str(s) @@ -957,6 +948,10 @@ try: if not args.manual_run: job = dockerjob.DockerJob(spec) server_jobs[lang] = job + http2_badserver_ports = tuple([ + job.mapped_port(_DEFAULT_SERVER_PORT + i) + for i in range(len(_HTTP2_BADSERVER_TEST_CASES)) + ]) else: # don't run the server, set server port to a placeholder value server_addresses[lang] = ('localhost', '${SERVER_PORT}') @@ -1043,11 +1038,12 @@ try: if args.http2_badserver_interop: for language in languages_http2_badserver_interop: for test_case in _HTTP2_BADSERVER_TEST_CASES: + offset = sorted(_HTTP2_BADSERVER_TEST_CASES).index(test_case) test_job = cloud_to_cloud_jobspec(language, test_case, str(http2InteropServer), 'localhost', - _DEFAULT_SERVER_PORT, + http2_badserver_ports[offset], docker_image=docker_images.get(str(language)), manual_cmd_log=client_manual_cmd_log) jobs.append(test_job) |