From cb9f356a69b2479d20645c36d0a94e84588f248c Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 29 Nov 2017 15:22:45 +0100 Subject: [PATCH] wait for proxy to exit in test_external_proxy .terminate() only sends the signal, it doesn't wait for the process to exit. If the process doesn't exit promptly, the next instance may try to grab the port before the previous process has released it, causing failure with EADDRINUSE. --- jupyterhub/tests/test_proxy.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jupyterhub/tests/test_proxy.py b/jupyterhub/tests/test_proxy.py index 4cf6b5a2..e8cbfa92 100644 --- a/jupyterhub/tests/test_proxy.py +++ b/jupyterhub/tests/test_proxy.py @@ -66,6 +66,7 @@ def test_external_proxy(request): def _cleanup_proxy(): if proxy.poll() is None: proxy.terminate() + proxy.wait(timeout=10) request.addfinalizer(_cleanup_proxy) def wait_for_proxy(): @@ -95,16 +96,17 @@ def test_external_proxy(request): host = '%s.%s' % (name, urlparse(app.subdomain_host).hostname) user_spec = host + user_path assert sorted(routes.keys()) == ['/', user_spec] - + # teardown the proxy and start a new one in the same place proxy.terminate() + proxy.wait(timeout=10) proxy = Popen(cmd, env=env) yield wait_for_proxy() routes = yield app.proxy.get_all_routes() assert list(routes.keys()) == [] - + # poke the server to update the proxy r = yield api_request(app, 'proxy', method='post') r.raise_for_status() @@ -115,6 +117,7 @@ def test_external_proxy(request): # teardown the proxy, and start a new one with different auth and port proxy.terminate() + proxy.wait(timeout=10) new_auth_token = 'different!' env['CONFIGPROXY_AUTH_TOKEN'] = new_auth_token proxy_port = 55432