Change in osmo-gsm-tester[master]: ms: Make the outer variables configurable

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 Jul 4 20:24:41 UTC 2018


Holger Freyther has submitted this change and it was merged. ( https://gerrit.osmocom.org/9713 )

Change subject: ms: Make the outer variables configurable
......................................................................

ms: Make the outer variables configurable

Do the easy part for making these variables configurable.

Change-Id: If8bbedcf672f6481a12c30d3669564704063626c
---
M src/osmo_ms_driver/__main__.py
M src/osmo_ms_driver/cdf.py
2 files changed, 31 insertions(+), 9 deletions(-)

Approvals:
  Harald Welte: Looks good to me, but someone else must approve
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo_ms_driver/__main__.py b/src/osmo_ms_driver/__main__.py
index 0e35280..7bca1d1 100644
--- a/src/osmo_ms_driver/__main__.py
+++ b/src/osmo_ms_driver/__main__.py
@@ -19,50 +19,65 @@
 from .event_server import EventServer
 from .simple_loop import SimpleLoop
 from .location_update_test import MassUpdateLocationTest
-from .cdf import ease_in_out_duration, linear_with_duration
+from .cdf import ease_in_out_duration, linear_with_duration, cdfs
 from osmo_gsm_tester import log
 
 # System modules
+import argparse
 import datetime
 import subprocess
 import signal
 import tempfile
 import os.path
+import os
 
+def parser():
+    parser = argparse.ArgumentParser(epilog=__doc__, formatter_class=argparse.RawTextHelpFormatter)
+    parser.add_argument('-s', '--launch-duration', dest='launch_duration',
+            default=60, type=int,
+            help="Time launching applications should take in seconds")
+    parser.add_argument('-i', '--launch-interval', dest='launch_interval',
+            default=100, type=int,
+            help="Time between launching in milliseconds")
+    parser.add_argument('-d', '--distribution', dest="cdf_name",
+            choices=cdfs.keys(), default="ease_in_out",
+            help="Curve to use for starting within launch duration")
+    parser.add_argument('-m', '--number-ms', dest="num_ms",
+            default=10, type=int,
+            help="Number of MobileStations to simulate")
+    return parser
 
 def main():
     # Create a default log to stdout
     log.LogTarget().style(src=False)
 
+    args = parser().parse_args()
+
     # We don't care what is happening to child processes we spawn!
     signal.signal(signal.SIGCHLD, signal.SIG_IGN)
 
     loop = SimpleLoop()
 
-    # TODO: Parse parameters and test composition. Right now we test
-    # with a single set of values.
-    num_ms = 10
-
     tmp_dir = tempfile.mkdtemp(suffix="osmo-ms-driver")
     log.log("Going to store files in ", tmp_dir=tmp_dir)
 
     # How long should starting all apps take
-    time_start=datetime.timedelta(seconds=60)
+    time_start=datetime.timedelta(seconds=args.launch_duration)
     # In which steps to start processes
-    time_step=datetime.timedelta(milliseconds=100)
+    time_step=datetime.timedelta(milliseconds=args.launch_interval)
 
     # Event server path
     event_server_path = os.path.join(tmp_dir,  "osmo_ms_driver.unix")
 
     # The function that decides when to start something
-    cdf = ease_in_out_duration(time_start, time_step)
+    cdf = cdfs[args.cdf_name](time_start, time_step)
 
     # Event server to handle MS->test events
     ev_server = EventServer("ev_server", event_server_path)
     ev_server.listen(loop)
 
     # Just a single test for now.
-    test = MassUpdateLocationTest("lu_test", num_ms, cdf, ev_server, tmp_dir)
+    test = MassUpdateLocationTest("lu_test", args.num_ms, cdf, ev_server, tmp_dir)
 
     # Run until everything has been launched
     test.launch(loop)
diff --git a/src/osmo_ms_driver/cdf.py b/src/osmo_ms_driver/cdf.py
index 781349b..e163cc3 100644
--- a/src/osmo_ms_driver/cdf.py
+++ b/src/osmo_ms_driver/cdf.py
@@ -103,3 +103,10 @@
     scale = 1.0/duration.total_seconds()
     return DistributionFunctionHandler(step_size, duration,
                                         lambda x: _in_out(x*scale))
+
+
+cdfs = {
+    'immediate': lambda x,y: immediate(y),
+    'linear': linear_with_duration,
+    'ease_in_out': ease_in_out_duration,
+}

-- 
To view, visit https://gerrit.osmocom.org/9713
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: If8bbedcf672f6481a12c30d3669564704063626c
Gerrit-Change-Number: 9713
Gerrit-PatchSet: 3
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
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/20180704/9a0e90bb/attachment.htm>


More information about the gerrit-log mailing list