1#!/usr/bin/env python 2# Copyright 2015 gRPC authors. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16# This file is auto-generated 17 18import argparse 19import sys 20import subprocess 21import tempfile 22import os 23import time 24import signal 25import platform 26 27 28argp = argparse.ArgumentParser(description='Run c-ares resolver tests') 29argp.add_argument('--test_bin_path', default=None, type=str, 30 help='Path to gtest test binary to invoke.') 31argp.add_argument('--dns_server_bin_path', default=None, type=str, 32 help='Path to local DNS server python script.') 33argp.add_argument('--records_config_path', default=None, type=str, 34 help=('Path to DNS records yaml file that ' 35 'specifies records for the DNS sever. ')) 36argp.add_argument('--dns_server_port', default=None, type=int, 37 help=('Port that local DNS server is listening on.')) 38argp.add_argument('--dns_resolver_bin_path', default=None, type=str, 39 help=('Path to the DNS health check utility.')) 40argp.add_argument('--tcp_connect_bin_path', default=None, type=str, 41 help=('Path to the TCP health check utility.')) 42args = argp.parse_args() 43 44def test_runner_log(msg): 45 sys.stderr.write('\n%s: %s\n' % (__file__, msg)) 46 47def python_args(arg_list): 48 if platform.system() == 'Windows': 49 return [sys.executable] + arg_list 50 return arg_list 51 52cur_resolver = os.environ.get('GRPC_DNS_RESOLVER') 53if cur_resolver and cur_resolver != 'ares': 54 test_runner_log(('WARNING: cur resolver set to %s. This set of tests ' 55 'needs to use GRPC_DNS_RESOLVER=ares.')) 56 test_runner_log('Exit 1 without running tests.') 57 sys.exit(1) 58os.environ.update({'GRPC_TRACE': 'cares_resolver,cares_address_sorting'}) 59 60def wait_until_dns_server_is_up(args, 61 dns_server_subprocess, 62 dns_server_subprocess_output): 63 for i in range(0, 30): 64 test_runner_log('Health check: attempt to connect to DNS server over TCP.') 65 tcp_connect_subprocess = subprocess.Popen(python_args([ 66 args.tcp_connect_bin_path, 67 '--server_host', '127.0.0.1', 68 '--server_port', str(args.dns_server_port), 69 '--timeout', str(1)])) 70 tcp_connect_subprocess.communicate() 71 if tcp_connect_subprocess.returncode == 0: 72 test_runner_log(('Health check: attempt to make an A-record ' 73 'query to DNS server.')) 74 dns_resolver_subprocess = subprocess.Popen(python_args([ 75 args.dns_resolver_bin_path, 76 '--qname', 'health-check-local-dns-server-is-alive.resolver-tests.grpctestingexp', 77 '--server_host', '127.0.0.1', 78 '--server_port', str(args.dns_server_port)]), 79 stdout=subprocess.PIPE) 80 dns_resolver_stdout, _ = dns_resolver_subprocess.communicate() 81 if dns_resolver_subprocess.returncode == 0: 82 if '123.123.123.123' in dns_resolver_stdout: 83 test_runner_log(('DNS server is up! ' 84 'Successfully reached it over UDP and TCP.')) 85 return 86 time.sleep(0.1) 87 dns_server_subprocess.kill() 88 dns_server_subprocess.wait() 89 test_runner_log(('Failed to reach DNS server over TCP and/or UDP. ' 90 'Exitting without running tests.')) 91 test_runner_log('======= DNS server stdout ' 92 '(merged stdout and stderr) =============') 93 with open(dns_server_subprocess_output, 'r') as l: 94 test_runner_log(l.read()) 95 test_runner_log('======= end DNS server output=========') 96 sys.exit(1) 97 98dns_server_subprocess_output = tempfile.mktemp() 99with open(dns_server_subprocess_output, 'w') as l: 100 dns_server_subprocess = subprocess.Popen(python_args([ 101 args.dns_server_bin_path, 102 '--port', str(args.dns_server_port), 103 '--records_config_path', args.records_config_path]), 104 stdin=subprocess.PIPE, 105 stdout=l, 106 stderr=l) 107 108def _quit_on_signal(signum, _frame): 109 test_runner_log('Received signal: %d' % signum) 110 dns_server_subprocess.kill() 111 dns_server_subprocess.wait() 112 sys.exit(1) 113 114signal.signal(signal.SIGINT, _quit_on_signal) 115signal.signal(signal.SIGTERM, _quit_on_signal) 116wait_until_dns_server_is_up(args, 117 dns_server_subprocess, 118 dns_server_subprocess_output) 119num_test_failures = 0 120 121test_runner_log('Run test with target: %s' % 'no-srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.') 122current_test_subprocess = subprocess.Popen([ 123 args.test_bin_path, 124 '--target_name', 'no-srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.', 125 '--do_ordered_address_comparison', 'False', 126 '--expected_addrs', '5.5.5.5:443,False', 127 '--expected_chosen_service_config', '', 128 '--expected_service_config_error', '', 129 '--expected_lb_policy', '', 130 '--enable_srv_queries', 'True', 131 '--enable_txt_queries', 'True', 132 '--inject_broken_nameserver_list', 'False', 133 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 134current_test_subprocess.communicate() 135if current_test_subprocess.returncode != 0: 136 num_test_failures += 1 137 138test_runner_log('Run test with target: %s' % 'srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.') 139current_test_subprocess = subprocess.Popen([ 140 args.test_bin_path, 141 '--target_name', 'srv-ipv4-single-target.resolver-tests-version-4.grpctestingexp.', 142 '--do_ordered_address_comparison', 'False', 143 '--expected_addrs', '1.2.3.4:1234,True', 144 '--expected_chosen_service_config', '', 145 '--expected_service_config_error', '', 146 '--expected_lb_policy', '', 147 '--enable_srv_queries', 'True', 148 '--enable_txt_queries', 'True', 149 '--inject_broken_nameserver_list', 'False', 150 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 151current_test_subprocess.communicate() 152if current_test_subprocess.returncode != 0: 153 num_test_failures += 1 154 155test_runner_log('Run test with target: %s' % 'srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp.') 156current_test_subprocess = subprocess.Popen([ 157 args.test_bin_path, 158 '--target_name', 'srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp.', 159 '--do_ordered_address_comparison', 'False', 160 '--expected_addrs', '1.2.3.5:1234,True;1.2.3.6:1234,True;1.2.3.7:1234,True', 161 '--expected_chosen_service_config', '', 162 '--expected_service_config_error', '', 163 '--expected_lb_policy', '', 164 '--enable_srv_queries', 'True', 165 '--enable_txt_queries', 'True', 166 '--inject_broken_nameserver_list', 'False', 167 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 168current_test_subprocess.communicate() 169if current_test_subprocess.returncode != 0: 170 num_test_failures += 1 171 172test_runner_log('Run test with target: %s' % 'srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp.') 173current_test_subprocess = subprocess.Popen([ 174 args.test_bin_path, 175 '--target_name', 'srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp.', 176 '--do_ordered_address_comparison', 'False', 177 '--expected_addrs', '[2607:f8b0:400a:801::1001]:1234,True', 178 '--expected_chosen_service_config', '', 179 '--expected_service_config_error', '', 180 '--expected_lb_policy', '', 181 '--enable_srv_queries', 'True', 182 '--enable_txt_queries', 'True', 183 '--inject_broken_nameserver_list', 'False', 184 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 185current_test_subprocess.communicate() 186if current_test_subprocess.returncode != 0: 187 num_test_failures += 1 188 189test_runner_log('Run test with target: %s' % 'srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp.') 190current_test_subprocess = subprocess.Popen([ 191 args.test_bin_path, 192 '--target_name', 'srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp.', 193 '--do_ordered_address_comparison', 'False', 194 '--expected_addrs', '[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1003]:1234,True;[2607:f8b0:400a:801::1004]:1234,True', 195 '--expected_chosen_service_config', '', 196 '--expected_service_config_error', '', 197 '--expected_lb_policy', '', 198 '--enable_srv_queries', 'True', 199 '--enable_txt_queries', 'True', 200 '--inject_broken_nameserver_list', 'False', 201 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 202current_test_subprocess.communicate() 203if current_test_subprocess.returncode != 0: 204 num_test_failures += 1 205 206test_runner_log('Run test with target: %s' % 'srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp.') 207current_test_subprocess = subprocess.Popen([ 208 args.test_bin_path, 209 '--target_name', 'srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp.', 210 '--do_ordered_address_comparison', 'False', 211 '--expected_addrs', '1.2.3.4:1234,True', 212 '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}', 213 '--expected_service_config_error', '', 214 '--expected_lb_policy', 'round_robin', 215 '--enable_srv_queries', 'True', 216 '--enable_txt_queries', 'True', 217 '--inject_broken_nameserver_list', 'False', 218 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 219current_test_subprocess.communicate() 220if current_test_subprocess.returncode != 0: 221 num_test_failures += 1 222 223test_runner_log('Run test with target: %s' % 'ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp.') 224current_test_subprocess = subprocess.Popen([ 225 args.test_bin_path, 226 '--target_name', 'ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp.', 227 '--do_ordered_address_comparison', 'False', 228 '--expected_addrs', '1.2.3.4:443,False', 229 '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService"}],"waitForReady":true}]}', 230 '--expected_service_config_error', '', 231 '--expected_lb_policy', 'round_robin', 232 '--enable_srv_queries', 'True', 233 '--enable_txt_queries', 'True', 234 '--inject_broken_nameserver_list', 'False', 235 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 236current_test_subprocess.communicate() 237if current_test_subprocess.returncode != 0: 238 num_test_failures += 1 239 240test_runner_log('Run test with target: %s' % 'ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp.') 241current_test_subprocess = subprocess.Popen([ 242 args.test_bin_path, 243 '--target_name', 'ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp.', 244 '--do_ordered_address_comparison', 'False', 245 '--expected_addrs', '1.2.3.4:443,False', 246 '--expected_chosen_service_config', '', 247 '--expected_service_config_error', '', 248 '--expected_lb_policy', '', 249 '--enable_srv_queries', 'True', 250 '--enable_txt_queries', 'True', 251 '--inject_broken_nameserver_list', 'False', 252 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 253current_test_subprocess.communicate() 254if current_test_subprocess.returncode != 0: 255 num_test_failures += 1 256 257test_runner_log('Run test with target: %s' % 'ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp.') 258current_test_subprocess = subprocess.Popen([ 259 args.test_bin_path, 260 '--target_name', 'ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp.', 261 '--do_ordered_address_comparison', 'False', 262 '--expected_addrs', '1.2.3.4:443,False', 263 '--expected_chosen_service_config', '', 264 '--expected_service_config_error', '', 265 '--expected_lb_policy', '', 266 '--enable_srv_queries', 'True', 267 '--enable_txt_queries', 'True', 268 '--inject_broken_nameserver_list', 'False', 269 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 270current_test_subprocess.communicate() 271if current_test_subprocess.returncode != 0: 272 num_test_failures += 1 273 274test_runner_log('Run test with target: %s' % 'ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp.') 275current_test_subprocess = subprocess.Popen([ 276 args.test_bin_path, 277 '--target_name', 'ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp.', 278 '--do_ordered_address_comparison', 'False', 279 '--expected_addrs', '1.2.3.4:443,False', 280 '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService"}],"waitForReady":true}]}', 281 '--expected_service_config_error', '', 282 '--expected_lb_policy', 'round_robin', 283 '--enable_srv_queries', 'True', 284 '--enable_txt_queries', 'True', 285 '--inject_broken_nameserver_list', 'False', 286 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 287current_test_subprocess.communicate() 288if current_test_subprocess.returncode != 0: 289 num_test_failures += 1 290 291test_runner_log('Run test with target: %s' % 'ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp.') 292current_test_subprocess = subprocess.Popen([ 293 args.test_bin_path, 294 '--target_name', 'ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp.', 295 '--do_ordered_address_comparison', 'False', 296 '--expected_addrs', '1.2.3.4:443,False', 297 '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService"}],"waitForReady":true}]}', 298 '--expected_service_config_error', '', 299 '--expected_lb_policy', 'round_robin', 300 '--enable_srv_queries', 'True', 301 '--enable_txt_queries', 'True', 302 '--inject_broken_nameserver_list', 'False', 303 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 304current_test_subprocess.communicate() 305if current_test_subprocess.returncode != 0: 306 num_test_failures += 1 307 308test_runner_log('Run test with target: %s' % 'srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.') 309current_test_subprocess = subprocess.Popen([ 310 args.test_bin_path, 311 '--target_name', 'srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.', 312 '--do_ordered_address_comparison', 'False', 313 '--expected_addrs', '1.2.3.4:1234,True;1.2.3.4:443,False', 314 '--expected_chosen_service_config', '', 315 '--expected_service_config_error', '', 316 '--expected_lb_policy', '', 317 '--enable_srv_queries', 'True', 318 '--enable_txt_queries', 'True', 319 '--inject_broken_nameserver_list', 'False', 320 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 321current_test_subprocess.communicate() 322if current_test_subprocess.returncode != 0: 323 num_test_failures += 1 324 325test_runner_log('Run test with target: %s' % 'srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.') 326current_test_subprocess = subprocess.Popen([ 327 args.test_bin_path, 328 '--target_name', 'srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.', 329 '--do_ordered_address_comparison', 'False', 330 '--expected_addrs', '[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1002]:443,False', 331 '--expected_chosen_service_config', '', 332 '--expected_service_config_error', '', 333 '--expected_lb_policy', '', 334 '--enable_srv_queries', 'True', 335 '--enable_txt_queries', 'True', 336 '--inject_broken_nameserver_list', 'False', 337 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 338current_test_subprocess.communicate() 339if current_test_subprocess.returncode != 0: 340 num_test_failures += 1 341 342test_runner_log('Run test with target: %s' % 'ipv4-config-causing-fallback-to-tcp.resolver-tests-version-4.grpctestingexp.') 343current_test_subprocess = subprocess.Popen([ 344 args.test_bin_path, 345 '--target_name', 'ipv4-config-causing-fallback-to-tcp.resolver-tests-version-4.grpctestingexp.', 346 '--do_ordered_address_comparison', 'False', 347 '--expected_addrs', '1.2.3.4:443,False', 348 '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwo","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooThree","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFour","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFive","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSix","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooSeven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEight","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooNine","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTen","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooEleven","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooTwelve","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooThirteen","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFourteen","service":"SimpleService"}],"waitForReady":true},{"name":[{"method":"FooFifteen","service":"SimpleService"}],"waitForReady":true}]}', 349 '--expected_service_config_error', '', 350 '--expected_lb_policy', '', 351 '--enable_srv_queries', 'True', 352 '--enable_txt_queries', 'True', 353 '--inject_broken_nameserver_list', 'False', 354 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 355current_test_subprocess.communicate() 356if current_test_subprocess.returncode != 0: 357 num_test_failures += 1 358 359test_runner_log('Run test with target: %s' % 'srv-ipv4-single-target-srv-disabled.resolver-tests-version-4.grpctestingexp.') 360current_test_subprocess = subprocess.Popen([ 361 args.test_bin_path, 362 '--target_name', 'srv-ipv4-single-target-srv-disabled.resolver-tests-version-4.grpctestingexp.', 363 '--do_ordered_address_comparison', 'False', 364 '--expected_addrs', '2.3.4.5:443,False', 365 '--expected_chosen_service_config', '', 366 '--expected_service_config_error', '', 367 '--expected_lb_policy', '', 368 '--enable_srv_queries', 'False', 369 '--enable_txt_queries', 'True', 370 '--inject_broken_nameserver_list', 'False', 371 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 372current_test_subprocess.communicate() 373if current_test_subprocess.returncode != 0: 374 num_test_failures += 1 375 376test_runner_log('Run test with target: %s' % 'srv-ipv4-multi-target-srv-disabled.resolver-tests-version-4.grpctestingexp.') 377current_test_subprocess = subprocess.Popen([ 378 args.test_bin_path, 379 '--target_name', 'srv-ipv4-multi-target-srv-disabled.resolver-tests-version-4.grpctestingexp.', 380 '--do_ordered_address_comparison', 'False', 381 '--expected_addrs', '9.2.3.5:443,False;9.2.3.6:443,False;9.2.3.7:443,False', 382 '--expected_chosen_service_config', '', 383 '--expected_service_config_error', '', 384 '--expected_lb_policy', '', 385 '--enable_srv_queries', 'False', 386 '--enable_txt_queries', 'True', 387 '--inject_broken_nameserver_list', 'False', 388 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 389current_test_subprocess.communicate() 390if current_test_subprocess.returncode != 0: 391 num_test_failures += 1 392 393test_runner_log('Run test with target: %s' % 'srv-ipv6-single-target-srv-disabled.resolver-tests-version-4.grpctestingexp.') 394current_test_subprocess = subprocess.Popen([ 395 args.test_bin_path, 396 '--target_name', 'srv-ipv6-single-target-srv-disabled.resolver-tests-version-4.grpctestingexp.', 397 '--do_ordered_address_comparison', 'False', 398 '--expected_addrs', '[2600::1001]:443,False', 399 '--expected_chosen_service_config', '', 400 '--expected_service_config_error', '', 401 '--expected_lb_policy', '', 402 '--enable_srv_queries', 'False', 403 '--enable_txt_queries', 'True', 404 '--inject_broken_nameserver_list', 'False', 405 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 406current_test_subprocess.communicate() 407if current_test_subprocess.returncode != 0: 408 num_test_failures += 1 409 410test_runner_log('Run test with target: %s' % 'srv-ipv6-multi-target-srv-disabled.resolver-tests-version-4.grpctestingexp.') 411current_test_subprocess = subprocess.Popen([ 412 args.test_bin_path, 413 '--target_name', 'srv-ipv6-multi-target-srv-disabled.resolver-tests-version-4.grpctestingexp.', 414 '--do_ordered_address_comparison', 'False', 415 '--expected_addrs', '[2600::1002]:443,False;[2600::1003]:443,False;[2600::1004]:443,False', 416 '--expected_chosen_service_config', '', 417 '--expected_service_config_error', '', 418 '--expected_lb_policy', '', 419 '--enable_srv_queries', 'False', 420 '--enable_txt_queries', 'True', 421 '--inject_broken_nameserver_list', 'False', 422 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 423current_test_subprocess.communicate() 424if current_test_subprocess.returncode != 0: 425 num_test_failures += 1 426 427test_runner_log('Run test with target: %s' % 'srv-ipv4-simple-service-config-srv-disabled.resolver-tests-version-4.grpctestingexp.') 428current_test_subprocess = subprocess.Popen([ 429 args.test_bin_path, 430 '--target_name', 'srv-ipv4-simple-service-config-srv-disabled.resolver-tests-version-4.grpctestingexp.', 431 '--do_ordered_address_comparison', 'False', 432 '--expected_addrs', '5.5.3.4:443,False', 433 '--expected_chosen_service_config', '{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService"}],"waitForReady":true}]}', 434 '--expected_service_config_error', '', 435 '--expected_lb_policy', 'round_robin', 436 '--enable_srv_queries', 'False', 437 '--enable_txt_queries', 'True', 438 '--inject_broken_nameserver_list', 'False', 439 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 440current_test_subprocess.communicate() 441if current_test_subprocess.returncode != 0: 442 num_test_failures += 1 443 444test_runner_log('Run test with target: %s' % 'srv-ipv4-simple-service-config-txt-disabled.resolver-tests-version-4.grpctestingexp.') 445current_test_subprocess = subprocess.Popen([ 446 args.test_bin_path, 447 '--target_name', 'srv-ipv4-simple-service-config-txt-disabled.resolver-tests-version-4.grpctestingexp.', 448 '--do_ordered_address_comparison', 'False', 449 '--expected_addrs', '1.2.3.4:1234,True', 450 '--expected_chosen_service_config', '', 451 '--expected_service_config_error', '', 452 '--expected_lb_policy', '', 453 '--enable_srv_queries', 'True', 454 '--enable_txt_queries', 'False', 455 '--inject_broken_nameserver_list', 'False', 456 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 457current_test_subprocess.communicate() 458if current_test_subprocess.returncode != 0: 459 num_test_failures += 1 460 461test_runner_log('Run test with target: %s' % 'ipv4-cpp-config-has-zero-percentage-txt-disabled.resolver-tests-version-4.grpctestingexp.') 462current_test_subprocess = subprocess.Popen([ 463 args.test_bin_path, 464 '--target_name', 'ipv4-cpp-config-has-zero-percentage-txt-disabled.resolver-tests-version-4.grpctestingexp.', 465 '--do_ordered_address_comparison', 'False', 466 '--expected_addrs', '1.2.3.4:443,False', 467 '--expected_chosen_service_config', '', 468 '--expected_service_config_error', '', 469 '--expected_lb_policy', '', 470 '--enable_srv_queries', 'True', 471 '--enable_txt_queries', 'False', 472 '--inject_broken_nameserver_list', 'False', 473 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 474current_test_subprocess.communicate() 475if current_test_subprocess.returncode != 0: 476 num_test_failures += 1 477 478test_runner_log('Run test with target: %s' % 'ipv4-second-language-is-cpp-txt-disabled.resolver-tests-version-4.grpctestingexp.') 479current_test_subprocess = subprocess.Popen([ 480 args.test_bin_path, 481 '--target_name', 'ipv4-second-language-is-cpp-txt-disabled.resolver-tests-version-4.grpctestingexp.', 482 '--do_ordered_address_comparison', 'False', 483 '--expected_addrs', '1.2.3.4:443,False', 484 '--expected_chosen_service_config', '', 485 '--expected_service_config_error', '', 486 '--expected_lb_policy', '', 487 '--enable_srv_queries', 'True', 488 '--enable_txt_queries', 'False', 489 '--inject_broken_nameserver_list', 'False', 490 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 491current_test_subprocess.communicate() 492if current_test_subprocess.returncode != 0: 493 num_test_failures += 1 494 495test_runner_log('Run test with target: %s' % 'ipv4-svc_cfg_bad_json.resolver-tests-version-4.grpctestingexp.') 496current_test_subprocess = subprocess.Popen([ 497 args.test_bin_path, 498 '--target_name', 'ipv4-svc_cfg_bad_json.resolver-tests-version-4.grpctestingexp.', 499 '--do_ordered_address_comparison', 'False', 500 '--expected_addrs', '1.2.3.4:443,False', 501 '--expected_chosen_service_config', '', 502 '--expected_service_config_error', 'JSON parse error', 503 '--expected_lb_policy', '', 504 '--enable_srv_queries', 'True', 505 '--enable_txt_queries', 'True', 506 '--inject_broken_nameserver_list', 'False', 507 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 508current_test_subprocess.communicate() 509if current_test_subprocess.returncode != 0: 510 num_test_failures += 1 511 512test_runner_log('Run test with target: %s' % 'ipv4-svc_cfg_bad_client_language.resolver-tests-version-4.grpctestingexp.') 513current_test_subprocess = subprocess.Popen([ 514 args.test_bin_path, 515 '--target_name', 'ipv4-svc_cfg_bad_client_language.resolver-tests-version-4.grpctestingexp.', 516 '--do_ordered_address_comparison', 'False', 517 '--expected_addrs', '1.2.3.4:443,False', 518 '--expected_chosen_service_config', '', 519 '--expected_service_config_error', 'field:clientLanguage error:should be of type array', 520 '--expected_lb_policy', '', 521 '--enable_srv_queries', 'True', 522 '--enable_txt_queries', 'True', 523 '--inject_broken_nameserver_list', 'False', 524 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 525current_test_subprocess.communicate() 526if current_test_subprocess.returncode != 0: 527 num_test_failures += 1 528 529test_runner_log('Run test with target: %s' % 'ipv4-svc_cfg_bad_percentage.resolver-tests-version-4.grpctestingexp.') 530current_test_subprocess = subprocess.Popen([ 531 args.test_bin_path, 532 '--target_name', 'ipv4-svc_cfg_bad_percentage.resolver-tests-version-4.grpctestingexp.', 533 '--do_ordered_address_comparison', 'False', 534 '--expected_addrs', '1.2.3.4:443,False', 535 '--expected_chosen_service_config', '', 536 '--expected_service_config_error', 'field:percentage error:should be of type number', 537 '--expected_lb_policy', '', 538 '--enable_srv_queries', 'True', 539 '--enable_txt_queries', 'True', 540 '--inject_broken_nameserver_list', 'False', 541 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 542current_test_subprocess.communicate() 543if current_test_subprocess.returncode != 0: 544 num_test_failures += 1 545 546test_runner_log('Run test with target: %s' % 'ipv4-svc_cfg_bad_wait_for_ready.resolver-tests-version-4.grpctestingexp.') 547current_test_subprocess = subprocess.Popen([ 548 args.test_bin_path, 549 '--target_name', 'ipv4-svc_cfg_bad_wait_for_ready.resolver-tests-version-4.grpctestingexp.', 550 '--do_ordered_address_comparison', 'False', 551 '--expected_addrs', '1.2.3.4:443,False', 552 '--expected_chosen_service_config', '', 553 '--expected_service_config_error', 'field:waitForReady error:Type should be true/false', 554 '--expected_lb_policy', '', 555 '--enable_srv_queries', 'True', 556 '--enable_txt_queries', 'True', 557 '--inject_broken_nameserver_list', 'False', 558 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 559current_test_subprocess.communicate() 560if current_test_subprocess.returncode != 0: 561 num_test_failures += 1 562 563test_runner_log('Run test with target: %s' % 'no-srv-ipv4-single-target-inject-broken-nameservers.resolver-tests-version-4.grpctestingexp.') 564current_test_subprocess = subprocess.Popen([ 565 args.test_bin_path, 566 '--target_name', 'no-srv-ipv4-single-target-inject-broken-nameservers.resolver-tests-version-4.grpctestingexp.', 567 '--do_ordered_address_comparison', 'False', 568 '--expected_addrs', '5.5.5.5:443,False', 569 '--expected_chosen_service_config', '', 570 '--expected_service_config_error', '', 571 '--expected_lb_policy', '', 572 '--enable_srv_queries', 'True', 573 '--enable_txt_queries', 'True', 574 '--inject_broken_nameserver_list', 'True', 575 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 576current_test_subprocess.communicate() 577if current_test_subprocess.returncode != 0: 578 num_test_failures += 1 579 580test_runner_log('Run test with target: %s' % 'ipv4-config-causing-fallback-to-tcp-inject-broken-nameservers.resolver-tests-version-4.grpctestingexp.') 581current_test_subprocess = subprocess.Popen([ 582 args.test_bin_path, 583 '--target_name', 'ipv4-config-causing-fallback-to-tcp-inject-broken-nameservers.resolver-tests-version-4.grpctestingexp.', 584 '--do_ordered_address_comparison', 'False', 585 '--expected_addrs', '1.2.3.4:443,False', 586 '--expected_chosen_service_config', '{"loadBalancingPolicy":["round_robin"]}', 587 '--expected_service_config_error', 'field:loadBalancingPolicy error:type should be string', 588 '--expected_lb_policy', '', 589 '--enable_srv_queries', 'True', 590 '--enable_txt_queries', 'True', 591 '--inject_broken_nameserver_list', 'True', 592 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 593current_test_subprocess.communicate() 594if current_test_subprocess.returncode != 0: 595 num_test_failures += 1 596 597test_runner_log('Run test with target: %s' % 'load-balanced-name-with-dualstack-balancer.resolver-tests-version-4.grpctestingexp.') 598current_test_subprocess = subprocess.Popen([ 599 args.test_bin_path, 600 '--target_name', 'load-balanced-name-with-dualstack-balancer.resolver-tests-version-4.grpctestingexp.', 601 '--do_ordered_address_comparison', 'True', 602 '--expected_addrs', '[::1]:1234,True;[2002::1111]:1234,True', 603 '--expected_chosen_service_config', '', 604 '--expected_service_config_error', '', 605 '--expected_lb_policy', '', 606 '--enable_srv_queries', 'True', 607 '--enable_txt_queries', 'True', 608 '--inject_broken_nameserver_list', 'False', 609 '--local_dns_server_address', '127.0.0.1:%d' % args.dns_server_port]) 610current_test_subprocess.communicate() 611if current_test_subprocess.returncode != 0: 612 num_test_failures += 1 613 614test_runner_log('now kill DNS server') 615dns_server_subprocess.kill() 616dns_server_subprocess.wait() 617test_runner_log('%d tests failed.' % num_test_failures) 618sys.exit(num_test_failures) 619