diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-02-27 02:01:37 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-02-28 18:26:49 +0000 |
commit | acc6e8323afad3cf7a2661b5c020f81d1dd9b0aa (patch) | |
tree | aa30b8aa4730dd7061a6363bd0c9f031c44f7dc2 /openbsc/tests | |
parent | 534034580c8ed6e0c03dcb488f20f2c526e9848b (diff) |
ctrl_test_runner: speed up more than 10 fold by sleeping less
Similar to a recent patch in osmo-python-tests for VTY based tests, but this is
for the Ctrl tests.
The TestCtrlBase tests gave a constant sleep(2) grace period for the process to
startup. This causes tests to take minutes for no reason at all.
Add code to TestCtrlBase to try and connect right away, retrying up to three
seconds in .1 second intervals. This flies through most tests without any
sleep() at all.
Change-Id: I06569767153838bd9cd3edac001df5f6c567874c
Diffstat (limited to 'openbsc/tests')
-rw-r--r-- | openbsc/tests/ctrl_test_runner.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index a11548823..5030e8b1b 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -86,9 +86,19 @@ class TestCtrlBase(unittest.TestCase): if verbose: print "Connecting to host %s:%i" % (host, port) - sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sck.setblocking(1) - sck.connect((host, port)) + retries = 30 + while True: + try: + sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sck.setblocking(1) + sck.connect((host, port)) + except IOError: + retries -= 1 + if retries <= 0: + raise + time.sleep(.1) + continue + break self.sock = sck return sck |