diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2021-05-20 15:52:52 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-05-24 13:49:37 -0400 |
commit | f7105cdfe49e0e6893632f1277368871481de65d (patch) | |
tree | 56fc3ae4c50e3f337693af33839e3dfb0babf03d | |
parent | 823eeff4c39766b84f5cc14309a1e9eab99e19ce (diff) | |
download | sos-f7105cdfe49e0e6893632f1277368871481de65d.tar.gz |
[tests] Add test for priority parameter in add_cmd_output()
Adds a test that checks that the new `priority` parameter is working as
expected for well known and common collections.
Resolves: #2553
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r-- | tests/report_tests/command_priority_tests.py | 54 | ||||
-rw-r--r-- | tests/sos_tests.py | 14 |
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/report_tests/command_priority_tests.py b/tests/report_tests/command_priority_tests.py new file mode 100644 index 00000000..ea6b38fa --- /dev/null +++ b/tests/report_tests/command_priority_tests.py @@ -0,0 +1,54 @@ +# This file is part of the sos project: https://github.com/sosreport/sos +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# version 2 of the GNU General Public License. +# +# See the LICENSE file in the source distribution for further information. + + +from sos_tests import StageOneReportTest + + +class CommandPriorityTest(StageOneReportTest): + """Ensure that the priority parameter for command execution is functioning + as expected + + :avocado: tags=stageone + """ + + sos_cmd = '-o logs,process' + + def test_logs_full_journal_correct_priority(self): + cmds = self.get_plugin_manifest('logs')['commands'] + fullj = cmds[-1] + self.assertEqual(fullj['priority'], 100) + + def test_logs_full_journal_run_last(self): + cmds = self.get_plugin_manifest('logs')['commands'] + cmds.sort(key=lambda x: x['start_time']) + # journal_full should be the last command executed + self.assertTrue('journal_full' in cmds[-1]['tags']) + + def test_process_correct_priorities(self): + cmds = self.get_plugin_manifest('process')['commands'] + # ensure root symlinked ps ran first + self.assertTrue(cmds[0]['priority'] == 1 and 'ps_aux' in cmds[0]['tags']) + + # get lsof and iotop command entries + _lsof = None + _iotop = None + for cmd in cmds: + if cmd['command'] == 'lsof': + _lsof = cmd + elif cmd['command'] == 'iotop': + _iotop = cmd + + self.assertTrue(_lsof and _iotop, "lsof or iotop output missing") + + self.assertEqual(_lsof['priority'], 50) + self.assertEqual(_iotop['priority'], 100) + self.assertTrue(_lsof['start_time'] < _iotop['start_time']) + + + diff --git a/tests/sos_tests.py b/tests/sos_tests.py index 5c7480f4..002de313 100644 --- a/tests/sos_tests.py +++ b/tests/sos_tests.py @@ -479,6 +479,20 @@ class BaseSoSReportTest(BaseSoSTest): for j in _executed: assert j in plugins, "Unrequested plugin '%s' ran as well" % j + def get_plugin_manifest(self, plugin): + """Get the manifest data for the specified plugin + + :param plugin: The name of the plugin + :type plugin: ``str`` + + :returns: The section of the manifest for the plugin + :rtype: ``dict`` + """ + if not self.manifest['components']['report']['plugins'][plugin]: + raise Exception("Manifest for %s not present" % plugin) + return self.manifest['components']['report']['plugins'][plugin] + + class StageOneReportTest(BaseSoSReportTest): """This is the test class to subclass for all Stage One (no mocking) tests within the sos test suite. |