aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2023-02-27 12:36:39 -0500
committerJake Hunsaker <jhunsake@redhat.com>2023-03-02 12:37:13 -0500
commit9a460e920eef5cfb6d34c3f32d0f1c05740e45cd (patch)
treefaa427ae2c863cea323f046e8d25e6f6e335a3ea /tests
parentff5e73b29b1fcc4c5531654d4f67f808408aa989 (diff)
downloadsos-9a460e920eef5cfb6d34c3f32d0f1c05740e45cd.tar.gz
[report,plugin] Control journal size separate from log-size
Historically, journal sizes have been limited to the *higher* of 100MB or `--log-size`. While this had the benefit of potentially controlling both logs and journals with the same option, it was not immediately intuitive to end users and downright prevented collecting less than 100MB of journals. Address this by separating journal size limiting from `--log-size` by adding a new `--journal-size` option (default 100). This will allow users to individually control journal sizes without any "gotcha" scenarios with relation to general log size limiting. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/report_tests/plugin_tests/logs.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/tests/report_tests/plugin_tests/logs.py b/tests/report_tests/plugin_tests/logs.py
index d62ab8e2..49f1c592 100644
--- a/tests/report_tests/plugin_tests/logs.py
+++ b/tests/report_tests/plugin_tests/logs.py
@@ -30,7 +30,7 @@ class LogsPluginTest(StageOneReportTest):
self.assertFileGlobInArchive('/var/log/journal/*')
-class LogsSizeLimitTest(StageTwoReportTest):
+class JournalSizeLimitTest(StageTwoReportTest):
"""Test that journal size limiting is working and is independent of
--log-size
@@ -40,7 +40,7 @@ class LogsSizeLimitTest(StageTwoReportTest):
:avocado: tags=stagetwo
"""
- sos_cmd = '-o logs'
+ sos_cmd = '-o logs --journal-size=20 --log-size=10'
sos_timeout = 500
packages = {
'rhel': ['python3-systemd'],
@@ -48,36 +48,35 @@ class LogsSizeLimitTest(StageTwoReportTest):
}
def pre_sos_setup(self):
+ # if the journal is already over our size limit, don't write anything
+ # new to it
+ from systemd import journal
+ _reader = journal.Reader()
+ _size = _reader.get_usage() / 1024 / 1024
+ if _size > 20:
+ return
# 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,
+ # write over 20MB to ensure we will actually size limit inside sos,
# allowing for any compression or de-dupe systemd does
- from systemd import journal
sosfd = journal.stream('sos-testing')
rsize = 10 * 1048576
- for i in range(6):
+ for i in range(2):
# generate 10MB, write it, then write it in reverse.
# Spend less time generating new strings
rand = ''.join(random.choice(ascii_uppercase + digits) for _ in range(rsize))
sosfd.write(rand + '\n')
# sleep to avoid burst rate-limiting
- sleep(10)
+ sleep(5)
sosfd.write(rand[::-1] + '\n')
def test_journal_size_limit(self):
journ = 'sos_commands/logs/journalctl_--no-pager'
self.assertFileCollected(journ)
jsize = os.stat(self.get_name_in_archive(journ)).st_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
+ assert jsize <= 20971520, "Collected journal is larger than 20MB (size: %s)" % jsize
def test_journal_tailed_and_linked(self):
tailed = self.get_name_in_archive('sos_strings/logs/journalctl_--no-pager.tailed')
self.assertFileExists(tailed)
journ = self.get_name_in_archive('sos_commands/logs/journalctl_--no-pager')
assert os.path.islink(journ), "Journal in sos_commands/logs is not a symlink"
-
- def test_string_not_in_manifest(self):
- # we don't want truncated collections appearing in the strings section
- # of the manifest for the plugin
- manifest = self.get_plugin_manifest('logs')
- self.assertFalse(manifest['strings'])