Change in osmo-gsm-tester[master]: EventLoop: Fix log error "Origin parent loop" during wait()

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
Wed Jun 10 18:03:52 UTC 2020


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

Change subject: EventLoop: Fix log error "Origin parent loop" during wait()
......................................................................

EventLoop: Fix log error "Origin parent loop" during wait()

Setting the log.ctx manually is not needed anymore and it's actually
harmful since all palces where it was used, a log.Origin already in path
was being passed, causing a origin loop.

Change-Id: I0511b9f7bc59e3c7f2269ff3155d0c95db58d063
---
M src/osmo_gsm_tester/core/event_loop.py
M src/osmo_gsm_tester/core/process.py
M src/osmo_gsm_tester/obj/bts_nanobts.py
M src/osmo_gsm_tester/obj/bts_osmotrx.py
M src/osmo_gsm_tester/obj/esme.py
M src/osmo_gsm_tester/obj/ms_ofono.py
M src/osmo_gsm_tester/obj/ms_srs.py
M src/osmo_gsm_tester/obj/osmocon.py
M src/osmo_gsm_tester/obj/powersupply.py
M src/osmo_gsm_tester/obj/powersupply_sispm.py
M src/osmo_gsm_tester/testenv.py
11 files changed, 29 insertions(+), 31 deletions(-)

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



diff --git a/src/osmo_gsm_tester/core/event_loop.py b/src/osmo_gsm_tester/core/event_loop.py
index fe88ef4..4092a66 100644
--- a/src/osmo_gsm_tester/core/event_loop.py
+++ b/src/osmo_gsm_tester/core/event_loop.py
@@ -85,9 +85,8 @@
         self.gctx.iteration(may_block)
         self.deferred_handling.handle_queue()
 
-    def wait_no_raise(self, log_obj, condition, condition_args, condition_kwargs, timeout, timestep):
+    def wait_no_raise(self, condition, condition_args, condition_kwargs, timeout, timestep):
         if not timeout or timeout < 0:
-            self = log_obj
             raise log.Error('wait() *must* time out at some point.', timeout=timeout)
         if timestep < 0.1:
             timestep = 0.1
@@ -105,14 +104,13 @@
                 success = wait_req.condition_ack
                 return success
 
-    def wait(self, log_obj, condition, *condition_args, timeout=300, timestep=1, **condition_kwargs):
-        if not self.wait_no_raise(log_obj, condition, condition_args, condition_kwargs, timeout, timestep):
-            log.ctx(log_obj)
+    def wait(self, condition, *condition_args, timeout=300, timestep=1, **condition_kwargs):
+        if not self.wait_no_raise(condition, condition_args, condition_kwargs, timeout, timestep):
             raise log.Error('Wait timeout', condition=condition, timeout=timeout, timestep=timestep)
 
-    def sleep(self, log_obj, seconds):
+    def sleep(self, seconds):
         assert seconds > 0.
-        self.wait_no_raise(log_obj, lambda: False, [], {}, timeout=seconds, timestep=seconds)
+        self.wait_no_raise(lambda: False, [], {}, timeout=seconds, timestep=seconds)
 
 
 MainLoop = EventLoop()
diff --git a/src/osmo_gsm_tester/core/process.py b/src/osmo_gsm_tester/core/process.py
index 33ae69a..8954674 100644
--- a/src/osmo_gsm_tester/core/process.py
+++ b/src/osmo_gsm_tester/core/process.py
@@ -347,7 +347,7 @@
         return self.result is not None
 
     def wait(self, timeout=300):
-        MainLoop.wait(self, self.terminated, timeout=timeout)
+        MainLoop.wait(self.terminated, timeout=timeout)
 
     def stdin_write(self, cmd):
         '''
diff --git a/src/osmo_gsm_tester/obj/bts_nanobts.py b/src/osmo_gsm_tester/obj/bts_nanobts.py
index a818a8f..03730a6 100644
--- a/src/osmo_gsm_tester/obj/bts_nanobts.py
+++ b/src/osmo_gsm_tester/obj/bts_nanobts.py
@@ -139,7 +139,7 @@
                 # Let some time for BTS to restart. It takes much more than 20 secs, and
                 # this way we make sure we don't catch responses in abisip-find prior to
                 # BTS restarting.
-                MainLoop.sleep(self, 20)
+                MainLoop.sleep(20)
 
                 self.dbg('Starting to connect id %d trx %d to' % (unitid, trx_i), self.bsc)
                 ipfind = AbisIpFind(self.testenv, self.run_dir, local_bind_ip, 'postconf')
@@ -150,7 +150,7 @@
             else:
                 self.dbg('nanoBTS id %d trx %d no need to change OML IP (%s) and restart' % (unitid, trx_i, running_oml_ip))
 
-        MainLoop.wait(self, self.bsc.bts_is_connected, self, timeout=600)
+        MainLoop.wait(self.bsc.bts_is_connected, self, timeout=600)
         self.log('nanoBTS connected to BSC')
 
         #According to roh, it can be configured to use a static IP in a permanent way:
@@ -239,11 +239,11 @@
         return self.get_line_by_ip(ipaddr) is not None
 
     def wait_bts_ready(self, ipaddr):
-        MainLoop.wait(self, self.bts_ready, ipaddr)
+        MainLoop.wait(self.bts_ready, ipaddr)
         # There's a period of time after boot in which nanobts answers to
         # abisip-find but tcp RSTs ipacces-config conns. Let's wait in here a
         # bit more time to avoid failing after stating the BTS is ready.
-        MainLoop.sleep(self, 2)
+        MainLoop.sleep(2)
 
 class IpAccessConfig(log.Origin):
     testenv = None
diff --git a/src/osmo_gsm_tester/obj/bts_osmotrx.py b/src/osmo_gsm_tester/obj/bts_osmotrx.py
index 0eeef49..8eed8cf 100644
--- a/src/osmo_gsm_tester/obj/bts_osmotrx.py
+++ b/src/osmo_gsm_tester/obj/bts_osmotrx.py
@@ -173,7 +173,7 @@
             self.trx = OsmoTrx.get_instance_by_type(self.get_osmo_trx_type(), self.testenv, self.conf_for_osmotrx())
             self.trx.start(keepalive)
             self.log('Waiting for %s to start up...' % self.trx.name())
-            MainLoop.wait(self, self.trx.trx_ready)
+            MainLoop.wait(self.trx.trx_ready)
 
         self.inst = util.Dir(os.path.abspath(self.testenv.suite().trial().get_inst('osmo-bts')))
         lib = self.inst.child('lib')
@@ -374,7 +374,7 @@
                 break
             keep_trying = keep_trying - 1
             self.log('Configuring SC5 TRX failed, retrying %d more times' % keep_trying)
-            MainLoop.sleep(self, 5)
+            MainLoop.sleep(5)
         if keep_trying == 0:
             raise log.Error('Failed configuring SC5!')
         self.ready = True
diff --git a/src/osmo_gsm_tester/obj/esme.py b/src/osmo_gsm_tester/obj/esme.py
index 13e1bba..cd416ab 100644
--- a/src/osmo_gsm_tester/obj/esme.py
+++ b/src/osmo_gsm_tester/obj/esme.py
@@ -190,7 +190,7 @@
             umref, self.pdus_pending = self.sms_send(sms_obj, mode, receipt)
             self.dbg('pdus_pending:', self.pdus_pending)
             self.client.set_message_sent_handler(self._process_pdus_pending)
-            MainLoop.wait(self, lambda: len(self.pdus_pending) == 0, timeout=10)
+            MainLoop.wait(lambda: len(self.pdus_pending) == 0, timeout=10)
             return umref
         finally:
             self.client.set_message_sent_handler(old_func)
diff --git a/src/osmo_gsm_tester/obj/ms_ofono.py b/src/osmo_gsm_tester/obj/ms_ofono.py
index cec6824..b604325 100644
--- a/src/osmo_gsm_tester/obj/ms_ofono.py
+++ b/src/osmo_gsm_tester/obj/ms_ofono.py
@@ -317,7 +317,7 @@
         self.log('Setting', name, val)
         self.interface(iface).SetProperty(name, Variant('b', val))
 
-        MainLoop.wait(self, self.property_is, name, bool_val)
+        MainLoop.wait(self.property_is, name, bool_val)
 
     def set_powered(self, powered=True):
         self.set_bool('Powered', powered)
@@ -461,10 +461,10 @@
                 if not self.is_powered():
                         self.set_powered()
                 # wait for SimManager iface to appear after we power on
-                MainLoop.wait(self, self.dbus.has_interface, I_SIMMGR, timeout=10)
+                MainLoop.wait(self.dbus.has_interface, I_SIMMGR, timeout=10)
                 simmgr = self.dbus.interface(I_SIMMGR)
                 # If properties are requested quickly, it may happen that Sim property is still not there.
-                MainLoop.wait(self, lambda: simmgr.GetProperties().get('SubscriberIdentity', None) is not None, timeout=10)
+                MainLoop.wait(lambda: simmgr.GetProperties().get('SubscriberIdentity', None) is not None, timeout=10)
                 props = simmgr.GetProperties()
                 self.dbg('got SIM properties', props)
                 self._imsi = props.get('SubscriberIdentity', None)
@@ -606,7 +606,7 @@
         self.set_powered(False)
         req_ifaces = self._required_ifaces()
         for iface in req_ifaces:
-            MainLoop.wait(self, lambda: not self.dbus.has_interface(iface), timeout=10)
+            MainLoop.wait(lambda: not self.dbus.has_interface(iface), timeout=10)
 
     def power_cycle(self):
         'Power the modem and put it online, power cycle it if it was already on'
@@ -618,7 +618,7 @@
             self.dbg('Powering on')
         self.set_powered()
         self.set_online()
-        MainLoop.wait(self, self.dbus.has_interface, *req_ifaces, timeout=10)
+        MainLoop.wait(self.dbus.has_interface, *req_ifaces, timeout=10)
 
     def connect(self, mcc_mnc=None):
         'Connect to MCC+MNC'
@@ -671,7 +671,7 @@
 
         # Activate can only be called after we are attached
         ctx.SetProperty('Active', Variant('b', True))
-        MainLoop.wait(self, lambda: ctx.GetProperties()['Active'] == True)
+        MainLoop.wait(lambda: ctx.GetProperties()['Active'] == True)
         self.log('context activated', path=ctx_path, apn=apn, user=user, properties=ctx.GetProperties())
         return ctx_path
 
@@ -679,7 +679,7 @@
         self.dbg('deactivate_context', path=ctx_id)
         ctx = systembus_get(ctx_id)
         ctx.SetProperty('Active', Variant('b', False))
-        MainLoop.wait(self, lambda: ctx.GetProperties()['Active'] == False)
+        MainLoop.wait(lambda: ctx.GetProperties()['Active'] == False)
         self.dbg('deactivate_context active=false, removing', path=ctx_id)
         connmgr = self.dbus.interface(I_CONNMGR)
         connmgr.RemoveContext(ctx_id)
@@ -770,7 +770,7 @@
         else:
             caller_msisdn = str(caller_msisdn_or_modem)
         self.dbg('Waiting for incoming call from:', caller_msisdn)
-        MainLoop.wait(self, lambda: self._find_call_msisdn_state(caller_msisdn, 'incoming') is not None, timeout=timeout)
+        MainLoop.wait(lambda: self._find_call_msisdn_state(caller_msisdn, 'incoming') is not None, timeout=timeout)
         return self._find_call_msisdn_state(caller_msisdn, 'incoming')
 
     def call_answer(self, call_id):
diff --git a/src/osmo_gsm_tester/obj/ms_srs.py b/src/osmo_gsm_tester/obj/ms_srs.py
index 0aad954..3aa6b0a 100644
--- a/src/osmo_gsm_tester/obj/ms_srs.py
+++ b/src/osmo_gsm_tester/obj/ms_srs.py
@@ -123,7 +123,7 @@
     def sleep_after_stop(self):
         # Only sleep once
         if self.stop_sleep_time > 0:
-            MainLoop.sleep(self, self.stop_sleep_time)
+            MainLoop.sleep(self.stop_sleep_time)
             self.stop_sleep_time = 0
 
     def stop(self):
diff --git a/src/osmo_gsm_tester/obj/osmocon.py b/src/osmo_gsm_tester/obj/osmocon.py
index c37cf36..18ee382 100644
--- a/src/osmo_gsm_tester/obj/osmocon.py
+++ b/src/osmo_gsm_tester/obj/osmocon.py
@@ -89,7 +89,7 @@
         self.testenv.remember_to_stop(self.process)
         self.process.launch()
         self.log('Waiting for osmocon to be up and running')
-        MainLoop.wait(self, os.path.exists, self.l2_socket_path())
+        MainLoop.wait(os.path.exists, self.l2_socket_path())
 
     def running(self):
         return not self.process.terminated()
diff --git a/src/osmo_gsm_tester/obj/powersupply.py b/src/osmo_gsm_tester/obj/powersupply.py
index bc7c0e3..7715a46 100644
--- a/src/osmo_gsm_tester/obj/powersupply.py
+++ b/src/osmo_gsm_tester/obj/powersupply.py
@@ -47,7 +47,7 @@
     def power_cycle(self, sleep=0):
         """Turns off the device, waits N.N seconds, then turn on the device."""
         self.power_set(False)
-        MainLoop.sleep(self, sleep)
+        MainLoop.sleep(sleep)
         self.power_set(True)
 
 def get_instance_by_type(pwsupply_type, pwsupply_opt):
diff --git a/src/osmo_gsm_tester/obj/powersupply_sispm.py b/src/osmo_gsm_tester/obj/powersupply_sispm.py
index 0b1ad07..4fec83e 100644
--- a/src/osmo_gsm_tester/obj/powersupply_sispm.py
+++ b/src/osmo_gsm_tester/obj/powersupply_sispm.py
@@ -48,7 +48,7 @@
             except USBError as e:
                     if e.errno == 16 or e.errno==110:
                         self.log('skip usb error, retry', repr(e))
-                        MainLoop.sleep(self, 0.1)
+                        MainLoop.sleep(0.1)
                         continue
                     raise e
 
diff --git a/src/osmo_gsm_tester/testenv.py b/src/osmo_gsm_tester/testenv.py
index 7ca854b..4709b4c 100644
--- a/src/osmo_gsm_tester/testenv.py
+++ b/src/osmo_gsm_tester/testenv.py
@@ -345,13 +345,13 @@
     log = test.log
     dbg = test.dbg
     err = test.err
-    wait = lambda *args, **kwargs: MainLoop.wait(suite_run, *args, **kwargs)
-    wait_no_raise = lambda *args, **kwargs: MainLoop.wait_no_raise(suite_run, *args, **kwargs)
-    sleep = lambda *args, **kwargs: MainLoop.sleep(suite_run, *args, **kwargs)
+    tenv = TestEnv(suite_run, _test)
+    wait = MainLoop.wait
+    wait_no_raise = MainLoop.wait_no_raise
+    sleep = MainLoop.sleep
     poll = MainLoop.poll
     Sms = Sms_class
     process = process_module
-    tenv = TestEnv(suite_run, _test)
     prompt = tenv.prompt
     return tenv
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/18777
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: I0511b9f7bc59e3c7f2269ff3155d0c95db58d063
Gerrit-Change-Number: 18777
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
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/20200610/0b183558/attachment.htm>


More information about the gerrit-log mailing list