From 550621c1b57c006fd18ddd0c9c3c589e8a2944ad Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Fri, 11 May 2018 14:20:11 -0700 Subject: [PATCH] Make local DNS server tests more generic --- .../resolver_component_tests_defs.include | 14 ++++++-------- .../resolver_gce_integration_tests_defs.include | 14 +++++++------- test/cpp/naming/gen_build_yaml.py | 17 ++++++++++++----- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/templates/test/cpp/naming/resolver_component_tests_defs.include b/templates/test/cpp/naming/resolver_component_tests_defs.include index 2690af4baa7..bc981dc83e1 100644 --- a/templates/test/cpp/naming/resolver_component_tests_defs.include +++ b/templates/test/cpp/naming/resolver_component_tests_defs.include @@ -113,20 +113,18 @@ wait_until_dns_server_is_up(args, num_test_failures = 0 % for test in tests: -test_runner_log('Run test with target: %s' % '${test['target_name']}')\ +test_runner_log('Run test with target: %s' % '${test['test_title']}')\ current_test_subprocess = subprocess.Popen([\ args.test_bin_path,\ - '--target_name', '${test['target_name']}',\ - - '--expected_addrs', '${test['expected_addrs']}',\ - - '--expected_chosen_service_config', '${test['expected_chosen_service_config']}',\ - - '--expected_lb_policy', '${test['expected_lb_policy']}',\ + % for arg_name_and_value in test['arg_names_and_values']: +\ + '--${arg_name_and_value[0]}', '${arg_name_and_value[1]}',\ +\ + % endfor '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port])\ current_test_subprocess.communicate()\ diff --git a/templates/test/cpp/naming/resolver_gce_integration_tests_defs.include b/templates/test/cpp/naming/resolver_gce_integration_tests_defs.include index 0cb8a1baf31..8a8377e38d1 100644 --- a/templates/test/cpp/naming/resolver_gce_integration_tests_defs.include +++ b/templates/test/cpp/naming/resolver_gce_integration_tests_defs.include @@ -48,15 +48,15 @@ echo "Sanity check PASSED. Run resolver tests:" ONE_FAILED=0 bins/$CONFIG/resolver_component_test \\ - --target_name='${test['target_name']}' \\ + % for arg_name_and_value in test['arg_names_and_values'][0:-1]: +\ + --${arg_name_and_value[0]}='${arg_name_and_value[1]}' \\ - --expected_addrs='${test['expected_addrs']}' \\ - - --expected_chosen_service_config='${test['expected_chosen_service_config']}' \\ - - --expected_lb_policy='${test['expected_lb_policy']}' || ONE_FAILED=1 +\ + % endfor + --${test['arg_names_and_values'][-1][0]}='${test['arg_names_and_values'][-1][1]}' || ONE_FAILED=1 if [[ "$ONE_FAILED" != 0 ]]; then - echo "Test based on target record: ${test['target_name']} FAILED" + echo "Test based on target record: ${test['test_title']} FAILED" EXIT_CODE=1 fi diff --git a/test/cpp/naming/gen_build_yaml.py b/test/cpp/naming/gen_build_yaml.py index adebc620841..493713ff0e7 100755 --- a/test/cpp/naming/gen_build_yaml.py +++ b/test/cpp/naming/gen_build_yaml.py @@ -119,12 +119,19 @@ def _resolver_test_cases(resolver_component_data, records_to_skip): for test_case in resolver_component_data['resolver_component_tests']: if test_case['record_to_resolve'] in records_to_skip: continue + target_name = _append_zone_name( + test_case['record_to_resolve'], + resolver_component_data['resolver_tests_common_zone_name']) out.append({ - 'target_name': _append_zone_name(test_case['record_to_resolve'], - resolver_component_data['resolver_tests_common_zone_name']), - 'expected_addrs': _build_expected_addrs_cmd_arg(test_case['expected_addrs']), - 'expected_chosen_service_config': (test_case['expected_chosen_service_config'] or ''), - 'expected_lb_policy': (test_case['expected_lb_policy'] or ''), + 'test_title': target_name, + 'arg_names_and_values': [ + ('target_name', target_name), + ('expected_addrs', + _build_expected_addrs_cmd_arg(test_case['expected_addrs'])), + ('expected_chosen_service_config', + (test_case['expected_chosen_service_config'] or '')), + ('expected_lb_policy', (test_case['expected_lb_policy'] or '')), + ], }) return out