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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Feb 27 01:15:12 UTC 2017


Review at  https://gerrit.osmocom.org/1926

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(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/26/1926/1

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: newchange
Gerrit-Change-Id: I06569767153838bd9cd3edac001df5f6c567874c
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list