This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has submitted this change and it was merged. Change subject: speed up python tests more than 10 fold by sleeping less ...................................................................... speed up python tests more than 10 fold by sleeping less The VTYInteract tests gave a constant sleep(1) grace period for the process to startup. This caused the test to take minutes for no reason at all. Add code to VTYInteract._connect_socket() 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. When TCP socket debugging is switched on, also print how many connection tries it took to connect the VTY socket. Note that the openbsc python tests also add some sleep()s that also need to be removed to benefit from this. Change-Id: Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39 --- M osmopy/obscvty.py M osmopy/osmodumpdoc.py M osmopy/osmotestconfig.py M osmopy/osmotestvty.py 4 files changed, 22 insertions(+), 8 deletions(-) Approvals: Holger Freyther: Looks good to me, approved diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py index 857d75b..f1f1c59 100755 --- a/osmopy/obscvty.py +++ b/osmopy/obscvty.py @@ -20,6 +20,7 @@ import socket import sys, subprocess import os +import time """VTYInteract: interact with an osmocom vty @@ -71,13 +72,29 @@ def _connect_socket(self): if self.socket is not None: return - self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.socket.setblocking(1) - self.socket.connect((self.host, self.port)) + retries = 30 + took = 0 + while True: + took += 1 + try: + self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.socket.setblocking(1) + self.socket.connect((self.host, self.port)) + except IOError: + retries -= 1 + if retries <= 0: + raise + # possibly the binary hasn't launched yet + if debug_tcp_sockets: + print "Connecting socket failed, retrying..." + time.sleep(.1) + continue + break + if debug_tcp_sockets: VTYInteract.all_sockets.append(self.socket) - print "Socket: connected to %s:%d %r (%d sockets open)" % ( - self.host, self.port, self.socket, + print "Socket: in %d tries, connected to %s:%d %r (%d sockets open)" % ( + took, self.host, self.port, self.socket, len(VTYInteract.all_sockets)) self.socket.recv(4096) diff --git a/osmopy/osmodumpdoc.py b/osmopy/osmodumpdoc.py index d9d52b5..0ff1f6b 100644 --- a/osmopy/osmodumpdoc.py +++ b/osmopy/osmodumpdoc.py @@ -48,7 +48,6 @@ print >> sys.stderr, "Skipping app %s" % appname failures += 1 else: - time.sleep(1) try: dump_doc(app[2], app[0], 'doc/%s_vty_reference.xml' % appname) successes += 1 diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index 0d2b2d9..7b8ad66 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -55,7 +55,6 @@ print "Verifying %s, test %s" % (' '.join(cmd), run_test.__name__) proc = osmoutil.popen_devnull(cmd) - time.sleep(1) end = app_desc[2] port = app_desc[0] vty = obscvty.VTYInteract(end, "127.0.0.1", port) diff --git a/osmopy/osmotestvty.py b/osmopy/osmotestvty.py index 9f8dd0a..e513c05 100644 --- a/osmopy/osmotestvty.py +++ b/osmopy/osmotestvty.py @@ -41,7 +41,6 @@ except OSError: print >> sys.stderr, "Current directory: %s" % os.getcwd() print >> sys.stderr, "Consider setting -b" - time.sleep(1) appstring = osmoappdesc.vty_app[2] appport = osmoappdesc.vty_app[0] -- To view, visit https://gerrit.osmocom.org/1924 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39 Gerrit-PatchSet: 2 Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Holger Freyther <holger at freyther.de> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>