[MERGED] openbsc[master]: ctrl_test_runner: speed up more than 10 fold by sleeping less

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Feb 28 18:26:49 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: ctrl_test_runner: speed up more than 10 fold by sleeping less
......................................................................


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
---
M openbsc/tests/ctrl_test_runner.py
1 file changed, 13 insertions(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
index a115488..5030e8b 100644
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -86,9 +86,19 @@
         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
 

-- 
To view, visit https://gerrit.osmocom.org/1926
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I06569767153838bd9cd3edac001df5f6c567874c
Gerrit-PatchSet: 3
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder


More information about the gerrit-log mailing list