diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2021-04-15 19:02:06 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-05-05 09:54:51 -0400 |
commit | 17ce8a7027c19019831796f4b016601019cfb725 (patch) | |
tree | 06808761b7691adab68bf0b6afcf4ebcfc6bc780 /tests/report_tests | |
parent | a8b16dd147613d69233e52ca561c5feafaf00827 (diff) | |
download | sos-17ce8a7027c19019831796f4b016601019cfb725.tar.gz |
[tests] Correct test package installation
First, correct the logs plugin stagetwo test to specify the needed
package in a list, and second move the import to within the test class
that needs it so that we don't fail on the stageone tests if the package
is not present.
Second, correct the journal injections that this plugin test does to use
`pre_sos_setup()` instead of overriding `setup_mocking()`, and call the
former after the mocking has been setup.
Finally, add the resulting size of the collected journal if we fail the
size requirements of the test.
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/report_tests')
-rw-r--r-- | tests/report_tests/plugin_tests/logs.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/report_tests/plugin_tests/logs.py b/tests/report_tests/plugin_tests/logs.py index cc6a8365..632ad2f6 100644 --- a/tests/report_tests/plugin_tests/logs.py +++ b/tests/report_tests/plugin_tests/logs.py @@ -12,7 +12,6 @@ import os from sos_tests import StageOneReportTest, StageTwoReportTest from string import ascii_uppercase, digits -from systemd import journal class LogsPluginTest(StageOneReportTest): @@ -43,15 +42,15 @@ class LogsSizeLimitTest(StageTwoReportTest): sos_cmd = '-o logs' packages = { - 'rhel': 'python3-systemd', - 'ubuntu': 'python3-systemd' + 'rhel': ['python3-systemd'], + 'ubuntu': ['python3-systemd'] } - # override the stage2 mocking here to inject a string into the journal - def setup_mocking(self): + def pre_sos_setup(self): # write 20MB at a time to side-step rate/size limiting on some distros # write over 100MB to ensure we will actually size limit inside sos, # allowing for any compression or de-dupe systemd does + from systemd import journal rsize = 20 * 1048576 for i in range(3): # generate 20MB, write it, then write it in reverse. @@ -64,8 +63,8 @@ class LogsSizeLimitTest(StageTwoReportTest): journ = 'sos_commands/logs/journalctl_--no-pager_--catalog_--boot' self.assertFileCollected(journ) jsize = os.stat(self.get_name_in_archive(journ)).st_size - assert jsize <= 105906176, "Collected journal is larger than 100MB" - assert jsize > 27262976, "Collected journal limited by --log-size" + assert jsize <= 105906176, "Collected journal is larger than 100MB (size: %s)" % jsize + assert jsize > 27262976, "Collected journal limited by --log-size (size: %s)" % jsize def test_journal_tailed_and_linked(self): self.assertFileCollected('sos_strings/logs/journalctl_--no-pager_--catalog_--boot.tailed') |