aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2019-04-30 22:03:12 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2019-04-30 22:53:06 +0100
commit04b20836eec07e61fbed64550b9728a859f6822a (patch)
treed2255dd5b578de29956713c38fb08d57dc6f4ca3
parent630d034fcf1ee43711c3ad82c236200dea2f7b7a (diff)
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
-rw-r--r--src/osmo_gsm_tester/ms_driver.py3
-rw-r--r--src/osmo_ms_driver/__main__.py1
-rw-r--r--src/osmo_ms_driver/location_update_test.py10
-rw-r--r--src/osmo_ms_driver/starter.py32
-rw-r--r--src/osmo_ms_driver/test_support.py13
5 files changed, 41 insertions, 18 deletions
diff --git a/src/osmo_gsm_tester/ms_driver.py b/src/osmo_gsm_tester/ms_driver.py
index 355a03e..1974920 100644
--- a/src/osmo_gsm_tester/ms_driver.py
+++ b/src/osmo_gsm_tester/ms_driver.py
@@ -122,7 +122,8 @@ class MsDriver(log.Origin):
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..30332d5 100644
--- a/src/osmo_ms_driver/__main__.py
+++ b/src/osmo_ms_driver/__main__.py
@@ -100,6 +100,7 @@ def main():
'auth_algo': 'comp128v1',
}
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 @@ class MassUpdateLocationTest(TestBase):
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 @@ class OsmoMobile(Launcher):
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 @@ class MobileTestStarter(log.Origin):
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 @@ class MobileTestStarter(log.Origin):
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 @@ class TestBase(log.Origin, metaclass=ABCMeta):
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 @@ class TestExecutor(log.Origin):
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: