Skip to content

Commit

Permalink
[tests] Enhance options_tests to cover presets
Browse files Browse the repository at this point in the history
Add some basic tests for presets.

Add plugin option tests covering sosreport#3855 .

Relevant: sosreport#3855

Signed-off-by: Pavel Moravec <[email protected]>
  • Loading branch information
pmoravec committed Jan 19, 2025
1 parent 00ef201 commit f57b69b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
50 changes: 41 additions & 9 deletions tests/report_tests/options_tests/options_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
# See the LICENSE file in the source distribution for further information.


from sos_tests import StageTwoReportTest
from sos_tests import StageTwoReportTest, redhat_only


class OptionsFromConfigTest(StageTwoReportTest):
"""Ensure that we handle options specified in sos.conf properly
class OptionsConfigPresetCmdlineTest(StageTwoReportTest):
"""Ensure that we handle options specified in sos.conf and
merge them with cmdline and preset properly
:avocado: tags=stagetwo
"""

files = [('options_tests_sos.conf', '/etc/sos/sos.conf')]
sos_cmd = ''
sos_cmd = '--preset minimal --journal-size 20 --cmd-timeout 60'

def test_case_id_from_config(self):
self.assertTrue('8675309' in self.archive)
Expand All @@ -44,8 +45,39 @@ def test_plugopts_actually_set(self):
self.assertFileCollected('sys/kernel/debug/tracing/trace')

def test_effective_options_logged_correctly(self):
self.assertSosLogContains(
"effective options now: --batch --case-id 8675309 "
"--only-plugins host,kernel "
"--plugopts kernel.with-timer=on,kernel.trace=yes"
)
for option in [
"--case-id 8675309",
"--only-plugins host,kernel",
"--plugopts kernel.with-timer=on,kernel.trace=yes",
"--preset minimal",
"--cmd-timeout 60", # cmdline beats config and preset
"--journal-size 20", # cmdline beats preset
"--log-size 10", # preset setting is honored
"--plugin-timeout 30", # preset beats config file
]:
self.assertSosLogContains(f"effective options now: .* {option}")

class PlugOptsConfigPresetCmdlineTest(StageTwoReportTest):
"""Ensure that plugin options specified in sos.conf or preset or cmdline
are handled and merged properly. Since the only presets with plugin options
belong to RHEL_PRESETS, we must limit tests to @redhat_only for now.
:avocado: tags=stagetwo
"""

files = [('options_tests_sos.conf', '/etc/sos/sos.conf')]
sos_cmd = '--preset ocp -o crio,networking --container-runtime=none ' \
'-k crio.timeout=10,networking.timeout=20'

@redhat_only
def test_effective_plugopts_logged_correctly(self):
for option in [
"--only-plugins crio,networking",
"--plugopts kernel.with-timer=on,kernel.trace=yes",
"--preset ocp",
"networking.timeout=20", # cmdline beats config and preset
"crio.timeout=10", # cmdline beats preset
"networking.ethtool-namespaces=False", # preset setting is honored
"networking.namespaces=100", # preset beats config file
]:
self.assertSosLogContains(f"effective options now: .* {option}")
4 changes: 4 additions & 0 deletions tests/report_tests/options_tests/options_tests_sos.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
[report]
only-plugins = host,kernel
case-id = 8675309
plugin-timeout = 150
cmd-timeout = 20

[collect]
#primary = myhost.example.com
Expand All @@ -16,3 +18,5 @@ case-id = 8675309
kernel.with-timer = on
kernel.trace = yes
networking.traceroute = yes
networking.timeout = 60
networking.namespaces = 100

0 comments on commit f57b69b

Please sign in to comment.