diff options
author | jiangtaoli2016 <jiangtao@google.com> | 2018-04-02 12:53:59 -0700 |
---|---|---|
committer | jiangtaoli2016 <jiangtao@google.com> | 2018-04-03 17:01:43 -0700 |
commit | fb7c84e5a6aa98923c8974d9480ae99a785c5a14 (patch) | |
tree | 0a4995fe4c6608589112776ceafcb5652b569f50 | |
parent | b801c867e81e201620c0393a18c97e54d8dec41c (diff) |
Update interop test script to support ALTS
-rw-r--r-- | tools/internal_ci/linux/grpc_interop_alts.cfg | 30 | ||||
-rwxr-xr-x | tools/run_tests/run_interop_tests.py | 81 |
2 files changed, 88 insertions, 23 deletions
diff --git a/tools/internal_ci/linux/grpc_interop_alts.cfg b/tools/internal_ci/linux/grpc_interop_alts.cfg new file mode 100644 index 0000000000..bda76faf44 --- /dev/null +++ b/tools/internal_ci/linux/grpc_interop_alts.cfg @@ -0,0 +1,30 @@ +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/grpc_run_interop_tests.sh" +timeout_mins: 60 +action { + define_artifacts { + regex: "**/sponge_log.xml" + regex: "github/grpc/reports/**" + } +} + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-l all -s all --use_docker --transport_security alts --internal_ci -t -j 12 --bq_result_table interop_results" +} diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 970b0d7902..26994ac128 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -637,6 +637,14 @@ _LANGUAGES_WITH_HTTP2_CLIENTS_FOR_HTTP2_SERVER_TEST_CASES = [ 'java', 'go', 'python', 'c++' ] +#TODO: Add c++ when c++ ALTS interop client is ready. +_LANGUAGES_FOR_ALTS_TEST_CASES = ['java', 'go'] + +#TODO: Add c++ when c++ ALTS interop server is ready. +_SERVERS_FOR_ALTS_TEST_CASES = ['java', 'go'] + +_TRANSPORT_SECURITY_OPTIONS = ['tls', 'alts', 'insecure'] + DOCKER_WORKDIR_ROOT = '/var/local/git/grpc' @@ -799,14 +807,22 @@ def cloud_to_cloud_jobspec(language, server_host, server_port, docker_image=None, - insecure=False, + transport_security='tls', manual_cmd_log=None): """Creates jobspec for cloud-to-cloud interop test""" interop_only_options = [ '--server_host_override=foo.test.google.fr', - '--use_tls=%s' % ('false' if insecure else 'true'), '--use_test_ca=true', ] + if transport_security == 'tls': + interop_only_options += ['--use_tls=true'] + elif transport_security == 'alts': + interop_only_options += ['--use_tls=false', '--use_alts=true'] + elif transport_security == 'insecure': + interop_only_options += ['--use_tls=false'] + else: + print('Invalid transport security option.') + sys.exit(1) client_test_case = test_case if test_case in _HTTP2_SERVER_TEST_CASES_THAT_USE_GRPC_CLIENTS: @@ -871,15 +887,24 @@ def cloud_to_cloud_jobspec(language, return test_job -def server_jobspec(language, docker_image, insecure=False, manual_cmd_log=None): +def server_jobspec(language, + docker_image, + transport_security='tls', + manual_cmd_log=None): """Create jobspec for running a server""" container_name = dockerjob.random_name( 'interop_server_%s' % language.safename) - cmdline = bash_cmdline( - language.server_cmd([ - '--port=%s' % _DEFAULT_SERVER_PORT, - '--use_tls=%s' % ('false' if insecure else 'true') - ])) + server_cmd = ['--port=%s' % _DEFAULT_SERVER_PORT] + if transport_security == 'tls': + server_cmd += ['--use_tls=true'] + elif transport_security == 'alts': + server_cmd += ['--use_tls=false', '--use_alts=true'] + elif transport_security == 'insecure': + server_cmd += ['--use_tls=false'] + else: + print('Invalid transport security option.') + sys.exit(1) + cmdline = bash_cmdline(language.server_cmd(server_cmd)) environ = language.global_env() docker_args = ['--name=%s' % container_name] if language.safename == 'http2': @@ -1086,11 +1111,13 @@ argp.add_argument( 'Enable HTTP/2 server edge case testing. (Includes positive and negative tests' ) argp.add_argument( - '--insecure', - default=False, - action='store_const', + '--transport_security', + choices=_TRANSPORT_SECURITY_OPTIONS, + default='tls', + type=str, + nargs='?', const=True, - help='Whether to use secure channel.') + help='Which transport security mechanism to use.') argp.add_argument( '--internal_ci', default=False, @@ -1110,6 +1137,9 @@ 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) if args.use_docker: if not args.travis: @@ -1139,6 +1169,10 @@ 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)) +# 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) + languages = languages.intersection(alts_languages) languages_http2_clients_for_http2_server_interop = set() if args.http2_server_interop: @@ -1207,7 +1241,7 @@ try: spec = server_jobspec( _LANGUAGES[lang], docker_images.get(lang), - args.insecure, + args.transport_security, manual_cmd_log=server_manual_cmd_log) if not args.manual_run: job = dockerjob.DockerJob(spec) @@ -1235,7 +1269,7 @@ try: jobs = [] if args.cloud_to_prod: - if args.insecure: + if args.transport_security != 'tls': print('TLS is always enabled for cloud_to_prod scenarios.') for server_host_name in args.prod_servers: for language in languages: @@ -1263,7 +1297,7 @@ try: jobs.append(test_job) if args.cloud_to_prod_auth: - if args.insecure: + if args.transport_security != 'tls': print('TLS is always enabled for cloud_to_prod scenarios.') for server_host_name in args.prod_servers: for language in languages: @@ -1301,7 +1335,7 @@ try: server_host, server_port, docker_image=docker_images.get(str(language)), - insecure=args.insecure, + transport_security=args.transport_security, manual_cmd_log=client_manual_cmd_log) jobs.append(test_job) @@ -1317,7 +1351,7 @@ try: server_host, server_port, docker_image=docker_images.get(str(http2Interop)), - insecure=args.insecure, + transport_security=args.transport_security, manual_cmd_log=client_manual_cmd_log) jobs.append(test_job) @@ -1353,11 +1387,12 @@ try: server_port = _DEFAULT_SERVER_PORT + offset if not args.manual_run: server_port = http2_server_job.mapped_port(server_port) - if not args.insecure: - print(( - 'Creating grpc cient to http2 server test case with insecure connection, even though' - ' args.insecure is False. Http2 test server only supports insecure connections.' - )) + if args.transport_security != 'insecure': + print( + ('Creating grpc client to http2 server test case ' + 'with insecure connection, even though ' + 'args.transport_security is not insecure. Http2 ' + 'test server only supports insecure connections.')) test_job = cloud_to_cloud_jobspec( language, test_case, @@ -1365,7 +1400,7 @@ try: 'localhost', server_port, docker_image=docker_images.get(str(language)), - insecure=True, + transport_security='insecure', manual_cmd_log=client_manual_cmd_log) jobs.append(test_job) |