[PATCH] osmo-gsm-tester[master]: Reserve ARFCN dynamically based on BTS band support

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Sep 11 10:46:09 UTC 2017


Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/3731

to look at the new patch set (#4).

Reserve ARFCN dynamically based on BTS band support

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
---
M example/default-suites.conf
M example/defaults.conf
M example/resources.conf
A example/scenarios/band-1900.conf
M selftest/conf/resources.conf
M selftest/resource_test.ok
M selftest/suite_test.ok
M selftest/suite_test/resources.conf
M src/osmo_gsm_tester/bts_osmotrx.py
M src/osmo_gsm_tester/bts_sysmo.py
M src/osmo_gsm_tester/resource.py
M src/osmo_gsm_tester/schema.py
M src/osmo_gsm_tester/suite.py
A suites/register/register_band_1900.py
A suites/register/suite.conf
15 files changed, 166 insertions(+), 39 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/31/3731/4

diff --git a/example/default-suites.conf b/example/default-suites.conf
index 1e8d47a..7fc97d3 100644
--- a/example/default-suites.conf
+++ b/example/default-suites.conf
@@ -7,3 +7,4 @@
 - smpp
 - aoip_smpp
 - aoip_encryption:cipher-a50+cipher-a51
+- register:band-1900
diff --git a/example/defaults.conf b/example/defaults.conf
index 969fac6..e9e7846 100644
--- a/example/defaults.conf
+++ b/example/defaults.conf
@@ -34,7 +34,6 @@
   osmobsc_bts_type: sysmobts
   trx_list:
   - max_power_red: 0
-    arfcn: 868
     timeslot_list:
     - phys_chan_config: CCCH+SDCCH4
     - phys_chan_config: SDCCH8
diff --git a/example/resources.conf b/example/resources.conf
index 95cb8cf..3ebd57f 100644
--- a/example/resources.conf
+++ b/example/resources.conf
@@ -12,14 +12,14 @@
   type: osmo-bts-sysmo
   ipa_unit_id: 1
   addr: 10.42.42.114
-  band: GSM-1800
+  bands: ['GSM-850', 'GSM-900', 'GSM-1800', 'GSM-1900']
   ciphers: [a5_0, a5_1, a5_3]
 
 - label: Ettus B200
   type: osmo-bts-trx
   ipa_unit_id: 6
   addr: 10.42.42.50
-  band: GSM-1800
+  bands: ['GSM-1800', 'GSM-1900']
   launch_trx: true
   ciphers: [a5_0, a5_1]
 
@@ -27,7 +27,7 @@
   type: osmo-bts-trx
   ipa_unit_id: 7
   addr: 10.42.42.51
-  band: GSM-1800
+  bands: ['GSM-1800']
   trx_remote_ip: 10.42.42.112
   ciphers: [a5_0, a5_1]
 
diff --git a/example/scenarios/band-1900.conf b/example/scenarios/band-1900.conf
new file mode 100644
index 0000000..956c8db
--- /dev/null
+++ b/example/scenarios/band-1900.conf
@@ -0,0 +1,4 @@
+resources:
+  bts:
+  - bands:
+    - GSM-1900
diff --git a/selftest/conf/resources.conf b/selftest/conf/resources.conf
index b186737..e5fe6e6 100644
--- a/selftest/conf/resources.conf
+++ b/selftest/conf/resources.conf
@@ -12,7 +12,7 @@
   type: osmo-bts-sysmo
   ipa_unit_id: 1
   addr: 10.42.42.114
-  band: GSM-1800
+  bands: ['GSM-850', 'GSM-900', 'GSM-1800', 'GSM-1900']
   ciphers:
   - 'a5_0'
   - 'a5_1'
@@ -21,7 +21,7 @@
   type: osmo-bts-trx
   ipa_unit_id: 6
   addr: 10.42.42.50
-  band: GSM-1800
+  bands: ['GSM-1800']
   launch_trx: true
   ciphers:
   - 'a5_0'
@@ -31,7 +31,7 @@
   type: osmo-bts-trx
   ipa_unit_id: 7
   addr: 10.42.42.51
-  band: GSM-1800
+  bands: ['GSM-1800']
   trx_remote_ip: 10.42.42.112
   ciphers:
   - 'a5_0'
diff --git a/selftest/resource_test.ok b/selftest/resource_test.ok
index c946d3d..207cfb0 100644
--- a/selftest/resource_test.ok
+++ b/selftest/resource_test.ok
@@ -46,16 +46,16 @@
            {'_hash': 'dc9ce027a257da087f31a5bc1ee6b4abd2637369',
             'arfcn': '548',
             'band': 'GSM-1900'}],
- 'bts': [{'_hash': '377ac78d5404b826d40c84efd04b4a9fd4e62b7e',
+ 'bts': [{'_hash': '2769d8f6cfe22f15e7dbd14f7ce929db2e56bdf3',
           'addr': '10.42.42.114',
-          'band': 'GSM-1800',
+          'bands': ['GSM-850', 'GSM-900', 'GSM-1800', 'GSM-1900'],
           'ciphers': ['a5_0', 'a5_1'],
           'ipa_unit_id': '1',
           'label': 'sysmoBTS 1002',
           'type': 'osmo-bts-sysmo'},
          {'_hash': '6a9c9fbd364e1563a5b9f0826030a7888fd19575',
           'addr': '10.42.42.50',
-          'band': 'GSM-1800',
+          'bands': ['GSM-1800'],
           'ciphers': ['a5_0', 'a5_1'],
           'ipa_unit_id': '6',
           'label': 'Ettus B200',
@@ -63,7 +63,7 @@
           'type': 'osmo-bts-trx'},
          {'_hash': 'e50fd38e3bfe8039ac13bc315bc84f46110b7443',
           'addr': '10.42.42.51',
-          'band': 'GSM-1800',
+          'bands': ['GSM-1800'],
           'ciphers': ['a5_0', 'a5_1'],
           'ipa_unit_id': '7',
           'label': 'sysmoCell 5000',
@@ -118,9 +118,13 @@
   arfcn: '514'
   band: GSM-1800
 --- testowner: Reserving 2 x bts (candidates: 3)
---- testowner: DBG: Picked - _hash: 377ac78d5404b826d40c84efd04b4a9fd4e62b7e
+--- testowner: DBG: Picked - _hash: 2769d8f6cfe22f15e7dbd14f7ce929db2e56bdf3
   addr: 10.42.42.114
-  band: GSM-1800
+  bands:
+  - GSM-850
+  - GSM-900
+  - GSM-1800
+  - GSM-1900
   ciphers:
   - a5_0
   - a5_1
@@ -129,7 +133,8 @@
   type: osmo-bts-sysmo
 - _hash: 6a9c9fbd364e1563a5b9f0826030a7888fd19575
   addr: 10.42.42.50
-  band: GSM-1800
+  bands:
+  - GSM-1800
   ciphers:
   - a5_0
   - a5_1
@@ -170,10 +175,14 @@
   arfcn: '514'
   band: GSM-1800
 bts:
-- _hash: 377ac78d5404b826d40c84efd04b4a9fd4e62b7e
+- _hash: 2769d8f6cfe22f15e7dbd14f7ce929db2e56bdf3
   _reserved_by: testowner-123-1490837279
   addr: 10.42.42.114
-  band: GSM-1800
+  bands:
+  - GSM-850
+  - GSM-900
+  - GSM-1800
+  - GSM-1900
   ciphers:
   - a5_0
   - a5_1
@@ -183,7 +192,8 @@
 - _hash: 6a9c9fbd364e1563a5b9f0826030a7888fd19575
   _reserved_by: testowner-123-1490837279
   addr: 10.42.42.50
-  band: GSM-1800
+  bands:
+  - GSM-1800
   ciphers:
   - a5_0
   - a5_1
diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok
index bc48a3e..c1281c0 100644
--- a/selftest/suite_test.ok
+++ b/selftest/suite_test.ok
@@ -33,23 +33,29 @@
 tst test_suite: DBG: {combining='resources'}
 tst {combining_scenarios='resources'}: DBG: {definition_conf={bts=[{'times': '1'}, {'times': '2'}], ip_address=[{'times': '1'}], modem=[{'times': '2'}]}}  [test_suite↪{combining_scenarios='resources'}]
 tst test_suite: Reserving 3 x bts (candidates: 6)
-tst test_suite: DBG: Picked - _hash: 07d9c8aaa940b674efcbbabdd69f58a6ce4e94f9
+tst test_suite: DBG: Picked - _hash: c8a01d42f3977e49ceff0734a1475857913dfb13
   addr: 10.42.42.114
-  band: GSM-1800
+  bands:
+  - GSM-850
+  - GSM-900
+  - GSM-1800
+  - GSM-1900
   ipa_unit_id: '1'
   label: sysmoBTS 1002
   type: sysmo
 - _hash: 76c8d2f459113cd6c99ed62d1a94bbe9a291ba94
   addr: 10.42.42.115
-  band: GSM-1800
+  bands:
+  - GSM-1800
   ipa_unit_id: '5'
   label: octBTS 3000
   trx_list:
   - hw_addr: 00:0c:90:32:b5:8a
   type: oct
-- _hash: 0b7fabd512b36aec43d7d496abd00af4e193b0f8
+- _hash: 78f070cc5e3c6773422b0d6770e04dd4ee0497d2
   addr: 10.42.42.190
-  band: GSM-1900
+  bands:
+  - GSM-1800
   ipa_unit_id: '1902'
   label: nanoBTS 1900
   trx_list:
@@ -171,7 +177,8 @@
 tst test_suite: Reserving 3 x bts (candidates: 6)  [resource.py:[LINENR]]
 tst test_suite: DBG: Picked - _hash: f1cab48db5b9004986e2030cb71730a5c55e823e
   addr: 10.42.42.52
-  band: GSM-1800
+  bands:
+  - GSM-1800
   ipa_unit_id: '6'
   label: Ettus B200
   launch_trx: 'True'
@@ -181,7 +188,8 @@
   type: osmo-bts-trx
 - _hash: 1d00bd0d6643db5590cdbefff3152e70500abefc
   addr: 10.42.42.53
-  band: GSM-1800
+  bands:
+  - GSM-1800
   ipa_unit_id: '7'
   label: sysmoCell 5000
   trx_list:
@@ -191,7 +199,8 @@
   type: osmo-bts-trx
 - _hash: 1d00bd0d6643db5590cdbefff3152e70500abefc
   addr: 10.42.42.53
-  band: GSM-1800
+  bands:
+  - GSM-1800
   ipa_unit_id: '7'
   label: sysmoCell 5000
   trx_list:
diff --git a/selftest/suite_test/resources.conf b/selftest/suite_test/resources.conf
index e302373..dc1d932 100644
--- a/selftest/suite_test/resources.conf
+++ b/selftest/suite_test/resources.conf
@@ -10,13 +10,13 @@
   type: sysmo
   ipa_unit_id: 1
   addr: 10.42.42.114
-  band: GSM-1800
+  bands: ['GSM-850', 'GSM-900', 'GSM-1800', 'GSM-1900']
 
 - label: octBTS 3000
   type: oct
   ipa_unit_id: 5
   addr: 10.42.42.115
-  band: GSM-1800
+  bands: ['GSM-1800']
   trx_list:
   - hw_addr: 00:0c:90:32:b5:8a
 
@@ -24,7 +24,7 @@
   type: nanobts
   ipa_unit_id: 1902
   addr: 10.42.42.190
-  band: GSM-1900
+  bands: ['GSM-1800']
   trx_list:
   - hw_addr: 00:02:95:00:41:b3
 
@@ -32,7 +32,7 @@
   type: osmo-bts-trx
   ipa_unit_id: 6
   addr: 10.42.42.52
-  band: GSM-1800
+  bands: ['GSM-1800']
   launch_trx: true
   trx_list:
     - nominal_power: 10
@@ -42,7 +42,7 @@
   type: osmo-bts-trx
   ipa_unit_id: 7
   addr: 10.42.42.53
-  band: GSM-1800
+  bands: ['GSM-1800']
   trx_remote_ip: 10.42.42.112
   trx_list:
     - nominal_power: 10
@@ -52,7 +52,7 @@
   type: osmo-bts-trx
   ipa_unit_id: 7
   addr: 10.42.42.53
-  band: GSM-1800
+  bands: ['GSM-1800']
   trx_remote_ip: 10.42.42.112
   trx_list:
     - nominal_power: 10
diff --git a/src/osmo_gsm_tester/bts_osmotrx.py b/src/osmo_gsm_tester/bts_osmotrx.py
index b5262a2..a53874f 100644
--- a/src/osmo_gsm_tester/bts_osmotrx.py
+++ b/src/osmo_gsm_tester/bts_osmotrx.py
@@ -43,6 +43,18 @@
     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:
@@ -105,7 +117,8 @@
                             'oml_remote_ip': self.bsc.addr(),
                             'trx_local_ip': self.remote_addr(),
                             'trx_remote_ip': self.trx_remote_ip(),
-                            'pcu_socket_path': os.path.join(str(self.run_dir), 'pcu_bts')
+                            'pcu_socket_path': os.path.join(str(self.run_dir), 'pcu_bts'),
+                            'band': self.band()
                         }
         })
         config.overlay(values, { 'osmo_bts_trx': self.conf })
@@ -121,6 +134,10 @@
         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 f37f88b..cae2828 100644
--- a/src/osmo_gsm_tester/bts_sysmo.py
+++ b/src/osmo_gsm_tester/bts_sysmo.py
@@ -29,6 +29,7 @@
     remote_inst = None
     remote_env = None
     remote_dir = None
+    band_arfcn = None
 
     REMOTE_DIR = '/osmo-gsm-tester'
     BTS_SYSMO_BIN = 'osmo-bts-sysmo'
@@ -110,6 +111,22 @@
     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')
@@ -122,7 +139,8 @@
         config.overlay(values, {
                         'osmo_bts_sysmo': {
                             'oml_remote_ip': self.bsc.addr(),
-                            'pcu_socket_path': os.path.join(SysmoBts.REMOTE_DIR, 'pcu_bts')
+                            'pcu_socket_path': os.path.join(SysmoBts.REMOTE_DIR, 'pcu_bts'),
+                            'band': self.band()
                         }
         })
         config.overlay(values, { 'osmo_bts_sysmo': self.conf })
@@ -138,6 +156,10 @@
         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 886c2b9..6437386 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -53,7 +53,7 @@
         'bts[].type': schema.STR,
         'bts[].ipa_unit_id': schema.INT,
         '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,
@@ -523,6 +523,11 @@
             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 cdf0a04..92d7b73 100644
--- a/src/osmo_gsm_tester/schema.py
+++ b/src/osmo_gsm_tester/schema.py
@@ -39,7 +39,7 @@
     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 b108703..f50a0b2 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -249,6 +249,11 @@
         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)
@@ -320,6 +325,14 @@
             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)
 
@@ -353,8 +366,18 @@
             ip_address = self.ip_address()
         return osmo_stp.OsmoStp(self, ip_address)
 
-    def bts(self, specifics=None):
-        return bts_obj(self, self.reserved_resources.get(resource.R_BTS, specifics=specifics))
+    def bts(self, arfcn=None, specifics=None):
+        return bts_obj(self, arfcn, self.reserved_resources.get(resource.R_BTS, specifics=specifics))
+
+    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)
@@ -451,12 +474,17 @@
     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
diff --git a/suites/register/register_band_1900.py b/suites/register/register_band_1900.py
new file mode 100755
index 0000000..3e0f6c3
--- /dev/null
+++ b/suites/register/register_band_1900.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+from osmo_gsm_tester.test import *
+
+nitb = suite.nitb()
+arfcn = suite.reserve_arfcn(band='GSM-1900')
+bts = suite.bts(arfcn)
+ms = suite.modem()
+
+print('start nitb and bts...')
+nitb.bts_add(bts)
+nitb.start()
+bts.start()
+
+nitb.subscriber_add(ms)
+
+ms.connect(nitb.mcc_mnc())
+
+ms.log_info()
+
+print('waiting for modems to attach...')
+wait(ms.is_connected, nitb.mcc_mnc())
+wait(nitb.subscriber_attached, ms)
diff --git a/suites/register/suite.conf b/suites/register/suite.conf
new file mode 100644
index 0000000..eb59abb
--- /dev/null
+++ b/suites/register/suite.conf
@@ -0,0 +1,10 @@
+resources:
+  ip_address:
+  - times: 1
+  bts:
+  - times: 1
+  modem:
+  - times: 1
+
+defaults:
+  timeout: 60s

-- 
To view, visit https://gerrit.osmocom.org/3731
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I6fb5d95bed1fa50c3deaf62a7a6df3cb276bc3c9
Gerrit-PatchSet: 4
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list