aboutsummaryrefslogtreecommitdiffstats
path: root/tests/report_tests/options_tests/options_tests.py
blob: 15f0b5724800669f3cdaba8ce3523f7304f1fbe0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 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 = [('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_only_from_config(self):
        self.assertOnlyPluginsIncluded(['host', 'kernel'])

    def test_plugopts_logged_from_config(self):
        self.assertSosLogContains(
            r"Set kernel plugin option to \(name=with-timer, "
            r"desc='gather /proc/timer\* statistics', value=True, "
            r"default=False\)"
        )
        self.assertSosLogContains(
            r"Set kernel plugin option to \(name=trace, "
            "desc='gather /sys/kernel/debug/tracing/trace file', "
            r"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 "
            "--only-plugins host,kernel "
            "--plugopts kernel.with-timer=on,kernel.trace=yes"
        )