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

Change-Id: Idf41243a497de7bc507b9f1cd1b38640f456f815
This commit is contained in:
Pau Espin 2020-05-05 12:54:37 +02:00
parent f574a46b37
commit a442cb8e5f
39 changed files with 282 additions and 288 deletions

View File

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

View File

@ -58,7 +58,7 @@ class Test(log.Origin):
testenv_obj = None testenv_obj = None
try: try:
self.log_target = log.FileLogTarget(self.get_run_dir().new_child('log')).set_all_levels(log.L_DBG).style_change(trace=True) 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.status = Test.UNKNOWN
self.start_timestamp = time.time() self.start_timestamp = time.time()
testenv_obj = testenv.setup(self.suite_run, self) testenv_obj = testenv.setup(self.suite_run, self)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,8 +45,8 @@ class AmarisoftENB(enb.eNodeB):
CFGFILE_DRB = 'amarisoft_drb.cfg' CFGFILE_DRB = 'amarisoft_drb.cfg'
LOGFILE = 'lteenb.log' LOGFILE = 'lteenb.log'
def __init__(self, suite_run, conf): def __init__(self, testenv, conf):
super().__init__(suite_run, conf, 'amarisoftenb') super().__init__(testenv, conf, 'amarisoftenb')
self.ue = None self.ue = None
self.run_dir = None self.run_dir = None
self.inst = None self.inst = None
@ -68,7 +68,7 @@ class AmarisoftENB(enb.eNodeB):
self.remote_config_drb_file = None self.remote_config_drb_file = None
self.remote_log_file = None self.remote_log_file = None
self.enable_measurements = False self.enable_measurements = False
self.suite_run = suite_run self.testenv = testenv
self.remote_user = conf.get('remote_user', None) self.remote_user = conf.get('remote_user', None)
if not rf_type_valid(conf.get('rf_dev_type', 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)) 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: if self._bin_prefix is None:
self._bin_prefix = os.getenv('AMARISOFT_PATH_ENB', None) self._bin_prefix = os.getenv('AMARISOFT_PATH_ENB', None)
if self._bin_prefix == 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 return self._bin_prefix
def cleanup(self): def cleanup(self):
@ -98,7 +98,7 @@ class AmarisoftENB(enb.eNodeB):
def start(self, epc): def start(self, epc):
self.log('Starting AmarisoftENB') self.log('Starting AmarisoftENB')
self._epc = epc 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.configure()
self._start() self._start()
@ -119,7 +119,7 @@ class AmarisoftENB(enb.eNodeB):
args = (remote_binary, self.remote_config_file) args = (remote_binary, self.remote_config_file)
self.process = self.rem_host.RemoteProcess(AmarisoftENB.BINFILE, args, remote_env=remote_env) 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() self.process.launch()
def gen_conf_file(self, path, filename, values): def gen_conf_file(self, path, filename, values):

View File

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

View File

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

View File

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

View File

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

View File

@ -25,20 +25,20 @@ from . import pcap_recorder
class OsmoGgsn(log.Origin): class OsmoGgsn(log.Origin):
def __init__(self, suite_run, ip_address): def __init__(self, testenv, ip_address):
super().__init__(log.C_RUN, 'osmo-ggsn_%s' % ip_address.get('addr')) super().__init__(log.C_RUN, 'osmo-ggsn_%s' % ip_address.get('addr'))
self.run_dir = None self.run_dir = None
self.config_file = None self.config_file = None
self.process = None self.process = None
self.suite_run = suite_run self.testenv = testenv
self.ip_address = ip_address self.ip_address = ip_address
def start(self): def start(self):
self.log('Starting osmo-ggsn') self.log('Starting osmo-ggsn')
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.configure()
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-ggsn'))) inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-ggsn')))
binary = inst.child('bin', 'osmo-ggsn') binary = inst.child('bin', 'osmo-ggsn')
if not os.path.isfile(binary): if not os.path.isfile(binary):
@ -47,7 +47,7 @@ class OsmoGgsn(log.Origin):
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise log.Error('No lib/ in', inst) raise log.Error('No lib/ in', inst)
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,
'host %s' % self.addr()) 'host %s' % self.addr())
env = {} env = {}
@ -64,7 +64,7 @@ class OsmoGgsn(log.Origin):
(binary, (binary,
'-c', os.path.abspath(self.config_file)), '-c', os.path.abspath(self.config_file)),
env=env) env=env)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def configure(self): def configure(self):
@ -72,7 +72,7 @@ class OsmoGgsn(log.Origin):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = dict(ggsn=config.get_defaults('ggsn')) values = dict(ggsn=config.get_defaults('ggsn'))
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, dict(ggsn=dict(ip_address=self.ip_address))) config.overlay(values, dict(ggsn=dict(ip_address=self.ip_address)))
config.overlay(values, dict(ggsn=dict(statedir=self.run_dir.new_dir('statedir')))) config.overlay(values, dict(ggsn=dict(statedir=self.run_dir.new_dir('statedir'))))

View File

@ -30,21 +30,21 @@ class OsmoHlr(log.Origin):
process = None process = None
next_subscriber_id = 1 next_subscriber_id = 1
def __init__(self, suite_run, ip_address): def __init__(self, testenv, ip_address):
super().__init__(log.C_RUN, 'osmo-hlr_%s' % ip_address.get('addr')) super().__init__(log.C_RUN, 'osmo-hlr_%s' % ip_address.get('addr'))
self.run_dir = None self.run_dir = None
self.config_file = None self.config_file = None
self.process = None self.process = None
self.next_subscriber_id = 1 self.next_subscriber_id = 1
self.suite_run = suite_run self.testenv = testenv
self.ip_address = ip_address self.ip_address = ip_address
def start(self): def start(self):
self.log('Starting osmo-hlr') self.log('Starting osmo-hlr')
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.configure()
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-hlr'))) inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-hlr')))
binary = inst.child('bin', 'osmo-hlr') binary = inst.child('bin', 'osmo-hlr')
if not os.path.isfile(binary): if not os.path.isfile(binary):
@ -60,7 +60,7 @@ class OsmoHlr(log.Origin):
raise log.Error('hlr.sql missing:', sql_input) raise log.Error('hlr.sql missing:', sql_input)
self.run_local('create_hlr_db', ('/bin/sh', '-c', 'sqlite3 %r < %r' % (self.db_file, sql_input))) self.run_local('create_hlr_db', ('/bin/sh', '-c', 'sqlite3 %r < %r' % (self.db_file, sql_input)))
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,
'host %s' % self.addr()) 'host %s' % self.addr())
env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) } env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
@ -71,7 +71,7 @@ class OsmoHlr(log.Origin):
'-c', os.path.abspath(self.config_file), '-c', os.path.abspath(self.config_file),
'--database', self.db_file), '--database', self.db_file),
env=env) env=env)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def configure(self): def configure(self):
@ -79,7 +79,7 @@ class OsmoHlr(log.Origin):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = dict(hlr=config.get_defaults('hlr')) values = dict(hlr=config.get_defaults('hlr'))
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, dict(hlr=dict(ip_address=self.ip_address))) config.overlay(values, dict(hlr=dict(ip_address=self.ip_address)))
self.dbg('HLR CONFIG:\n' + pprint.pformat(values)) self.dbg('HLR CONFIG:\n' + pprint.pformat(values))
@ -106,7 +106,7 @@ class OsmoHlr(log.Origin):
def subscriber_add(self, modem, msisdn=None, algo_str=None): def subscriber_add(self, modem, msisdn=None, algo_str=None):
if msisdn is None: if msisdn is None:
msisdn = self.suite_run.resources_pool.next_msisdn(modem) msisdn = self.testenv.msisdn()
modem.set_msisdn(msisdn) modem.set_msisdn(msisdn)
subscriber_id = self.next_subscriber_id subscriber_id = self.next_subscriber_id
self.next_subscriber_id += 1 self.next_subscriber_id += 1

View File

@ -52,12 +52,12 @@ class IPerf3Server(log.Origin):
LOGFILE = 'iperf3_srv.json' LOGFILE = 'iperf3_srv.json'
REMOTE_DIR = '/tmp' REMOTE_DIR = '/tmp'
def __init__(self, suite_run, ip_address): def __init__(self, testenv, ip_address):
super().__init__(log.C_RUN, 'iperf3-srv_%s' % ip_address.get('addr')) super().__init__(log.C_RUN, 'iperf3-srv_%s' % ip_address.get('addr'))
self.run_dir = None self.run_dir = None
self.process = None self.process = None
self._run_node = None self._run_node = None
self.suite_run = suite_run self.testenv = testenv
self.ip_address = ip_address self.ip_address = ip_address
self._port = IPerf3Server.DEFAULT_SRV_PORT self._port = IPerf3Server.DEFAULT_SRV_PORT
self.log_file = None self.log_file = None
@ -84,7 +84,7 @@ class IPerf3Server(log.Origin):
def start(self): def start(self):
self.log('Starting iperf3-srv') self.log('Starting iperf3-srv')
self.log_copied = False self.log_copied = False
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.log_file = self.run_dir.new_file(IPerf3Server.LOGFILE) self.log_file = self.run_dir.new_file(IPerf3Server.LOGFILE)
if self.runs_locally(): if self.runs_locally():
self.start_locally() self.start_locally()
@ -105,11 +105,11 @@ class IPerf3Server(log.Origin):
args += ('--logfile', self.remote_log_file,) args += ('--logfile', self.remote_log_file,)
self.process = self.rem_host.RemoteProcess(self.name(), args) self.process = self.rem_host.RemoteProcess(self.name(), args)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def start_locally(self): def start_locally(self):
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,
'host %s and port not 22' % self.addr()) 'host %s and port not 22' % self.addr())
args = ('iperf3', '-s', '-B', self.addr(), args = ('iperf3', '-s', '-B', self.addr(),
@ -118,7 +118,7 @@ class IPerf3Server(log.Origin):
args += ('--logfile', os.path.abspath(self.log_file),) args += ('--logfile', os.path.abspath(self.log_file),)
self.process = process.Process(self.name(), self.run_dir, args, env={}) self.process = process.Process(self.name(), self.run_dir, args, env={})
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def set_run_node(self, run_node): def set_run_node(self, run_node):
@ -128,7 +128,7 @@ class IPerf3Server(log.Origin):
self._port = port self._port = port
def stop(self): def stop(self):
self.suite_run.stop_process(self.process) self.testenv.stop_process(self.process)
def get_results(self): def get_results(self):
if self.logfile_supported: if self.logfile_supported:
@ -153,20 +153,20 @@ class IPerf3Server(log.Origin):
return not self.process.terminated() return not self.process.terminated()
def create_client(self): def create_client(self):
return IPerf3Client(self.suite_run, self) return IPerf3Client(self.testenv, self)
class IPerf3Client(log.Origin): class IPerf3Client(log.Origin):
REMOTE_DIR = '/tmp' REMOTE_DIR = '/tmp'
LOGFILE = 'iperf3_cli.json' LOGFILE = 'iperf3_cli.json'
def __init__(self, suite_run, iperf3srv): def __init__(self, testenv, iperf3srv):
super().__init__(log.C_RUN, 'iperf3-cli_%s' % iperf3srv.addr()) super().__init__(log.C_RUN, 'iperf3-cli_%s' % iperf3srv.addr())
self.run_dir = None self.run_dir = None
self.process = None self.process = None
self._run_node = None self._run_node = None
self.server = iperf3srv self.server = iperf3srv
self.suite_run = suite_run self.testenv = testenv
self.log_file = None self.log_file = None
self.rem_host = None self.rem_host = None
self.remote_log_file = None self.remote_log_file = None
@ -180,7 +180,7 @@ class IPerf3Client(log.Origin):
def prepare_test_proc(self, downlink=False, netns=None, time_sec=None): def prepare_test_proc(self, downlink=False, netns=None, time_sec=None):
if time_sec is None: if time_sec is None:
values = config.get_defaults('iperf3cli') values = config.get_defaults('iperf3cli')
config.overlay(values, self.suite_run.config().get('iperf3cli', {})) config.overlay(values, self.testenv.suite().config().get('iperf3cli', {}))
time_sec_str = values.get('time', time_sec) time_sec_str = values.get('time', time_sec)
# Convert duration to seconds # Convert duration to seconds
@ -195,7 +195,7 @@ class IPerf3Client(log.Origin):
self.log('Preparing iperf3-client connecting to %s:%d (time=%ds)' % (self.server.addr(), self.server.port(), time_sec)) self.log('Preparing iperf3-client connecting to %s:%d (time=%ds)' % (self.server.addr(), self.server.port(), time_sec))
self.log_copied = False self.log_copied = False
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.log_file = self.run_dir.new_file(IPerf3Client.LOGFILE) self.log_file = self.run_dir.new_file(IPerf3Client.LOGFILE)
if self.runs_locally(): if self.runs_locally():
return self.prepare_test_proc_locally(downlink, netns, time_sec) return self.prepare_test_proc_locally(downlink, netns, time_sec)
@ -226,7 +226,7 @@ class IPerf3Client(log.Origin):
return self.process return self.process
def prepare_test_proc_locally(self, downlink, netns, time_sec): def prepare_test_proc_locally(self, downlink, netns, time_sec):
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,
'host %s and port not 22' % self.server.addr(), netns) 'host %s and port not 22' % self.server.addr(), netns)
popen_args = ('iperf3', '-c', self.server.addr(), popen_args = ('iperf3', '-c', self.server.addr(),

View File

@ -25,21 +25,21 @@ from . import pcap_recorder
class OsmoMgcpgw(log.Origin): class OsmoMgcpgw(log.Origin):
def __init__(self, suite_run, ip_address, bts_ip): def __init__(self, testenv, ip_address, bts_ip):
super().__init__(log.C_RUN, 'osmo-mgcpgw_%s' % ip_address.get('addr')) super().__init__(log.C_RUN, 'osmo-mgcpgw_%s' % ip_address.get('addr'))
self.run_dir = None self.run_dir = None
self.config_file = None self.config_file = None
self.process = None self.process = None
self.suite_run = suite_run self.testenv = testenv
self.ip_address = ip_address self.ip_address = ip_address
# hack: so far mgcpgw needs one specific BTS IP. # hack: so far mgcpgw needs one specific BTS IP.
self.bts_ip = bts_ip self.bts_ip = bts_ip
def start(self): def start(self):
self.log('Starting osmo-mgcpgw') self.log('Starting osmo-mgcpgw')
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.configure()
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-nitb'))) inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-nitb')))
binary = inst.child('bin', 'osmo-bsc_mgcp') binary = inst.child('bin', 'osmo-bsc_mgcp')
if not os.path.isfile(binary): if not os.path.isfile(binary):
raise RuntimeError('Binary missing: %r' % binary) raise RuntimeError('Binary missing: %r' % binary)
@ -47,7 +47,7 @@ class OsmoMgcpgw(log.Origin):
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise RuntimeError('No lib/ in %r' % inst) raise RuntimeError('No lib/ in %r' % inst)
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,
'host %s and port not 22' % self.addr()) 'host %s and port not 22' % self.addr())
env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) } env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
@ -57,7 +57,7 @@ class OsmoMgcpgw(log.Origin):
(binary, '-c', (binary, '-c',
os.path.abspath(self.config_file)), os.path.abspath(self.config_file)),
env=env) env=env)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def configure(self): def configure(self):
@ -65,7 +65,7 @@ class OsmoMgcpgw(log.Origin):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = dict(mgcpgw=config.get_defaults('mgcpgw')) values = dict(mgcpgw=config.get_defaults('mgcpgw'))
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, dict(mgcpgw=dict(ip_address=self.ip_address, bts_ip=self.bts_ip))) config.overlay(values, dict(mgcpgw=dict(ip_address=self.ip_address, bts_ip=self.bts_ip)))
self.dbg('MGCPGW CONFIG:\n' + pprint.pformat(values)) self.dbg('MGCPGW CONFIG:\n' + pprint.pformat(values))

View File

@ -25,20 +25,20 @@ from . import pcap_recorder
class OsmoMgw(log.Origin): class OsmoMgw(log.Origin):
def __init__(self, suite_run, ip_address): def __init__(self, testenv, ip_address):
super().__init__(log.C_RUN, 'osmo-mgw_%s' % ip_address.get('addr')) super().__init__(log.C_RUN, 'osmo-mgw_%s' % ip_address.get('addr'))
self.run_dir = None self.run_dir = None
self.config_file = None self.config_file = None
self.process = None self.process = None
self.suite_run = suite_run self.testenv = testenv
self.ip_address = ip_address self.ip_address = ip_address
self.use_osmux = "off" self.use_osmux = "off"
def start(self): def start(self):
self.log('Starting osmo-mgw') self.log('Starting osmo-mgw')
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.configure()
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-mgw'))) inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-mgw')))
binary = inst.child('bin', 'osmo-mgw') binary = inst.child('bin', 'osmo-mgw')
if not os.path.isfile(binary): if not os.path.isfile(binary):
raise RuntimeError('Binary missing: %r' % binary) raise RuntimeError('Binary missing: %r' % binary)
@ -46,7 +46,7 @@ class OsmoMgw(log.Origin):
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise RuntimeError('No lib/ in %r' % inst) raise RuntimeError('No lib/ in %r' % inst)
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,
'host %s and port not 22' % self.addr()) 'host %s and port not 22' % self.addr())
env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) } env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
@ -56,7 +56,7 @@ class OsmoMgw(log.Origin):
(binary, '-c', (binary, '-c',
os.path.abspath(self.config_file)), os.path.abspath(self.config_file)),
env=env) env=env)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def configure(self): def configure(self):
@ -64,7 +64,7 @@ class OsmoMgw(log.Origin):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = dict(mgw=config.get_defaults('mgw')) values = dict(mgw=config.get_defaults('mgw'))
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, { 'mgw': { config.overlay(values, { 'mgw': {
'ip_address': self.ip_address, 'ip_address': self.ip_address,
'use_osmux': self.use_osmux 'use_osmux': self.use_osmux

View File

@ -54,7 +54,7 @@ class MS(log.Origin, metaclass=ABCMeta):
"""Cleans up resources allocated.""" """Cleans up resources allocated."""
pass pass
def get_instance_by_type(suite_run, conf): def get_instance_by_type(testenv, conf):
"""Allocate a MS child class based on type. Opts are passed to the newly created object.""" """Allocate a MS child class based on type. Opts are passed to the newly created object."""
ms_type = conf.get('type') ms_type = conf.get('type')
if ms_type is None: if ms_type is None:
@ -75,7 +75,7 @@ class MS(log.Origin, metaclass=ABCMeta):
ms_class = AmarisoftUE ms_class = AmarisoftUE
else: else:
raise log.Error('MS type not supported:', ms_type) raise log.Error('MS type not supported:', ms_type)
return ms_class(suite_run, conf) return ms_class(testenv, conf)
################### ###################
# PUBLIC (test API included) # PUBLIC (test API included)

View File

@ -78,7 +78,7 @@ class AmarisoftUE(MS):
LOGFILE = 'lteue.log' LOGFILE = 'lteue.log'
IFUPFILE = 'ue-ifup' IFUPFILE = 'ue-ifup'
def __init__(self, suite_run, conf): def __init__(self, testenv, conf):
self._addr = conf.get('addr', None) self._addr = conf.get('addr', None)
if self._addr is None: if self._addr is None:
raise log.Error('addr not set') raise log.Error('addr not set')
@ -98,7 +98,7 @@ class AmarisoftUE(MS):
self.remote_config_rf_file = None self.remote_config_rf_file = None
self.remote_log_file = None self.remote_log_file = None
self.remote_ifup_file = None self.remote_ifup_file = None
self.suite_run = suite_run self.testenv = testenv
self.remote_user = conf.get('remote_user', None) self.remote_user = conf.get('remote_user', None)
if not rf_type_valid(conf.get('rf_dev_type', 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)) raise log.Error('Invalid rf_dev_type=%s' % conf.get('rf_dev_type', None))
@ -107,7 +107,7 @@ class AmarisoftUE(MS):
if self._bin_prefix is None: if self._bin_prefix is None:
self._bin_prefix = os.getenv('AMARISOFT_PATH_UE', None) self._bin_prefix = os.getenv('AMARISOFT_PATH_UE', None)
if self._bin_prefix == None: if self._bin_prefix == None:
self._bin_prefix = self.suite_run.trial.get_inst('amarisoftue') self._bin_prefix = self.testenv.suite().trial().get_inst('amarisoftue')
return self._bin_prefix return self._bin_prefix
def cleanup(self): def cleanup(self):
@ -128,12 +128,12 @@ class AmarisoftUE(MS):
return "amarisoftue1" return "amarisoftue1"
def stop(self): def stop(self):
self.suite_run.stop_process(self.process) self.testenv.stop_process(self.process)
def connect(self, enb): def connect(self, enb):
self.log('Starting amarisoftue') self.log('Starting amarisoftue')
self.enb = enb self.enb = enb
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.configure()
if self.setup_runs_locally(): if self.setup_runs_locally():
self.start_locally() self.start_locally()
@ -161,7 +161,7 @@ class AmarisoftUE(MS):
args = (remote_binary, self.remote_config_file) args = (remote_binary, self.remote_config_file)
self.process = self.rem_host.RemoteProcess(AmarisoftUE.BINFILE, args) self.process = self.rem_host.RemoteProcess(AmarisoftUE.BINFILE, args)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def start_locally(self): def start_locally(self):
@ -182,7 +182,7 @@ class AmarisoftUE(MS):
args = (binary, os.path.abspath(self.config_file)) args = (binary, os.path.abspath(self.config_file))
self.dbg(run_dir=self.run_dir, binary=binary, env=env) self.dbg(run_dir=self.run_dir, binary=binary, env=env)
self.process = process.Process(self.name(), self.run_dir, args, env=env) 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() self.process.launch()
def gen_conf_file(self, path, filename, values): def gen_conf_file(self, path, filename, values):
@ -232,8 +232,8 @@ class AmarisoftUE(MS):
values = dict(ue=config.get_defaults('amarisoft')) values = dict(ue=config.get_defaults('amarisoft'))
config.overlay(values, dict(ue=config.get_defaults('amarisoftue'))) config.overlay(values, dict(ue=config.get_defaults('amarisoftue')))
config.overlay(values, dict(ue=self.suite_run.config().get('amarisoft', {}))) config.overlay(values, dict(ue=self.testenv.suite().config().get('amarisoft', {})))
config.overlay(values, dict(ue=self.suite_run.config().get('modem', {}))) config.overlay(values, dict(ue=self.testenv.suite().config().get('modem', {})))
config.overlay(values, dict(ue=self._conf)) config.overlay(values, dict(ue=self._conf))
config.overlay(values, dict(ue=dict(num_antennas = self.enb.num_ports()))) config.overlay(values, dict(ue=dict(num_antennas = self.enb.num_ports())))

View File

@ -30,9 +30,9 @@ import tempfile
class MsDriver(log.Origin): class MsDriver(log.Origin):
def __init__(self, suite_run): def __init__(self, testenv):
super().__init__(log.C_RUN, 'ms-driver') super().__init__(log.C_RUN, 'ms-driver')
self._suite_run = suite_run self._testenv = testenv
# TODO: take config out of the test scenario # TODO: take config out of the test scenario
self._time_start = timedelta(seconds=60) self._time_start = timedelta(seconds=60)
@ -67,7 +67,7 @@ class MsDriver(log.Origin):
""" """
# Get the base directory for the virtphy/mobile application # Get the base directory for the virtphy/mobile application
inst = util.Dir(os.path.abspath(self._suite_run.trial.get_inst('osmocom-bb'))) inst = util.Dir(os.path.abspath(self._testenv.trial.get_inst('osmocom-bb')))
# Assume these are dynamically linked and verify there is a lib dir. # Assume these are dynamically linked and verify there is a lib dir.
lib = inst.child('lib') lib = inst.child('lib')
@ -117,7 +117,7 @@ class MsDriver(log.Origin):
self._starter = MobileTestStarter("mass", options, self._cdf, self._starter = MobileTestStarter("mass", options, self._cdf,
self._ev_server, self._ev_server,
util.Dir(self.event_server_sk_tmp_dir), util.Dir(self.event_server_sk_tmp_dir),
self._results, suite_run=self._suite_run) self._results, testenv=self._testenv)
for sub in self._subscribers: for sub in self._subscribers:
self._starter.subscriber_add(sub) self._starter.subscriber_add(sub)

View File

@ -361,7 +361,7 @@ class Modem(MS):
CTX_PROT_IPv6 = 'ipv6' CTX_PROT_IPv6 = 'ipv6'
CTX_PROT_IPv46 = 'dual' CTX_PROT_IPv46 = 'dual'
def __init__(self, suite_run, conf): def __init__(self, testenv, conf):
self.syspath = conf.get('path') self.syspath = conf.get('path')
self.dbuspath = get_dbuspath_from_syspath(self.syspath) self.dbuspath = get_dbuspath_from_syspath(self.syspath)
super().__init__(self.dbuspath, conf) super().__init__(self.dbuspath, conf)
@ -369,7 +369,7 @@ class Modem(MS):
self._ki = None self._ki = None
self._imsi = None self._imsi = None
self._apn_ipaddr = None self._apn_ipaddr = None
self.run_dir = util.Dir(suite_run.get_test_run_dir().new_dir(self.name().strip('/'))) self.run_dir = util.Dir(testenv.suite().get_run_dir().new_dir(self.name().strip('/')))
self.sms_received_list = [] self.sms_received_list = []
self.dbus = ModemDbusInteraction(self.dbuspath) self.dbus = ModemDbusInteraction(self.dbuspath)
self.register_attempts = 0 self.register_attempts = 0

View File

@ -77,7 +77,7 @@ class srsUE(MS):
LOGFILE = 'srsue.log' LOGFILE = 'srsue.log'
METRICSFILE = 'srsue_metrics.csv' METRICSFILE = 'srsue_metrics.csv'
def __init__(self, suite_run, conf): def __init__(self, testenv, conf):
self._addr = conf.get('addr', None) self._addr = conf.get('addr', None)
if self._addr is None: if self._addr is None:
raise log.Error('addr not set') raise log.Error('addr not set')
@ -97,7 +97,7 @@ class srsUE(MS):
self.remote_metrics_file = None self.remote_metrics_file = None
self.enable_pcap = False self.enable_pcap = False
self.num_carriers = 1 self.num_carriers = 1
self.suite_run = suite_run self.testenv = testenv
self.remote_user = conf.get('remote_user', None) self.remote_user = conf.get('remote_user', None)
self._additional_args = [] self._additional_args = []
if not rf_type_valid(conf.get('rf_dev_type', None)): if not rf_type_valid(conf.get('rf_dev_type', None)):
@ -132,12 +132,12 @@ class srsUE(MS):
return "srsue1" return "srsue1"
def stop(self): def stop(self):
self.suite_run.stop_process(self.process) self.testenv.stop_process(self.process)
def connect(self, enb): def connect(self, enb):
self.log('Starting srsue') self.log('Starting srsue')
self.enb = enb self.enb = enb
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.configure()
if self.setup_runs_locally(): if self.setup_runs_locally():
self.start_locally() self.start_locally()
@ -170,7 +170,7 @@ class srsUE(MS):
self.process = self.rem_host.RemoteProcess(srsUE.BINFILE, args) self.process = self.rem_host.RemoteProcess(srsUE.BINFILE, args)
#self.process = self.rem_host.RemoteProcessFixIgnoreSIGHUP(srsUE.BINFILE, remote_run_dir, args, remote_lib) #self.process = self.rem_host.RemoteProcessFixIgnoreSIGHUP(srsUE.BINFILE, remote_run_dir, args, remote_lib)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def start_locally(self): def start_locally(self):
@ -194,11 +194,11 @@ class srsUE(MS):
args += tuple(self._additional_args) args += tuple(self._additional_args)
self.process = process.Process(self.name(), self.run_dir, args, env=env) 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() self.process.launch()
def configure(self): 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')): if not os.path.isdir(self.inst.child('lib')):
raise log.Error('No lib/ in', self.inst) raise log.Error('No lib/ in', self.inst)
if not self.inst.isfile('bin', srsUE.BINFILE): if not self.inst.isfile('bin', srsUE.BINFILE):
@ -220,7 +220,7 @@ class srsUE(MS):
self.remote_metrics_file = remote_run_dir.child(srsUE.METRICSFILE) self.remote_metrics_file = remote_run_dir.child(srsUE.METRICSFILE)
values = dict(ue=config.get_defaults('srsue')) values = dict(ue=config.get_defaults('srsue'))
config.overlay(values, dict(ue=self.suite_run.config().get('modem', {}))) config.overlay(values, dict(ue=self.testenv.suite().config().get('modem', {})))
config.overlay(values, dict(ue=self._conf)) config.overlay(values, dict(ue=self._conf))
config.overlay(values, dict(ue=dict(num_antennas = self.enb.num_ports()))) config.overlay(values, dict(ue=dict(num_antennas = self.enb.num_ports())))

View File

@ -32,7 +32,7 @@ def on_register_schemas():
class OsmoMsc(log.Origin): class OsmoMsc(log.Origin):
def __init__(self, suite_run, hlr, mgw, stp, ip_address): def __init__(self, testenv, hlr, mgw, stp, ip_address):
super().__init__(log.C_RUN, 'osmo-msc_%s' % ip_address.get('addr')) super().__init__(log.C_RUN, 'osmo-msc_%s' % ip_address.get('addr'))
self.run_dir = None self.run_dir = None
self.config_file = None self.config_file = None
@ -41,7 +41,7 @@ class OsmoMsc(log.Origin):
self.encryption = None self.encryption = None
self.authentication = None self.authentication = None
self.use_osmux = "off" self.use_osmux = "off"
self.suite_run = suite_run self.testenv = testenv
self.ip_address = ip_address self.ip_address = ip_address
self.hlr = hlr self.hlr = hlr
self.mgw = mgw self.mgw = mgw
@ -50,9 +50,9 @@ class OsmoMsc(log.Origin):
def start(self): def start(self):
self.log('Starting osmo-msc') self.log('Starting osmo-msc')
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.configure()
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-msc'))) inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-msc')))
binary = inst.child('bin', 'osmo-msc') binary = inst.child('bin', 'osmo-msc')
if not os.path.isfile(binary): if not os.path.isfile(binary):
raise RuntimeError('Binary missing: %r' % binary) raise RuntimeError('Binary missing: %r' % binary)
@ -60,7 +60,7 @@ class OsmoMsc(log.Origin):
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise RuntimeError('No lib/ in %r' % inst) raise RuntimeError('No lib/ in %r' % inst)
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,
'host %s and port not 22' % self.addr()) 'host %s and port not 22' % self.addr())
env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) } env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
@ -70,7 +70,7 @@ class OsmoMsc(log.Origin):
(binary, '-c', (binary, '-c',
os.path.abspath(self.config_file)), os.path.abspath(self.config_file)),
env=env) env=env)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def configure(self): def configure(self):
@ -78,7 +78,7 @@ class OsmoMsc(log.Origin):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = dict(msc=config.get_defaults('msc')) values = dict(msc=config.get_defaults('msc'))
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, dict(msc=dict(ip_address=self.ip_address))) config.overlay(values, dict(msc=dict(ip_address=self.ip_address)))
config.overlay(values, self.mgw.conf_for_client()) config.overlay(values, self.mgw.conf_for_client())
config.overlay(values, self.hlr.conf_for_client()) config.overlay(values, self.hlr.conf_for_client())

View File

@ -26,22 +26,22 @@ from . import osmo_ctrl, pcap_recorder, smsc
class OsmoNitb(log.Origin): class OsmoNitb(log.Origin):
def __init__(self, suite_run, ip_address): def __init__(self, testenv, ip_address):
super().__init__(log.C_RUN, 'osmo-nitb_%s' % ip_address.get('addr')) super().__init__(log.C_RUN, 'osmo-nitb_%s' % ip_address.get('addr'))
self.run_dir = None self.run_dir = None
self.config_file = None self.config_file = None
self.process = None self.process = None
self.encryption = None self.encryption = None
self.suite_run = suite_run self.testenv = testenv
self.ip_address = ip_address self.ip_address = ip_address
self.bts = [] self.bts = []
self.smsc = smsc.Smsc((ip_address.get('addr'), 2775)) self.smsc = smsc.Smsc((ip_address.get('addr'), 2775))
def start(self): def start(self):
self.log('Starting osmo-nitb') self.log('Starting osmo-nitb')
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.configure()
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-nitb'))) inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-nitb')))
binary = inst.child('bin', 'osmo-nitb') binary = inst.child('bin', 'osmo-nitb')
if not os.path.isfile(binary): if not os.path.isfile(binary):
raise RuntimeError('Binary missing: %r' % binary) raise RuntimeError('Binary missing: %r' % binary)
@ -49,7 +49,7 @@ class OsmoNitb(log.Origin):
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise RuntimeError('No lib/ in %r' % inst) raise RuntimeError('No lib/ in %r' % inst)
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,
'host %s and port not 22' % self.addr()) 'host %s and port not 22' % self.addr())
env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) } env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
@ -59,7 +59,7 @@ class OsmoNitb(log.Origin):
(binary, '-c', (binary, '-c',
os.path.abspath(self.config_file)), os.path.abspath(self.config_file)),
env=env) env=env)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def configure(self): def configure(self):
@ -67,7 +67,7 @@ class OsmoNitb(log.Origin):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = dict(nitb=config.get_defaults('nitb')) values = dict(nitb=config.get_defaults('nitb'))
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, dict(nitb=dict(ip_address=self.ip_address))) config.overlay(values, dict(nitb=dict(ip_address=self.ip_address)))
bts_list = [] bts_list = []
@ -120,7 +120,7 @@ class OsmoNitb(log.Origin):
def subscriber_add(self, modem, msisdn=None, algo=None): def subscriber_add(self, modem, msisdn=None, algo=None):
if msisdn is None: if msisdn is None:
msisdn = self.suite_run.resources_pool.next_msisdn(modem) msisdn = self.testenv.msisdn()
modem.set_msisdn(msisdn) modem.set_msisdn(msisdn)
if not algo: if not algo:

View File

@ -35,7 +35,7 @@ class Osmocon(log.Origin):
FIRMWARE_FILE="opt/osmocom-bb/target/firmware/board/compal_e88/layer1.compalram.bin" FIRMWARE_FILE="opt/osmocom-bb/target/firmware/board/compal_e88/layer1.compalram.bin"
def __init__(self, suite_run, conf): def __init__(self, testenv, conf):
serial_device = conf.get('serial_device') serial_device = conf.get('serial_device')
if serial_device is None: if serial_device is None:
raise log.Error('osmocon_phone contains no attr "serial_device"') raise log.Error('osmocon_phone contains no attr "serial_device"')
@ -43,7 +43,7 @@ class Osmocon(log.Origin):
super().__init__(log.C_RUN, 'osmocon_%s' % os.path.basename(self.serial_device)) super().__init__(log.C_RUN, 'osmocon_%s' % os.path.basename(self.serial_device))
self.run_dir = None self.run_dir = None
self.process = None self.process = None
self.suite_run = suite_run self.testenv = testenv
self.conf = conf self.conf = conf
self.sk_tmp_dir = tempfile.mkdtemp('', 'ogtosmoconsk') self.sk_tmp_dir = tempfile.mkdtemp('', 'ogtosmoconsk')
if len(self.l2_socket_path().encode()) > 107: if len(self.l2_socket_path().encode()) > 107:
@ -62,9 +62,9 @@ class Osmocon(log.Origin):
# TODO: make sure the pone is powered off before starting osmocon # TODO: make sure the pone is powered off before starting osmocon
self.log('Starting osmocon') self.log('Starting osmocon')
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()))
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmocom-bb'))) inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmocom-bb')))
binary = inst.child('sbin', 'osmocon') binary = inst.child('sbin', 'osmocon')
if not os.path.isfile(binary): if not os.path.isfile(binary):
@ -86,7 +86,7 @@ class Osmocon(log.Origin):
'-l', self.loader_socket_path(), '-l', self.loader_socket_path(),
firmware_path), firmware_path),
env=env) env=env)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
self.log('Waiting for osmocon to be up and running') self.log('Waiting for osmocon to be up and running')
MainLoop.wait(self, os.path.exists, self.l2_socket_path()) MainLoop.wait(self, os.path.exists, self.l2_socket_path())

View File

@ -23,13 +23,13 @@ from ..core import log, process
class PcapRecorder(log.Origin): class PcapRecorder(log.Origin):
def __init__(self, suite_run, run_dir, iface=None, filters='', netns=None): def __init__(self, testenv, run_dir, iface=None, filters='', netns=None):
self.iface = iface self.iface = iface
if not self.iface: if not self.iface:
self.iface = "any" self.iface = "any"
self.filters = filters self.filters = filters
super().__init__(log.C_RUN, 'pcap-recorder_%s' % self.iface, filters=self.filters) super().__init__(log.C_RUN, 'pcap-recorder_%s' % self.iface, filters=self.filters)
self.suite_run = suite_run self.testenv = testenv
self.run_dir = run_dir self.run_dir = run_dir
self.netns = netns self.netns = netns
self.start() self.start()
@ -45,7 +45,7 @@ class PcapRecorder(log.Origin):
self.process = process.NetNSProcess(self.name(), self.run_dir, self.netns, popen_args) self.process = process.NetNSProcess(self.name(), self.run_dir, self.netns, popen_args)
else: else:
self.process = process.Process(self.name(), self.run_dir, popen_args) self.process = process.Process(self.name(), self.run_dir, popen_args)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def running(self): def running(self):

View File

@ -27,10 +27,10 @@ class Pcu(log.Origin, metaclass=ABCMeta):
# PROTECTED # PROTECTED
############## ##############
def __init__(self, suite_run, bts, conf, name): def __init__(self, testenv, bts, conf, name):
"""Base constructor. Must be called by subclass.""" """Base constructor. Must be called by subclass."""
super().__init__(log.C_RUN, name) super().__init__(log.C_RUN, name)
self.suite_run = suite_run self.testenv = testenv
self.bts = bts self.bts = bts
self.conf = conf self.conf = conf
@ -55,8 +55,8 @@ class Pcu(log.Origin, metaclass=ABCMeta):
class PcuDummy(Pcu): class PcuDummy(Pcu):
"""PCU for BTS without proper PCU control""" """PCU for BTS without proper PCU control"""
def __init__(self, suite_run, bts, conf): def __init__(self, testenv, bts, conf):
super().__init__(suite_run, bts, conf, 'PcuDummy') super().__init__(testenv, bts, conf, 'PcuDummy')
def start(self, keepalive=False): def start(self, keepalive=False):
pass pass

View File

@ -28,8 +28,8 @@ class OsmoPcuOC2G(pcu.Pcu):
PCU_OC2G_BIN = 'osmo-pcu' PCU_OC2G_BIN = 'osmo-pcu'
PCU_OC2G_CFG = 'osmo-pcu-oc2g.cfg' PCU_OC2G_CFG = 'osmo-pcu-oc2g.cfg'
def __init__(self, suite_run, btsoc2g, conf): def __init__(self, testenv, btsoc2g, conf):
super().__init__(suite_run, btsoc2g, conf, self.PCU_OC2G_BIN) super().__init__(testenv, btsoc2g, conf, self.PCU_OC2G_BIN)
self.run_dir = None self.run_dir = None
self.bsc = None self.bsc = None
self.inst = None self.inst = None
@ -39,10 +39,10 @@ class OsmoPcuOC2G(pcu.Pcu):
self.remote_user = 'root' self.remote_user = 'root'
def start(self, keepalive=False): def start(self, keepalive=False):
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.configure()
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-pcu-oc2g'))) self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-pcu-oc2g')))
lib = self.inst.child('lib') lib = self.inst.child('lib')
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise log.Error('No lib/ in', self.inst) raise log.Error('No lib/ in', self.inst)
@ -87,7 +87,7 @@ class OsmoPcuOC2G(pcu.Pcu):
def launch_remote(self, name, popen_args, remote_cwd=None, keepalive=False): def launch_remote(self, name, popen_args, remote_cwd=None, keepalive=False):
proc = self._process_remote(name, popen_args, remote_cwd) proc = self._process_remote(name, popen_args, remote_cwd)
self.suite_run.remember_to_stop(proc, keepalive) self.testenv.remember_to_stop(proc, keepalive)
proc.launch() proc.launch()
def run_local(self, name, popen_args): def run_local(self, name, popen_args):
@ -104,7 +104,7 @@ class OsmoPcuOC2G(pcu.Pcu):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = { 'osmo_pcu_oc2g': config.get_defaults('osmo_pcu_oc2g') } values = { 'osmo_pcu_oc2g': config.get_defaults('osmo_pcu_oc2g') }
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, { config.overlay(values, {
'osmo_pcu_oc2g': { 'osmo_pcu_oc2g': {
'bts_addr': self.bts.remote_addr(), 'bts_addr': self.bts.remote_addr(),

View File

@ -27,18 +27,18 @@ class OsmoPcu(pcu.Pcu):
BIN_PCU = 'osmo-pcu' BIN_PCU = 'osmo-pcu'
PCU_OSMO_CFG = 'osmo-pcu.cfg' PCU_OSMO_CFG = 'osmo-pcu.cfg'
def __init__(self, suite_run, bts, conf): def __init__(self, testenv, bts, conf):
super().__init__(suite_run, bts, conf, OsmoPcu.BIN_PCU) super().__init__(testenv, bts, conf, OsmoPcu.BIN_PCU)
self.run_dir = None self.run_dir = None
self.inst = None self.inst = None
self.conf = conf self.conf = conf
self.env = {} self.env = {}
def start(self, keepalive=False): def start(self, keepalive=False):
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.configure()
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-pcu'))) self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-pcu')))
lib = self.inst.child('lib') lib = self.inst.child('lib')
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise RuntimeError('No lib/ in %r' % self.inst) raise RuntimeError('No lib/ in %r' % self.inst)
@ -47,7 +47,7 @@ class OsmoPcu(pcu.Pcu):
self.launch_process(keepalive, OsmoPcu.BIN_PCU, '-r', '1', self.launch_process(keepalive, OsmoPcu.BIN_PCU, '-r', '1',
'-c', os.path.abspath(self.config_file), '-c', os.path.abspath(self.config_file),
'-i', self.bts.bsc.addr()) '-i', self.bts.bsc.addr())
self.suite_run.poll() self.testenv.poll()
def launch_process(self, keepalive, binary_name, *args): def launch_process(self, keepalive, binary_name, *args):
binary = os.path.abspath(self.inst.child('bin', binary_name)) binary = os.path.abspath(self.inst.child('bin', binary_name))
@ -57,7 +57,7 @@ class OsmoPcu(pcu.Pcu):
proc = process.Process(binary_name, run_dir, proc = process.Process(binary_name, run_dir,
(binary,) + args, (binary,) + args,
env=self.env) env=self.env)
self.suite_run.remember_to_stop(proc, keepalive) self.testenv.remember_to_stop(proc, keepalive)
proc.launch() proc.launch()
return proc return proc
@ -66,7 +66,7 @@ class OsmoPcu(pcu.Pcu):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = dict(osmo_pcu=config.get_defaults('osmo_pcu')) values = dict(osmo_pcu=config.get_defaults('osmo_pcu'))
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, { config.overlay(values, {
'osmo_pcu': { 'osmo_pcu': {
'bts_addr': self.bts.remote_addr(), 'bts_addr': self.bts.remote_addr(),

View File

@ -28,8 +28,8 @@ class OsmoPcuSysmo(pcu.Pcu):
PCU_SYSMO_BIN = 'osmo-pcu' PCU_SYSMO_BIN = 'osmo-pcu'
PCU_SYSMO_CFG = 'osmo-pcu-sysmo.cfg' PCU_SYSMO_CFG = 'osmo-pcu-sysmo.cfg'
def __init__(self, suite_run, sysmobts, conf): def __init__(self, testenv, sysmobts, conf):
super().__init__(suite_run, sysmobts, conf, self.PCU_SYSMO_BIN) super().__init__(testenv, sysmobts, conf, self.PCU_SYSMO_BIN)
self.run_dir = None self.run_dir = None
self.bsc = None self.bsc = None
self.inst = None self.inst = None
@ -39,10 +39,10 @@ class OsmoPcuSysmo(pcu.Pcu):
self.remote_user = 'root' self.remote_user = 'root'
def start(self, keepalive=False): def start(self, keepalive=False):
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.configure()
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-pcu-sysmo'))) self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-pcu-sysmo')))
lib = self.inst.child('lib') lib = self.inst.child('lib')
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise log.Error('No lib/ in', self.inst) raise log.Error('No lib/ in', self.inst)
@ -87,7 +87,7 @@ class OsmoPcuSysmo(pcu.Pcu):
def launch_remote(self, name, popen_args, remote_cwd=None, keepalive=False): def launch_remote(self, name, popen_args, remote_cwd=None, keepalive=False):
proc = self._process_remote(name, popen_args, remote_cwd) proc = self._process_remote(name, popen_args, remote_cwd)
self.suite_run.remember_to_stop(proc, keepalive) self.testenv.remember_to_stop(proc, keepalive)
proc.launch() proc.launch()
def run_local(self, name, popen_args): def run_local(self, name, popen_args):
@ -104,7 +104,7 @@ class OsmoPcuSysmo(pcu.Pcu):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = { 'osmo_pcu_sysmo': config.get_defaults('osmo_pcu_sysmo') } values = { 'osmo_pcu_sysmo': config.get_defaults('osmo_pcu_sysmo') }
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, { config.overlay(values, {
'osmo_pcu_sysmo': { 'osmo_pcu_sysmo': {
'bts_addr': self.bts.remote_addr(), 'bts_addr': self.bts.remote_addr(),

View File

@ -25,22 +25,22 @@ from . import pcap_recorder
class OsmoSgsn(log.Origin): class OsmoSgsn(log.Origin):
def __init__(self, suite_run, hlr, ggsn, ip_address): def __init__(self, testenv, hlr, ggsn, ip_address):
super().__init__(log.C_RUN, 'osmo-sgsn_%s' % ip_address.get('addr')) super().__init__(log.C_RUN, 'osmo-sgsn_%s' % ip_address.get('addr'))
self.run_dir = None self.run_dir = None
self.config_file = None self.config_file = None
self.process = None self.process = None
self.suite_run = suite_run self.testenv = testenv
self.hlr = hlr self.hlr = hlr
self.ggsn = ggsn self.ggsn = ggsn
self.ip_address = ip_address self.ip_address = ip_address
def start(self): def start(self):
self.log('Starting osmo-sgsn') self.log('Starting osmo-sgsn')
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.configure()
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-sgsn'))) inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-sgsn')))
binary = inst.child('bin', 'osmo-sgsn') binary = inst.child('bin', 'osmo-sgsn')
if not os.path.isfile(binary): if not os.path.isfile(binary):
@ -49,7 +49,7 @@ class OsmoSgsn(log.Origin):
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise log.Error('No lib/ in', inst) raise log.Error('No lib/ in', inst)
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,
'host %s' % self.addr()) 'host %s' % self.addr())
env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) } env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
@ -59,7 +59,7 @@ class OsmoSgsn(log.Origin):
(binary, (binary,
'-c', os.path.abspath(self.config_file)), '-c', os.path.abspath(self.config_file)),
env=env) env=env)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def configure(self): def configure(self):
@ -67,7 +67,7 @@ class OsmoSgsn(log.Origin):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = dict(sgsn=config.get_defaults('sgsn')) values = dict(sgsn=config.get_defaults('sgsn'))
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, dict(sgsn=dict(ip_address=self.ip_address))) config.overlay(values, dict(sgsn=dict(ip_address=self.ip_address)))
config.overlay(values, self.hlr.conf_for_client()) config.overlay(values, self.hlr.conf_for_client())
config.overlay(values, self.ggsn.conf_for_client()) config.overlay(values, self.ggsn.conf_for_client())

View File

@ -25,20 +25,20 @@ from . import pcap_recorder
class OsmoStp(log.Origin): class OsmoStp(log.Origin):
def __init__(self, suite_run, ip_address): def __init__(self, testenv, ip_address):
super().__init__(log.C_RUN, 'osmo-stp_%s' % ip_address.get('addr')) super().__init__(log.C_RUN, 'osmo-stp_%s' % ip_address.get('addr'))
self.run_dir = None self.run_dir = None
self.config_file = None self.config_file = None
self.process = None self.process = None
self.suite_run = suite_run self.testenv = testenv
self.ip_address = ip_address self.ip_address = ip_address
def start(self): def start(self):
self.log('Starting osmo-stp') self.log('Starting osmo-stp')
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.configure()
inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-stp'))) inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-stp')))
binary = inst.child('bin', 'osmo-stp') binary = inst.child('bin', 'osmo-stp')
if not os.path.isfile(binary): if not os.path.isfile(binary):
@ -47,7 +47,7 @@ class OsmoStp(log.Origin):
if not os.path.isdir(lib): if not os.path.isdir(lib):
raise RuntimeError('No lib/ in %r' % inst) raise RuntimeError('No lib/ in %r' % inst)
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,
'host %s and port not 22' % self.addr()) 'host %s and port not 22' % self.addr())
env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) } env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
@ -57,7 +57,7 @@ class OsmoStp(log.Origin):
(binary, '-c', (binary, '-c',
os.path.abspath(self.config_file)), os.path.abspath(self.config_file)),
env=env) env=env)
self.suite_run.remember_to_stop(self.process) self.testenv.remember_to_stop(self.process)
self.process.launch() self.process.launch()
def configure(self): def configure(self):
@ -65,7 +65,7 @@ class OsmoStp(log.Origin):
self.dbg(config_file=self.config_file) self.dbg(config_file=self.config_file)
values = dict(stp=config.get_defaults('stp')) values = dict(stp=config.get_defaults('stp'))
config.overlay(values, self.suite_run.config()) config.overlay(values, self.testenv.suite().config())
config.overlay(values, dict(stp=dict(ip_address=self.ip_address))) config.overlay(values, dict(stp=dict(ip_address=self.ip_address)))
self.dbg('STP CONFIG:\n' + pprint.pformat(values)) self.dbg('STP CONFIG:\n' + pprint.pformat(values))

View File

@ -36,7 +36,6 @@ from .obj import enb
from .obj import bts from .obj import bts
from .obj import ms from .obj import ms
trial = None
suite = None suite = None
test = None test = None
resources = None resources = None
@ -59,24 +58,17 @@ class TestEnv(log_module.Origin):
super().__init__(log_module.C_TST, test.name()) super().__init__(log_module.C_TST, test.name())
self.suite_run = suite_run self.suite_run = suite_run
self._test = test self._test = test
self.trial = suite_run.trial # backward compat with objects
self.resources_pool = suite_run.resource_pool() # backward compat with objects
self._processes = [] self._processes = []
self.test_import_modules_to_clean_up = [] self.test_import_modules_to_clean_up = []
self.objects_to_clean_up = None self.objects_to_clean_up = None
MainLoop.register_poll_func(self.poll) MainLoop.register_poll_func(self.poll)
def test(self):
return self._test
def suite(self): def suite(self):
return self.suite_run return self.suite_run
# backward compat with objects
def get_test_run_dir(self):
return self._test.get_run_dir()
# backward compat with objects
def config(self):
return self.suite_run.config()
def remember_to_stop(self, process, respawn=False): def remember_to_stop(self, process, respawn=False):
'''Ask suite to monitor and manage lifecycle of the Process object. If a '''Ask suite to monitor and manage lifecycle of the Process object. If a
process managed by suite finishes before cleanup time, the current test process managed by suite finishes before cleanup time, the current test
@ -321,9 +313,8 @@ def setup(suite_run, _test):
from .core.event_loop import MainLoop from .core.event_loop import MainLoop
from .obj.sms import Sms as Sms_class from .obj.sms import Sms as Sms_class
global trial, suite, test, resources, log, dbg, err, wait, wait_no_raise, sleep, poll, prompt, Sms, process global suite, test, resources, log, dbg, err, wait, wait_no_raise, sleep, poll, prompt, Sms, process
trial = suite_run.trial
test = _test test = _test
resources = suite_run.reserved_resources # TODO: remove this global, only used in selftest resources = suite_run.reserved_resources # TODO: remove this global, only used in selftest
log = test.log log = test.log

View File

@ -52,9 +52,9 @@ class OsmoVirtPhy(Launcher):
def phy_filename(self): def phy_filename(self):
return self._phy_filename return self._phy_filename
def start(self, loop, suite_run=None): def start(self, loop, testenv=None):
if suite_run is not None: # overwrite run_dir to store files if run from inside osmo-gsm-tester: if testenv is not None: # overwrite run_dir to store files if run from inside osmo-gsm-tester:
self.run_dir = util.Dir(suite_run.get_test_run_dir().new_dir(self.name())) self.run_dir = util.Dir(testenv.suite().get_run_dir().new_dir(self.name()))
if len(self._phy_filename.encode()) > 107: if len(self._phy_filename.encode()) > 107:
raise log.Error('Path for unix socket is longer than max allowed len for unix socket path (107):', self._phy_filename) raise log.Error('Path for unix socket is longer than max allowed len for unix socket path (107):', self._phy_filename)
@ -62,8 +62,8 @@ class OsmoVirtPhy(Launcher):
args = [self._binary, "--l1ctl-sock=" + self._phy_filename] args = [self._binary, "--l1ctl-sock=" + self._phy_filename]
self._vphy_proc = process.Process(self.name(), self.run_dir, self._vphy_proc = process.Process(self.name(), self.run_dir,
args, env=self._env) args, env=self._env)
if suite_run is not None: if testenv is not None:
suite_run.remember_to_stop(self._vphy_proc) testenv.remember_to_stop(self._vphy_proc)
self._vphy_proc.launch() self._vphy_proc.launch()
def verify_ready(self): def verify_ready(self):
@ -134,9 +134,9 @@ class OsmoMobile(Launcher):
w.write(mob_vty) w.write(mob_vty)
return mob_cfg_file return mob_cfg_file
def start(self, loop, suite_run=None): def start(self, loop, testenv=None):
if suite_run is not None: # overwrite run_dir to store files if run from inside osmo-gsm-tester: if testenv is not None: # overwrite run_dir to store files if run from inside osmo-gsm-tester:
self.run_dir = util.Dir(suite_run.get_test_run_dir().new_dir(self.name())) self.run_dir = util.Dir(testenv.suite().get_run_dir().new_dir(self.name()))
lua_filename = self.write_lua_cfg() lua_filename = self.write_lua_cfg()
mob_filename = self.write_mob_cfg(lua_filename, self._phy_filename) mob_filename = self.write_mob_cfg(lua_filename, self._phy_filename)
@ -145,8 +145,8 @@ class OsmoMobile(Launcher):
args = [self._binary, "-c", mob_filename] args = [self._binary, "-c", mob_filename]
self._omob_proc = process.Process(self.name(), self.run_dir, self._omob_proc = process.Process(self.name(), self.run_dir,
args, env=self._env) args, env=self._env)
if suite_run is not None: if testenv is not None:
suite_run.remember_to_stop(self._omob_proc) testenv.remember_to_stop(self._omob_proc)
self._omob_proc.launch() self._omob_proc.launch()
def terminate(self): def terminate(self):
@ -168,11 +168,11 @@ class MobileTestStarter(log.Origin):
TEMPLATE_CFG = "osmo-mobile.cfg" TEMPLATE_CFG = "osmo-mobile.cfg"
def __init__(self, name, options, cdf_function, def __init__(self, name, options, cdf_function,
event_server, tmp_dir, results, suite_run=None): event_server, tmp_dir, results, testenv=None):
super().__init__(log.C_RUN, name) super().__init__(log.C_RUN, name)
self._binary_options = options self._binary_options = options
self._cdf = cdf_function self._cdf = cdf_function
self._suite_run = suite_run self._testenv = testenv
self._tmp_dir = tmp_dir self._tmp_dir = tmp_dir
self._event_server = event_server self._event_server = event_server
self._results = results self._results = results
@ -225,7 +225,7 @@ class MobileTestStarter(log.Origin):
""" """
self.log("Pre-launching all virtphy's") self.log("Pre-launching all virtphy's")
for phy in self._phys: for phy in self._phys:
phy.start(loop, self._suite_run) phy.start(loop, self._testenv)
self.log("Checking if sockets are in the filesystem") self.log("Checking if sockets are in the filesystem")
for phy in self._phys: for phy in self._phys:
@ -257,7 +257,7 @@ class MobileTestStarter(log.Origin):
# start pending MS # start pending MS
while len(self._started) < self._cdf.current_scaled_value() and len(self._unstarted) > 0: while len(self._started) < self._cdf.current_scaled_value() and len(self._unstarted) > 0:
ms = self._unstarted.pop(0) ms = self._unstarted.pop(0)
ms.start(loop, self._suite_run) ms.start(loop, self._testenv)
launch_time = time.clock_gettime(time.CLOCK_MONOTONIC) launch_time = time.clock_gettime(time.CLOCK_MONOTONIC)
self._results[ms.name_number()].set_launch_time(launch_time) self._results[ms.name_number()].set_launch_time(launch_time)
self._started.append(ms) self._started.append(ms)