diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-09-28 23:38:45 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-09-28 23:53:24 +0200 |
commit | caeb62d7ffc6fc0de7101c53a725d12bf3aa4f85 (patch) | |
tree | 5d31c33d9db561b5ee4940c114319740f3fe84ae /openbsc | |
parent | 7e5bb6283dbfe9c44d5be85b2cd04675153c011e (diff) |
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
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/tests/vty_test_runner.py | 27 |
1 files changed, 22 insertions, 5 deletions
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)) |