diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2021-06-10 13:11:25 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-06-14 09:23:41 -0400 |
commit | 8ed7f525ef3b603f901f5d0aa1285bb3f6fd66a8 (patch) | |
tree | d0623f967b8e26a7c701209900107d7c7c5cc4f0 /tests/report_tests | |
parent | 6725bf9280d4d2c93b5273518fe4d0cec15c58bc (diff) | |
download | sos-8ed7f525ef3b603f901f5d0aa1285bb3f6fd66a8.tar.gz |
[Plugin] Add default journal collection for Plugin services
Adds automatic collection of journals for any service defined in a
plugin's `services` tuple, if that service exists on the system.
Updates several plugins to define a `services` tuple in place of
manually calling `add_journal()` (and as a bonus, removing redundant
`add_service_status()` calls that are already performed based on the
tuple).
Additionally, add an appropriate tag to each `add_journal` call for
easier collection lookup in the manifest.
Resolves: #2579
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/report_tests')
-rw-r--r-- | tests/report_tests/plugin_tests/defaults.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/report_tests/plugin_tests/defaults.py b/tests/report_tests/plugin_tests/defaults.py new file mode 100644 index 00000000..4cdaabd4 --- /dev/null +++ b/tests/report_tests/plugin_tests/defaults.py @@ -0,0 +1,42 @@ +# 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 StageTwoReportTest + + +class DefaultCollectionsTest(StageTwoReportTest): + """Ensure that the default collections are firing for Plugins based on + their enablement triggers, which gives us more atomicity in Plugin design + + :avocado: tags=stagetwo + """ + + packages = {'rhel': 'cups', + 'Ubuntu': 'cups'} + + sos_cmd = '-o cups' + + def test_service_status_collected(self): + self.assertFileCollected('sos_commands/cups/systemctl_status_cups') + _m = self.get_plugin_manifest('cups') + ent = None + for cmd in _m['commands']: + if cmd['exec'] == 'systemctl status cups': + ent = cmd + assert ent, "No manifest entry for systemctl status cups" + + def test_journal_collected(self): + self.assertFileCollected('sos_commands/cups/journalctl_--no-pager_--unit_cups') + _m = self.get_plugin_manifest('cups') + ent = None + for cmd in _m['commands']: + if cmd['exec'] == 'journalctl --no-pager --unit cups': + ent = cmd + assert ent, "No manifest entry for journalctl cups" + + assert 'journal_cups' in ent['tags'], "Journal tags not correct: %s" % ent['tags'] |