[MERGED] osmo-gsm-tester[master]: fix problem in origin ancestry: don't add self twice

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Jun 7 17:57:23 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: fix problem in origin ancestry: don't add self twice
......................................................................


fix problem in origin ancestry: don't add self twice

Also add various comments to illustrate what is going on during origin
resolution.

In the regression tests' expectations, some duplicate entries in the origins
are removed, and hence no list of deeper origin ancestry is printed anymore.

Change-Id: I42c3b8635b54c31c27699140e200c1f75a6ada29
---
M selftest/process_test.ok
M selftest/suite_test.ok
M src/osmo_gsm_tester/log.py
3 files changed, 20 insertions(+), 13 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/selftest/process_test.ok b/selftest/process_test.ok
index 4245eeb..f168ee3 100644
--- a/selftest/process_test.ok
+++ b/selftest/process_test.ok
@@ -1,7 +1,7 @@
-run foo: DBG: cd '[TMP]'; PATH=[$PATH] foo.py arg1 arg2  [foo↪foo]
-run foo: DBG: [TMP]/stdout  [foo↪foo]
-run foo: DBG: [TMP]/stderr  [foo↪foo]
-run foo(pid=[PID]): Launched  [foo(pid=[PID])↪foo(pid=[PID])]
+run foo: DBG: cd '[TMP]'; PATH=[$PATH] foo.py arg1 arg2
+run foo: DBG: [TMP]/stdout
+run foo: DBG: [TMP]/stderr
+run foo(pid=[PID]): Launched
 stdout:
 (launched: [DATETIME])
 foo stdout
diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok
index b9a8fb3..fd4d743 100644
--- a/selftest/suite_test.ok
+++ b/selftest/suite_test.ok
@@ -6,11 +6,11 @@
 --- -: ERR: RuntimeError: Suite not found: 'does_not_exist' in [PATH]/selftest/suite_test
 - no suite.conf
 cnf -: DBG: Found path suites_dir as [PATH]/selftest/suite_test
-cnf empty_dir: DBG: reading suite.conf  [empty_dir↪empty_dir]
+cnf empty_dir: DBG: reading suite.conf
 --- [PATH]/selftest/suite_test/empty_dir/suite.conf: ERR: FileNotFoundError: [Errno 2] No such file or directory: '[PATH]/selftest/suite_test/empty_dir/suite.conf'  [empty_dir↪[PATH]/selftest/suite_test/empty_dir/suite.conf]
 - valid suite dir
 cnf -: DBG: Found path suites_dir as [PATH]/selftest/suite_test
-cnf test_suite: DBG: reading suite.conf  [test_suite↪test_suite]
+cnf test_suite: DBG: reading suite.conf
 defaults:
   timeout: 60s
 resources:
@@ -26,21 +26,19 @@
 cnf -: DBG: Found path state_dir as [PATH]/selftest/suite_test/test_work/state_dir
 tst test_suite: Suite run start
 tst test_suite: reserving resources in [PATH]/selftest/suite_test/test_work/state_dir ...
-tst test_suite: DBG: {combining='resources'}  [test_suite↪test_suite]
+tst test_suite: DBG: {combining='resources'}
 tst test_suite: DBG: {definition_conf={bts=[{'times': '1'}], ip_address=[{'times': '1'}], modem=[{'times': '2'}]}}  [test_suite↪(combining_scenarios='resources')↪test_suite]
-tst test_suite: Reserving 1 x bts (candidates: 3)  [test_suite↪test_suite]
+tst test_suite: Reserving 1 x bts (candidates: 3)
 tst test_suite: DBG: Picked - _hash: 07d9c8aaa940b674efcbbabdd69f58a6ce4e94f9
   addr: 10.42.42.114
   band: GSM-1800
   ipa_unit_id: '1'
   label: sysmoBTS 1002
   type: sysmo
-  [test_suite↪test_suite]
-tst test_suite: Reserving 1 x ip_address (candidates: 3)  [test_suite↪test_suite]
+tst test_suite: Reserving 1 x ip_address (candidates: 3)
 tst test_suite: DBG: Picked - _hash: cde1debf28f07f94f92c761b4b7c6bf35785ced4
   addr: 10.42.42.1
-  [test_suite↪test_suite]
-tst test_suite: Reserving 2 x modem (candidates: 16)  [test_suite↪test_suite]
+tst test_suite: Reserving 2 x modem (candidates: 16)
 tst test_suite: DBG: Picked - _hash: 19c69e45aa090fb511446bd00797690aa82ff52f
   imsi: '901700000007801'
   ki: D620F48487B1B782DA55DF6717F08FF9
@@ -51,7 +49,6 @@
   ki: 47FDB2D55CE6A10A85ABDAD034A5B7B3
   label: m7802
   path: /wavecom_1
-  [test_suite↪test_suite]
 tst hello_world.py:[LINENR] START  [test_suite↪hello_world.py]
 tst hello_world.py:[LINENR]: hello world  [test_suite↪hello_world.py:[LINENR]]
 tst hello_world.py:[LINENR]: I am 'test_suite' / 'hello_world.py:[LINENR]'  [test_suite↪hello_world.py:[LINENR]]
diff --git a/src/osmo_gsm_tester/log.py b/src/osmo_gsm_tester/log.py
index ede3b16..fb6d55b 100644
--- a/src/osmo_gsm_tester/log.py
+++ b/src/osmo_gsm_tester/log.py
@@ -352,10 +352,20 @@
 
     def gather_origins(self):
         origins = Origins()
+        # this object shall always be seen as the immediate origin of the log message.
         origins.add(self)
+        # now go through the parents of this object.
         origin = self._parent_origin
+        # but if this object is "loose" and not set up with cascaded 'with' statements,
+        # take the last seen 'with' statement's object as next parent:
         if origin is None and Origin._global_current_origin is not None:
             origin = Origin._global_current_origin
+            # if this object is currently the _global_current_origin, we don't
+            # need to add it twice.
+            if origin is self:
+                origin = origin._parent_origin
+        # whichever we determined to be the parent above, go up through all its
+        # ancestors.
         while origin is not None:
             origins.add(origin)
             origin = origin._parent_origin

-- 
To view, visit https://gerrit.osmocom.org/2850
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I42c3b8635b54c31c27699140e200c1f75a6ada29
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list