[PATCH] openbsc[master]: vty_test_runner.py: fix nat_msc_test(): socket attach: reduc...

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.org
Wed Sep 28 21:55:55 UTC 2016


vty_test_runner.py: fix nat_msc_test(): socket attach: reduce timeout, retry

In nat_msc_test(), upon socket timeout, retry up to six times. Reduce the
timeout between retries. This should get rid of sporadic test failures that
we've been seeing a lot on jenkins lately.

Raise an exception upon unexpected vty response.

Print more detail to stdout. Since we would actually want as much output as we
can get in a test suite, remove the 'if (verbose)' and just always print the
connection source. unittest is keeping all stdout silent by default anyway.

Change-Id: I2f83eef55592778e54164a90e1eabeb80fb918da
---
M openbsc/tests/vty_test_runner.py
1 file changed, 22 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/70/970/2

diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index f624fc9..5bb27a8 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -1228,16 +1228,33 @@
 
 def nat_msc_test(x, ip, port, verbose = False):
     msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-    msc.settimeout(32)
+    msc.settimeout(5)
     msc.bind((ip, port))
     msc.listen(5)
     if (verbose):
         print "MSC is ready at " + ip
     conn = None
-    while "MSC is connected: 0" == x.vty.command("show msc connection"):
-        conn, addr = msc.accept()
-        if (verbose):
-            print "MSC got connection from ", addr
+    while True:
+        vty_response = x.vty.command("show msc connection")
+        print "'show msc connection' says: %r" % vty_response
+        if vty_response == "MSC is connected: 1":
+            # success
+            break;
+        if vty_response != "MSC is connected: 0":
+            raise Exception("Unexpected response to 'show msc connection'"
+                            " vty command: %r" % vty_response)
+
+        timeout_retries = 6
+        while timeout_retries > 0:
+            try:
+                conn, addr = msc.accept()
+                print "MSC got connection from ", addr
+                break
+            except socket.timeout:
+                print "socket timed out."
+                timeout_retries -= 1
+                continue
+
     if not conn:
 	raise Exception("VTY reports MSC is connected, but I haven't"
 			" connected yet: %r %r" % (ip, port))

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I2f83eef55592778e54164a90e1eabeb80fb918da
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list