Change in osmo-gsm-tester[master]: ms_srs: fix scp-back-metrics routine

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

pespin gerrit-no-reply at lists.osmocom.org
Thu Jun 25 13:53:54 UTC 2020


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

Change subject: ms_srs: fix scp-back-metrics routine
......................................................................

ms_srs: fix scp-back-metrics routine

every call to verify_metrics would copy back metrics again. see log here:

23:29:22.149299 run                 srsue(pid=31521): Terminating (SIGINT)
23:29:22.368263 run                 srsue(pid=31521): Terminated: ok {rc=0}
23:29:28.401035 run      scp-back-metrics(pid=32265): Launched
23:29:29.423083 run      scp-back-metrics(pid=32265): Terminated: ok {rc=0}
23:29:29.490275 run      scp-back-metrics(pid=32271): Launched
23:29:30.513852 run      scp-back-metrics(pid=32271): Terminated: ok {rc=0}
23:29:30.550862 run      scp-back-metrics(pid=32277): Launched
23:29:31.573962 run      scp-back-metrics(pid=32277): Terminated: ok {rc=0}

this patch only copies back metrics only once. also make sure that, similar
to logs, metrics are always copied back at the end of the run even if they
are not used for metrics checking. this is needed to run the plotting
script.

Change-Id: Ie7c156a5b2c8768bf90ff8e86515976e0d454c25
---
M src/osmo_gsm_tester/obj/ms_srs.py
1 file changed, 27 insertions(+), 11 deletions(-)

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



diff --git a/src/osmo_gsm_tester/obj/ms_srs.py b/src/osmo_gsm_tester/obj/ms_srs.py
index cf2e166..57721ac 100644
--- a/src/osmo_gsm_tester/obj/ms_srs.py
+++ b/src/osmo_gsm_tester/obj/ms_srs.py
@@ -81,6 +81,7 @@
         self.log_file = None
         self.pcap_file = None
         self.metrics_file = None
+        self.have_metrics_file = False
         self.process = None
         self.rem_host = None
         self.remote_inst = None
@@ -107,6 +108,7 @@
         self.sleep_after_stop()
 
         # copy back files (may not exist, for instance if there was an early error of process):
+        self.scp_back_metrics(raiseException=False)
         try:
             self.rem_host.scpfrom('scp-back-log', self.remote_log_file, self.log_file)
         except Exception as e:
@@ -117,6 +119,29 @@
             except Exception as e:
                 self.log(repr(e))
 
+    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:
+            # file is not properly flushed until the process has stopped.
+            if self.running():
+                self.stop()
+
+            # only SCP back if not running locally
+            if not self._run_node.is_local():
+                try:
+                    self.rem_host.scpfrom('scp-back-metrics', self.remote_metrics_file, self.metrics_file)
+                except Exception as e:
+                    if raiseException:
+                        self.err('Failed copying back metrics file from remote host')
+                        raise e
+                    else:
+                        # only log error
+                        self.log(repr(e))
+            # make sure to only call it once
+            self.have_metrics_file = True
+        else:
+            self.dbg('Metrics have already been copied back')
+
     def netns(self):
         return "srsue1"
 
@@ -362,17 +387,8 @@
         raise log.Error('counter %s not implemented!' % counter_name)
 
     def verify_metric(self, value, operation='avg', metric='dl_brate', criterion='gt', window=1):
-        # file is not properly flushed until the process has stopped.
-        if self.running():
-            self.stop()
-
-        if not self._run_node.is_local():
-            try:
-                self.rem_host.scpfrom('scp-back-metrics', self.remote_metrics_file, self.metrics_file)
-            except Exception as e:
-                self.err('Failed copying back metrics file from remote host')
-                raise e
-
+        # copy back metrics if we have not already done so
+        self.scp_back_metrics(self)
         metrics = srsUEMetrics(self.metrics_file)
         return metrics.verify(value, operation, metric, criterion, window)
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/18983
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: Ie7c156a5b2c8768bf90ff8e86515976e0d454c25
Gerrit-Change-Number: 18983
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre <andre at softwareradiosystems.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200625/69d90831/attachment.htm>


More information about the gerrit-log mailing list