[PATCH] osmo-gsm-tester[master]: WIP.. use gerrit as backup

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

Holger Freyther gerrit-no-reply at lists.osmocom.org
Wed Jan 31 23:16:59 UTC 2018


Review at  https://gerrit.osmocom.org/6233

WIP.. use gerrit as backup

Change-Id: Ifff16c72e301236636f80de44a8564f772966ab7
---
A src/osmo_ms_driver/README
A src/osmo_ms_driver/__main__.py
M src/osmo_ms_driver/cdf.py
A src/osmo_ms_driver/event_server.py
A src/osmo_ms_driver/server.py
A src/osmo_ms_driver/starter.py
A src/osmo_ms_driver/ul_test.py
7 files changed, 230 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/33/6233/1

diff --git a/src/osmo_ms_driver/README b/src/osmo_ms_driver/README
new file mode 100644
index 0000000..0b3a010
--- /dev/null
+++ b/src/osmo_ms_driver/README
@@ -0,0 +1,6 @@
+
+* Test. E.g. LU test
+  * Test lua script repeated n-times
+  * Success criteria definition
+  * Event handling
+
diff --git a/src/osmo_ms_driver/__main__.py b/src/osmo_ms_driver/__main__.py
new file mode 100644
index 0000000..e6bc45f
--- /dev/null
+++ b/src/osmo_ms_driver/__main__.py
@@ -0,0 +1,60 @@
+# osmo_ms_driver: Main test runner
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Local modules
+from .event_server import EventServer
+from .ul_test import MassUpdateLocationTest
+from .cdf import ease_in_out_duration
+
+# System modules
+import datetime
+import asyncio
+
+
+# TODO: Parse parameters and test composition. Right now we test
+# with a single set of values.
+
+num_ms = 10
+
+# How long should starting all apps take
+time_start=datetime.timedelta(seconds=60)
+# In which steps to start processes
+time_step=datetime.timedelta(milliseconds=100)
+# Event server path
+event_server_path="osmo_ms_driver.unix"
+
+
+# The function that decides when to start something
+cdf = ease_in_out_duration(time_start, time_step)
+
+ev_loop = asyncio.get_event_loop()
+
+# Event server to handle MS->test events
+ev_server = EventServer("ev_server", event_server_path)
+ev_server.listen(ev_loop)
+
+# Just a single test for now.
+test = MassUpdateLocationTest("lu_test", num_ms, cdf, ev_server)
+
+# Run until everything has been launched
+ev_loop.run_until_complete(test.run(ev_loop))
+
+# Wait for it to complete
+ev_loop.run_until_complete(test.complete())
+test.stop_all()
+
+# TODO: do the analysis
diff --git a/src/osmo_ms_driver/cdf.py b/src/osmo_ms_driver/cdf.py
index e84d9c7..8aa06e9 100644
--- a/src/osmo_ms_driver/cdf.py
+++ b/src/osmo_ms_driver/cdf.py
@@ -19,8 +19,6 @@
 
 from datetime import timedelta
 
-import math
-
 class DistributionFunctionHandler(object):
     """
     The goal is to start n "mobile" processes. We like to see some
@@ -39,6 +37,9 @@
         self._y = self._fun(self._x)
         self._target = 1.0
 
+    def step_size(self):
+        return self._step
+
     def set_target(self, scale):
         """
         Scale the percentage to the target value..
diff --git a/src/osmo_ms_driver/event_server.py b/src/osmo_ms_driver/event_server.py
new file mode 100644
index 0000000..41aa94d
--- /dev/null
+++ b/src/osmo_ms_driver/event_server.py
@@ -0,0 +1,31 @@
+
+import socket
+import os
+
+from osmo_gsm_tester import log
+
+import asyncio
+
+class MSConnection(asyncio.Protocol, log.Origin):
+    def __init__(self):
+        super().__init__(log.C_RUN, "MSConnection")
+
+    def connection_made(self, transport):
+        # TODO: Update the name once we know the MS.
+        pass
+
+    def data_received(self, read):
+        # TODO: Update the name once we know the MS.
+        pass
+
+class EventServer(log.Origin):
+    def __init__(self, name, path):
+        super().__init__(log.C_RUN, name)
+        self._path = path
+        self._handlers = []
+
+    def register(self, cb):
+        self._handlers.append(cb)
+
+    def listen(self, loop):
+        self._server = loop.create_unix_server(lambda: MSConnection(self), self._path)
diff --git a/src/osmo_ms_driver/server.py b/src/osmo_ms_driver/server.py
new file mode 100644
index 0000000..7486d20
--- /dev/null
+++ b/src/osmo_ms_driver/server.py
@@ -0,0 +1,3 @@
+# WIP...
+
+import asyncio
diff --git a/src/osmo_ms_driver/starter.py b/src/osmo_ms_driver/starter.py
new file mode 100644
index 0000000..28b2cc8
--- /dev/null
+++ b/src/osmo_ms_driver/starter.py
@@ -0,0 +1,48 @@
+# osmo_ms_driver: Starter for processes
+# Help to start processes over time.
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from osmo_gsm_tester import log, template, process
+
+import asyncio
+
+class Launcher(log.Origin):
+    """
+    I launch an OsmocomBB mobile and the virtphy. In the future we
+    might want to test with real phones and then don't launch the
+    virtphy. This needs to be handled once we move to bare iron.
+
+    >>> Launcher("osmo-ms/0000", "mobile", "mobile.tmpl", {})
+    osmo-ms/0000
+    """
+    def __init__(self, name, lua_tmpl, cfg_tmpl, options):
+        super().__init__(log.C_RUN, name)
+        self._lua_template = lua_tmpl
+        self._cfg_template = cfg_tmpl
+        self._options = options
+
+    def start(self, loop):
+        self.log("Starting mobile and virtphy")
+        #process = asyncio.create_subprocess_exec([binary])
+        pass 
+
+    def kill(self):
+        """Clean up things."""
+        if self._vphy_proc:
+            self._vphy_proc.kill()
+        if self._omob_proc:
+            self._omob_proc.kill()
diff --git a/src/osmo_ms_driver/ul_test.py b/src/osmo_ms_driver/ul_test.py
new file mode 100644
index 0000000..ebbcb87
--- /dev/null
+++ b/src/osmo_ms_driver/ul_test.py
@@ -0,0 +1,79 @@
+# osmo_ms_driver: Starter for processes
+# Help to start processes over time.
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+from osmo_gsm_tester import log
+from .starter import Launcher
+
+import asyncio
+
+class MassUpdateLocationTest(log.Origin):
+    """
+    A test to launch a configurable amount of MS and make them
+    execute a Location Updating Procedure.
+
+    Configure the number of MS to be tested and a function that
+    decides how quickly to start them and a timeout.
+    """
+
+    TEMPLATE_LUA = "ms_lu_test.lua.tmpl"
+    TEMPLATE_CFG = "ms_lu_test.cfg.tmpl"
+
+    def __init__(self, name, number_of_ms, cdf_function, event_server):
+        super().__init__(log.C_RUN, name)
+        self._number_of_ms = number_of_ms
+        self._cdf = cdf_function
+        self._cdf.set_target(number_of_ms)
+        self._unstarted = []
+        options = {}
+        for i in range(0, number_of_ms):
+            ms_name = "osmo-ms-lu-test/%.5d" % i
+            launcher = Launcher(ms_name, self.TEMPLATE_LUA,
+                                self.TEMPLATE_CFG, options)
+            self._unstarted.append(launcher)
+        self._event_server = event_server
+        self._event_server.register(self)
+
+    async def run(self, loop):
+        self._started = []
+
+        while len(self._unstarted) > 0:
+            # Check for timeout
+            # start pending MS
+            while len(self._started) < self._cdf.current_scaled_value():
+                ms = self._unstarted.pop(0)
+                ms.start(loop)
+                self._started.append(ms)
+
+            # Progress and sleep
+            self._cdf.step_once()
+            await asyncio.sleep(self._cdf.step_size().total_seconds())
+
+        print("All started...")
+
+    def stop_all(self):
+        for launcher in self._started:
+            launcher.kill()
+
+    def on_event(self, launcher, status):
+        # We got a message from the MS
+        pass
+
+    def on_process_end(self, launcher):
+        pass
+

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifff16c72e301236636f80de44a8564f772966ab7
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther <holger at freyther.de>



More information about the gerrit-log mailing list