ms_driver: Add a virtual bts and make use of it

It's very close to the osmo-bts-trx but without osmo-trx. Modify
the suite to make use of this BTS.

Change-Id: I9f5a2501eb4473ccf2287c902ee207c6a45a1bc5
This commit is contained in:
Holger Hans Peter Freyther 2018-12-06 18:34:53 +00:00
parent 52e5797b3d
commit d2db10d80e
6 changed files with 175 additions and 2 deletions

View File

@ -84,3 +84,6 @@ osmo_trx:
type: uhd
launch_trx: true
clock_reference: internal
osmo_bts_virtual:
max_trx: 1

View File

@ -110,6 +110,12 @@ bts:
device: '01:01:4d:98:24'
port: '3'
- label: OsmoBTS Virtual
type: osmo-bts-virtual
ipa_unit_id: 13
addr: 10.42.42.55
band: GSM-1800
arfcn:
- arfcn: 512
band: GSM-1800

View File

@ -0,0 +1,115 @@
# osmo_gsm_tester: specifics for running an osmo-bts-virtual
#
# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
# Copyright (C) 2018 Holger Hans Peter Freyther
#
# Author: Neels Hofmeyr <neels@hofmeyr.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import pprint
from . import config, util, template, process, bts_osmo
class OsmoBtsVirtual(bts_osmo.OsmoBtsMainUnit):
##############
# PROTECTED
##############
BIN_BTS = 'osmo-bts-virtual'
BIN_PCU = 'osmo-pcu'
CONF_BTS = 'osmo-bts-virtual.cfg'
def __init__(self, suite_run, conf):
"""Initializes the OsmoBtsVirtual."""
super().__init__(suite_run, conf, OsmoBtsVirtual.BIN_BTS, 'osmo_bts_virtual')
self.run_dir = None
self.inst = None
self.env = {}
def launch_process(self, keepalive, binary_name, *args):
"""Launches the osmo-bts-virtual process."""
binary = os.path.abspath(self.inst.child('bin', binary_name))
run_dir = self.run_dir.new_dir(binary_name)
if not os.path.isfile(binary):
raise RuntimeError('Binary missing: %r' % binary)
proc = process.Process(binary_name, run_dir,
(binary,) + args,
env=self.env)
self.suite_run.remember_to_stop(proc, keepalive)
proc.launch()
return proc
def configure(self):
"""Builds the configuration for osmo-bts-virtual and writes it to a file."""
if self.bsc is None:
raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be configured')
self.config_file = self.run_dir.new_file(OsmoBtsVirtual.CONF_BTS)
self.dbg(config_file=self.config_file)
values = dict(osmo_bts_virtual=config.get_defaults('osmo_bts_virtual'))
config.overlay(values, self.suite_run.config())
config.overlay(values, {
'osmo_bts_virtual': {
'oml_remote_ip': self.bsc.addr(),
'pcu_socket_path': self.pcu_socket_path(),
}
})
config.overlay(values, { 'osmo_bts_virtual': self.conf })
self.dbg('OSMO-BTS-VIRTUAL CONFIG:\n' + pprint.pformat(values))
with open(self.config_file, 'w') as f:
r = template.render(OsmoBtsVirtual.CONF_BTS, values)
self.dbg(r)
f.write(r)
########################
# PUBLIC - INTERNAL API
########################
def conf_for_bsc(self):
"""Returns the configuration for the BSC (including the BSC/NITB IP)."""
values = self.conf_for_bsc_prepare()
self.dbg(conf=values)
return values
###################
# PUBLIC (test API included)
###################
def start(self, keepalive=False):
"""Handles starting/turning-up the osmo-bts-virtual process."""
if self.bsc is None:
raise RuntimeError('BTS needs to be added to a BSC or NITB before it can be started')
self.suite_run.poll()
self.log('Starting to connect to', self.bsc)
self.run_dir = util.Dir(self.suite_run.get_test_run_dir().new_dir(self.name()))
self.configure()
self.inst = util.Dir(os.path.abspath(self.suite_run.trial.get_inst('osmo-bts')))
lib = self.inst.child('lib')
if not os.path.isdir(lib):
raise RuntimeError('No lib/ in %r' % self.inst)
self.env = { 'LD_LIBRARY_PATH': util.prepend_library_path(lib) }
self.proc_bts = self.launch_process(keepalive, OsmoBtsVirtual.BIN_BTS, '-r', '1',
'-c', os.path.abspath(self.config_file),
'-i', self.bsc.addr())
self.suite_run.poll()
# vim: expandtab tabstop=4 shiftwidth=4

View File

@ -29,7 +29,7 @@ from . import util
from . import schema
from . import modem
from . import osmo_nitb
from . import bts_sysmo, bts_osmotrx, bts_octphy, bts_nanobts
from . import bts_sysmo, bts_osmotrx, bts_osmovirtual, bts_octphy, bts_nanobts
from .util import is_dict, is_list
@ -102,6 +102,7 @@ KNOWN_BTS_TYPES = {
'osmo-bts-sysmo': bts_sysmo.SysmoBts,
'osmo-bts-trx': bts_osmotrx.OsmoBtsTrx,
'osmo-bts-octphy': bts_octphy.OsmoBtsOctphy,
'osmo-bts-virtual': bts_osmovirtual.OsmoBtsVirtual,
'nanobts': bts_nanobts.NanoBts,
}

View File

@ -0,0 +1,48 @@
! Configuration rendered by osmo-gsm-tester
log stderr
logging color 1
logging print extended-timestamp 1
logging print category 1
logging level abis debug
logging level oml debug
logging level pag debug
logging level rll debug
logging level rr debug
logging level rsl debug
logging level l1c info
logging level l1p error
logging level trx info
! Level required by ready_for_pcu(): pcu info
logging level pcu info
!
line vty
bind ${osmo_bts_virtual.addr}
ctrl
bind ${osmo_bts_virtual.addr}
!
phy 0
instance 0
bts 0
band ${osmo_bts_virtual.band}
ipa unit-id ${osmo_bts_virtual.ipa_unit_id} 0
oml remote-ip ${osmo_bts_virtual.oml_remote_ip}
pcu-socket ${osmo_bts_virtual.pcu_socket_path}
gsmtap-sapi bcch
gsmtap-sapi ccch
gsmtap-sapi rach
gsmtap-sapi agch
gsmtap-sapi pch
gsmtap-sapi sdcch
gsmtap-sapi tch/f
gsmtap-sapi tch/h
gsmtap-sapi pacch
gsmtap-sapi pdtch
gsmtap-sapi ptcch
gsmtap-sapi cbch
gsmtap-sapi sacch
trx 0
power-ramp max-initial 23000 mdBm
power-ramp step-size 2000 mdB
power-ramp step-interval 1
ms-power-control dsp
phy 0 instance 0

View File

@ -2,7 +2,7 @@ resources:
ip_address:
- times: 1
bts:
- times: 1
- type: osmo-bts-virtual
defaults:
timeout: 40s