From caeb62d7ffc6fc0de7101c53a725d12bf3aa4f85 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 28 Sep 2016 23:38:45 +0200 Subject: 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 --- openbsc/tests/vty_test_runner.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'openbsc/tests/vty_test_runner.py') diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index f624fc96d..5bb27a8ad 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -1228,16 +1228,33 @@ def data2str(d): 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)) -- cgit v1.2.3