Change in osmo-gsm-tester[master]: process: Move standalone run_local_sync as method of Process

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue Nov 13 12:10:48 UTC 2018


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/11747 )

Change subject: process: Move standalone run_local_sync as method of Process
......................................................................

process: Move standalone run_local_sync as method of Process

Change-Id: Ib2b3fd39db5400a93a8caabae367dac3e3250247
---
M src/osmo_gsm_tester/iperf3.py
M src/osmo_gsm_tester/modem.py
M src/osmo_gsm_tester/process.py
3 files changed, 20 insertions(+), 16 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/src/osmo_gsm_tester/iperf3.py b/src/osmo_gsm_tester/iperf3.py
index e1ed6ff..894b10f 100644
--- a/src/osmo_gsm_tester/iperf3.py
+++ b/src/osmo_gsm_tester/iperf3.py
@@ -105,7 +105,7 @@
             self.process = process.NetNSProcess(self.name(), self.run_dir, netns, popen_args, env={})
         else:
             self.process = process.Process(self.name(), self.run_dir, popen_args, env={})
-        process.run_proc_sync(self.process)
+        self.process.launch_sync()
         return self.get_results()
 
     def get_results(self):
diff --git a/src/osmo_gsm_tester/modem.py b/src/osmo_gsm_tester/modem.py
index d35933a..5106702 100644
--- a/src/osmo_gsm_tester/modem.py
+++ b/src/osmo_gsm_tester/modem.py
@@ -636,7 +636,7 @@
     def run_netns_wait(self, name, popen_args):
         proc = process.NetNSProcess(name, self.run_dir.new_dir(name), self.netns(), popen_args,
                                        env={})
-        process.run_proc_sync(proc)
+        proc.launch_sync()
 
     def setup_context_data_plane(self, ctx_id):
         self.dbg('setup_context_data', path=ctx_id)
diff --git a/src/osmo_gsm_tester/process.py b/src/osmo_gsm_tester/process.py
index a845f7f..40d0cc1 100644
--- a/src/osmo_gsm_tester/process.py
+++ b/src/osmo_gsm_tester/process.py
@@ -77,6 +77,21 @@
         self.set_name(self.name_str, pid=self.process_obj.pid)
         self.log('Launched')
 
+    def launch_sync(self):
+        '''
+        calls launch() method and block waiting for it to finish, serving the
+        mainloop meanwhile.
+        '''
+        try:
+            self.launch()
+            self.wait()
+        except Exception as e:
+            self.terminate()
+            raise e
+        if self.result != 0:
+            log.ctx(self)
+            raise log.Error('Exited in error')
+
     def respawn(self):
         self.dbg('respawn')
         assert not self.is_running()
@@ -255,31 +270,20 @@
         run_local_netns_sync(self.run_dir, self.name()+"-kill", self.netns, kill_cmd)
 
 
-def run_proc_sync(proc):
-    try:
-        proc.launch()
-        proc.wait()
-    except Exception as e:
-        proc.terminate()
-        raise e
-    if proc.result != 0:
-        log.ctx(proc)
-        raise log.Error('Exited in error')
-
 def run_local_sync(run_dir, name, popen_args):
     run_dir =run_dir.new_dir(name)
     proc = Process(name, run_dir, popen_args)
-    run_proc_sync(proc)
+    proc.launch_sync()
 
 def run_local_netns_sync(run_dir, name, netns, popen_args):
     run_dir =run_dir.new_dir(name)
     proc = NetNSProcess(name, run_dir, netns, popen_args)
-    run_proc_sync(proc)
+    proc.launch_sync()
 
 def run_remote_sync(run_dir, remote_user, remote_addr, name, popen_args, remote_cwd=None):
     run_dir = run_dir.new_dir(name)
     proc = RemoteProcess(name, run_dir, remote_user, remote_addr, remote_cwd, popen_args)
-    run_proc_sync(proc)
+    proc.launch_sync()
 
 def scp(run_dir, remote_user, remote_addr, name, local_path, remote_path):
     run_local_sync(run_dir, name, ('scp', '-r', local_path, '%s@%s:%s' % (remote_user, remote_addr, remote_path)))

-- 
To view, visit https://gerrit.osmocom.org/11747
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib2b3fd39db5400a93a8caabae367dac3e3250247
Gerrit-Change-Number: 11747
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181113/9d3edf40/attachment.html>


More information about the gerrit-log mailing list