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 | |
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')
-rw-r--r-- | tests/report_tests/plugin_tests/defaults.py | 42 | ||||
-rw-r--r-- | tests/sos_tests.py | 6 |
2 files changed, 47 insertions, 1 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'] diff --git a/tests/sos_tests.py b/tests/sos_tests.py index 5df94794..8c8e6d05 100644 --- a/tests/sos_tests.py +++ b/tests/sos_tests.py @@ -651,6 +651,10 @@ class StageTwoReportTest(BaseSoSReportTest): self.installer = software_manager self.sm = self.installer.SoftwareManager() + for dist in self.packages: + if isinstance(self.packages[dist], str): + self.packages[dist] = [self.packages[dist]] + keys = self.packages.keys() # allow for single declaration of packages for the RH family # for our purposes centos == rhel here @@ -716,7 +720,7 @@ class StageTwoReportTest(BaseSoSReportTest): return installed = self.installer.install_distro_packages(self.packages) if not installed: - raise("Unable to install requested packages %" + raise("Unable to install requested packages %s" % ', '.join(pkg for pkg in self.packages[self.local_distro])) # save installed package list to our tmpdir to be removed later self._write_file_to_tmpdir('mocked_packages', json.dumps(self.packages[self.local_distro])) |