aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/naming/utils/dns_server.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/naming/utils/dns_server.py')
-rwxr-xr-xtest/cpp/naming/utils/dns_server.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/cpp/naming/utils/dns_server.py b/test/cpp/naming/utils/dns_server.py
index 1e8e2e3287..bf11d14c30 100755
--- a/test/cpp/naming/utils/dns_server.py
+++ b/test/cpp/naming/utils/dns_server.py
@@ -93,6 +93,10 @@ def start_local_dns_server(args):
_push_record(record_full_name, dns.Record_SRV(p, w, port, target_full_name, ttl=r_ttl))
if r_type == 'TXT':
_maybe_split_up_txt_data(record_full_name, r_data, r_ttl)
+ # Add an optional IPv4 record is specified
+ if args.add_a_record:
+ extra_host, extra_host_ipv4 = args.add_a_record.split(':')
+ _push_record(extra_host, dns.Record_A(extra_host_ipv4, ttl=0))
# Server health check record
_push_record(_SERVER_HEALTH_CHECK_RECORD_NAME, dns.Record_A(_SERVER_HEALTH_CHECK_RECORD_DATA, ttl=0))
soa_record = dns.Record_SOA(mname = common_zone_name)
@@ -122,7 +126,7 @@ def flush_stdout_loop():
num_timeouts_so_far = 0
sleep_time = 1
# Prevent zombies. Tests that use this server are short-lived.
- max_timeouts = 60 * 2
+ max_timeouts = 60 * 10
while num_timeouts_so_far < max_timeouts:
sys.stdout.flush()
time.sleep(sleep_time)
@@ -136,7 +140,14 @@ def main():
help='Port for DNS server to listen on for TCP and UDP.')
argp.add_argument('-r', '--records_config_path', default=None, type=str,
help=('Directory of resolver_test_record_groups.yaml file. '
- 'Defauls to path needed when the test is invoked as part of run_tests.py.'))
+ 'Defaults to path needed when the test is invoked as part '
+ 'of run_tests.py.'))
+ argp.add_argument('--add_a_record', default=None, type=str,
+ help=('Add an A record via the command line. Useful for when we '
+ 'need to serve a one-off A record that is under a '
+ 'different domain then the rest the records configured in '
+ '--records_config_path (which all need to be under the '
+ 'same domain). Format: <name>:<ipv4 address>'))
args = argp.parse_args()
signal.signal(signal.SIGTERM, _quit_on_signal)
signal.signal(signal.SIGINT, _quit_on_signal)