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/.
Alejandro Leal gerrit-no-reply at lists.osmocom.orgAlejandro Leal has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/24278 ) Change subject: srs-enb: runs the given list of scripts before and after launching the eNodeB. ...................................................................... srs-enb: runs the given list of scripts before and after launching the eNodeB. Allows to run given scripts before and after the execution of the SRS eNodeB. The scripts are retrieved as a list from the resource.conf file. Change-Id: I5017caae933809b89b32ea132be8552d6554e20e --- M src/osmo_gsm_tester/obj/enb_srs.py 1 file changed, 72 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/78/24278/1 diff --git a/src/osmo_gsm_tester/obj/enb_srs.py b/src/osmo_gsm_tester/obj/enb_srs.py index 708e63a..a3551c6 100644 --- a/src/osmo_gsm_tester/obj/enb_srs.py +++ b/src/osmo_gsm_tester/obj/enb_srs.py @@ -29,6 +29,12 @@ from ..core import schema def on_register_schemas(): + resource_schema = { + 'prerun_scripts[]': schema.STR, + 'postrun_scripts[]': schema.STR, + } + schema.register_resource_schema('enb', resource_schema) + config_schema = { 'enable_pcap': schema.BOOL_STR, 'enable_tracing': schema.BOOL_STR, @@ -100,6 +106,10 @@ # Make sure we give the UE time to tear down self.sleep_after_stop() + # Execute the post run tasks. + if not self.postrun_tasks(): + self.log('Could not execute the post run tasks') + # copy back files (may not exist, for instance if there was an early error of process): self.scp_back_metrics(raiseException=False) @@ -151,11 +161,73 @@ else: self.dbg('Metrics have already been copied back') + 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 eNodeb. + 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 + + # Runs all the tasks that are intended to run after the execution of the eNodeb. + def postrun_tasks(self): + postrun_tasklist = self._conf.get('postrun_scripts', None) + if not postrun_tasklist: + return True + + for task in postrun_tasklist: + if not self.run_task(task): + return False + + return True + def start(self, epc): self.log('Starting srsENB') self._epc = epc self.run_dir = util.Dir(self.testenv.test().get_run_dir().new_dir(self.name())) self.configure() + + if not self.prerun_tasks(): + self.log('Pre run tasks failed. Aborting') + return + if self._run_node.is_local(): self.start_locally() else: -- To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/24278 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: I5017caae933809b89b32ea132be8552d6554e20e Gerrit-Change-Number: 24278 Gerrit-PatchSet: 1 Gerrit-Owner: Alejandro Leal <alejandro.leal at srs.io> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210519/e30c2287/attachment.htm>