Make c-ares resolver unit tests runnable under python3

pull/25012/head
Alexander Polcyn 4 years ago
parent 9e58d0645b
commit 408a02379d
  1. 4
      templates/test/cpp/naming/resolver_component_tests_defs.include
  2. 4
      test/cpp/naming/resolver_component_tests_runner.py
  3. 10
      test/cpp/naming/utils/dns_server.py

@ -77,9 +77,9 @@ def wait_until_dns_server_is_up(args,
'--server_host', '127.0.0.1',
'--server_port', str(args.dns_server_port)]),
stdout=subprocess.PIPE)
dns_resolver_stdout, _ = dns_resolver_subprocess.communicate()
dns_resolver_stdout, _ = dns_resolver_subprocess.communicate(str.encode('ascii'))
if dns_resolver_subprocess.returncode == 0:
if '123.123.123.123' in dns_resolver_stdout:
if bytes('123.123.123.123'.encode('ascii')) in dns_resolver_stdout:
test_runner_log(('DNS server is up! '
'Successfully reached it over UDP and TCP.'))
return

@ -77,9 +77,9 @@ def wait_until_dns_server_is_up(args,
'--server_host', '127.0.0.1',
'--server_port', str(args.dns_server_port)]),
stdout=subprocess.PIPE)
dns_resolver_stdout, _ = dns_resolver_subprocess.communicate()
dns_resolver_stdout, _ = dns_resolver_subprocess.communicate(str.encode('ascii'))
if dns_resolver_subprocess.returncode == 0:
if '123.123.123.123' in dns_resolver_stdout:
if bytes('123.123.123.123'.encode('ascii')) in dns_resolver_stdout:
test_runner_log(('DNS server is up! '
'Successfully reached it over UDP and TCP.'))
return

@ -53,6 +53,7 @@ def start_local_dns_server(args):
all_records = {}
def _push_record(name, r):
name = bytes(name.encode('ascii'))
print('pushing record: |%s|' % name)
if all_records.get(name) is not None:
all_records[name].append(r)
@ -60,6 +61,7 @@ def start_local_dns_server(args):
all_records[name] = [r]
def _maybe_split_up_txt_data(name, txt_data, r_ttl):
txt_data = bytes(txt_data.encode('ascii'))
start = 0
txt_data_list = []
while len(txt_data[start:]) > 0:
@ -93,8 +95,8 @@ def start_local_dns_server(args):
p = int(p)
w = int(w)
port = int(port)
target_full_name = '%s.%s' % (target, common_zone_name)
r_data = '%s %s %s %s' % (p, w, port, target_full_name)
target_full_name = bytes(
('%s.%s' % (target, common_zone_name)).encode('ascii'))
_push_record(
record_full_name,
dns.Record_SRV(p, w, port, target_full_name, ttl=r_ttl))
@ -107,9 +109,9 @@ def start_local_dns_server(args):
# 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)
soa_record = dns.Record_SOA(mname=bytes(common_zone_name.encode('ascii')))
test_domain_com = NoFileAuthority(
soa=(common_zone_name, soa_record),
soa=(bytes(common_zone_name.encode('ascii')), soa_record),
records=all_records,
)
server = twisted.names.server.DNSServerFactory(

Loading…
Cancel
Save