Update obj classes in obj/ to use testenv instead of suite_run

Change-Id: Idf41243a497de7bc507b9f1cd1b38640f456f815
changes/45/18045/1
Pau Espin 3 years ago
parent f574a46b37
commit a442cb8e5f
  1. 11
      src/osmo_gsm_tester/core/suite.py
  2. 2
      src/osmo_gsm_tester/core/test.py
  3. 14
      src/osmo_gsm_tester/obj/bsc_osmo.py
  4. 8
      src/osmo_gsm_tester/obj/bts.py
  5. 36
      src/osmo_gsm_tester/obj/bts_nanobts.py
  6. 14
      src/osmo_gsm_tester/obj/bts_oc2g.py
  7. 16
      src/osmo_gsm_tester/obj/bts_octphy.py
  8. 10
      src/osmo_gsm_tester/obj/bts_osmo.py
  9. 52
      src/osmo_gsm_tester/obj/bts_osmotrx.py
  10. 16
      src/osmo_gsm_tester/obj/bts_osmovirtual.py
  11. 14
      src/osmo_gsm_tester/obj/bts_sysmo.py
  12. 10
      src/osmo_gsm_tester/obj/enb.py
  13. 12
      src/osmo_gsm_tester/obj/enb_amarisoft.py
  14. 14
      src/osmo_gsm_tester/obj/enb_srs.py
  15. 14
      src/osmo_gsm_tester/obj/epc.py
  16. 14
      src/osmo_gsm_tester/obj/epc_amarisoft.py
  17. 14
      src/osmo_gsm_tester/obj/epc_srs.py
  18. 14
      src/osmo_gsm_tester/obj/ggsn_osmo.py
  19. 16
      src/osmo_gsm_tester/obj/hlr_osmo.py
  20. 26
      src/osmo_gsm_tester/obj/iperf3.py
  21. 14
      src/osmo_gsm_tester/obj/mgcpgw_osmo.py
  22. 14
      src/osmo_gsm_tester/obj/mgw_osmo.py
  23. 4
      src/osmo_gsm_tester/obj/ms.py
  24. 18
      src/osmo_gsm_tester/obj/ms_amarisoft.py
  25. 8
      src/osmo_gsm_tester/obj/ms_driver.py
  26. 4
      src/osmo_gsm_tester/obj/ms_ofono.py
  27. 16
      src/osmo_gsm_tester/obj/ms_srs.py
  28. 14
      src/osmo_gsm_tester/obj/msc_osmo.py
  29. 16
      src/osmo_gsm_tester/obj/nitb_osmo.py
  30. 10
      src/osmo_gsm_tester/obj/osmocon.py
  31. 6
      src/osmo_gsm_tester/obj/pcap_recorder.py
  32. 8
      src/osmo_gsm_tester/obj/pcu.py
  33. 12
      src/osmo_gsm_tester/obj/pcu_oc2g.py
  34. 14
      src/osmo_gsm_tester/obj/pcu_osmo.py
  35. 12
      src/osmo_gsm_tester/obj/pcu_sysmo.py
  36. 14
      src/osmo_gsm_tester/obj/sgsn_osmo.py
  37. 14
      src/osmo_gsm_tester/obj/stp_osmo.py
  38. 17
      src/osmo_gsm_tester/testenv.py
  39. 28
      src/osmo_ms_driver/starter.py

@ -72,13 +72,16 @@ class SuiteRun(log.Origin):
self._resource_modifiers = None
self._config = None
self._run_dir = None
self.trial = trial
self._trial = trial
self.definition = suite_definition
self.scenarios = scenarios
self.resources_pool = resource.ResourcesPool()
self.status = SuiteRun.UNKNOWN
self.load_tests()
def trial(self):
return self._trial
def load_tests(self):
self.tests = []
for test_basename in self.definition.test_basenames:
@ -109,7 +112,7 @@ class SuiteRun(log.Origin):
def get_run_dir(self):
if self._run_dir is None:
self._run_dir = util.Dir(self.trial.get_run_dir().new_dir(self.name()))
self._run_dir = util.Dir(self._trial.get_run_dir().new_dir(self.name()))
return self._run_dir
def resource_requirements(self):
@ -142,7 +145,7 @@ class SuiteRun(log.Origin):
def run_tests(self, names=None):
suite_libdir = os.path.join(self.definition.suite_dir, 'lib')
try:
log.large_separator(self.trial.name(), self.name(), sublevel=2)
log.large_separator(self._trial.name(), self.name(), sublevel=2)
self.mark_start()
util.import_path_prepend(suite_libdir)
if not self.reserved_resources:
@ -171,7 +174,7 @@ class SuiteRun(log.Origin):
else:
self.status = SuiteRun.FAIL
log.large_separator(self.trial.name(), self.name(), self.status, sublevel=2, space_above=False)
log.large_separator(self._trial.name(), self.name(), self.status, sublevel=2, space_above=False)
def passed(self):
return self.status == SuiteRun.PASS

@ -58,7 +58,7 @@ class Test(log.Origin):
testenv_obj = None
try:
self.log_target = log.FileLogTarget(self.get_run_dir().new_child('log')).set_all_levels(log.L_DBG).style_change(trace=True)
log.large_separator(self.suite_run.trial.name(), self.suite_run.name(), self.name(), sublevel=3)
log.large_separator(self.suite_run.trial().name(), self.suite_run.name(), self.name(), sublevel=3)
self.status = Test.UNKNOWN
self.start_timestamp = time.time()
testenv_obj = testenv.setup(self.suite_run, self)

@ -34,7 +34,7 @@ def on_register_schemas():
class OsmoBsc(log.Origin):
def __init__(self, suite_run, msc, mgw, stp, ip_address):
def __init__(self, testenv, msc, mgw, stp, ip_address):
super().__init__(log.C_RUN, 'osmo-bsc_%s' % ip_address.get('addr'))
self.run_dir = None
self.config_file = None
@ -42,7 +42,7 @@ class OsmoBsc(log.Origin):
self.encryption = None
self.rsl_ip = None
self.use_osmux = "off"
self.suite_run = suite_run
self.testenv = testenv
self.ip_address = ip_address
self.bts = []
self.msc = msc
@ -51,10 +51,10 @@ class OsmoBsc(log.Origin):
def start(self):
self.log('Starting osmo-bsc')
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-bsc')))
inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-bsc')))
binary = inst.child('bin', 'osmo-bsc')
if not os.path.isfile(binary):
@ -67,7 +67,7 @@ class OsmoBsc(log.Origin):
filter = 'host %s or host %s and port not 22' % (self.addr(), self.rsl_ip)
else:
filter = 'host %s and port not 22' % self.addr()
pcap_recorder.PcapRecorder(self.suite_run, self.run_dir.new_dir('pcap'), None, filter)
pcap_recorder.PcapRecorder(self.testenv, self.run_dir.new_dir('pcap'), None, filter)
env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
@ -76,7 +76,7 @@ class OsmoBsc(log.Origin):
(binary, '-c',
os.path.abspath(self.config_file)),
env=env)
self.suite_run.remember_to_stop(self.process)
self.testenv.remember_to_stop(self.process)
self.process.launch()
def configure(self):
@ -84,7 +84,7 @@ class OsmoBsc(log.Origin):
self.dbg(config_file=self.config_file)
values = dict(bsc=config.get_defaults('bsc'))
config.overlay(values, self.suite_run.config())
config.overlay(values, self.testenv.suite().config())
config.overlay(values, dict(bsc=dict(ip_address=self.ip_address)))
config.overlay(values, self.mgw.conf_for_client())
config.overlay(values, self.stp.conf_for_client())

@ -50,7 +50,7 @@ class Bts(log.Origin, metaclass=ABCMeta):
##############
# PROTECTED
##############
def __init__(self, suite_run, conf, name, defaults_cfg_name):
def __init__(self, testenv, conf, name, defaults_cfg_name):
super().__init__(log.C_RUN, name)
self.bsc = None
self.sgsn = None
@ -61,7 +61,7 @@ class Bts(log.Origin, metaclass=ABCMeta):
self._num_trx = 1
self._max_trx = None
self.overlay_trx_list = []
self.suite_run = suite_run
self.testenv = testenv
self.conf = conf
self.defaults_cfg_name = defaults_cfg_name
self._init_num_trx()
@ -162,7 +162,7 @@ class Bts(log.Origin, metaclass=ABCMeta):
'Nothing to do by default. Subclass can override if required.'
pass
def get_instance_by_type(suite_run, conf):
def get_instance_by_type(testenv, conf):
"""Allocate a BTS child class based on type. Opts are passed to the newly created object."""
bts_type = conf.get('type')
if bts_type is None:
@ -188,7 +188,7 @@ class Bts(log.Origin, metaclass=ABCMeta):
bts_class = NanoBts
else:
raise log.Error('BTS type not supported:', bts_type)
return bts_class(suite_run, conf)
return bts_class(testenv, conf)
###################
# PUBLIC (test API included)

@ -30,8 +30,8 @@ class NanoBts(bts.Bts):
##############
# PROTECTED
##############
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf, 'nanobts_%s' % conf.get('label', 'nolabel'), 'nanobts')
def __init__(self, testenv, conf):
super().__init__(testenv, conf, 'nanobts_%s' % conf.get('label', 'nolabel'), 'nanobts')
self.pwsup_list = []
self._pcu = None
@ -94,7 +94,7 @@ class NanoBts(bts.Bts):
def start(self, keepalive=False):
if self.conf.get('ipa_unit_id') is None:
raise log.Error('No attribute ipa_unit_id provided in conf!')
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self._configure()
unitid = int(self.conf.get('ipa_unit_id'))
@ -104,7 +104,7 @@ class NanoBts(bts.Bts):
self.dbg('Powering cycling NanoBTS TRX')
pwsup.power_cycle(1.0)
pcap_recorder.PcapRecorder(self.suite_run, self.run_dir.new_dir('pcap'), None,
pcap_recorder.PcapRecorder(self.testenv, self.run_dir.new_dir('pcap'), None,
'%s and port not 22' % self.get_pcap_filter_all_trx_ip())
@ -116,14 +116,14 @@ class NanoBts(bts.Bts):
local_bind_ip = util.dst_ip_get_local_bind(bts_trx_ip)
self.log('Finding nanobts %s, binding on %s...' % (bts_trx_ip, local_bind_ip))
ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 'preconf')
ipfind = AbisIpFind(self.testenv, self.run_dir, local_bind_ip, 'preconf')
ipfind.start()
ipfind.wait_bts_ready(bts_trx_ip)
running_unitid, running_trx = ipfind.get_unitid_by_ip(bts_trx_ip)
self.log('Found nanobts %s with unit_id %d trx %d' % (bts_trx_ip, running_unitid, running_trx))
ipfind.stop()
ipconfig = IpAccessConfig(self.suite_run, self.run_dir, bts_trx_ip)
ipconfig = IpAccessConfig(self.testenv, self.run_dir, bts_trx_ip)
running_oml_ip = ipconfig.get_oml_ip()
if running_unitid != unitid or running_trx != trx_i:
@ -142,7 +142,7 @@ class NanoBts(bts.Bts):
MainLoop.sleep(self, 20)
self.dbg('Starting to connect id %d trx %d to' % (unitid, trx_i), self.bsc)
ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 'postconf')
ipfind = AbisIpFind(self.testenv, self.run_dir, local_bind_ip, 'postconf')
ipfind.start()
ipfind.wait_bts_ready(bts_trx_ip)
self.log('nanoBTS id %d trx %d configured and running' % (unitid, trx_i))
@ -171,12 +171,12 @@ class NanoBts(bts.Bts):
def pcu(self):
if not self._pcu:
self._pcu = pcu.PcuDummy(self.suite_run, self, self.conf)
self._pcu = pcu.PcuDummy(self.testenv, self, self.conf)
return self._pcu
class AbisIpFind(log.Origin):
suite_run = None
testenv = None
parent_run_dir = None
run_dir = None
inst = None
@ -187,16 +187,16 @@ class AbisIpFind(log.Origin):
BIN_ABISIP_FIND = 'abisip-find'
BTS_UNIT_ID_RE = re.compile("Unit_ID='(?P<unit_id>\d+)/\d+/(?P<trx_id>\d+)'")
def __init__(self, suite_run, parent_run_dir, bind_ip, name_suffix):
def __init__(self, testenv, parent_run_dir, bind_ip, name_suffix):
super().__init__(log.C_RUN, AbisIpFind.BIN_ABISIP_FIND + '-' + name_suffix)
self.suite_run = suite_run
self.testenv = testenv
self.parent_run_dir = parent_run_dir
self.bind_ip = bind_ip
self.env = {}
def start(self):
self.run_dir = util.Dir(self.parent_run_dir.new_dir(self.name()))
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-bsc')))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-bsc')))
lib = self.inst.child('lib')
if not os.path.isdir(lib):
@ -209,11 +209,11 @@ class AbisIpFind(log.Origin):
self.proc = process.Process(self.name(), self.run_dir,
(ipfind_path, '-i', '1', '-b', self.bind_ip),
env=env)
self.suite_run.remember_to_stop(self.proc)
self.testenv.remember_to_stop(self.proc)
self.proc.launch()
def stop(self):
self.suite_run.stop_process(self.proc)
self.testenv.stop_process(self.proc)
def get_line_by_ip(self, ipaddr):
"""Get latest line (more up to date) from abisip-find based on ip address."""
@ -246,7 +246,7 @@ class AbisIpFind(log.Origin):
MainLoop.sleep(self, 2)
class IpAccessConfig(log.Origin):
suite_run = None
testenv = None
parent_run_dir = None
run_dir = None
inst = None
@ -255,9 +255,9 @@ class IpAccessConfig(log.Origin):
BIN_IPACCESS_CONFIG = 'ipaccess-config'
def __init__(self, suite_run, parent_run_dir, bts_ip):
def __init__(self, testenv, parent_run_dir, bts_ip):
super().__init__(log.C_RUN, IpAccessConfig.BIN_IPACCESS_CONFIG)
self.suite_run = suite_run
self.testenv = testenv
self.parent_run_dir = parent_run_dir
self.bts_ip = bts_ip
self.env = {}
@ -274,7 +274,7 @@ class IpAccessConfig(log.Origin):
def run(self, name_suffix, *args):
self.run_dir = util.Dir(self.parent_run_dir.new_dir(self.name()+'-'+name_suffix))
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-bsc')))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-bsc')))
lib = self.inst.child('lib')
self.env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
self.proc = self.create_process(IpAccessConfig.BIN_IPACCESS_CONFIG, *args)

@ -31,8 +31,8 @@ class OsmoBtsOC2G(bts_osmo.OsmoBts):
BTS_OC2G_BIN = 'osmo-bts-oc2g'
BTS_OC2G_CFG = 'osmo-bts-oc2g.cfg'
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf, OsmoBtsOC2G.BTS_OC2G_BIN, 'osmo_bts_oc2g')
def __init__(self, testenv, conf):
super().__init__(testenv, conf, OsmoBtsOC2G.BTS_OC2G_BIN, 'osmo_bts_oc2g')
self.run_dir = None
self.inst = None
self.remote_inst = None
@ -44,7 +44,7 @@ class OsmoBtsOC2G(bts_osmo.OsmoBts):
return util.str2bool(self.conf.get('direct_pcu'))
def create_pcu(self):
return pcu_oc2g.OsmoPcuOC2G(self.suite_run, self, self.conf)
return pcu_oc2g.OsmoPcuOC2G(self.testenv, self, self.conf)
def configure(self):
if self.bsc is None:
@ -54,7 +54,7 @@ class OsmoBtsOC2G(bts_osmo.OsmoBts):
self.dbg(config_file=self.config_file)
values = { 'osmo_bts_oc2g': config.get_defaults('osmo_bts_oc2g') }
config.overlay(values, self.suite_run.config())
config.overlay(values, self.testenv.suite().config())
config.overlay(values, {
'osmo_bts_oc2g': {
'oml_remote_ip': self.bsc.addr(),
@ -100,10 +100,10 @@ class OsmoBtsOC2G(bts_osmo.OsmoBts):
if self.bsc is None:
raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be started')
log.log('Starting OsmoBtsOC2G to connect to', self.bsc)
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst(OsmoBtsOC2G.BTS_OC2G_BIN)))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst(OsmoBtsOC2G.BTS_OC2G_BIN)))
lib = self.inst.child('lib')
if not os.path.isdir(lib):
raise log.Error('No lib/ in', self.inst)
@ -131,6 +131,6 @@ class OsmoBtsOC2G(bts_osmo.OsmoBts):
args += ('-M',)
self.proc_bts = rem_host.RemoteProcess(OsmoBtsOC2G.BTS_OC2G_BIN, args)
self.suite_run.remember_to_stop(self.proc_bts, keepalive)
self.testenv.remember_to_stop(self.proc_bts, keepalive)
self.proc_bts.launch()
# vim: expandtab tabstop=4 shiftwidth=4

@ -31,8 +31,8 @@ class OsmoBtsOctphy(bts_osmo.OsmoBtsMainUnit):
BIN_BTS_OCTPHY = 'osmo-bts-octphy'
CONF_BTS_OCTPHY = 'osmo-bts-octphy.cfg'
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf, OsmoBtsOctphy.BIN_BTS_OCTPHY, 'osmo_bts_octphy')
def __init__(self, testenv, conf):
super().__init__(testenv, conf, OsmoBtsOctphy.BIN_BTS_OCTPHY, 'osmo_bts_octphy')
self.run_dir = None
self.inst = None
self.env = {}
@ -46,7 +46,7 @@ class OsmoBtsOctphy(bts_osmo.OsmoBtsMainUnit):
proc = process.Process(binary_name, run_dir,
(binary,) + args,
env=self.env)
self.suite_run.remember_to_stop(proc)
self.testenv.remember_to_stop(proc)
proc.launch()
return proc
@ -85,7 +85,7 @@ class OsmoBtsOctphy(bts_osmo.OsmoBtsMainUnit):
self.dbg(config_file=self.config_file)
values = dict(osmo_bts_octphy=config.get_defaults('osmo_bts_octphy'))
config.overlay(values, self.suite_run.config())
config.overlay(values, self.testenv.suite().config())
config.overlay(values, {
'osmo_bts_octphy': {
'oml_remote_ip': self.bsc.addr(),
@ -117,13 +117,13 @@ class OsmoBtsOctphy(bts_osmo.OsmoBtsMainUnit):
def start(self):
if self.bsc is None:
raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be started')
self.suite_run.poll()
self.testenv.poll()
self.log('Starting to connect to', self.bsc)
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-bts')))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-bts')))
btsoct_path = self.inst.child('bin', OsmoBtsOctphy.BIN_BTS_OCTPHY)
lib = self.inst.child('lib')
if not os.path.isdir(lib):
@ -139,6 +139,6 @@ class OsmoBtsOctphy(bts_osmo.OsmoBtsMainUnit):
self.proc_bts = self.launch_process(OsmoBtsOctphy.BIN_BTS_OCTPHY, '-r', '1',
'-c', os.path.abspath(self.config_file),
'-i', self.bsc.addr(), '-t', str(self.num_trx()))
self.suite_run.poll()
self.testenv.poll()
# vim: expandtab tabstop=4 shiftwidth=4

@ -38,8 +38,8 @@ class OsmoBts(bts.Bts, metaclass=ABCMeta):
##############
# PROTECTED
##############
def __init__(self, suite_run, conf, name, defaults_cfg_name):
super().__init__(suite_run, conf, name, defaults_cfg_name)
def __init__(self, testenv, conf, name, defaults_cfg_name):
super().__init__(testenv, conf, name, defaults_cfg_name)
self._pcu = None
self.proc_bts = None
if len(self.pcu_socket_path().encode()) > 107:
@ -86,9 +86,9 @@ class OsmoBtsMainUnit(OsmoBts, metaclass=ABCMeta):
# PROTECTED
##############
def __init__(self, suite_run, conf, name, defaults_cfg_name):
def __init__(self, testenv, conf, name, defaults_cfg_name):
self.pcu_sk_tmp_dir = None
super().__init__(suite_run, conf, name, defaults_cfg_name)
super().__init__(testenv, conf, name, defaults_cfg_name)
########################
# PUBLIC - INTERNAL API
@ -107,7 +107,7 @@ class OsmoBtsMainUnit(OsmoBts, metaclass=ABCMeta):
os.rmdir(self.pcu_sk_tmp_dir)
def create_pcu(self):
return pcu_osmo.OsmoPcu(self.suite_run, self, self.conf)
return pcu_osmo.OsmoPcu(self.testenv, self, self.conf)
def pcu_socket_path(self):
if self.pcu_sk_tmp_dir is None:

@ -50,8 +50,8 @@ class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
CONF_BTS_TRX = 'osmo-bts-trx.cfg'
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf, OsmoBtsTrx.BIN_BTS_TRX, 'osmo_bts_trx')
def __init__(self, testenv, conf):
super().__init__(testenv, conf, OsmoBtsTrx.BIN_BTS_TRX, 'osmo_bts_trx')
self.run_dir = None
self.inst = None
self.trx = None
@ -74,7 +74,7 @@ class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
proc = process.Process(binary_name, run_dir,
(binary,) + args,
env=self.env)
self.suite_run.remember_to_stop(proc, keepalive)
self.testenv.remember_to_stop(proc, keepalive)
proc.launch()
return proc
@ -86,7 +86,7 @@ class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
values = dict(osmo_bts_trx=config.get_defaults('osmo_bts_trx'))
config.overlay(values, dict(osmo_bts_trx=dict(osmo_trx=config.get_defaults('osmo_trx'))))
config.overlay(values, self.suite_run.config())
config.overlay(values, self.testenv.suite().config())
config.overlay(values, {
'osmo_bts_trx': {
'oml_remote_ip': self.bsc.addr(),
@ -155,10 +155,10 @@ class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
def start(self, keepalive=False):
if self.bsc is None:
raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be started')
self.suite_run.poll()
self.testenv.poll()
self.log('Starting to connect to', self.bsc)
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
# Power cycle all TRX if needed (right now only TRX0 for SC5):
@ -170,12 +170,12 @@ class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
i = i + 1
if self.launch_trx_enabled():
self.trx = OsmoTrx.get_instance_by_type(self.get_osmo_trx_type(), self.suite_run, self.conf_for_osmotrx())
self.trx = OsmoTrx.get_instance_by_type(self.get_osmo_trx_type(), self.testenv, self.conf_for_osmotrx())
self.trx.start(keepalive)
self.log('Waiting for %s to start up...' % self.trx.name())
MainLoop.wait(self, self.trx.trx_ready)
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-bts')))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-bts')))
lib = self.inst.child('lib')
if not os.path.isdir(lib):
raise RuntimeError('No lib/ in %r' % self.inst)
@ -184,7 +184,7 @@ class OsmoBtsTrx(bts_osmo.OsmoBtsMainUnit):
self.proc_bts = self.launch_process(keepalive, OsmoBtsTrx.BIN_BTS_TRX, '-r', '1',
'-c', os.path.abspath(self.config_file),
'-i', self.bsc.addr())
self.suite_run.poll()
self.testenv.poll()
################################################################################
@ -195,23 +195,23 @@ class Trx(log.Origin, metaclass=ABCMeta):
##############
# PROTECTED
##############
def __init__(self, suite_run, conf, name):
def __init__(self, testenv, conf, name):
super().__init__(log.C_RUN, name)
self.suite_run = suite_run
self.testenv = testenv
self.conf = conf
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.listen_ip = conf.get('osmo_trx', {}).get('trx_ip')
self.remote_user = conf.get('osmo_trx', {}).get('remote_user', None)
@classmethod
def get_instance_by_type(cls, type, suite_run, conf):
def get_instance_by_type(cls, type, testenv, conf):
KNOWN_OSMOTRX_TYPES = {
'uhd': OsmoTrxUHD,
'lms': OsmoTrxLMS,
'sc5': TrxSC5
}
osmo_trx_class = KNOWN_OSMOTRX_TYPES.get(type)
return osmo_trx_class(suite_run, conf)
return osmo_trx_class(testenv, conf)
##############
# PUBLIC (test API included)
@ -233,8 +233,8 @@ class OsmoTrx(Trx, metaclass=ABCMeta):
##############
# PROTECTED
##############
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf, self.binary_name())
def __init__(self, testenv, conf):
super().__init__(testenv, conf, self.binary_name())
self.env = {}
self.log("OSMOTRX CONF: %r" % conf)
self.bts_ip = conf.get('osmo_trx', {}).get('bts_ip')
@ -274,7 +274,7 @@ class OsmoTrx(Trx, metaclass=ABCMeta):
proc = process.Process(binary_name, run_dir,
(binary,) + args,
env=self.env)
self.suite_run.remember_to_stop(proc, keepalive)
self.testenv.remember_to_stop(proc, keepalive)
proc.launch()
return proc
@ -292,7 +292,7 @@ class OsmoTrx(Trx, metaclass=ABCMeta):
have_inst = rem_host.inst_compatible_for_remote()
if have_inst:
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-trx')))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-trx')))
rem_host.recreate_remote_dir(remote_prefix_dir)
if have_inst:
@ -311,7 +311,7 @@ class OsmoTrx(Trx, metaclass=ABCMeta):
remote_binary = self.binary_name()
args = (remote_binary, '-C', remote_config_file)
self.proc_trx = rem_host.RemoteProcessFixIgnoreSIGHUP(self.binary_name(), remote_run_dir, args, remote_env=remote_env)
self.suite_run.remember_to_stop(self.proc_trx, keepalive)
self.testenv.remember_to_stop(self.proc_trx, keepalive)
self.proc_trx.launch()
##############
@ -323,7 +323,7 @@ class OsmoTrx(Trx, metaclass=ABCMeta):
self.start_remotely(keepalive)
return
# Run locally if ssh user is not set
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-trx')))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-trx')))
lib = self.inst.child('lib')
self.env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
self.proc_trx = self.launch_process_local(keepalive, self.binary_name(),
@ -337,8 +337,8 @@ class OsmoTrx(Trx, metaclass=ABCMeta):
class OsmoTrxUHD(OsmoTrx):
BIN_TRX = 'osmo-trx-uhd'
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf)
def __init__(self, testenv, conf):
super().__init__(testenv, conf)
def binary_name(self):
return OsmoTrxUHD.BIN_TRX
@ -346,16 +346,16 @@ class OsmoTrxUHD(OsmoTrx):
class OsmoTrxLMS(OsmoTrx):
BIN_TRX = 'osmo-trx-lms'
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf)
def __init__(self, testenv, conf):
super().__init__(testenv, conf)
def binary_name(self):
return OsmoTrxLMS.BIN_TRX
class TrxSC5(Trx):
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf, "sc5-trx")
def __init__(self, testenv, conf):
super().__init__(testenv, conf, "sc5-trx")
self.ready = False
def start(self, keepalive=False):

@ -33,9 +33,9 @@ class OsmoBtsVirtual(bts_osmo.OsmoBtsMainUnit):
CONF_BTS = 'osmo-bts-virtual.cfg'
def __init__(self, suite_run, conf):
def __init__(self, testenv, conf):
"""Initializes the OsmoBtsVirtual."""
super().__init__(suite_run, conf, OsmoBtsVirtual.BIN_BTS, 'osmo_bts_virtual')
super().__init__(testenv, conf, OsmoBtsVirtual.BIN_BTS, 'osmo_bts_virtual')
self.run_dir = None
self.inst = None
self.env = {}
@ -50,7 +50,7 @@ class OsmoBtsVirtual(bts_osmo.OsmoBtsMainUnit):
proc = process.Process(binary_name, run_dir,
(binary,) + args,
env=self.env)
self.suite_run.remember_to_stop(proc, keepalive)
self.testenv.remember_to_stop(proc, keepalive)
proc.launch()
return proc
@ -63,7 +63,7 @@ class OsmoBtsVirtual(bts_osmo.OsmoBtsMainUnit):
self.dbg(config_file=self.config_file)
values = dict(osmo_bts_virtual=config.get_defaults('osmo_bts_virtual'))
config.overlay(values, self.suite_run.config())
config.overlay(values, self.testenv.suite().config())
config.overlay(values, {
'osmo_bts_virtual': {
'oml_remote_ip': self.bsc.addr(),
@ -95,13 +95,13 @@ class OsmoBtsVirtual(bts_osmo.OsmoBtsMainUnit):
"""Handles starting/turning-up the osmo-bts-virtual process."""
if self.bsc is None:
raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be started')
self.suite_run.poll()
self.testenv.poll()
self.log('Starting to connect to', self.bsc)
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-bts')))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-bts')))
lib = self.inst.child('lib')
if not os.path.isdir(lib):
raise RuntimeError('No lib/ in %r' % self.inst)
@ -110,6 +110,6 @@ class OsmoBtsVirtual(bts_osmo.OsmoBtsMainUnit):
self.proc_bts = self.launch_process(keepalive, OsmoBtsVirtual.BIN_BTS, '-r', '1',
'-c', os.path.abspath(self.config_file),
'-i', self.bsc.addr())
self.suite_run.poll()
self.testenv.poll()
# vim: expandtab tabstop=4 shiftwidth=4

@ -31,8 +31,8 @@ class SysmoBts(bts_osmo.OsmoBts):
BTS_SYSMO_BIN = 'osmo-bts-sysmo'
BTS_SYSMO_CFG = 'osmo-bts-sysmo.cfg'
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf, SysmoBts.BTS_SYSMO_BIN, 'osmo_bts_sysmo')
def __init__(self, testenv, conf):
super().__init__(testenv, conf, SysmoBts.BTS_SYSMO_BIN, 'osmo_bts_sysmo')
self.run_dir = None
self.inst = None
self.remote_inst = None
@ -44,7 +44,7 @@ class SysmoBts(bts_osmo.OsmoBts):
return util.str2bool(self.conf.get('direct_pcu'))
def create_pcu(self):
return pcu_sysmo.OsmoPcuSysmo(self.suite_run, self, self.conf)
return pcu_sysmo.OsmoPcuSysmo(self.testenv, self, self.conf)
def configure(self):
if self.bsc is None:
@ -54,7 +54,7 @@ class SysmoBts(bts_osmo.OsmoBts):
self.dbg(config_file=self.config_file)
values = { 'osmo_bts_sysmo': config.get_defaults('osmo_bts_sysmo') }
config.overlay(values, self.suite_run.config())
config.overlay(values, self.testenv.suite().config())
config.overlay(values, {
'osmo_bts_sysmo': {
'oml_remote_ip': self.bsc.addr(),
@ -94,10 +94,10 @@ class SysmoBts(bts_osmo.OsmoBts):
if self.bsc is None:
raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be started')
log.log('Starting sysmoBTS to connect to', self.bsc)
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst(SysmoBts.BTS_SYSMO_BIN)))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst(SysmoBts.BTS_SYSMO_BIN)))
lib = self.inst.child('lib')
if not os.path.isdir(lib):
raise log.Error('No lib/ in', self.inst)
@ -127,7 +127,7 @@ class SysmoBts(bts_osmo.OsmoBts):
args += ('-M',)
self.proc_bts = rem_host.RemoteProcess(SysmoBts.BTS_SYSMO_BIN, args)
self.suite_run.remember_to_stop(self.proc_bts, keepalive)
self.testenv.remember_to_stop(self.proc_bts, keepalive)
self.proc_bts.launch()
# vim: expandtab tabstop=4 shiftwidth=4

@ -66,7 +66,7 @@ class eNodeB(log.Origin, metaclass=ABCMeta):
##############
# PROTECTED
##############
def __init__(self, suite_run, conf, name):
def __init__(self, testenv, conf, name):
super().__init__(log.C_RUN, '%s' % name)
self._conf = conf
self._addr = conf.get('addr', None)
@ -86,9 +86,9 @@ class eNodeB(log.Origin, metaclass=ABCMeta):
values = dict(enb=config.get_defaults('enb'))
for config_specifics in config_specifics_li:
config.overlay(values, dict(enb=config.get_defaults(config_specifics)))
config.overlay(values, dict(enb=self.suite_run.config().get('enb', {})))
config.overlay(values, dict(enb=self.testenv.suite().config().get('enb', {})))
for config_specifics in config_specifics_li:
config.overlay(values, dict(enb=self.suite_run.config().get(config_specifics, {})))
config.overlay(values, dict(enb=self.testenv.suite().config().get(config_specifics, {})))
config.overlay(values, dict(enb=self._conf))
self._id = int(values['enb'].get('id', None))
assert self._id is not None
@ -192,7 +192,7 @@ class eNodeB(log.Origin, metaclass=ABCMeta):
return rf_dev_args
def get_instance_by_type(suite_run, conf):
def get_instance_by_type(testenv, conf):
"""Allocate a ENB child class based on type. Opts are passed to the newly created object."""
enb_type = conf.get('type')
if enb_type is None:
@ -206,7 +206,7 @@ class eNodeB(log.Origin, metaclass=ABCMeta):
enb_class = srsENB
else:
raise log.Error('ENB type not supported:', enb_type)
return enb_class(suite_run, conf)
return enb_class(testenv, conf)
###################
# PUBLIC (test API included)

@ -45,8 +45,8 @@ class AmarisoftENB(enb.eNodeB):
CFGFILE_DRB = 'amarisoft_drb.cfg'
LOGFILE = 'lteenb.log'
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf, 'amarisoftenb')
def __init__(self, testenv, conf):
super().__init__(testenv, conf, 'amarisoftenb')
self.ue = None
self.run_dir = None
self.inst = None
@ -68,7 +68,7 @@ class AmarisoftENB(enb.eNodeB):
self.remote_config_drb_file = None
self.remote_log_file = None
self.enable_measurements = False
self.suite_run = suite_run
self.testenv = testenv
self.remote_user = conf.get('remote_user', None)
if not rf_type_valid(conf.get('rf_dev_type', None)):
raise log.Error('Invalid rf_dev_type=%s' % conf.get('rf_dev_type', None))
@ -77,7 +77,7 @@ class AmarisoftENB(enb.eNodeB):
if self._bin_prefix is None:
self._bin_prefix = os.getenv('AMARISOFT_PATH_ENB', None)
if self._bin_prefix == None:
self._bin_prefix = self.suite_run.trial.get_inst('amarisoftenb')
self._bin_prefix = self.testenv.suite().trial().get_inst('amarisoftenb')
return self._bin_prefix
def cleanup(self):
@ -98,7 +98,7 @@ class AmarisoftENB(enb.eNodeB):
def start(self, epc):
self.log('Starting AmarisoftENB')
self._epc = epc
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
self._start()
@ -119,7 +119,7 @@ class AmarisoftENB(enb.eNodeB):
args = (remote_binary, self.remote_config_file)
self.process = self.rem_host.RemoteProcess(AmarisoftENB.BINFILE, args, remote_env=remote_env)
self.suite_run.remember_to_stop(self.process)
self.testenv.remember_to_stop(self.process)
self.process.launch()
def gen_conf_file(self, path, filename, values):

@ -46,8 +46,8 @@ class srsENB(enb.eNodeB):
LOGFILE = 'srsenb.log'
PCAPFILE = 'srsenb.pcap'
def __init__(self, suite_run, conf):
super().__init__(suite_run, conf, srsENB.BINFILE)
def __init__(self, testenv, conf):
super().__init__(testenv, conf, srsENB.BINFILE)
self.ue = None
self.run_dir = None
self.gen_conf = None
@ -66,7 +66,7 @@ class srsENB(enb.eNodeB):
self.remote_log_file = None
self.remote_pcap_file = None
self.enable_pcap = False
self.suite_run = suite_run
self.testenv = testenv
self.remote_user = conf.get('remote_user', None)
self._additional_args = []
if not rf_type_valid(conf.get('rf_dev_type', None)):
@ -94,7 +94,7 @@ class srsENB(enb.eNodeB):
def start(self, epc):
self.log('Starting srsENB')
self._epc = epc
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
if self.remote_user:
self.start_remotely()
@ -112,7 +112,7 @@ class srsENB(enb.eNodeB):
args += tuple(self._additional_args)
self.process = self.rem_host.RemoteProcess(srsENB.BINFILE, args, remote_env=remote_env)
self.suite_run.remember_to_stop(self.process)
self.testenv.remember_to_stop(self.process)
self.process.launch()
def start_locally(self):
@ -123,7 +123,7 @@ class srsENB(enb.eNodeB):
args += tuple(self._additional_args)
self.process = process.Process(self.name(), self.run_dir, args, env=env)
self.suite_run.remember_to_stop(self.process)
self.testenv.remember_to_stop(self.process)
self.process.launch()
def gen_conf_file(self, path, filename, values):
@ -135,7 +135,7 @@ class srsENB(enb.eNodeB):
f.write(r)
def configure(self):
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('srslte')))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('srslte')))
if not os.path.isdir(self.inst.child('lib')):
raise log.Error('No lib/ in', self.inst)
if not self.inst.isfile('bin', srsENB.BINFILE):

@ -33,20 +33,20 @@ class EPC(log.Origin, metaclass=ABCMeta):
##############
# PROTECTED
##############
def __init__(self, suite_run, run_node, name):
def __init__(self, testenv, run_node, name):
super().__init__(log.C_RUN, '%s' % name)
self._addr = run_node.run_addr()
self.set_name('%s_%s' % (name, self._addr))
self.suite_run = suite_run
self.testenv = testenv
self._run_node = run_node
def configure(self, config_specifics_li):
values = dict(epc=config.get_defaults('epc'))
for config_specifics in config_specifics_li:
config.overlay(values, dict(epc=config.get_defaults(config_specifics)))
config.overlay(values, dict(epc=self.suite_run.config().get('epc', {})))
config.overlay(values, dict(epc=self.testenv.suite().config().get('epc', {})))
for config_specifics in config_specifics_li:
config.overlay(values, dict(epc=self.suite_run.config().get(config_specifics, {})))
config.overlay(values, dict(epc=self.testenv.suite().config().get(config_specifics, {})))
config.overlay(values, dict(epc={'run_addr': self.addr()}))
return values
@ -57,10 +57,10 @@ class EPC(log.Origin, metaclass=ABCMeta):
'Nothing to do by default. Subclass can override if required.'
pass
def get_instance_by_type(suite_run, run_node):
def get_instance_by_type(testenv, run_node):
"""Allocate a EPC child class based on type. Opts are passed to the newly created object."""
values = dict(epc=config.get_defaults('epc'))
config.overlay(values, dict(epc=suite_run.config().get('epc', {})))
config.overlay(values, dict(epc=testenv.suite().config().get('epc', {})))
epc_type = values['epc'].get('type', None)
if epc_type is None:
raise RuntimeError('EPC type is not defined!')
@ -74,7 +74,7 @@ class EPC(log.Origin, metaclass=ABCMeta):
else:
raise log.Error('EPC type not supported:', epc_type)
return epc_class(suite_run, run_node)
return epc_class(testenv, run_node)
###################
# PUBLIC (test API included)

@ -38,8 +38,8 @@ class AmarisoftEPC(epc.EPC):
LOGFILE = 'ltemme.log'
IFUPFILE = 'mme-ifup'
def __init__(self, suite_run, run_node):
super().__init__(suite_run, run_node, 'amarisoftepc')
def __init__(self, testenv, run_node):
super().__init__(testenv, run_node, 'amarisoftepc')
self.run_dir = None
self.config_file = None
self.log_file = None
@ -58,7 +58,7 @@ class AmarisoftEPC(epc.EPC):
if self._bin_prefix is None:
self._bin_prefix = os.getenv('AMARISOFT_PATH_EPC', None)
if self._bin_prefix == None:
self._bin_prefix = self.suite_run.trial.get_inst('amarisoftepc')
self._bin_prefix = self.testenv.suite().trial().get_inst('amarisoftepc')
return self._bin_prefix
def cleanup(self):
@ -74,7 +74,7 @@ class AmarisoftEPC(epc.EPC):
def start(self):
self.log('Starting amarisoftepc')
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
if self._run_node.is_local():
self.start_locally()
@ -94,7 +94,7 @@ class AmarisoftEPC(epc.EPC):
self.process = self.rem_host.RemoteProcess(AmarisoftEPC.BINFILE, args)
#self.process = self.rem_host.RemoteProcessFixIgnoreSIGHUP(AmarisoftEPC.BINFILE, remote_run_dir, args)
self.suite_run.remember_to_stop(self.process)
self.testenv.remember_to_stop(self.process)
self.process.launch()
def start_locally(self):
@ -112,7 +112,7 @@ class AmarisoftEPC(epc.EPC):
args = (binary, os.path.abspath(self.config_file))
self.process = process.Process(self.name(), self.run_dir, args, env=env)
self.suite_run.remember_to_stop(self.process)
self.testenv.remember_to_stop(self.process)
self.process.launch()
def configure(self):
@ -168,7 +168,7 @@ class AmarisoftEPC(epc.EPC):
def subscriber_add(self, modem, msisdn=None, algo_str=None):
if msisdn is None:
msisdn = self.suite_run.resources_pool.next_msisdn(modem)
msisdn = self.testenv.msisdn()
modem.set_msisdn(msisdn)
if algo_str is None:

@ -39,8 +39,8 @@ class srsEPC(epc.EPC):
PCAPFILE = 'srsepc.pcap'
LOGFILE = 'srsepc.log'
def __init__(self, suite_run, run_node):
super().__init__(suite_run, run_node, 'srsepc')
def __init__(self, testenv, run_node):
super().__init__(testenv, run_node, 'srsepc')
self.run_dir = None
self.config_file = None
self.db_file = None
@ -74,7 +74,7 @@ class srsEPC(epc.EPC):
def start(self):
self.log('Starting srsepc')
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.run_dir = util.Dir(self.testenv.suite().get_run_dir().new_dir(self.name()))
self.configure()
if self._run_node.is_local():
self.start_locally()
@ -95,7 +95,7 @@ class srsEPC(epc.EPC):
args = (remote_binary, self.remote_config_file)
self.process = self.rem_host.RemoteProcess(srsEPC.BINFILE, args)
self.suite_run.remember_to_stop(self.process)
self.testenv.remember_to_stop(self.process)
self.process.launch()
def start_locally(self):
@ -114,11 +114,11 @@ class srsEPC(epc.EPC):
args = (binary, os.path.abspath(self.config_file))
self.process = process.Process(self.name(), self.run_dir, args, env=env)
self.suite_run.remember_to_stop(self.process)
self.testenv.remember_to_stop(self.process)
self.process.launch()
def configure(self):
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('srslte')))
self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('srslte')))
if not os.path.isdir(self.inst.child('lib')):
raise log.Error('No lib/ in', self.inst)
if not self.inst.isfile('bin', srsEPC.BINFILE):
@ -180,7 +180,7 @@ class srsEPC(epc.EPC):
def subscriber_add(self, modem, msisdn=None, algo_str=None):
if msisdn is None:
msisdn = self.suite_run.resources_pool.next_msisdn(modem)
msisdn = self.testenv.msisdn()
modem.set_msisdn(msisdn)
if algo_str is None: