Change in osmo-gsm-tester[master]: virtual: Make mass tests be able to activate themselves

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun May 12 10:36:01 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13827 )

Change subject: virtual: Make mass tests be able to activate themselves
......................................................................

virtual: Make mass tests be able to activate themselves

We will need to enable/disable generation of lua script code
depending on the subscriber and mass test.

Change-Id: Ide4d788543d910356efe9f61e789b3975f7bc558
---
M src/osmo_gsm_tester/ms_driver.py
M src/osmo_ms_driver/__main__.py
M src/osmo_ms_driver/location_update_test.py
M src/osmo_ms_driver/starter.py
M src/osmo_ms_driver/test_support.py
5 files changed, 42 insertions(+), 18 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/src/osmo_gsm_tester/ms_driver.py b/src/osmo_gsm_tester/ms_driver.py
index 0b2bd98..f1334fc 100644
--- a/src/osmo_gsm_tester/ms_driver.py
+++ b/src/osmo_gsm_tester/ms_driver.py
@@ -122,7 +122,8 @@
         for sub in self._subscribers:
             self._starter.subscriber_add(sub)
 
-        self._executor.configure(len(self._subscribers))
+        self._starter.configure_tasks()
+        self._executor.configure(self._subscribers, self._starter.mobiles())
         self._configured = True
 
     def run_test(self):
diff --git a/src/osmo_ms_driver/__main__.py b/src/osmo_ms_driver/__main__.py
index c3da49d..a752c37 100644
--- a/src/osmo_ms_driver/__main__.py
+++ b/src/osmo_ms_driver/__main__.py
@@ -98,8 +98,10 @@
             'imsi': imsi,
             'ki': ki,
             'auth_algo': 'comp128v1',
+            'run_lu_test': False,
         }
         starter.subscriber_add(ms_osmo_mobile.MSOsmoMobile("ms_%d" % i, conf))
+    starter.configure_tasks()
     test.configure(args.num_ms)
 
     atexit.register(starter.stop_all)
diff --git a/src/osmo_ms_driver/location_update_test.py b/src/osmo_ms_driver/location_update_test.py
index 1a33f09..d0d572d 100644
--- a/src/osmo_ms_driver/location_update_test.py
+++ b/src/osmo_ms_driver/location_update_test.py
@@ -60,9 +60,13 @@
         super().__init__(name, event_server, results)
         self._event_server.register(self.handle_msg)
 
-    def configure(self, num_subscribers):
-        self._num_subscribers = num_subscribers
-        self._outstanding = num_subscribers
+    def configure(self, subscribers, mobiles):
+        # Enable the LU test script in each mobile
+        for mobile in mobiles:
+            mobile.set_cfg_item('run_lu_test', True)
+
+        self._num_subscribers = len(subscribers)
+        self._outstanding = self._num_subscribers
 
     def handle_msg(self, _data, addr, time):
         data = json.loads(_data.decode())
diff --git a/src/osmo_ms_driver/starter.py b/src/osmo_ms_driver/starter.py
index 61d3bb0..2ae423d 100644
--- a/src/osmo_ms_driver/starter.py
+++ b/src/osmo_ms_driver/starter.py
@@ -85,23 +85,32 @@
         self._ki = subscriber.ki()
         self._omob_proc = None
 
+        lua_support = os.path.join(os.path.dirname(__file__), 'lua')
+        self._cfg = {
+            'test': {
+                'event_path': self._ev_server_path,
+                'lua_support': lua_support,
+            }
+        }
+
     def imsi(self):
         return self._imsi
 
     def ki(self):
         return self._ki
 
+    def set_cfg_item(self, key, value):
+        """
+        Sets `key` to `value` inside the test dictionary.
+
+        Used by testcases to pass per MS settings into the lua script
+        generator.
+        """
+        self._cfg['test'][key] = value
+
     def write_lua_cfg(self):
-        lua_support = os.path.join(os.path.dirname(__file__), 'lua')
-        cfg = {
-            'test': {
-                'event_path': self._ev_server_path,
-                'lua_support': lua_support,
-                'run_lu_test': True,
-            }
-        }
         lua_cfg_file = os.path.join(self._tmp_dir, "lua_" + self._name_number + ".lua")
-        lua_script = template.render(self._lua_template, cfg)
+        lua_script = template.render(self._lua_template, self._cfg)
         with open(lua_cfg_file, 'w') as w:
             w.write(lua_script)
         return lua_cfg_file
@@ -220,7 +229,6 @@
     def prepare(self, loop):
         self.log("Starting testcase")
 
-        self.configure_tasks()
         self.pre_launch(loop)
 
         self._start_time = time.clock_gettime(time.CLOCK_MONOTONIC)
@@ -296,3 +304,7 @@
             ms.set_start_time(time)
             launch_delay = ms.start_time() - ms.launch_time()
             self.log("MS start registered ", ms=ms, at=time, delay=launch_delay)
+
+    def mobiles(self):
+        """Returns the list of mobiles configured."""
+        return self._mobiles
diff --git a/src/osmo_ms_driver/test_support.py b/src/osmo_ms_driver/test_support.py
index f7910dd..ce3f5f1 100644
--- a/src/osmo_ms_driver/test_support.py
+++ b/src/osmo_ms_driver/test_support.py
@@ -76,8 +76,13 @@
         self._event_server = event_server
         self._results = results
 
-    def configure(self, num_subscribers):
-        """Configures the test given the (number) of subscribers."""
+    def configure(self, subscribers, mobiles):
+        """
+        Configures the test given the subscribers.
+
+        The subscriber at index _i_ belongs to the mobile at the
+        same index. subscribers[i] == mobiles[i].subscriber().
+        """
         pass
 
     def before_start(self):
@@ -107,9 +112,9 @@
     def add_test(self, test):
         self._tests.append(test)
 
-    def configure(self, num_subscriber):
+    def configure(self, subscribers, mobiles):
         for test in self._tests:
-            test.configure(num_subscriber)
+            test.configure(subscribers, mobiles)
 
     def before_start(self):
         for test in self._tests:

-- 
To view, visit https://gerrit.osmocom.org/13827
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ide4d788543d910356efe9f61e789b3975f7bc558
Gerrit-Change-Number: 13827
Gerrit-PatchSet: 7
Gerrit-Owner: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190512/2cf5838f/attachment.htm>


More information about the gerrit-log mailing list