cwd = language.client_cwd
if docker_image:
- container_name = dockerjob.random_name(
- 'interop_client_%s' % language.safename)
+ container_name = dockerjob.random_name('interop_client_%s' %
+ language.safename)
cmdline = docker_run_cmdline(
cmdline,
image=docker_image,
'--name=%s' % container_name])
if manual_cmd_log is not None:
if manual_cmd_log == []:
- manual_cmd_log.append(
- 'echo "Testing ${docker_image:=%s}"' % docker_image)
+ manual_cmd_log.append('echo "Testing ${docker_image:=%s}"' %
+ docker_image)
manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
cwd = None
environ = None
suite_name = 'cloud_to_prod_auth' if auth else 'cloud_to_prod'
- test_job = jobset.JobSpec(
- cmdline=cmdline,
- cwd=cwd,
- environ=environ,
- shortname='%s:%s:%s:%s:%s' %
- (suite_name, language, server_host_nickname, test_case,
- transport_security),
- timeout_seconds=_TEST_TIMEOUT,
- flake_retries=4 if args.allow_flakes else 0,
- timeout_retries=2 if args.allow_flakes else 0,
- kill_handler=_job_kill_handler)
+ test_job = jobset.JobSpec(cmdline=cmdline,
+ cwd=cwd,
+ environ=environ,
+ shortname='%s:%s:%s:%s:%s' %
+ (suite_name, language, server_host_nickname,
+ test_case, transport_security),
+ timeout_seconds=_TEST_TIMEOUT,
+ flake_retries=4 if args.allow_flakes else 0,
+ timeout_retries=2 if args.allow_flakes else 0,
+ kill_handler=_job_kill_handler)
if docker_image:
test_job.container_name = container_name
return test_job
elif transport_security == 'insecure':
interop_only_options += ['--use_tls=false']
else:
- print('Invalid transport security option %s in cloud_to_cloud_jobspec.'
- % transport_security)
+ print(
+ 'Invalid transport security option %s in cloud_to_cloud_jobspec.' %
+ transport_security)
sys.exit(1)
client_test_case = test_case
environ = language.global_env()
if docker_image and language.safename != 'objc':
# we can't run client in docker for objc.
- container_name = dockerjob.random_name(
- 'interop_client_%s' % language.safename)
+ container_name = dockerjob.random_name('interop_client_%s' %
+ language.safename)
cmdline = docker_run_cmdline(
cmdline,
image=docker_image,
'--name=%s' % container_name])
if manual_cmd_log is not None:
if manual_cmd_log == []:
- manual_cmd_log.append(
- 'echo "Testing ${docker_image:=%s}"' % docker_image)
+ manual_cmd_log.append('echo "Testing ${docker_image:=%s}"' %
+ docker_image)
manual_cmd_log.append(manual_cmdline(cmdline, docker_image))
cwd = None
transport_security='tls',
manual_cmd_log=None):
"""Create jobspec for running a server"""
- container_name = dockerjob.random_name(
- 'interop_server_%s' % language.safename)
+ container_name = dockerjob.random_name('interop_server_%s' %
+ language.safename)
server_cmd = ['--port=%s' % _DEFAULT_SERVER_PORT]
if transport_security == 'tls':
server_cmd += ['--use_tls=true']
# command line.
docker_args += [
'--health-cmd=python test/http2_test/http2_server_health_check.py '
- '--server_host=%s --server_port=%d' % ('localhost',
- _DEFAULT_SERVER_PORT),
+ '--server_host=%s --server_port=%d' %
+ ('localhost', _DEFAULT_SERVER_PORT),
'--health-interval=1s',
'--health-retries=5',
'--health-timeout=10s',
else:
docker_args += ['-p', str(_DEFAULT_SERVER_PORT)]
- docker_cmdline = docker_run_cmdline(
- cmdline,
- image=docker_image,
- cwd=language.server_cwd,
- environ=environ,
- docker_args=docker_args)
+ docker_cmdline = docker_run_cmdline(cmdline,
+ image=docker_image,
+ cwd=language.server_cwd,
+ environ=environ,
+ docker_args=docker_args)
if manual_cmd_log is not None:
if manual_cmd_log == []:
- manual_cmd_log.append(
- 'echo "Testing ${docker_image:=%s}"' % docker_image)
+ manual_cmd_log.append('echo "Testing ${docker_image:=%s}"' %
+ docker_image)
manual_cmd_log.append(manual_cmdline(docker_cmdline, docker_image))
- server_job = jobset.JobSpec(
- cmdline=docker_cmdline,
- environ=environ,
- shortname='interop_server_%s' % language,
- timeout_seconds=30 * 60)
+ server_job = jobset.JobSpec(cmdline=docker_cmdline,
+ environ=environ,
+ shortname='interop_server_%s' % language,
+ timeout_seconds=30 * 60)
server_job.container_name = container_name
return server_job
}
argp = argparse.ArgumentParser(description='Run interop tests.')
-argp.add_argument(
- '-l',
- '--language',
- choices=['all'] + sorted(_LANGUAGES),
- nargs='+',
- default=['all'],
- help='Clients to run. Objc client can be only run on OSX.')
+argp.add_argument('-l',
+ '--language',
+ choices=['all'] + sorted(_LANGUAGES),
+ nargs='+',
+ default=['all'],
+ help='Clients to run. Objc client can be only run on OSX.')
argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int)
-argp.add_argument(
- '--cloud_to_prod',
- default=False,
- action='store_const',
- const=True,
- help='Run cloud_to_prod tests.')
-argp.add_argument(
- '--cloud_to_prod_auth',
- default=False,
- action='store_const',
- const=True,
- help='Run cloud_to_prod_auth tests.')
-argp.add_argument(
- '--google_default_creds_use_key_file',
- default=False,
- action='store_const',
- const=True,
- help=('Whether or not we should use a key file for the '
- 'google_default_credentials test case, e.g. by '
- 'setting env var GOOGLE_APPLICATION_CREDENTIALS.'))
-argp.add_argument(
- '--prod_servers',
- choices=prod_servers.keys(),
- default=['default'],
- nargs='+',
- help=('The servers to run cloud_to_prod and '
- 'cloud_to_prod_auth tests against.'))
-argp.add_argument(
- '-s',
- '--server',
- choices=['all'] + sorted(_SERVERS),
- nargs='+',
- help='Run cloud_to_cloud servers in a separate docker ' +
- 'image. Servers can only be started automatically if ' +
- '--use_docker option is enabled.',
- default=[])
+argp.add_argument('--cloud_to_prod',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Run cloud_to_prod tests.')
+argp.add_argument('--cloud_to_prod_auth',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Run cloud_to_prod_auth tests.')
+argp.add_argument('--google_default_creds_use_key_file',
+ default=False,
+ action='store_const',
+ const=True,
+ help=('Whether or not we should use a key file for the '
+ 'google_default_credentials test case, e.g. by '
+ 'setting env var GOOGLE_APPLICATION_CREDENTIALS.'))
+argp.add_argument('--prod_servers',
+ choices=prod_servers.keys(),
+ default=['default'],
+ nargs='+',
+ help=('The servers to run cloud_to_prod and '
+ 'cloud_to_prod_auth tests against.'))
+argp.add_argument('-s',
+ '--server',
+ choices=['all'] + sorted(_SERVERS),
+ nargs='+',
+ help='Run cloud_to_cloud servers in a separate docker ' +
+ 'image. Servers can only be started automatically if ' +
+ '--use_docker option is enabled.',
+ default=[])
argp.add_argument(
'--override_server',
action='append',
type=str,
help='Default GCE service account email to use for some auth interop tests.',
default='830293263384-compute@developer.gserviceaccount.com')
-argp.add_argument(
- '-t', '--travis', default=False, action='store_const', const=True)
-argp.add_argument(
- '-v', '--verbose', default=False, action='store_const', const=True)
+argp.add_argument('-t',
+ '--travis',
+ default=False,
+ action='store_const',
+ const=True)
+argp.add_argument('-v',
+ '--verbose',
+ default=False,
+ action='store_const',
+ const=True)
argp.add_argument(
'--use_docker',
default=False,
help=
'Allow flaky tests to show as passing (re-runs failed tests up to five times)'
)
-argp.add_argument(
- '--manual_run',
- default=False,
- action='store_const',
- const=True,
- help='Prepare things for running interop tests manually. ' +
- 'Preserve docker images after building them and skip '
- 'actually running the tests. Only print commands to run by ' + 'hand.')
+argp.add_argument('--manual_run',
+ default=False,
+ action='store_const',
+ const=True,
+ help='Prepare things for running interop tests manually. ' +
+ 'Preserve docker images after building them and skip '
+ 'actually running the tests. Only print commands to run by ' +
+ 'hand.')
argp.add_argument(
'--http2_interop',
default=False,
help=
'Enable HTTP/2 server edge case testing. (Includes positive and negative tests'
)
-argp.add_argument(
- '--transport_security',
- choices=_TRANSPORT_SECURITY_OPTIONS,
- default='tls',
- type=str,
- nargs='?',
- const=True,
- help='Which transport security mechanism to use.')
+argp.add_argument('--transport_security',
+ choices=_TRANSPORT_SECURITY_OPTIONS,
+ default='tls',
+ type=str,
+ nargs='?',
+ const=True,
+ help='Which transport security mechanism to use.')
argp.add_argument(
'--custom_credentials_type',
choices=_CUSTOM_CREDENTIALS_TYPE_OPTIONS,
help=(
'(Deprecated, has no effect) Put reports into subdirectories to improve '
'presentation of results by Internal CI.'))
-argp.add_argument(
- '--bq_result_table',
- default='',
- type=str,
- nargs='?',
- help='Upload test results to a specified BQ table.')
+argp.add_argument('--bq_result_table',
+ default='',
+ type=str,
+ nargs='?',
+ help='Upload test results to a specified BQ table.')
args = argp.parse_args()
-servers = set(
- s
- for s in itertools.chain.from_iterable(
- _SERVERS if x == 'all' else [x] for x in args.server))
+servers = set(s for s in itertools.chain.from_iterable(
+ _SERVERS if x == 'all' else [x] for x in args.server))
# ALTS servers are only available for certain languages.
if args.transport_security == 'alts':
servers = servers.intersection(_SERVERS_FOR_ALTS_TEST_CASES)
# we want to include everything but objc in 'all'
# because objc won't run on non-mac platforms
all_but_objc = set(six.iterkeys(_LANGUAGES)) - set(['objc'])
-languages = set(_LANGUAGES[l]
- for l in itertools.chain.from_iterable(
- all_but_objc if x == 'all' else [x] for x in args.language))
+languages = set(_LANGUAGES[l] for l in itertools.chain.from_iterable(
+ all_but_objc if x == 'all' else [x] for x in args.language))
# ALTS interop clients are only available for certain languages.
if args.transport_security == 'alts':
alts_languages = set(_LANGUAGES[l] for l in _LANGUAGES_FOR_ALTS_TEST_CASES)
docker_images = {}
if args.use_docker:
# languages for which to build docker images
- languages_to_build = set(
- _LANGUAGES[k]
- for k in set([str(l) for l in languages] + [s for s in servers]))
+ languages_to_build = set(_LANGUAGES[k]
+ for k in set([str(l) for l in languages] +
+ [s for s in servers]))
languages_to_build = languages_to_build | languages_http2_clients_for_http2_server_interop
if args.http2_interop:
build_jobs.append(job)
if build_jobs:
- jobset.message(
- 'START', 'Building interop docker images.', do_newline=True)
+ jobset.message('START',
+ 'Building interop docker images.',
+ do_newline=True)
if args.verbose:
print('Jobs to run: \n%s\n' % '\n'.join(str(j) for j in build_jobs))
- num_failures, build_resultset = jobset.run(
- build_jobs, newline_on_success=True, maxjobs=args.jobs)
+ num_failures, build_resultset = jobset.run(build_jobs,
+ newline_on_success=True,
+ maxjobs=args.jobs)
report_utils.render_junit_xml_report(build_resultset,
_DOCKER_BUILD_XML_REPORT)
if num_failures == 0:
- jobset.message(
- 'SUCCESS',
- 'All docker images built successfully.',
- do_newline=True)
+ jobset.message('SUCCESS',
+ 'All docker images built successfully.',
+ do_newline=True)
else:
- jobset.message(
- 'FAILED',
- 'Failed to build interop docker images.',
- do_newline=True)
+ jobset.message('FAILED',
+ 'Failed to build interop docker images.',
+ do_newline=True)
for image in six.itervalues(docker_images):
dockerjob.remove_image(image, skip_nonexistent=True)
sys.exit(1)
try:
for s in servers:
lang = str(s)
- spec = server_jobspec(
- _LANGUAGES[lang],
- docker_images.get(lang),
- args.transport_security,
- manual_cmd_log=server_manual_cmd_log)
+ spec = server_jobspec(_LANGUAGES[lang],
+ docker_images.get(lang),
+ args.transport_security,
+ manual_cmd_log=server_manual_cmd_log)
if not args.manual_run:
job = dockerjob.DockerJob(spec)
server_jobs[lang] = job
if args.http2_server_interop:
# launch a HTTP2 server emulator that creates edge cases
lang = str(http2InteropServer)
- spec = server_jobspec(
- http2InteropServer,
- docker_images.get(lang),
- manual_cmd_log=server_manual_cmd_log)
+ spec = server_jobspec(http2InteropServer,
+ docker_images.get(lang),
+ manual_cmd_log=server_manual_cmd_log)
if not args.manual_run:
http2_server_job = dockerjob.DockerJob(spec)
server_jobs[lang] = http2_server_job
if args.verbose:
print('Jobs to run: \n%s\n' % '\n'.join(str(job) for job in jobs))
- num_failures, resultset = jobset.run(
- jobs,
- newline_on_success=True,
- maxjobs=args.jobs,
- skip_jobs=args.manual_run)
+ num_failures, resultset = jobset.run(jobs,
+ newline_on_success=True,
+ maxjobs=args.jobs,
+ skip_jobs=args.manual_run)
if args.bq_result_table and resultset:
upload_interop_results_to_bq(resultset, args.bq_result_table)
if num_failures: