summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/osmo_gsm_tester/bts_osmotrx.py17
-rw-r--r--src/osmo_gsm_tester/bts_sysmo.py22
-rw-r--r--src/osmo_gsm_tester/resource.py7
-rw-r--r--src/osmo_gsm_tester/schema.py2
-rw-r--r--src/osmo_gsm_tester/suite.py36
5 files changed, 78 insertions, 6 deletions
diff --git a/src/osmo_gsm_tester/bts_osmotrx.py b/src/osmo_gsm_tester/bts_osmotrx.py
index 3077b0f..39bfcae 100644
--- a/src/osmo_gsm_tester/bts_osmotrx.py
+++ b/src/osmo_gsm_tester/bts_osmotrx.py
@@ -59,6 +59,18 @@ class OsmoBtsTrx(log.Origin):
def remote_addr(self):
return self.conf.get('addr')
+ def supported_bands(self):
+ return self.conf.get('bands', [])
+
+ def set_arfcn_resource(self, band_arfcn):
+ self.band_arfcn = band_arfcn
+
+ def band(self):
+ return self.band_arfcn.get('band')
+
+ def arfcn(self):
+ return int(self.band_arfcn.get('arfcn'))
+
def trx_remote_ip(self):
conf_ip = self.conf.get('trx_remote_ip', None)
if conf_ip is not None:
@@ -122,6 +134,7 @@ class OsmoBtsTrx(log.Origin):
'trx_local_ip': self.remote_addr(),
'trx_remote_ip': self.trx_remote_ip(),
'pcu_socket_path': self.pcu_socket_path(),
+ 'band': self.band(),
}
})
config.overlay(values, { 'osmo_bts_trx': self.conf })
@@ -137,6 +150,10 @@ class OsmoBtsTrx(log.Origin):
values = config.get_defaults('bsc_bts')
config.overlay(values, config.get_defaults('osmo_bts_trx'))
config.overlay(values, self.conf)
+ config.overlay(values, {
+ 'band': self.band(),
+ 'trx_list': [ { 'arfcn': self.arfcn() } ]
+ })
self.dbg(conf=values)
return values
diff --git a/src/osmo_gsm_tester/bts_sysmo.py b/src/osmo_gsm_tester/bts_sysmo.py
index e8ac7c2..5c4f7c0 100644
--- a/src/osmo_gsm_tester/bts_sysmo.py
+++ b/src/osmo_gsm_tester/bts_sysmo.py
@@ -29,6 +29,7 @@ class SysmoBts(log.Origin):
remote_inst = None
remote_env = None
remote_dir = None
+ band_arfcn = None
REMOTE_DIR = '/osmo-gsm-tester'
BTS_SYSMO_BIN = 'osmo-bts-sysmo'
@@ -116,6 +117,22 @@ class SysmoBts(log.Origin):
def remote_addr(self):
return self.conf.get('addr')
+ def supported_bands(self):
+ return self.conf.get('bands', [])
+
+ def set_arfcn_resource(self, band_arfcn):
+ self.band_arfcn = band_arfcn
+
+ def band(self):
+ if not self.band_arfcn:
+ return None
+ return self.band_arfcn.get('band')
+
+ def arfcn(self):
+ if not self.band_arfcn:
+ return None
+ return int(self.band_arfcn.get('arfcn'))
+
def configure(self):
if self.bsc is None:
raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be configured')
@@ -129,6 +146,7 @@ class SysmoBts(log.Origin):
'osmo_bts_sysmo': {
'oml_remote_ip': self.bsc.addr(),
'pcu_socket_path': self.pcu_socket_path(),
+ 'band': self.band(),
}
})
config.overlay(values, { 'osmo_bts_sysmo': self.conf })
@@ -144,6 +162,10 @@ class SysmoBts(log.Origin):
values = config.get_defaults('bsc_bts')
config.overlay(values, config.get_defaults('osmo_bts_sysmo'))
config.overlay(values, self.conf)
+ config.overlay(values, {
+ 'band': self.band(),
+ 'trx_list': [ { 'arfcn': self.arfcn() } ]
+ })
self.dbg(conf=values)
return values
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index a4643ac..34901b9 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -53,7 +53,7 @@ RESOURCES_SCHEMA = {
'bts[].type': schema.STR,
'bts[].ipa_unit_id': schema.UINT,
'bts[].addr': schema.IPV4,
- 'bts[].band': schema.BAND,
+ 'bts[].bands[]': schema.BAND,
'bts[].trx_remote_ip': schema.IPV4,
'bts[].launch_trx': schema.BOOL_STR,
'bts[].ciphers[]': schema.CIPHER,
@@ -533,6 +533,11 @@ class ReservedResources(log.Origin):
for item in item_list:
item.pop(USED_KEY, None)
+ def add(self, more):
+ if more is self or more is self.reserved:
+ raise RuntimeError('adding a list of reserved resources to itself')
+ config.add(self.reserved, copy.deepcopy(more.reserved))
+
def free(self):
if self.reserved:
self.resources_pool.free(self.origin, self.reserved)
diff --git a/src/osmo_gsm_tester/schema.py b/src/osmo_gsm_tester/schema.py
index 6d5f7ad..043f5c1 100644
--- a/src/osmo_gsm_tester/schema.py
+++ b/src/osmo_gsm_tester/schema.py
@@ -39,7 +39,7 @@ def match_re(name, regex, val):
raise ValueError('Invalid %s: %r' % (name, val))
def band(val):
- if val in ('GSM-1800', 'GSM-1900'):
+ if val in ('GSM-850', 'GSM-900', 'GSM-1800', 'GSM-1900'):
return
raise ValueError('Unknown GSM band: %r' % val)
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index f4cba1e..214b8b9 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -246,6 +246,11 @@ class SuiteRun(log.Origin):
self.log('reserving resources in', self.resources_pool.state_dir, '...')
self.reserved_resources = self.resources_pool.reserve(self, self.resource_requirements())
+ def reserve_resources_append(self, requirements):
+ new_reserved = self.resources_pool.reserve(self, requirements)
+ self.dbg('reserving new resources %r' % new_reserved)
+ self.reserved_resources.add(new_reserved)
+
def run_tests(self, names=None):
try:
log.large_separator(self.trial.name(), self.name(), sublevel=2)
@@ -317,6 +322,14 @@ class SuiteRun(log.Origin):
return
self.reserved_resources.free()
+ def reserve_arfcn(self, band, arfcn=None):
+ '''To be used by tests. Returned resource can be passed when requested a bts object'''
+
+ if arfcn is None:
+ return self._try_reserve_arfcn((band,))
+ else:
+ return self.reserve_resources_append({ 'arfcn': [{'band': band, 'arfcn': arfcn, 'times': '1'}] })
+
def ip_address(self, specifics=None):
return self.reserved_resources.get(resource.R_IP_ADDRESS, specifics=specifics)
@@ -350,11 +363,21 @@ class SuiteRun(log.Origin):
ip_address = self.ip_address()
return osmo_stp.OsmoStp(self, ip_address)
- def bts(self, specifics=None):
- bts = bts_obj(self, self.reserved_resources.get(resource.R_BTS, specifics=specifics))
+ def bts(self, arfcn=None, specifics=None):
+ bts = bts_obj(self, arfcn, self.reserved_resources.get(resource.R_BTS, specifics=specifics))
self.register_for_cleanup(bts)
return bts
+ def _try_reserve_arfcn(self, supported_bands):
+ for band in supported_bands:
+ try:
+ self.reserve_resources_append({ 'arfcn': [{'band': band, 'times': '1'}] })
+ except resource.NoResourceExn as e:
+ self.dbg('Band %s has no available arfcns' % band)
+ continue
+ return self.reserved_resources.get(resource.R_ARFCN)
+ raise resource.NoResourceExn("No free arfcns in any of bands", bands=supported_bands)
+
def modem(self, specifics=None):
conf = self.reserved_resources.get(resource.R_MODEM, specifics=specifics)
self.dbg('create Modem object', conf=conf)
@@ -450,12 +473,17 @@ def load_suite_scenario_str(suite_scenario_str):
scenarios = [config.get_scenario(scenario_name) for scenario_name in scenario_names]
return (suite_scenario_str, suite, scenarios)
-def bts_obj(suite_run, conf):
+def bts_obj(suite_run, arfcn, conf):
bts_type = conf.get('type')
log.dbg('create BTS object', type=bts_type)
bts_class = resource.KNOWN_BTS_TYPES.get(bts_type)
if bts_class is None:
raise RuntimeError('No such BTS type is defined: %r' % bts_type)
- return bts_class(suite_run, conf)
+ bts_inst = bts_class(suite_run, conf)
+ if arfcn is None:
+ supported_bands = bts_inst.supported_bands()
+ arfcn = suite_run._try_reserve_arfcn(supported_bands)
+ bts_inst.set_arfcn_resource(arfcn)
+ return bts_inst
# vim: expandtab tabstop=4 shiftwidth=4