[PATCH] osmo-gsm-tester[master]: Verify that BTS successfully connects to NITB

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 May 22 16:51:53 UTC 2017


Hello Neels Hofmeyr, Jenkins Builder,

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

    https://gerrit.osmocom.org/2692

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

Verify that BTS successfully connects to NITB

The current API to request the NITB if a BTS is connected has many
drawbacks. Afaik, with the split NITB->BSC+MSC there will be new
better APIs to request this kind of information, otherwise we need to
add/fix them.

Once that's changed, we can change cell_identity to be increased on
every test similarlly to how it is done for MSISDN. With the current
API, it's really difficult to find the matching BTS unless they are
using sequential cellular_id starting from 0 and without no gaps, so
let's stick with that for now.

Change-Id: I1bbf9ac2b05d95a113ed4ad5e93093431496d44e
---
M selftest/template_test/osmo-nitb.cfg.tmpl
M src/osmo_gsm_tester/bts_sysmo.py
M src/osmo_gsm_tester/osmo_nitb.py
3 files changed, 64 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/92/2692/2

diff --git a/selftest/template_test/osmo-nitb.cfg.tmpl b/selftest/template_test/osmo-nitb.cfg.tmpl
index 3404b7f..a4df36d 100644
--- a/selftest/template_test/osmo-nitb.cfg.tmpl
+++ b/selftest/template_test/osmo-nitb.cfg.tmpl
@@ -59,7 +59,7 @@
  bts ${loop.index}
   type ${bts.type}
   band ${bts.band}
-  cell_identity 0
+  cell_identity ${bts.cell_identity}
   location_area_code ${bts.location_area_code}
   training_sequence_code 7
   base_station_id_code ${bts.base_station_id_code}
diff --git a/src/osmo_gsm_tester/bts_sysmo.py b/src/osmo_gsm_tester/bts_sysmo.py
index 771d303..c16d86b 100644
--- a/src/osmo_gsm_tester/bts_sysmo.py
+++ b/src/osmo_gsm_tester/bts_sysmo.py
@@ -41,6 +41,7 @@
         self.set_log_category(log.C_RUN)
         self.remote_env = {}
         self.remote_user = 'root'
+        self._cell_identity = -1
 
     def start(self):
         with self:
@@ -81,6 +82,8 @@
                  remote_binary, '-c', remote_config_file, '-r', '1',
                  '-i', self.nitb.addr()),
                 remote_cwd=remote_run_dir)
+            self.suite_run.wait(self.nitb.bts_is_connected, self)
+            self.dbg('connected to', self.nitb.name())
 
     def _process_remote(self, name, popen_args, remote_cwd=None):
         run_dir = self.run_dir.new_dir(name)
@@ -130,6 +133,7 @@
     def conf_for_nitb(self):
         values = config.get_defaults('nitb_bts')
         config.overlay(values, config.get_defaults('osmo_bts_sysmo'))
+        config.overlay(values, { 'cell_identity': self.cell_identity })
         config.overlay(values, self.conf)
         self.dbg(conf=values)
         return values
@@ -137,4 +141,10 @@
     def set_nitb(self, nitb):
         self.nitb = nitb
 
+    def set_cell_identity(self, cell_identity):
+        self._cell_identity = cell_identity
+
+    def cell_identity(self):
+        return self._cell_identity
+
 # vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/osmo_gsm_tester/osmo_nitb.py b/src/osmo_gsm_tester/osmo_nitb.py
index 07a3623..1857e4b 100644
--- a/src/osmo_gsm_tester/osmo_nitb.py
+++ b/src/osmo_gsm_tester/osmo_nitb.py
@@ -38,6 +38,7 @@
         self.set_log_category(log.C_RUN)
         self.set_name('osmo-nitb_%s' % nitb_iface.get('addr'))
         self.bts = []
+        self.next_cell_identity = 0
 
     def start(self):
         self.log('Starting osmo-nitb')
@@ -91,6 +92,8 @@
     def bts_add(self, bts):
         self.bts.append(bts)
         bts.set_nitb(self)
+        bts.set_cell_identity(self.next_cell_identity)
+        self.next_cell_identity += 1
 
     def subscriber_add(self, modem, msisdn=None):
         if msisdn is None:
@@ -115,12 +118,21 @@
     def running(self):
         return not self.process.terminated()
 
+    def bts_is_connected(self, bts):
+        with self:
+            return OsmoNitbCtrl(self).bts_is_connected(bts)
 
 class OsmoNitbCtrl(log.Origin):
     PORT = 4249
     SUBSCR_MODIFY_VAR = 'subscriber-modify-v1'
     SUBSCR_MODIFY_REPLY_RE = re.compile("SET_REPLY (\d+) %s OK" % SUBSCR_MODIFY_VAR)
     SUBSCR_LIST_ACTIVE_VAR = 'subscriber-list-active-v1'
+    NUM_BTS_VAR = "number-of-bts"
+    NUM_BTS_RE = re.compile("GET_REPLY (\d+) number-of-bts (?P<bts_count>\d+)")
+    BTS_CELL_IDENTITY_VAR = "bts.%d.cell-identity"
+    BTS_CELL_IDENTITY_RE = re.compile("GET_REPLY (\d+) bts.\d+.cell-identity (?P<cell_identity>\d+)")
+    BTS_OML_STATE_VAR = "bts.%d.oml-connection-state"
+    BTS_OML_STATE_RE = re.compile("GET_REPLY (\d+) bts.\d+.oml-connection-state (?P<oml_state>\w+)")
 
     def __init__(self, nitb):
         self.nitb = nitb
@@ -165,4 +177,45 @@
                 aslist_str = answer_str
             return aslist_str
 
+    def count_bts_connected(self):
+        bts_count = 0
+        with self.ctrl() as ctrl:
+            ctrl.do_get(OsmoNitbCtrl.NUM_BTS_VAR)
+            data = ctrl.receive()
+            while len(data) > 0:
+                (answer, data) = ctrl.remove_ipa_ctrl_header(data)
+                answer_str = answer.decode('utf-8')
+                res = OsmoNitbCtrl.NUM_BTS_RE.match(answer_str)
+                if res:
+                    bts_count = int(res.group('bts_count'))
+                else:
+                    self.raise_exn('Failed to get number of BTSes connected with', self.nitb)
+        return bts_count
+
+    def bts_is_connected(self, bts):
+        num_bts = self.count_bts_connected()
+        with self.ctrl() as ctrl:
+            for i in range(0, num_bts):
+                ctrl.do_get(OsmoNitbCtrl.BTS_CELL_IDENTITY_VAR % i)
+                data = ctrl.receive()
+                while len(data) > 0:
+                    (answer, data) = ctrl.remove_ipa_ctrl_header(data)
+                    answer_str = answer.decode('utf-8')
+                    res = OsmoNitbCtrl.BTS_CELL_IDENTITY_RE.match(answer_str)
+                    if res:
+                        cell_id = int(res.group('cell_identity'))
+                    else:
+                        continue
+                    if cell_id != bts.cell_identity():
+                        continue
+                    ctrl.do_get(OsmoNitbCtrl.BTS_OML_STATE_VAR % i)
+                    data = ctrl.receive()
+                    (answer, data) = ctrl.remove_ipa_ctrl_header(data)
+                    answer_str = answer.decode('utf-8')
+                    res = OsmoNitbCtrl.BTS_OML_STATE_RE.match(answer_str)
+                    if res:
+                        oml_state = str(res.group('oml_state'))
+                        if oml_state == 'connected':
+                            return True
+        return False
 # vim: expandtab tabstop=4 shiftwidth=4

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I1bbf9ac2b05d95a113ed4ad5e93093431496d44e
Gerrit-PatchSet: 2
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>



More information about the gerrit-log mailing list