aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-05-24 16:02:04 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-05-26 09:33:48 -0400
commit681a6ee9ac5b82e883c312273384fa9bbbd86681 (patch)
tree7a157cd933309c54d0232988f24dbc23da6316e8
parentf7105cdfe49e0e6893632f1277368871481de65d (diff)
downloadsos-681a6ee9ac5b82e883c312273384fa9bbbd86681.tar.gz
[tests] Improve failed command reporting in test output
Improves error reporting for failed sos commands by logging stderr (or stdout if stderr is not populated) to the console, which was previously being truncated by the builtin error handling of avocado. Printed output is limited to the last 8k to avoid dumping several MBs at a time for scenarios such as timeouts where command failure may generate significant logging prior to failing. Included with this are 2 minor changes to existing tests. First, remove verbose output from the expected plugins test to reduce otherwise irrelevant output for command failures. Second limit the number of plugins run for the LogLevelTest, both to reduce overall run time for a test where we aren't testing specific plugins and to improve readability of failures for such a test. Resolves: #2556 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--tests/report_tests/basic_report_tests.py2
-rw-r--r--tests/report_tests/smoke_tests.py2
-rw-r--r--tests/sos_tests.py12
3 files changed, 13 insertions, 3 deletions
diff --git a/tests/report_tests/basic_report_tests.py b/tests/report_tests/basic_report_tests.py
index 4a5e0001..2d2a6c30 100644
--- a/tests/report_tests/basic_report_tests.py
+++ b/tests/report_tests/basic_report_tests.py
@@ -39,7 +39,7 @@ class LogLevelTest(StageOneReportTest):
:avocado: tags=stageone
"""
- sos_cmd = '-vvv'
+ sos_cmd = '-vvv -o kernel,host,boot,filesys'
def test_archive_logging_enabled(self):
self.assertSosLogContains('DEBUG: \[archive:.*\]')
diff --git a/tests/report_tests/smoke_tests.py b/tests/report_tests/smoke_tests.py
index cf79a076..a313405e 100644
--- a/tests/report_tests/smoke_tests.py
+++ b/tests/report_tests/smoke_tests.py
@@ -64,7 +64,7 @@ class ExpectedDefaultPluginsTest(StageOneReportTest):
:avocado: tags=stageone
"""
- sos_cmd = '-v '
+ sos_cmd = ' '
def test_default_plugins_enabled(self):
"""These plugins should run on all supported hosts by default everytime
diff --git a/tests/sos_tests.py b/tests/sos_tests.py
index 002de313..25057ba3 100644
--- a/tests/sos_tests.py
+++ b/tests/sos_tests.py
@@ -8,6 +8,7 @@
from avocado.core.exceptions import TestSkipError
+from avocado.core.output import LOG_UI
from avocado import Test
from avocado.utils import archive, process, distro, software_manager
from fnmatch import fnmatch
@@ -218,7 +219,16 @@ class BaseSoSReportTest(BaseSoSTest):
if self._exception_expected:
self.cmd_output = err.result
else:
- raise
+ msg = err.result.stderr.decode() or err.result.stdout.decode()
+ # a little hacky, but using self.log methods here will not
+ # print to console unless we ratchet up the verbosity for the
+ # entire test suite, which will become very difficult to read
+ LOG_UI.error('ERROR:\n' + msg[:8196]) # don't flood w/ super verbose logs
+ if err.result.interrupted:
+ raise Exception("Timeout exceeded, see output above")
+ else:
+ raise Exception("Command failed, see output above: '%s'"
+ % err.command.split('bin/')[1])
with open(os.path.join(self.tmpdir, 'output'), 'wb') as pfile:
pickle.dump(self.cmd_output, pfile)
self.cmd_output.stdout = self.cmd_output.stdout.decode()