Skip to content
Failed

Changes

Summary

  1. fix and refactor logging: drop 'with', simplify (details)
  2. log_test.py: cosmetic follow-up (details)
  3. ofono_client: gracefully handle Scan() failure (details)
Commit 1a7a3f0e4318bccbd3ed177d5b07fa3618d06868 by Neels Hofmeyr
fix and refactor logging: drop 'with', simplify
With the recent fix of the junit report related issues, another issue
arose: the 'with log.Origin' was changed to disallow __enter__ing an
object twice to fix problems, now still code would fail because it tries
to do 'with' on the same object twice. The only reason is to ensure that
logging is associated with a given object. Instead of complicating even
more, implement differently.
Refactor logging to simplify use: drop the 'with Origin' style
completely, and instead use the python stack to determine which objects
are created by which, and which object to associate a log statement
with.
The new way: we rely on the convention that each class instance has a
local
'self' referencing the object instance. If we need to find an origin as
a new object's parent, or to associate a log message with, we traverse
each stack frame, fetching the first local 'self' object that is a
log.Origin class instance.
How to use:
Simply call log.log() anywhere, and it finds an Origin object to log
for, from the stack. Alternatively call self.log() for any Origin()
object to skip the lookup.
Create classes as child class of log.Origin and make sure to call
super().__init__(category, name). This constructor will magically find a
parent Origin on the stack.
When an exception happens, we first escalate the exception up through
call scopes to where ever it is handled by log.log_exn(). This then
finds an Origin object in the traceback's stack frames, no need to nest
in 'with' scopes.
Hence the 'with log.Origin' now "happens implicitly", we can write pure
natural python code, no more hassles with scope ordering.
Furthermore, any frame can place additional logging information in a
frame by calling log.ctx(). This is automatically inserted in the
ancestry associated with a log statement / exception.
Change-Id: I5f9b53150f2bb6fa9d63ce27f0806f0ca6a45e90
The file was modifiedsrc/osmo_gsm_tester/pcap_recorder.py
The file was modifiedsrc/osmo_gsm_tester/osmo_bsc.py
The file was modifiedsrc/osmo_gsm_tester/osmo_ctrl.py
The file was modifiedsrc/osmo_gsm_tester/resource.py
The file was modifiedsrc/osmo_gsm_tester/osmo_hlr.py
The file was modifiedsrc/osmo_gsm_tester/suite.py
The file was modifiedsrc/osmo_gsm_tester/osmo_mgcpgw.py
The file was modifiedselftest/log_test.ok
The file was modifiedsrc/osmo_gsm_tester/process.py
The file was modifiedsrc/osmo_gsm_tester/osmo_nitb.py
The file was modifiedselftest/resource_test.ok
The file was modifiedselftest/resource_test.py
The file was modifiedselftest/suite_test.ok
The file was modifiedsrc/osmo_gsm_tester/event_loop.py
The file was modifiedselftest/log_test.py
The file was modifiedsrc/osmo_gsm_tester/bts_sysmo.py
The file was modifiedsrc/osmo_gsm_tester/osmo_msc.py
The file was modifiedsrc/osmo_gsm_tester/config.py
The file was modifiedsrc/osmo_gsm_tester/schema.py
The file was modifiedsrc/osmo_gsm_tester/log.py
The file was modifiedselftest/template_test.ok
The file was modifiedselftest/config_test.ok
The file was modifiedsrc/osmo_gsm_tester/template.py
The file was modifiedselftest/suite_test.py
The file was modifiedsrc/osmo_gsm_tester/trial.py
The file was modifiedsrc/osmo_gsm_tester/bts_osmotrx.py
The file was modifiedsrc/osmo_gsm_tester/ofono_client.py
Commit e4cd7910a544019f6c01ae8a8b5a26e6c85a361e by Neels Hofmeyr
log_test.py: cosmetic follow-up
This is kept separate to not clutter up previous patch
I5f9b53150f2bb6fa9d63ce27f0806f0ca6a45e90.
Change-Id: I0ce50375fdb028da96c2159d577d8ed1967d4fe6
The file was modifiedselftest/log_test.ok
The file was modifiedselftest/log_test.py
Commit 4d63d920333c23996b4a2773aa7c363812971b37 by Neels Hofmeyr
ofono_client: gracefully handle Scan() failure
ofono's NetworkRegistration.Scan() method fails sporadically. On
failure, check if we are now registered to the desired network, and
schedule another scan otherwise.
For instance it fails with org.ofono.Error.Failed if the modem starts to
register internally after we started Scan() and the registering succeeds
while we are still waiting for Scan() to finsih.
Change-Id: I4a2265ee39a94daa00f525b1c7037a6775509425
The file was modifiedsrc/osmo_gsm_tester/ofono_client.py