{ms,enb}_srs: add method to read kpi from a test run

this method uses the kpi_analyzer module for analyzing
stdout, CSV metrics and the logfile (if present).

if the module can't be loaded, no KPI will be added.

Change-Id: I28226a375f9ac4e08424c488062ae6a74a19af92
This commit is contained in:
Andre Puschmann 2020-06-19 15:47:32 +02:00
parent 20087ad8c4
commit f14ff812ce
3 changed files with 56 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import pprint
from ..core import log, util, config, template, process, remote
from . import enb
from . import rfemu
from .srslte_common import srslte_common
from ..core import schema
@ -36,7 +37,7 @@ def on_register_schemas():
def rf_type_valid(rf_type_str):
return rf_type_str in ('zmq', 'uhd', 'soapy', 'bladerf')
class srsENB(enb.eNodeB):
class srsENB(enb.eNodeB, srslte_common):
REMOTE_DIR = '/osmo-gsm-tester-srsenb'
BINFILE = 'srsenb'
@ -68,6 +69,7 @@ class srsENB(enb.eNodeB):
self.remote_log_file = None
self.remote_pcap_file = None
self.enable_pcap = False
self.metrics_file = None
self.testenv = testenv
self._additional_args = []
if not rf_type_valid(conf.get('rf_dev_type', None)):
@ -89,6 +91,9 @@ class srsENB(enb.eNodeB):
except Exception as e:
self.log(repr(e))
# Collect KPIs for each TC
self.testenv.test().set_kpis(self.get_kpis())
def start(self, epc):
self.log('Starting srsENB')
self._epc = epc

View File

@ -26,6 +26,7 @@ from ..core import schema
from .run_node import RunNode
from ..core.event_loop import MainLoop
from .ms import MS
from .srslte_common import srslte_common
def rf_type_valid(rf_type_str):
return rf_type_str in ('zmq', 'uhd', 'soapy', 'bladerf')
@ -64,7 +65,7 @@ def num_prb2symbol_sz(num_prb):
def num_prb2base_srate(num_prb):
return num_prb2symbol_sz(num_prb) * 15 * 1000
class srsUE(MS):
class srsUE(MS, srslte_common):
REMOTE_DIR = '/osmo-gsm-tester-srsue'
BINFILE = 'srsue'
@ -120,6 +121,9 @@ class srsUE(MS):
except Exception as e:
self.log(repr(e))
# Collect KPIs for each TC
self.testenv.test().set_kpis(self.get_kpis())
def scp_back_metrics(self, raiseException=True):
''' Copy back metrics only if they have not been copied back yet '''
if not self.have_metrics_file:

View File

@ -0,0 +1,45 @@
# osmo_gsm_tester: common methods shared among srsLTE components
#
# Copyright (C) 2020 by Software Radio Systems Ltd
#
# Author: Andre Puschmann <andre@softwareradiosystems.com>
#
# 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/>.
from ..core import log
class srslte_common(): # don't inherit from log.Origin here but instead use .name() from whoever inherits from us
def __init__(self):
self.log_file = None
self.process = None
self.metrics_file = None
def get_kpis(self):
''' Use the srsLTE KPI analyzer module (part of srsLTE.git) if available to collect KPIs '''
kpis = {}
try:
# Please make sure the srsLTE scripts folder is included in your PYTHONPATH env variable
from kpi_analyzer import kpi_analyzer
analyzer = kpi_analyzer(self.name())
if self.log_file is not None:
kpis["log_" + self.name()] = analyzer.get_kpi_from_logfile(self.log_file)
if self.process.get_output_file('stdout') is not None:
kpis["stdout_" + self.name()] = analyzer.get_kpi_from_stdout(self.process.get_output_file('stdout'))
if self.metrics_file is not None:
kpis["csv_" + self.name()] = analyzer.get_kpi_from_csv(self.metrics_file)
except ImportError:
self.log("Can't load KPI analyzer module.")
return kpis