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.orgHolger Freyther has uploaded this change for review. ( https://gerrit.osmocom.org/13042 Change subject: nitb_netreg_mass: Allow to define subscribers from the outside ...................................................................... nitb_netreg_mass: Allow to define subscribers from the outside Remove hardcoded configuration and replace it with a reservation in the suite. In the future this can be used to specify MSISDN and KI as well. We can now scale the subscriber count to something beyond one can easily test by hand. Change-Id: Ic9fd560c2924731e4fd6eea5aaf3ad565cb4ef52 --- M src/osmo_gsm_tester/ms_driver.py M src/osmo_gsm_tester/suite.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 suites/nitb_netreg_mass/register_default_mass.py 6 files changed, 77 insertions(+), 51 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/42/13042/1 diff --git a/src/osmo_gsm_tester/ms_driver.py b/src/osmo_gsm_tester/ms_driver.py index 6292d7d..c7f2540 100644 --- a/src/osmo_gsm_tester/ms_driver.py +++ b/src/osmo_gsm_tester/ms_driver.py @@ -21,7 +21,7 @@ from osmo_ms_driver.event_server import EventServer from osmo_ms_driver.simple_loop import SimpleLoop from osmo_ms_driver.location_update_test import MassUpdateLocationTest -from osmo_ms_driver.starter import BinaryOptions, Subscriber +from osmo_ms_driver.starter import BinaryOptions import os.path import shutil @@ -34,7 +34,6 @@ self._suite_run = suite_run # TODO: take config out of the test scenario - self._num_ms = 10 self._time_start = timedelta(seconds=60) self._time_step = timedelta(milliseconds=100) self._test_duration = timedelta(seconds=120) @@ -42,6 +41,7 @@ self._loop = SimpleLoop() self._test_case = None self.event_server_sk_tmp_dir = None + self._subscribers = [] if len(self.event_server_path().encode()) > 107: raise log.Error('Path for event_server socket is longer than max allowed len for unix socket path (107):', self.event_server_path()) @@ -78,6 +78,10 @@ mobile = check_and_return_binary('mobile') return BinaryOptions(virtphy, mobile, env) + def subscriber_add(self, subscriber): + """Adds a subscriber to the list of subscribers.""" + self._subscribers.append(subscriber) + def configure(self): """ Configures the subscribers, tests and registration server. Needs to be @@ -88,24 +92,14 @@ self._ev_server = EventServer("ev_server", event_server_path) self._ev_server.listen(self._loop) options = self.build_binary_options() - self._test_case = MassUpdateLocationTest("mass", options, self._num_ms, self._cdf, + self._test_case = MassUpdateLocationTest("mass", options, self._cdf, self._ev_server, util.Dir(self.event_server_sk_tmp_dir), suite_run=self._suite_run) - # TODO: We should pass subscribers down to the test and not get it from - # there. - self._subs = [Subscriber(imsi=mob.imsi(), ki=mob.ki()) for mob in self._test_case.mobiles()] - - - def ms_subscribers(self): - """ - Returns a list of 'subscribers' that were configured in the - current scenario. - """ - if not hasattr(self, '_subs'): - self.configure() - return self._subs + for sub in self._subscribers: + self._test_case.subscriber_add(sub) + self._configured = True def run_test(self): """ @@ -113,7 +107,7 @@ devices according to their schedule. Returns once all tests succeeded or the configured timeout has passed. """ - if not hasattr(self, '_subs'): + if not hasattr(self, '_configured'): self.configure() self._test_case.run_test(self._loop, self._test_duration) diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py index 71e7c04..14a205d 100644 --- a/src/osmo_gsm_tester/suite.py +++ b/src/osmo_gsm_tester/suite.py @@ -25,8 +25,7 @@ from . import config, log, util, resource, test from .event_loop import MainLoop from . import osmo_nitb, osmo_hlr, osmo_mgcpgw, osmo_mgw, osmo_msc, osmo_bsc, osmo_stp, osmo_ggsn, osmo_sgsn, modem, esme, osmocon, ms_driver, iperf3 - -Mobile = collections.namedtuple("Mobile", ["imsi"]) +from osmo_ms_driver.starter import Subscriber class Timeout(Exception): pass @@ -321,7 +320,18 @@ def mobile(self): mobile_cfg = self.reserved_resources.get(resource.R_MOBILE) - return Mobile(mobile_cfg['imsi']) + # TODO(zecke): Pick a random KI and convert to hex. + return Subscriber(mobile_cfg['imsi'], + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00") + + def all_mobiles(self): + """Returns all mobiles reserved.""" + mobiles = [] + while True: + try: + mobiles.append(self.mobile()) + except resource.NoResourceExn: + return mobiles def bts(self, specifics=None): bts = bts_obj(self, self.reserved_resources.get(resource.R_BTS, specifics=specifics)) diff --git a/src/osmo_ms_driver/__main__.py b/src/osmo_ms_driver/__main__.py index 7e1afa8..bbade48 100644 --- a/src/osmo_ms_driver/__main__.py +++ b/src/osmo_ms_driver/__main__.py @@ -20,7 +20,8 @@ from .simple_loop import SimpleLoop from .location_update_test import MassUpdateLocationTest from .cdf import cdfs -from .starter import BinaryOptions +from .starter import BinaryOptions, Subscriber +from .test_support import imsi_ki_gen from osmo_gsm_tester import log, util # System modules @@ -84,7 +85,14 @@ # Just a single test for now. options = BinaryOptions("virtphy", "mobile", os.environ) - test = MassUpdateLocationTest("lu_test", options, args.num_ms, cdf, ev_server, tmp_dir) + test = MassUpdateLocationTest("lu_test", options, cdf, ev_server, tmp_dir) + + # Add subscribers to the test. + imsi_gen = imsi_ki_gen() + for i in range(0, args.num_ms): + imsi, ki = next(imsi_gen) + test.subscriber_add(Subscriber(imsi, ki)) + atexit.register(test.stop_all) # Run until everything has been launched diff --git a/src/osmo_ms_driver/location_update_test.py b/src/osmo_ms_driver/location_update_test.py index f14bd28..5ff2199 100644 --- a/src/osmo_ms_driver/location_update_test.py +++ b/src/osmo_ms_driver/location_update_test.py @@ -19,7 +19,7 @@ from copy import copy from osmo_gsm_tester import log from .starter import OsmoVirtPhy, OsmoMobile -from .test_support import imsi_ki_gen, Results +from .test_support import Results from datetime import timedelta @@ -62,42 +62,53 @@ TEMPLATE_LUA = "osmo-mobile-lu.lua" TEMPLATE_CFG = "osmo-mobile.cfg" - def __init__(self, name, options, number_of_ms, cdf_function, + def __init__(self, name, options, cdf_function, event_server, tmp_dir, suite_run=None): super().__init__(log.C_RUN, name) self._binary_options = options - self._number_of_ms = number_of_ms self._cdf = cdf_function - self._cdf.set_target(number_of_ms) self._suite_run = suite_run + self._tmp_dir = tmp_dir self._unstarted = [] self._mobiles = [] self._phys = [] self._results = {} - imsi_gen = imsi_ki_gen() - self._outstanding = number_of_ms - for i in range(0, number_of_ms): - ms_name = "%.5d" % i - - phy = OsmoVirtPhy(options.virtphy, options.env, - ms_name, tmp_dir) - self._phys.append(phy) - - launcher = OsmoMobile(options.mobile, options.env, - ms_name, tmp_dir, self.TEMPLATE_LUA, - self.TEMPLATE_CFG, imsi_gen, - phy.phy_filename(), - event_server.server_path()) - self._results[ms_name] = LUResult(ms_name) - self._mobiles.append(launcher) self._event_server = event_server self._event_server.register(self.handle_msg) - self._unstarted = copy(self._mobiles) self._started = [] + self._subscribers = [] - def mobiles(self): - return self._mobiles + def subscriber_add(self, subscriber): + """ + Adds a subscriber to the list of subscribers. + + Must be called before starting the testcase. + """ + self._subscribers.append(subscriber) + + def configure_tasks(self): + """Sets up the test run.""" + + self._cdf.set_target(len(self._subscribers)) + self._outstanding = len(self._subscribers) + for i in range(0, self._outstanding): + ms_name = "%.5d" % i + + phy = OsmoVirtPhy(self._binary_options.virtphy, + self._binary_options.env, + ms_name, self._tmp_dir) + self._phys.append(phy) + + launcher = OsmoMobile(self._binary_options.mobile, + self._binary_options.env, + ms_name, self._tmp_dir, self.TEMPLATE_LUA, + self.TEMPLATE_CFG, self._subscribers[i], + phy.phy_filename(), + self._event_server.server_path()) + self._results[ms_name] = LUResult(ms_name) + self._mobiles.append(launcher) + self._unstarted = copy(self._mobiles) def pre_launch(self, loop): """ @@ -117,6 +128,7 @@ def prepare(self, loop): self.log("Starting testcase") + self.configure_tasks() self.pre_launch(loop) self._start_time = time.clock_gettime(time.CLOCK_MONOTONIC) @@ -223,7 +235,7 @@ """ Returns a statistical summary of the test. """ - attempted = self._number_of_ms + attempted = len(self._subscribers) completed = attempted - self._outstanding min_latency, max_latency = self.find_min_max(filter(lambda x: x.has_lu_time(), self._results.values())) return LUStats(attempted, completed, min_latency, max_latency) diff --git a/src/osmo_ms_driver/starter.py b/src/osmo_ms_driver/starter.py index 7710766..bc8548f 100644 --- a/src/osmo_ms_driver/starter.py +++ b/src/osmo_ms_driver/starter.py @@ -93,14 +93,14 @@ self._vphy_proc.terminate() class OsmoMobile(Launcher): - def __init__(self, binary, env, name_number, tmp_dir, lua_tmpl, cfg_tmpl, imsi_ki_generator, phy_filename, ev_server_path): + def __init__(self, binary, env, name_number, tmp_dir, lua_tmpl, cfg_tmpl, subscriber, phy_filename, ev_server_path): super().__init__(binary, env, "osmo-ms-mob", name_number, tmp_dir) self._lua_template = lua_tmpl self._cfg_template = cfg_tmpl - self._imsi_ki_generator = imsi_ki_generator self._phy_filename = phy_filename self._ev_server_path = ev_server_path - self._imsi, self._ki = next(self._imsi_ki_generator) + self._imsi = subscriber.imsi() + self._ki = subscriber.ki() self._omob_proc = None def imsi(self): diff --git a/suites/nitb_netreg_mass/register_default_mass.py b/suites/nitb_netreg_mass/register_default_mass.py index 9772197..cec8c65 100644 --- a/suites/nitb_netreg_mass/register_default_mass.py +++ b/suites/nitb_netreg_mass/register_default_mass.py @@ -10,6 +10,7 @@ nitb = suite.nitb() bts = suite.bts() ms_driver = suite.ms_driver() +mobiles = suite.all_mobiles() print('Launching a simple network') nitb.bts_add(bts) @@ -18,8 +19,9 @@ wait(nitb.bts_is_connected, bts) # Configure all MS that the MS driver knows about. -for ms in ms_driver.ms_subscribers(): - nitb.subscriber_add(ms) +for mobile in mobiles: + nitb.subscriber_add(mobile) + ms_driver.subscriber_add(mobile) # Run the base test. ms_driver.run_test() -- To view, visit https://gerrit.osmocom.org/13042 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-gsm-tester Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Ic9fd560c2924731e4fd6eea5aaf3ad565cb4ef52 Gerrit-Change-Number: 13042 Gerrit-PatchSet: 1 Gerrit-Owner: Holger Freyther <holger at freyther.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190225/b687a2f2/attachment.htm>