Improve failed test diagnostics.

This commit is contained in:
Pavel Minaev 2019-11-18 12:27:26 -08:00 committed by Pavel Minaev
parent 3e29307d65
commit fb6d35ebea
3 changed files with 6 additions and 5 deletions

View file

@ -63,11 +63,11 @@ def wait_until_port_is_listening(port, interval=1, max_attempts=1000):
try:
log.info("Probing localhost:{0} (attempt {1})...", port, i)
sock.connect(("localhost", port))
except socket.error:
except socket.error as exc:
# The first attempt will almost always fail, because the port isn't
# open yet. But if it keeps failing after that, we want to know why.
if i > 1:
log.exception()
log.warning("Failed to connect to localhost:{0}:\n{1}", port, exc)
time.sleep(interval)
else:
log.info("localhost:{0} is listening - server is up!", port)