From 14e3e50b6ee2631315336bb8fa4d2f409f5f4457 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 12 Nov 2018 18:44:47 +0100 Subject: nanobts: Use -G parameter of ipaccess-config to avoid need to restart nanoBTS If OML IP doesn't need to be changed because it's the one already configured, then there's no need to set + restart the nanoBTS, which means we can speed up a test running a nanoBTS by aprox 2 minutes per nanoBTS used. Requires osmo-bsc.git 5c2485dcff35996fce328798351af79c0ff4474c, which fixes json generation in ipaccess-config after -G -q was implemented. Related: OS#3624 Change-Id: I2871dee3de11512250445127f0b807a8990fd4c6 --- src/osmo_gsm_tester/bts_nanobts.py | 56 +++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/src/osmo_gsm_tester/bts_nanobts.py b/src/osmo_gsm_tester/bts_nanobts.py index ab75b16..5fe8bae 100644 --- a/src/osmo_gsm_tester/bts_nanobts.py +++ b/src/osmo_gsm_tester/bts_nanobts.py @@ -19,6 +19,7 @@ import os import re +import json from . import log, config, util, process, pcap_recorder, bts, pcu from . import powersupply from .event_loop import MainLoop @@ -122,24 +123,31 @@ class NanoBts(bts.Bts): ipfind.stop() ipconfig = IpAccessConfig(self.suite_run, self.run_dir, bts_trx_ip) + running_oml_ip = ipconfig.get_oml_ip() + if running_unitid != unitid or running_trx != trx_i: if not ipconfig.set_unit_id(unitid, trx_i, False): raise log.Error('Failed configuring unit id %d trx %d' % (unitid, trx_i)) - # Apply OML IP and restart nanoBTS as it is required to apply the changes. - if not ipconfig.set_oml_ip(self.bsc.addr(), True): - raise log.Error('Failed configuring OML IP %s' % bts_trx_ip) - # Let some time for BTS to restart. It takes much more than 20 secs, and - # this way we make sure we don't catch responses in abisip-find prior to - # BTS restarting. - MainLoop.sleep(self, 20) - - self.log('Starting to connect id %d trx %d to' % (unitid, trx_i), self.bsc) - ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 'postconf') - ipfind.start() - ipfind.wait_bts_ready(bts_trx_ip) - self.log('nanoBTS id %d trx %d configured and running' % (unitid, trx_i)) - ipfind.stop() + if running_oml_ip != self.bsc.addr(): + # Apply OML IP and restart nanoBTS as it is required to apply the changes. + self.dbg('Current OML IPaddr "%s" does not match BSC IPaddr "%s", reconfiguring and restarting it' % (running_oml_ip, self.bsc.addr())) + if not ipconfig.set_oml_ip(self.bsc.addr(), True): + raise log.Error('Failed configuring OML IP %s' % bts_trx_ip) + + # Let some time for BTS to restart. It takes much more than 20 secs, and + # this way we make sure we don't catch responses in abisip-find prior to + # BTS restarting. + MainLoop.sleep(self, 20) + + self.dbg('Starting to connect id %d trx %d to' % (unitid, trx_i), self.bsc) + ipfind = AbisIpFind(self.suite_run, self.run_dir, local_bind_ip, 'postconf') + ipfind.start() + ipfind.wait_bts_ready(bts_trx_ip) + self.log('nanoBTS id %d trx %d configured and running' % (unitid, trx_i)) + ipfind.stop() + else: + self.dbg('nanoBTS id %d trx %d no need to change OML IP (%s) and restart' % (unitid, trx_i, running_oml_ip)) MainLoop.wait(self, self.bsc.bts_is_connected, self, timeout=600) self.log('nanoBTS connected to BSC') @@ -274,20 +282,30 @@ class IpAccessConfig(log.Origin): def set_unit_id(self, unitid, trx_num, restart=False): uid_str = '%d/0/%d' % (unitid, trx_num) if restart: - retcode = self.run('unitid', '--restart', '--unit-id', '%s' % uid_str, self.bts_ip) + retcode = self.run('setunitid', '--restart', '--unit-id', '%s' % uid_str, self.bts_ip) else: - retcode = self.run('unitid', '--unit-id', '%s' % uid_str, self.bts_ip) + retcode = self.run('setunitid', '--unit-id', '%s' % uid_str, self.bts_ip) if retcode != 0: - log.err('ipaccess-config --unit-id %s returned error code %d' % (uid_str, retcode)) + self.err('ipaccess-config --unit-id %s returned error code %d' % (uid_str, retcode)) return retcode == 0 def set_oml_ip(self, omlip, restart=False): if restart: - retcode = self.run('oml', '--restart', '--oml-ip', omlip, self.bts_ip) + retcode = self.run('setoml', '--restart', '--oml-ip', omlip, self.bts_ip) else: - retcode = self.run('oml', '--oml-ip', omlip, self.bts_ip) + retcode = self.run('setoml', '--oml-ip', omlip, self.bts_ip) if retcode != 0: self.error('ipaccess-config --oml-ip %s returned error code %d' % (omlip, retcode)) return retcode == 0 + def get_oml_ip(self): + retcode = self.run('getoml', '-q', '-G', self.bts_ip) + if retcode != 0: + raise log.Error('ipaccess-config -q -G %s returned error code %d' % (self.bts_ip, retcode)) + output = self.proc.get_stdout() + # Our logging system adds "launched on" line at the start, so let's skip until the json code: + output_json = output[output.index('{'):] + json_data = json.loads(output_json) + return json_data['primary_oml_ip'] + # vim: expandtab tabstop=4 shiftwidth=4 -- cgit v1.2.3