Skip to content
Snippets Groups Projects
Commit 48392dc0 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Test-runner: do not attempt to run tests if the port is in use.

Do not try to start another server on a port if it's already in use.
This can lead to very confusing results when running
tests that start and stop the server in parallel.
parent a815a85f
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,15 @@ def wait_until_connected(port):
except socket.error as e:
time.sleep(0.001)
def check_port(port):
"""Check if the port we're connecting to is available"""
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", port))
except socket.error as e:
return
raise RuntimeError("The server is already running on port {0}".format(port))
def prepare_gdb(args):
"""Prepare server startup arguments to run under gdb."""
if "TERM" in os.environ:
......@@ -165,6 +174,7 @@ class Server(object):
version = self.version()
print "Starting {0} {1}.".format(os.path.basename(self.binary),
version)
check_port(self.port)
args = self.prepare_args()
if self.gdb:
args = prepare_gdb(args)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment