[PATCH] osmo-gsm-tester[master]: junit result: also write for aborted runs

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
Fri Jun 9 12:58:26 UTC 2017


Hello Pau Espin Pedrol, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/2854

to look at the new patch set (#8).

junit result: also write for aborted runs

Even if aborted due to signal, write a JUnit report XML, and make sure to
indicate the runs as erratic.

Change-Id: I7a334ef3463896c543c0fe592d3903c15e67d4c4
---
M src/osmo_gsm_tester/report.py
M src/osmo_gsm_tester/suite.py
M src/osmo_gsm_tester/trial.py
3 files changed, 25 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/54/2854/8

diff --git a/src/osmo_gsm_tester/report.py b/src/osmo_gsm_tester/report.py
index ae63408..82b2f13 100644
--- a/src/osmo_gsm_tester/report.py
+++ b/src/osmo_gsm_tester/report.py
@@ -38,8 +38,9 @@
     testsuite = et.Element('testsuite')
     testsuite.set('name', suite.name())
     testsuite.set('hostname', 'localhost')
-    testsuite.set('timestamp', datetime.fromtimestamp(round(suite.start_timestamp)).isoformat())
-    testsuite.set('time', str(math.ceil(suite.duration)))
+    if suite.start_timestamp:
+        testsuite.set('timestamp', datetime.fromtimestamp(round(suite.start_timestamp)).isoformat())
+        testsuite.set('time', str(math.ceil(suite.duration)))
     testsuite.set('tests', str(len(suite.tests)))
     testsuite.set('failures', str(suite.count_test_results()[2]))
     for test in suite.tests:
@@ -60,6 +61,9 @@
         if test.fail_tb:
             system_err = et.SubElement(testcase, 'system-err')
             system_err.text = test.fail_tb
+    elif test.status != suite.Test.PASS:
+        error = et.SubElement(testcase, 'error')
+        error.text = 'could not run'
     return testcase
 
 def trial_to_text(trial):
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index 0dd8790..55f81b1 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -161,6 +161,8 @@
 
     trial = None
     status = None
+    start_timestamp = None
+    duration = None
     resources_pool = None
     reserved_resources = None
     objects_to_clean_up = None
diff --git a/src/osmo_gsm_tester/trial.py b/src/osmo_gsm_tester/trial.py
index 11f8a15..741f3a7 100644
--- a/src/osmo_gsm_tester/trial.py
+++ b/src/osmo_gsm_tester/trial.py
@@ -188,21 +188,23 @@
 
     def run_suites(self, names=None):
         self.status = Trial.UNKNOWN
-        for suite_run in self.suites:
-            try:
-                suite_run.run_tests(names)
-            except BaseException as e:
-                # when the program is aborted by a signal (like Ctrl-C), escalate to abort all.
-                self.err('TRIAL RUN ABORTED: %s' % type(e).__name__)
-                raise
-            finally:
-                if suite_run.status != suite.SuiteRun.PASS:
-                    self.status = Trial.FAIL
-        if self.status == Trial.UNKNOWN:
-            self.status = Trial.PASS
-        junit_path = self.get_run_dir().new_file(self.name()+'.xml')
-        self.log('Storing JUnit report in', junit_path)
-        report.trial_to_junit_write(self, junit_path)
+        try:
+            for suite_run in self.suites:
+                try:
+                    suite_run.run_tests(names)
+                except BaseException as e:
+                    # when the program is aborted by a signal (like Ctrl-C), escalate to abort all.
+                    self.err('TRIAL RUN ABORTED: %s' % type(e).__name__)
+                    raise
+                finally:
+                    if suite_run.status != suite.SuiteRun.PASS:
+                        self.status = Trial.FAIL
+            if self.status == Trial.UNKNOWN:
+                self.status = Trial.PASS
+        finally:
+            junit_path = self.get_run_dir().new_file(self.name()+'.xml')
+            self.log('Storing JUnit report in', junit_path)
+            report.trial_to_junit_write(self, junit_path)
 
     def log_report(self):
         log.large_separator(self.name(), self.status)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I7a334ef3463896c543c0fe592d3903c15e67d4c4
Gerrit-PatchSet: 8
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