aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/naming
diff options
context:
space:
mode:
authorGravatar Alexander Polcyn <apolcyn@google.com>2018-05-01 20:52:57 -0700
committerGravatar Alexander Polcyn <apolcyn@google.com>2018-05-01 20:52:57 -0700
commit6f8f914f8d71bd01a3adfe3c4cbc528ff9e4ffab (patch)
tree82a6d6d71a519b0f68b22d38371e9d9edc77ccf9 /test/cpp/naming
parent29fead7d492b3655ea876b1ddcbdf3719a91392d (diff)
cleanup, and get rid of unnecessary timeouts in two places
Diffstat (limited to 'test/cpp/naming')
-rwxr-xr-xtest/cpp/naming/resolver_component_tests_runner.py2
-rwxr-xr-xtest/cpp/naming/utils/dns_resolver.py8
-rwxr-xr-xtest/cpp/naming/utils/dns_server.py9
-rwxr-xr-xtest/cpp/naming/utils/tcp_connect.py14
4 files changed, 5 insertions, 28 deletions
diff --git a/test/cpp/naming/resolver_component_tests_runner.py b/test/cpp/naming/resolver_component_tests_runner.py
index 4bf1701935..69386ebeb0 100755
--- a/test/cpp/naming/resolver_component_tests_runner.py
+++ b/test/cpp/naming/resolver_component_tests_runner.py
@@ -41,7 +41,7 @@ argp.add_argument('--tcp_connect_bin_path', default=None, type=str,
args = argp.parse_args()
def test_runner_log(msg):
- sys.stderr.write('%s: %s\n' % (__file__, msg))
+ sys.stderr.write('\n%s: %s\n' % (__file__, msg))
cur_resolver = os.environ.get('GRPC_DNS_RESOLVER')
if cur_resolver and cur_resolver != 'ares':
diff --git a/test/cpp/naming/utils/dns_resolver.py b/test/cpp/naming/utils/dns_resolver.py
index f0d2f7fe93..74f4ca2351 100755
--- a/test/cpp/naming/utils/dns_resolver.py
+++ b/test/cpp/naming/utils/dns_resolver.py
@@ -22,10 +22,6 @@ import twisted.internet.task as task
import twisted.names.client as client
import twisted.internet.reactor as reactor
-def exit_after_timeout(timeout):
- time.sleep(timeout)
- print('Time limit reached. Forcing exit')
- reactor.stop()
def main():
argp = argparse.ArgumentParser(description='Make DNS queries for A records')
@@ -48,10 +44,6 @@ def main():
deferred_result = resolver.lookupAddress(args.qname)
deferred_result.addCallback(OnResolverResultAvailable)
return deferred_result
- # We can't use sigalarm on windows, so start a thread.
- timeout_thread = threading.Thread(target=exit_after_timeout, args=[args.timeout])
- timeout_thread.setDaemon(True)
- timeout_thread.start()
task.react(BeginQuery, [args.qname])
if __name__ == '__main__':
diff --git a/test/cpp/naming/utils/dns_server.py b/test/cpp/naming/utils/dns_server.py
index d63364a187..1e8e2e3287 100755
--- a/test/cpp/naming/utils/dns_server.py
+++ b/test/cpp/naming/utils/dns_server.py
@@ -112,15 +112,12 @@ def start_local_dns_server(args):
twisted.internet.reactor.suggestThreadPoolSize(1)
twisted.internet.reactor.run()
-def shutdown_process():
+def _quit_on_signal(signum, _frame):
+ print('Received SIGNAL %d. Quitting with exit code 0' % signum)
twisted.internet.reactor.stop()
sys.stdout.flush()
sys.exit(0)
-def _quit_on_signal(signum, _frame):
- print('Received SIGNAL %d. Quitting with exit code 0' % signum)
- shutdown_process()
-
def flush_stdout_loop():
num_timeouts_so_far = 0
sleep_time = 1
@@ -131,7 +128,7 @@ def flush_stdout_loop():
time.sleep(sleep_time)
num_timeouts_so_far += 1
print('Process timeout reached, or cancelled. Exitting 0.')
- shutdown_process()
+ os.kill(os.getpid(), signal.SIGTERM)
def main():
argp = argparse.ArgumentParser(description='Local DNS Server for resolver tests')
diff --git a/test/cpp/naming/utils/tcp_connect.py b/test/cpp/naming/utils/tcp_connect.py
index 15fb0e7ff6..5773c7cae8 100755
--- a/test/cpp/naming/utils/tcp_connect.py
+++ b/test/cpp/naming/utils/tcp_connect.py
@@ -21,12 +21,6 @@ import threading
import time
import sys
-connect_success = False
-
-def try_connect(args):
- socket.create_connection([args.server_host, args.server_port])
- global connect_success
- connect_success = True
def main():
argp = argparse.ArgumentParser(description='Open a TCP handshake to a server')
@@ -37,13 +31,7 @@ def main():
argp.add_argument('-t', '--timeout', default=1, type=int,
help='Force process exit after this number of seconds.')
args = argp.parse_args()
- t = threading.Thread(target=try_connect, args=[args])
- t.setDaemon(True)
- t.start()
- # We can't use sigalarm on windows, so join with a timeout.
- t.join(timeout=args.timeout)
- if t.isAlive() or not connect_success:
- sys.exit(1)
+ socket.create_connection([args.server_host, args.server_port])
if __name__ == '__main__':
main()