From a39479ac2763815a93ee2649f26cd74855bb1c9f Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Thu, 2 Apr 2020 17:09:35 -0700 Subject: [PATCH 1/2] Add --bootstrap_file to run_xds_tests.py This allows using an external bootstrap generator. --- tools/run_tests/run_xds_tests.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tools/run_tests/run_xds_tests.py b/tools/run_tests/run_xds_tests.py index c770f17d735..7fd0cfcc693 100755 --- a/tools/run_tests/run_xds_tests.py +++ b/tools/run_tests/run_xds_tests.py @@ -86,12 +86,17 @@ argp.add_argument( type=parse_test_cases, help='Comma-separated list of test cases to run, or \'all\' to run every ' 'test. Available tests: %s' % ' '.join(_TEST_CASES)) +argp.add_argument( + '--bootstrap_file', + default='', + help='File to reference via GRPC_XDS_BOOTSTRAP. Disables built-in ' + 'bootstrap generation') argp.add_argument( '--client_cmd', default=None, - help='Command to launch xDS test client. This script will fill in ' - '{server_uri}, {stats_port} and {qps} parameters using str.format(), and ' - 'generate the GRPC_XDS_BOOTSTRAP file.') + help='Command to launch xDS test client. {server_uri}, {stats_port} and ' + '{qps} references will be replaced using str.format(). GRPC_XDS_BOOTSTRAP ' + 'will be set for the command') argp.add_argument('--zone', default='us-central1-a') argp.add_argument('--secondary_zone', default='us-west1-b', @@ -1085,11 +1090,14 @@ try: server_uri = service_host_name else: server_uri = service_host_name + ':' + str(gcp.service_port) - with tempfile.NamedTemporaryFile(delete=False) as bootstrap_file: - bootstrap_file.write( - _BOOTSTRAP_TEMPLATE.format( - node_id=socket.gethostname()).encode('utf-8')) - bootstrap_path = bootstrap_file.name + if args.bootstrap_file: + bootstrap_path = os.path.abspath(args.bootstrap_file) + else: + with tempfile.NamedTemporaryFile(delete=False) as bootstrap_file: + bootstrap_file.write( + _BOOTSTRAP_TEMPLATE.format( + node_id=socket.gethostname()).encode('utf-8')) + bootstrap_path = bootstrap_file.name client_env = dict(os.environ, GRPC_XDS_BOOTSTRAP=bootstrap_path) client_cmd = shlex.split( args.client_cmd.format(server_uri=server_uri, From 2ac5fde78aa3e56ba05af81c79b87faca78f611b Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Fri, 3 Apr 2020 09:43:37 -0700 Subject: [PATCH 2/2] Fix indentation --- tools/run_tests/run_xds_tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/run_tests/run_xds_tests.py b/tools/run_tests/run_xds_tests.py index 7fd0cfcc693..b9d662aaa0c 100755 --- a/tools/run_tests/run_xds_tests.py +++ b/tools/run_tests/run_xds_tests.py @@ -1091,13 +1091,13 @@ try: else: server_uri = service_host_name + ':' + str(gcp.service_port) if args.bootstrap_file: - bootstrap_path = os.path.abspath(args.bootstrap_file) + bootstrap_path = os.path.abspath(args.bootstrap_file) else: - with tempfile.NamedTemporaryFile(delete=False) as bootstrap_file: - bootstrap_file.write( - _BOOTSTRAP_TEMPLATE.format( - node_id=socket.gethostname()).encode('utf-8')) - bootstrap_path = bootstrap_file.name + with tempfile.NamedTemporaryFile(delete=False) as bootstrap_file: + bootstrap_file.write( + _BOOTSTRAP_TEMPLATE.format( + node_id=socket.gethostname()).encode('utf-8')) + bootstrap_path = bootstrap_file.name client_env = dict(os.environ, GRPC_XDS_BOOTSTRAP=bootstrap_path) client_cmd = shlex.split( args.client_cmd.format(server_uri=server_uri,