[PATCH] openbsc[master]: vty tests: testBSCreload: randomize port for msc

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
Mon Sep 26 01:20:35 UTC 2016


vty tests: testBSCreload: randomize port for msc

The build server often hits below timeout by random, so let's give it random
ports and three retries:

ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 782, in testBSCreload
    msc = nat_msc_test(self, ip, port)
  File "./vty_test_runner.py", line 1237, in nat_msc_test
    conn, addr = msc.accept()
  File "/usr/lib/python2.7/socket.py", line 202, in accept
    sock, addr = self._sock.accept()
timeout: timed out

Change-Id: I8e1023f6ddd913f95402bb4afb8d02dccda17533
---
M openbsc/tests/vty_test_runner.py
1 file changed, 17 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/45/945/2

diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 00eae70..eecb5bf 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -19,6 +19,7 @@
 import time
 import unittest
 import socket
+import random
 
 import osmopy.obscvty as obscvty
 import osmopy.osmoutil as osmoutil
@@ -752,10 +753,6 @@
         return (4244, "src/osmo-bsc_nat/osmo-bsc_nat",  "OsmoBSCNAT", "nat")
 
     def testBSCreload(self):
-        # Use different port for the mock msc to avoid clashing with
-        # the osmo-bsc_nat itself
-        ip = "127.0.0.1"
-        port = 5522
         self.vty.enable()
         bscs1 = self.vty.command("show bscs-config")
         nat_bsc_reload(self)
@@ -778,8 +775,22 @@
         self.vty.command("token xyu")
         self.vty.command("end")
 
-        nat_msc_ip(self, ip, port)
-        msc = nat_msc_test(self, ip, port)
+        # Choose a random port for the mock msc to avoid clashing with the
+        # osmo-bsc_nat itself, and to reduce the chance of two test runs
+        # clashing on the build server.
+        timeout_retries = 3
+        ip = "127.0.0.1"
+        while True:
+            port = random.randrange(32768, 65535)
+            try:
+                nat_msc_ip(self, ip, port)
+                msc = nat_msc_test(self, ip, port)
+                break
+            except socket.timeout:
+                timeout_retries -= 1
+                if timeout_retries < 1:
+                    raise
+
         b0 = nat_bsc_sock_test(0, "lol")
         b1 = nat_bsc_sock_test(1, "xyu")
         b2 = nat_bsc_sock_test(5, "key")

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

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



More information about the gerrit-log mailing list