[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 11:18:09 UTC 2017


Review at  https://gerrit.osmocom.org/2692

Verify that BTS successfully connects to NITB

Change-Id: I1bbf9ac2b05d95a113ed4ad5e93093431496d44e
---
M example/defaults.conf
M selftest/template_test/osmo-nitb.cfg.tmpl
M src/osmo_gsm_tester/bts_sysmo.py
M src/osmo_gsm_tester/osmo_nitb.py
4 files changed, 68 insertions(+), 7 deletions(-)


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

diff --git a/example/defaults.conf b/example/defaults.conf
index 3685446..5df0a8c 100644
--- a/example/defaults.conf
+++ b/example/defaults.conf
@@ -10,6 +10,7 @@
 nitb_bts:
   location_area_code: 23
   base_station_id_code: 63
+  cell_identity: 0
   stream_id: 255
   osmobsc_bts_type: sysmobts
   trx_list:
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..8955ba8 100644
--- a/src/osmo_gsm_tester/bts_sysmo.py
+++ b/src/osmo_gsm_tester/bts_sysmo.py
@@ -37,6 +37,7 @@
     def __init__(self, suite_run, conf):
         self.suite_run = suite_run
         self.conf = conf
+        self._conf_for_ntib = None
         self.set_name('osmo-bts-sysmo')
         self.set_log_category(log.C_RUN)
         self.remote_env = {}
@@ -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)
@@ -128,13 +131,17 @@
             f.write(r)
 
     def conf_for_nitb(self):
-        values = config.get_defaults('nitb_bts')
-        config.overlay(values, config.get_defaults('osmo_bts_sysmo'))
-        config.overlay(values, self.conf)
-        self.dbg(conf=values)
-        return values
+        if not self._conf_for_ntib:
+            self._conf_for_ntib = config.get_defaults('nitb_bts')
+            config.overlay(self._conf_for_ntib, config.get_defaults('osmo_bts_sysmo'))
+            config.overlay(self._conf_for_ntib, self.conf)
+            self.dbg(conf=self._conf_for_ntib)
+        return self._conf_for_ntib
 
     def set_nitb(self, nitb):
         self.nitb = nitb
 
+    def cell_identity(self):
+        return int(self.conf_for_nitb()['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 13dfe27..c0c6de5 100644
--- a/src/osmo_gsm_tester/osmo_nitb.py
+++ b/src/osmo_gsm_tester/osmo_nitb.py
@@ -115,12 +115,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
@@ -152,7 +161,6 @@
             return True
 
     def subscriber_list_active(self):
-        var = 'subscriber-list-active-v1'
         aslist_str = ""
         with self.ctrl() as ctrl:
             ctrl.do_get(OsmoNitbCtrl.SUBSCR_LIST_ACTIVE_VAR)
@@ -166,4 +174,49 @@
                 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: newchange
Gerrit-Change-Id: I1bbf9ac2b05d95a113ed4ad5e93093431496d44e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list