Change in osmo-gsm-tester[master]: srs-ms: allows to run given scripts before the execution of the UE.

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
Fri Jun 11 11:49:09 UTC 2021


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

Change subject: srs-ms: allows to run given scripts before the execution of the UE.
......................................................................

srs-ms: allows to run given scripts before the execution of the UE.

Executes the scripts given by the 'prerun_scripts' variable before launching the UE.

Change-Id: I718e686b5844f2f07eda820914678052f1008182
---
M src/osmo_gsm_tester/obj/ms_srs.py
1 file changed, 51 insertions(+), 1 deletion(-)

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



diff --git a/src/osmo_gsm_tester/obj/ms_srs.py b/src/osmo_gsm_tester/obj/ms_srs.py
index ec4486f..bb5d226 100644
--- a/src/osmo_gsm_tester/obj/ms_srs.py
+++ b/src/osmo_gsm_tester/obj/ms_srs.py
@@ -45,7 +45,8 @@
         'freq_offset': schema.INT,
         'force_ul_amplitude': schema.STR,
         'dl_freq': schema.STR,
-        'ul_freq': schema.STR
+        'ul_freq': schema.STR,
+        'prerun_scripts[]': schema.STR,
         }
     for key, val in RunNode.schema().items():
         resource_schema['run_node.%s' % key] = val
@@ -171,11 +172,60 @@
     def zmq_base_bind_port(self):
         return self._zmq_base_bind_port
 
+    def run_task(self, task):
+        # Get the arguments.
+        args_index = task.find('args=')
+
+        args = ()
+        # No arguments, all the string is the script.
+        if args_index == -1:
+            index = task.rfind('/')
+            task_name = task [index + 1:]
+            run_dir = util.Dir(self.run_dir.new_dir(task_name))
+            args = (task,)
+            self.log(f'task name is: {task_name}')
+            self.log(f'Running the script: {task} in the run dir: {run_dir}')
+        else:
+            ntask = task[:args_index - 1]
+            index = ntask.rfind('/')
+            task_name = ntask [index + 1:]
+            run_dir = util.Dir(self.run_dir.new_dir(task_name))
+            args = (ntask,)
+            args += tuple(task[args_index + 5:].split(','))
+            self.log(f'task name is: {task_name}')
+            self.log(f'Running the script: {task} in the run dir: {run_dir} with args: {args}')
+
+        proc = process.Process(task_name, run_dir, args)
+        # Set the timeout to a high value 20 minutes.
+        proc.set_default_wait_timeout(1200)
+        returncode = proc.launch_sync()
+        if returncode != 0:
+            raise log.Error('Error executing the pre run scripts. Aborting')
+            return False
+
+        return True
+
+    # Runs all the tasks that are intended to run before the execution of the MS.
+    def prerun_tasks(self):
+        prerun_tasklist = self._conf.get('prerun_scripts', None)
+        if not prerun_tasklist:
+            return True
+
+        for task in prerun_tasklist:
+            if not self.run_task(task):
+                return False
+
+        return True
+
     def connect(self, enb):
         self.log('Starting srsue')
         self.enb = enb
         self.run_dir = util.Dir(self.testenv.test().get_run_dir().new_dir(self.name()))
         self.configure()
+
+        if not self.prerun_tasks():
+            return
+
         if self._run_node.is_local():
             self.start_locally()
         else:

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/24277
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: I718e686b5844f2f07eda820914678052f1008182
Gerrit-Change-Number: 24277
Gerrit-PatchSet: 3
Gerrit-Owner: alealcon <alejandro.leal at srs.io>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-CC: 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/20210611/a08a78b4/attachment.htm>


More information about the gerrit-log mailing list