summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-02-27 02:01:37 +0100
committerHarald Welte <laforge@gnumonks.org>2017-02-28 18:26:49 +0000
commitacc6e8323afad3cf7a2661b5c020f81d1dd9b0aa (patch)
treeaa30b8aa4730dd7061a6363bd0c9f031c44f7dc2
parent534034580c8ed6e0c03dcb488f20f2c526e9848b (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
-rw-r--r--openbsc/tests/ctrl_test_runner.py16
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