[MERGED] osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-04-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: ms: Add a first test to use all parts of the system
..


ms: Add a first test to use all parts of the system

This is an interim solution but is bringing all parts together.
We will need to:

 * Abstract this into a base class
 * Be able to mix different tests without interfering with each
   other (e.g. 10k LU tests, 2k SMS sending)
 * The event loop will need to handle multiple timers/timeouts
 * Stats printing should print more information and test pass/fail
 * The test should quit early if everything has already passed

Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
---
A src/osmo_ms_driver/location_update_test.py
1 file changed, 207 insertions(+), 0 deletions(-)

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



diff --git a/src/osmo_ms_driver/location_update_test.py 
b/src/osmo_ms_driver/location_update_test.py
new file mode 100644
index 000..2d661ca
--- /dev/null
+++ b/src/osmo_ms_driver/location_update_test.py
@@ -0,0 +1,207 @@
+# 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 .
+
+
+from osmo_gsm_tester import log
+from .starter import OsmoVirtPhy, OsmoMobile
+
+from datetime import timedelta
+
+import time
+
+def imsi_ki_gen():
+"""
+Generate IMSIs and KIs to be used by test.
+"""
+n = 10100
+while True:
+yield ("%.15d" % n, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
+n += 1
+
+class Results(log.Origin):
+
+def __init__(self, name):
+super().__init__(log.C_RUN, name)
+self._time_of_registration = None
+self._time_of_launch = None
+self._time_of_lu = None
+
+def set_start_time(self, time):
+assert self._time_of_registration is None
+self._time_of_registration = time
+
+def set_launch_time(self, time):
+assert self._time_of_launch is None
+self._time_of_launch = time
+
+def set_lu_time(self, time):
+assert self._time_of_lu is None
+self._time_of_lu = time
+
+def start_time(self):
+return self._time_of_registration or 0
+
+def launch_time(self):
+return self._time_of_launch or 0
+
+def lu_time(self):
+return self._time_of_lu or 0
+
+def lu_delay(self):
+return self.lu_time() - self.start_time()
+
+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 = "osmo-mobile-lu.lua"
+TEMPLATE_CFG = "osmo-mobile.cfg"
+TEST_TIME = timedelta(seconds=120)
+
+def __init__(self, name, number_of_ms, cdf_function, event_server, 
tmp_dir):
+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 = []
+self._phys = []
+self._results = {}
+imsi_gen = imsi_ki_gen()
+
+for i in range(0, number_of_ms):
+ms_name = "%.5d" % i
+
+phy = OsmoVirtPhy(ms_name, tmp_dir)
+self._phys.append(phy)
+
+launcher = OsmoMobile(ms_name, tmp_dir, self.TEMPLATE_LUA,
+self.TEMPLATE_CFG, imsi_gen,
+phy.phy_filename(),
+event_server.server_path())
+self._results[ms_name] = Results(ms_name)
+self._unstarted.append(launcher)
+self._event_server = event_server
+self._event_server.register(self.handle_msg)
+
+def pre_launch(self, loop):
+"""
+We need the virtphy's be ready when the lua script in the
+mobile comes and kicks-off the test. In lua we don't seem to
+be able to just stat/check if a file/socket exists so we need
+to do this from here.
+"""
+self.log("Pre-launching all virtphy's")
+for phy in self._phys:
+phy.start(loop)
+
+self.log("Checking if sockets 

osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-03-07 Thread Holger Freyther

Patch Set 6:

(1 comment)

https://gerrit.osmocom.org/#/c/6918/6/src/osmo_ms_driver/location_update_test.py
File src/osmo_ms_driver/location_update_test.py:

Line 115: ms.start(loop)
> Oh I now see what you were saying about the variables. This should be bette
Good point. That wasn't intentional and the result of the refactoring.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
Gerrit-PatchSet: 6
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-03-07 Thread Pau Espin Pedrol

Patch Set 7: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
Gerrit-PatchSet: 7
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-03-07 Thread Pau Espin Pedrol

Patch Set 6: Code-Review+2

(2 comments)

https://gerrit.osmocom.org/#/c/6918/6/src/osmo_ms_driver/location_update_test.py
File src/osmo_ms_driver/location_update_test.py:

Line 115: ms.start(loop)
Oh I now see what you were saying about the variables. This should be better 
called phy instead of ms. Can be fixed later if it's easier for you.


Line 118: for ms in self._phys:
Same here, it should be named phy instead of ms, and of course then 
ms.verify_phy_ready() can already be called phy.verify_ready(). Again, can be 
fixed later if t's a lot of hassle to change it now.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
Gerrit-PatchSet: 6
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: Yes


[PATCH] osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-03-07 Thread Holger Freyther
Hello Pau Espin Pedrol, Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6918

to look at the new patch set (#6).

ms: Add a first test to use all parts of the system

This is an interim solution but is bringing all parts together.
We will need to:

 * Abstract this into a base class
 * Be able to mix different tests without interfering with each
   other (e.g. 10k LU tests, 2k SMS sending)
 * The event loop will need to handle multiple timers/timeouts
 * Stats printing should print more information and test pass/fail
 * The test should quit early if everything has already passed

Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
---
A src/osmo_ms_driver/location_update_test.py
1 file changed, 207 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/18/6918/6

diff --git a/src/osmo_ms_driver/location_update_test.py 
b/src/osmo_ms_driver/location_update_test.py
new file mode 100644
index 000..7a2159d
--- /dev/null
+++ b/src/osmo_ms_driver/location_update_test.py
@@ -0,0 +1,207 @@
+# 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 .
+
+
+from osmo_gsm_tester import log
+from .starter import OsmoVirtPhy, OsmoMobile
+
+from datetime import timedelta
+
+import time
+
+def imsi_ki_gen():
+"""
+Generate IMSIs and KIs to be used by test.
+"""
+n = 10100
+while True:
+yield ("%.15d" % n, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
+n += 1
+
+class Results(log.Origin):
+
+def __init__(self, name):
+super().__init__(log.C_RUN, name)
+self._time_of_registration = None
+self._time_of_launch = None
+self._time_of_lu = None
+
+def set_start_time(self, time):
+assert self._time_of_registration is None
+self._time_of_registration = time
+
+def set_launch_time(self, time):
+assert self._time_of_launch is None
+self._time_of_launch = time
+
+def set_lu_time(self, time):
+assert self._time_of_lu is None
+self._time_of_lu = time
+
+def start_time(self):
+return self._time_of_registration or 0
+
+def launch_time(self):
+return self._time_of_launch or 0
+
+def lu_time(self):
+return self._time_of_lu or 0
+
+def lu_delay(self):
+return self.lu_time() - self.start_time()
+
+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 = "osmo-mobile-lu.lua"
+TEMPLATE_CFG = "osmo-mobile.cfg"
+TEST_TIME = timedelta(seconds=120)
+
+def __init__(self, name, number_of_ms, cdf_function, event_server, 
tmp_dir):
+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 = []
+self._phys = []
+self._results = {}
+imsi_gen = imsi_ki_gen()
+
+for i in range(0, number_of_ms):
+ms_name = "%.5d" % i
+
+phy = OsmoVirtPhy(ms_name, tmp_dir)
+self._phys.append(phy)
+
+launcher = OsmoMobile(ms_name, tmp_dir, self.TEMPLATE_LUA,
+self.TEMPLATE_CFG, imsi_gen,
+phy.phy_filename(),
+event_server.server_path())
+self._results[ms_name] = Results(ms_name)
+self._unstarted.append(launcher)
+self._event_server = event_server
+self._event_server.register(self.handle_msg)
+
+def pre_launch(self, loop):
+"""
+We need the virtphy's be ready when the lua script in the
+mobile comes and kicks-off the test. In lua we don't seem to
+be able to just stat/check if a file/socket exists so we need
+to do this from here.
+"""
+self.log("Pre-launching all virtphy's")
+for ms in self._phys:
+ms.start(loop)
+
+self.log("Checking if sockets are in the filesystem")
+   

osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-03-05 Thread Pau Espin Pedrol

Patch Set 5: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
Gerrit-PatchSet: 5
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


[PATCH] osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-02-28 Thread Holger Freyther
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6918

to look at the new patch set (#5).

ms: Add a first test to use all parts of the system

This is an interim solution but is bringing all parts together.
We will need to:

 * Abstract this into a base class
 * Be able to mix different tests without interfering with each
   other (e.g. 10k LU tests, 2k SMS sending)
 * The event loop will need to handle multiple timers/timeouts
 * Stats printing should print more information and test pass/fail
 * The test should quit early if everything has already passed

Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
---
A src/osmo_ms_driver/location_update_test.py
1 file changed, 207 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/18/6918/5

diff --git a/src/osmo_ms_driver/location_update_test.py 
b/src/osmo_ms_driver/location_update_test.py
new file mode 100644
index 000..f7371a6
--- /dev/null
+++ b/src/osmo_ms_driver/location_update_test.py
@@ -0,0 +1,207 @@
+# 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 .
+
+
+from osmo_gsm_tester import log
+from .starter import OsmoVirtPhy, OsmoMobile
+
+from datetime import timedelta
+
+import time
+
+def imsi_ki_gen():
+"""
+Generate IMSIs and KIs to be used by test.
+"""
+n = 10100
+while True:
+yield ("%.15d" % n, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
+n += 1
+
+class Results(log.Origin):
+
+def __init__(self, name):
+super().__init__(log.C_RUN, name)
+self._time_of_registration = None
+self._time_of_launch = None
+self._time_of_lu = None
+
+def set_start_time(self, time):
+assert self._time_of_registration is None
+self._time_of_registration = time
+
+def set_launch_time(self, time):
+assert self._time_of_launch is None
+self._time_of_launch = time
+
+def set_lu_time(self, time):
+assert self._time_of_lu is None
+self._time_of_lu = time
+
+def start_time(self):
+return self._time_of_registration or 0
+
+def launch_time(self):
+return self._time_of_launch or 0
+
+def lu_time(self):
+return self._time_of_lu or 0
+
+def lu_delay(self):
+return self.lu_time() - self.start_time()
+
+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 = "osmo-mobile-lu.lua"
+TEMPLATE_CFG = "osmo-mobile.cfg"
+TEST_TIME = timedelta(seconds=120)
+
+def __init__(self, name, number_of_ms, cdf_function, event_server, 
tmp_dir):
+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 = []
+self._phys = []
+self._results = {}
+imsi_gen = imsi_ki_gen()
+
+for i in range(0, number_of_ms):
+ms_name = "%.5d" % i
+
+phy = OsmoVirtPhy(ms_name, tmp_dir)
+self._phys.append(phy)
+
+launcher = OsmoMobile(ms_name, tmp_dir, self.TEMPLATE_LUA,
+self.TEMPLATE_CFG, imsi_gen,
+phy.phy_filename(),
+event_server.server_path())
+self._results[ms_name] = Results(ms_name)
+self._unstarted.append(launcher)
+self._event_server = event_server
+self._event_server.register(self.handle_msg)
+
+def pre_launch(self, loop):
+"""
+We need the virtphy's be ready when the lua script in the
+mobile comes and kicks-off the test. In lua we don't seem to
+be able to just stat/check if a file/socket exists so we need
+to do this from here.
+"""
+self.log("Pre-launching all virtphy's")
+for ms in self._phys:
+ms.start_virtphy(loop)
+
+self.log("Checking if sockets are in the filesystem")
+for 

osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-02-26 Thread Harald Welte

Patch Set 3: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 
Gerrit-HasComments: No


[PATCH] osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-02-25 Thread Holger Freyther

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

ms: Add a first test to use all parts of the system

This is an interim solution but is bringing all parts together.
We will need to:

 * Abstract this into a base class
 * Be able to mix different tests without interfering with each
   other (e.g. 10k LU tests, 2k SMS sending)
 * The event loop will need to handle multiple timers/timeouts
 * Stats printing should print more information and test pass/fail
 * The test should quit early if everything has already passed

Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
---
A src/osmo_ms_driver/location_update_test.py
1 file changed, 200 insertions(+), 0 deletions(-)


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

diff --git a/src/osmo_ms_driver/location_update_test.py 
b/src/osmo_ms_driver/location_update_test.py
new file mode 100644
index 000..893ee72
--- /dev/null
+++ b/src/osmo_ms_driver/location_update_test.py
@@ -0,0 +1,200 @@
+# 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 .
+
+
+from osmo_gsm_tester import log
+from .starter import Launcher
+
+from datetime import timedelta
+
+import time
+
+def imsi_ki_gen():
+"""
+Generate IMSIs and KIs to be used by test.
+"""
+n = 10100
+while True:
+yield ("%.15d" % n, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
+n += 1
+
+class Results(log.Origin):
+
+def __init__(self, name):
+super().__init__(log.C_RUN, name)
+self._time_of_registration = None
+self._time_of_launch = None
+self._time_of_lu = None
+
+def set_start_time(self, time):
+assert self._time_of_registration is None
+self._time_of_registration = time
+
+def set_launch_time(self, time):
+assert self._time_of_launch is None
+self._time_of_launch = time
+
+def set_lu_time(self, time):
+assert self._time_of_lu is None
+self._time_of_lu = time
+
+def start_time(self):
+return self._time_of_registration
+
+def launch_time(self):
+return self._time_of_launch
+
+def lu_time(self):
+return self._time_of_lu
+
+def lu_delay(self):
+return self._time_of_lu - self._time_of_registration
+
+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 = "osmocom-bb-lu.lua"
+TEMPLATE_CFG = "osmocom-bb.cfg"
+TEST_TIME = timedelta(seconds=120)
+
+def __init__(self, name, number_of_ms, cdf_function, event_server, 
tmp_dir):
+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 = []
+self._results = {}
+imsi_gen = imsi_ki_gen()
+for i in range(0, number_of_ms):
+ms_name = "%.5d" % i
+launcher = Launcher(ms_name, tmp_dir, self.TEMPLATE_LUA,
+self.TEMPLATE_CFG, imsi_gen,
+event_server.server_path())
+self._results[ms_name] = Results(ms_name)
+self._unstarted.append(launcher)
+self._event_server = event_server
+self._event_server.register(self.handle_msg)
+
+def pre_launch(self, loop):
+"""
+We need the virtphy's be ready when the lua script in the
+mobile comes and kicks-off the test. In lua we don't seem to
+be able to just stat/check if a file/socket exists so we need
+to do this from here.
+"""
+self.log("Pre-launching all virtphy's")
+for ms in self._unstarted:
+ms.start_virtphy(loop)
+
+self.log("Checking if sockets are in the filesystem")
+for ms in self._unstarted:
+ms.verify_phy_ready()
+
+def launch(self, loop):
+self.log("Starting testcase")
+
+self.pre_launch(loop)
+
+self._start_time = time.clock_gettime(time.CLOCK_MONOTONIC)
+self._end_time = self._start_time + \
+