diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2021-08-31 16:17:57 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-09-08 09:40:35 -0400 |
commit | 4fac6655bd329b89dcbab847837f23fea6763c22 (patch) | |
tree | e355f1cbd703532bd4488b3015543bfb143c1bcc | |
parent | c7802cf5cfea8ca62a4342f1793fce5a5d22362c (diff) | |
download | sos-4fac6655bd329b89dcbab847837f23fea6763c22.tar.gz |
[tests] Add tests for proper handling and logging of conf file options
Adds a new report test that ensures that options set in `sos.conf` are
picked up, handled properly, and logged as we expect them to be.
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r-- | tests/report_tests/options_tests.py | 45 | ||||
-rw-r--r-- | tests/test_data/etc/sos/options_tests_sos.conf | 18 |
2 files changed, 63 insertions, 0 deletions
diff --git a/tests/report_tests/options_tests.py b/tests/report_tests/options_tests.py new file mode 100644 index 00000000..17948795 --- /dev/null +++ b/tests/report_tests/options_tests.py @@ -0,0 +1,45 @@ +# 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 OptionsFromConfigTest(StageTwoReportTest): + """Ensure that we handle options specified in sos.conf properly + + :avocado: tags=stagetwo + """ + + files = [('/etc/sos/options_tests_sos.conf', '/etc/sos/sos.conf')] + sos_cmd = '-v ' + + def test_case_id_from_config(self): + self.assertTrue('8675309' in self.archive) + + def test_plugins_skipped_from_config(self): + self.assertPluginNotIncluded(['networking', 'logs']) + + def test_plugopts_logged_from_config(self): + self.assertSosLogContains( + "Set kernel plugin option to \(name=with-timer, desc='gather /proc/timer\* statistics', value=True, default=False\)" + ) + self.assertSosLogContains( + "Set kernel plugin option to \(name=trace, desc='gather /sys/kernel/debug/tracing/trace file', value=True, default=False\)" + ) + + def test_disabled_plugopts_not_loaded(self): + self.assertSosLogNotContains("Set networking plugin option to") + + 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 --plugopts kernel.with-timer=on,kernel.trace=yes --skip-plugins networking,logs" + ) diff --git a/tests/test_data/etc/sos/options_tests_sos.conf b/tests/test_data/etc/sos/options_tests_sos.conf new file mode 100644 index 00000000..c0f641d9 --- /dev/null +++ b/tests/test_data/etc/sos/options_tests_sos.conf @@ -0,0 +1,18 @@ +[global] +#verbose = 3 + +[report] +skip-plugins = networking,logs +case-id = 8675309 + +[collect] +#primary = myhost.example.com + +[clean] +#no-update = true + +[plugin_options] +#rpm.rpmva = off +kernel.with-timer = on +kernel.trace = yes +networking.traceroute = yes |