Change in osmo-gsm-tester[master]: {ms, enb}_srs: add method to read kpi from a test run

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/.

srs_andre gerrit-no-reply at lists.osmocom.org
Wed Jul 1 09:49:40 UTC 2020


srs_andre has submitted this change. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/18986 )

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

{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
---
M src/osmo_gsm_tester/obj/enb_srs.py
M src/osmo_gsm_tester/obj/ms_srs.py
A src/osmo_gsm_tester/obj/srslte_common.py
3 files changed, 56 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved



diff --git a/src/osmo_gsm_tester/obj/enb_srs.py b/src/osmo_gsm_tester/obj/enb_srs.py
index 0bf4f8b..fe1ea4e 100644
--- a/src/osmo_gsm_tester/obj/enb_srs.py
+++ b/src/osmo_gsm_tester/obj/enb_srs.py
@@ -23,6 +23,7 @@
 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 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 @@
         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 @@
             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
diff --git a/src/osmo_gsm_tester/obj/ms_srs.py b/src/osmo_gsm_tester/obj/ms_srs.py
index 9f77bb6..ebd066d 100644
--- a/src/osmo_gsm_tester/obj/ms_srs.py
+++ b/src/osmo_gsm_tester/obj/ms_srs.py
@@ -26,6 +26,7 @@
 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_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 @@
             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:
diff --git a/src/osmo_gsm_tester/obj/srslte_common.py b/src/osmo_gsm_tester/obj/srslte_common.py
new file mode 100644
index 0000000..33f12d4
--- /dev/null
+++ b/src/osmo_gsm_tester/obj/srslte_common.py
@@ -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 at 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

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/18986
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I28226a375f9ac4e08424c488062ae6a74a19af92
Gerrit-Change-Number: 18986
Gerrit-PatchSet: 4
Gerrit-Owner: srs_andre <andre at softwareradiosystems.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: srs_andre <andre at softwareradiosystems.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200701/eb480cce/attachment.htm>


More information about the gerrit-log mailing list