path: root/src/osmo_gsm_tester/
diff options
authorPau Espin Pedrol <>2017-08-28 18:07:40 +0200
committerPau Espin Pedrol <>2017-09-14 17:41:48 +0200
commit82aed176a824d64925142a140e3b0e7c67045508 (patch)
tree6de409bae471f5adf6c635603725634694a6a90e /src/osmo_gsm_tester/
parente9f6917f3229f67958c503943cd4d934d4a514fc (diff)
Reserve ARFCN dynamically based on BTS band supportpespin/arfcn
Instead of statically specifying a band for a BTS to use, declare a list of supported bands for each BTS. At the time of BTS object creation, ask the BTS for band support and try to dynamically reserve an ARFCN resource which is compatible with any of the bands supported by the BTS. All this happens transparently to the test. Still, the test may want to use a specific band / arfcn. In this case, a test can use suite.reserve_arfcn(band, arfcn) to reserve a specific band/arfcn and pass that to the BTS at creation time, which will then use that one instead of trying to find a suitable one. It is left as future work to support BTs with multiple TRX, in which case several arfcn must be reserved. It should not be that difficult, mostly using "times: X" where X is the amount of trx, changing the API to use a list of arfcns and the configure() methods of the BTS. Related: OS#2230 Change-Id: I6fb5d95bed1fa50c3deaf62a7a6df3cb276bc3c9
Diffstat (limited to 'src/osmo_gsm_tester/')
1 files changed, 32 insertions, 4 deletions
diff --git a/src/osmo_gsm_tester/ b/src/osmo_gsm_tester/
index f4cba1e..214b8b9 100644
--- a/src/osmo_gsm_tester/
+++ b/src/osmo_gsm_tester/
@@ -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):
log.large_separator(,, sublevel=2)
@@ -317,6 +322,14 @@ class SuiteRun(log.Origin):
+ 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))
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