Beispiel #1
0
 def test_unknown_options(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean",
         "SBD_UNKNOWN": "",
         "another_unknown_option": "some value"
     }
     assert_report_item_list_equal(
         cmd_sbd._validate_sbd_options(config),
         [
             (
                 Severities.ERROR,
                 report_codes.INVALID_OPTION,
                 {
                     "option_name": "SBD_UNKNOWN",
                     "option_type": None,
                     "allowed": self.allowed_sbd_options,
                     "allowed_str": self.allowed_sbd_options_str
                 },
                 report_codes.FORCE_OPTIONS
             ),
             (
                 Severities.ERROR,
                 report_codes.INVALID_OPTION,
                 {
                     "option_name": "another_unknown_option",
                     "option_type": None,
                     "allowed": self.allowed_sbd_options,
                     "allowed_str": self.allowed_sbd_options_str
                 },
                 report_codes.FORCE_OPTIONS
             )
         ]
     )
 def test_unknown_options_forced(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean",
         "SBD_UNKNOWN": "",
         "another_unknown_option": "some value"
     }
     # just make sure there is no exception raised
     assert_report_item_list_equal(
         cmd_sbd._validate_sbd_options(config, allow_unknown_opts=True),
         [
             (
                 Severities.WARNING,
                 report_codes.INVALID_OPTION,
                 {
                     "option_names": ["SBD_UNKNOWN"],
                     "option_type": None,
                     "allowed": self.allowed_sbd_options,
                 },
                 None
             ),
             (
                 Severities.WARNING,
                 report_codes.INVALID_OPTION,
                 {
                     "option_names": ["another_unknown_option"],
                     "option_type": None,
                     "allowed": self.allowed_sbd_options,
                 },
                 None
             )
         ]
     )
    def test_invalid_and_unsupported_options_forced(self):
        config = {
            "SBD_DELAY_START": "yes",
            "SBD_WATCHDOG_TIMEOUT": "5",
            "SBD_STARTMODE": "clean",
            "SBD_WATCHDOG_DEV": "/dev/watchdog",
            "SBD_UNKNOWN": "",
            "SBD_OPTS": "  ",
            "SBD_PACEMAKER": "false",
        }

        assert_report_item_list_equal(
            cmd_sbd._validate_sbd_options(config, allow_unknown_opts=True),
            [
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTIONS,
                    {
                        "option_names": ["SBD_WATCHDOG_DEV"],
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                        "allowed_patterns": [],
                    },
                    None
                ),
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTIONS,
                    {
                        "option_names": ["SBD_OPTS"],
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                        "allowed_patterns": [],
                    },
                    None
                ),
                (
                    Severities.WARNING,
                    report_codes.INVALID_OPTIONS,
                    {
                        "option_names": ["SBD_UNKNOWN"],
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                        "allowed_patterns": [],
                    },
                    None
                ),
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTIONS,
                    {
                        "option_names": ["SBD_PACEMAKER"],
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                        "allowed_patterns": [],
                    },
                    None
                )
            ]
        )
Beispiel #4
0
    def test_unsupported_options(self):
        config = {
            "SBD_DELAY_START": "yes",
            "SBD_WATCHDOG_TIMEOUT": "5",
            "SBD_STARTMODE": "clean",
            "SBD_WATCHDOG_DEV": "/dev/watchdog",
            "SBD_OPTS": "  "
        }

        assert_report_item_list_equal(
            cmd_sbd._validate_sbd_options(config),
            [
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTION,
                    {
                        "option_name": "SBD_WATCHDOG_DEV",
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                    },
                    None
                ),
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTION,
                    {
                        "option_name": "SBD_OPTS",
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                    },
                    None
                )
            ]
        )
    def test_unsupported_options(self):
        config = {
            "SBD_DELAY_START": "yes",
            "SBD_WATCHDOG_TIMEOUT": "5",
            "SBD_STARTMODE": "clean",
            "SBD_WATCHDOG_DEV": "/dev/watchdog",
            "SBD_OPTS": "  "
        }

        assert_report_item_list_equal(
            cmd_sbd._validate_sbd_options(config),
            [
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTION,
                    {
                        "option_names": ["SBD_WATCHDOG_DEV"],
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                    },
                    None
                ),
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTION,
                    {
                        "option_names": ["SBD_OPTS"],
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                    },
                    None
                )
            ]
        )
Beispiel #6
0
    def test_invalid_and_unsupported_options_forced(self):
        config = {
            "SBD_DELAY_START": "yes",
            "SBD_WATCHDOG_TIMEOUT": "5",
            "SBD_STARTMODE": "clean",
            "SBD_WATCHDOG_DEV": "/dev/watchdog",
            "SBD_UNKNOWN": "",
            "SBD_OPTS": "  ",
            "SBD_PACEMAKER": "false",
        }

        assert_report_item_list_equal(
            cmd_sbd._validate_sbd_options(config, allow_unknown_opts=True),
            [
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTION,
                    {
                        "option_name": "SBD_WATCHDOG_DEV",
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                        "allowed_str": self.allowed_sbd_options_str
                    },
                    None
                ),
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTION,
                    {
                        "option_name": "SBD_OPTS",
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                        "allowed_str": self.allowed_sbd_options_str
                    },
                    None
                ),
                (
                    Severities.WARNING,
                    report_codes.INVALID_OPTION,
                    {
                        "option_name": "SBD_UNKNOWN",
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                        "allowed_str": self.allowed_sbd_options_str
                    },
                    None
                ),
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTION,
                    {
                        "option_name": "SBD_PACEMAKER",
                        "option_type": None,
                        "allowed": self.allowed_sbd_options,
                        "allowed_str": self.allowed_sbd_options_str
                    },
                    None
                )
            ]
        )
Beispiel #7
0
    def test_invalid_and_unsupported_options_forced(self):
        config = {
            "SBD_DELAY_START": "yes",
            "SBD_WATCHDOG_TIMEOUT": "5",
            "SBD_STARTMODE": "clean",
            "SBD_WATCHDOG_DEV": "/dev/watchdog",
            "SBD_UNKNOWN": "",
            "SBD_OPTS": "  ",
            "SBD_PACEMAKER": "false",
        }

        assert_report_item_list_equal(
            cmd_sbd._validate_sbd_options(config, allow_unknown_opts=True),
            [
                fixture.error(
                    report_codes.INVALID_OPTIONS,
                    option_names=sorted(
                        ["SBD_WATCHDOG_DEV", "SBD_OPTS", "SBD_PACEMAKER"]
                    ),
                    option_type=None,
                    allowed=self.allowed_sbd_options,
                    allowed_patterns=[],
                ),
                fixture.warn(
                    report_codes.INVALID_OPTIONS,
                    option_names=["SBD_UNKNOWN"],
                    option_type=None,
                    allowed=self.allowed_sbd_options,
                    allowed_patterns=[],
                ),
            ]
        )
Beispiel #8
0
 def test_all_ok(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean"
     }
     self.assertEqual([], cmd_sbd._validate_sbd_options(config))
Beispiel #9
0
    def test_invalid_and_unsupported_options_forced(self):
        config = {
            "SBD_DELAY_START": "yes",
            "SBD_WATCHDOG_TIMEOUT": "5",
            "SBD_STARTMODE": "clean",
            "SBD_WATCHDOG_DEV": "/dev/watchdog",
            "SBD_UNKNOWN": "",
            "SBD_OPTS": "  ",
            "SBD_PACEMAKER": "false",
        }

        assert_report_item_list_equal(
            cmd_sbd._validate_sbd_options(config, allow_unknown_opts=True),
            [
                fixture.error(
                    reports.codes.INVALID_OPTIONS,
                    option_names=sorted(
                        ["SBD_WATCHDOG_DEV", "SBD_OPTS", "SBD_PACEMAKER"]),
                    option_type=None,
                    allowed=self.allowed_sbd_options,
                    allowed_patterns=[],
                ),
                fixture.warn(
                    reports.codes.INVALID_OPTIONS,
                    option_names=["SBD_UNKNOWN"],
                    option_type=None,
                    allowed=self.allowed_sbd_options,
                    allowed_patterns=[],
                ),
            ],
        )
Beispiel #10
0
 def test_unknown_options(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean",
         "SBD_UNKNOWN": "",
         "another_unknown_option": "some value"
     }
     assert_report_item_list_equal(
         cmd_sbd._validate_sbd_options(config),
         [
             (
                 Severities.ERROR,
                 report_codes.INVALID_OPTION,
                 {
                     "option_name": "SBD_UNKNOWN",
                     "option_type": None,
                     "allowed": self.allowed_sbd_options,
                 },
                 report_codes.FORCE_OPTIONS
             ),
             (
                 Severities.ERROR,
                 report_codes.INVALID_OPTION,
                 {
                     "option_name": "another_unknown_option",
                     "option_type": None,
                     "allowed": self.allowed_sbd_options,
                 },
                 report_codes.FORCE_OPTIONS
             )
         ]
     )
Beispiel #11
0
    def test_invalid_and_unsupported_options(self):
        config = {
            "SBD_DELAY_START": "yes",
            "SBD_WATCHDOG_TIMEOUT": "5",
            "SBD_STARTMODE": "clean",
            "SBD_WATCHDOG_DEV": "/dev/watchdog",
            "SBD_UNKNOWN": "",
            "SBD_OPTS": "  "
        }

        assert_report_item_list_equal(cmd_sbd._validate_sbd_options(config), [
            fixture.error(
                report_codes.INVALID_OPTIONS,
                option_names=sorted(["SBD_WATCHDOG_DEV", "SBD_OPTS"]),
                option_type=None,
                allowed=self.allowed_sbd_options,
                allowed_patterns=[],
            ),
            fixture.error(
                report_codes.INVALID_OPTIONS,
                option_names=["SBD_UNKNOWN"],
                option_type=None,
                allowed=self.allowed_sbd_options,
                allowed_patterns=[],
                force_code=report_codes.FORCE_OPTIONS,
            ),
        ])
Beispiel #12
0
 def test_all_ok(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean"
     }
     self.assertEqual([], cmd_sbd._validate_sbd_options(config))
Beispiel #13
0
 def test_unknown_options_forced(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean",
         "SBD_UNKNOWN": "",
         "another_unknown_option": "some value"
     }
     # just make sure there is no exception raised
     assert_report_item_list_equal(
         cmd_sbd._validate_sbd_options(config, allow_unknown_opts=True),
         [
             (
                 Severities.WARNING,
                 report_codes.INVALID_OPTION,
                 {
                     "option_name": "SBD_UNKNOWN",
                     "option_type": None,
                     "allowed": self.allowed_sbd_options,
                 },
                 None
             ),
             (
                 Severities.WARNING,
                 report_codes.INVALID_OPTION,
                 {
                     "option_name": "another_unknown_option",
                     "option_type": None,
                     "allowed": self.allowed_sbd_options,
                 },
                 None
             )
         ]
     )
Beispiel #14
0
    def test_watchdog_timeout_is_none(self):
        config = {
            "SBD_WATCHDOG_TIMEOUT": None,
        }

        assert_report_item_list_equal(
            cmd_sbd._validate_sbd_options(config),
            [(Severities.ERROR, report_codes.INVALID_OPTION_VALUE, {
                "option_name": "SBD_WATCHDOG_TIMEOUT",
                "option_value": None,
                "allowed_values": "a non-negative integer",
            }, None)])
Beispiel #15
0
 def test_invalid_value(self):
     config = {
         "SBD_TIMEOUT_ACTION": "flush,noflush",
     }
     assert_report_item_list_equal(cmd_sbd._validate_sbd_options(config), [
         fixture.error(
             report_codes.INVALID_OPTION_VALUE,
             force_code=report_codes.FORCE_OPTIONS,
             option_name="SBD_TIMEOUT_ACTION",
             option_value="flush,noflush",
             allowed_values=self.timeout_action_allowed_values,
             cannot_be_empty=False,
             forbidden_characters=None,
         ),
     ])
Beispiel #16
0
    def test_watchdog_timeout_is_none(self):
        # pylint: disable=no-self-use
        config = {
            "SBD_WATCHDOG_TIMEOUT": None,
        }

        assert_report_item_list_equal(cmd_sbd._validate_sbd_options(config), [
            fixture.error(
                report_codes.INVALID_OPTION_VALUE,
                option_name="SBD_WATCHDOG_TIMEOUT",
                option_value=None,
                allowed_values="a non-negative integer",
                cannot_be_empty=False,
                forbidden_characters=None,
            )
        ])
Beispiel #17
0
 def test_invalid_value(self):
     config = {
         "SBD_TIMEOUT_ACTION": "flush,noflush",
     }
     assert_report_item_list_equal(
         cmd_sbd._validate_sbd_options(config),
         [
             fixture.error(
                 report_codes.INVALID_OPTION_VALUE,
                 option_name="SBD_TIMEOUT_ACTION",
                 option_value="flush,noflush",
                 allowed_values=self.timeout_action_allowed_values,
                 force_code=report_codes.FORCE_OPTIONS
             ),
         ]
     )
Beispiel #18
0
 def test_unknown_options(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean",
         "SBD_UNKNOWN": "",
         "another_unknown_option": "some value"
     }
     assert_report_item_list_equal(cmd_sbd._validate_sbd_options(config), [
         fixture.error(report_codes.INVALID_OPTIONS,
                       option_names=sorted(
                           ["SBD_UNKNOWN", "another_unknown_option"]),
                       option_type=None,
                       allowed=self.allowed_sbd_options,
                       allowed_patterns=[],
                       force_code=report_codes.FORCE_OPTIONS),
     ])
Beispiel #19
0
 def test_invalid_value_forced(self):
     config = {
         "SBD_TIMEOUT_ACTION": "flush,noflush",
     }
     assert_report_item_list_equal(
         cmd_sbd._validate_sbd_options(
             config, allow_invalid_option_values=True
         ),
         [
             fixture.warn(
                 report_codes.INVALID_OPTION_VALUE,
                 option_name="SBD_TIMEOUT_ACTION",
                 option_value="flush,noflush",
                 allowed_values=self.timeout_action_allowed_values,
             ),
         ]
     )
Beispiel #20
0
 def test_unknown_options_forced(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean",
         "SBD_UNKNOWN": "",
         "another_unknown_option": "some value"
     }
     # just make sure there is no exception raised
     assert_report_item_list_equal(
         cmd_sbd._validate_sbd_options(config, allow_unknown_opts=True), [
             fixture.warn(
                 report_codes.INVALID_OPTIONS,
                 option_names=sorted(
                     ["SBD_UNKNOWN", "another_unknown_option"]),
                 option_type=None,
                 allowed=self.allowed_sbd_options,
                 allowed_patterns=[],
             ),
         ])
    def test_watchdog_timeout_is_none(self):
        config = {
            "SBD_WATCHDOG_TIMEOUT": None,
        }

        assert_report_item_list_equal(
            cmd_sbd._validate_sbd_options(config),
            [
                (
                    Severities.ERROR,
                    report_codes.INVALID_OPTION_VALUE,
                    {
                        "option_name": "SBD_WATCHDOG_TIMEOUT",
                        "option_value": None,
                        "allowed_values": "nonnegative integer",
                    },
                    None
                )
            ]
        )
Beispiel #22
0
 def test_unknown_options_forced(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean",
         "SBD_UNKNOWN": "",
         "another_unknown_option": "some value"
     }
     # just make sure there is no exception raised
     assert_report_item_list_equal(
         cmd_sbd._validate_sbd_options(config, allow_unknown_opts=True),
         [
             fixture.warn(
                 report_codes.INVALID_OPTIONS,
                 option_names=sorted(
                     ["SBD_UNKNOWN", "another_unknown_option"]
                 ),
                 option_type=None,
                 allowed=self.allowed_sbd_options,
                 allowed_patterns=[],
             ),
         ]
     )
Beispiel #23
0
 def test_unknown_options(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_WATCHDOG_TIMEOUT": "5",
         "SBD_STARTMODE": "clean",
         "SBD_UNKNOWN": "",
         "another_unknown_option": "some value"
     }
     assert_report_item_list_equal(
         cmd_sbd._validate_sbd_options(config),
         [
             fixture.error(
                 report_codes.INVALID_OPTIONS,
                 option_names=sorted(
                     ["SBD_UNKNOWN", "another_unknown_option"]
                 ),
                 option_type=None,
                 allowed=self.allowed_sbd_options,
                 allowed_patterns=[],
                 force_code=report_codes.FORCE_OPTIONS
             ),
         ]
     )
Beispiel #24
0
    def test_unsupported_options(self):
        config = {
            "SBD_DELAY_START": "yes",
            "SBD_WATCHDOG_TIMEOUT": "5",
            "SBD_STARTMODE": "clean",
            "SBD_WATCHDOG_DEV": "/dev/watchdog",
            "SBD_OPTS": "  ",
            "SBD_DEVICE": "/dev/vda",
        }

        assert_report_item_list_equal(
            cmd_sbd._validate_sbd_options(config),
            [
                fixture.error(
                    report_codes.INVALID_OPTIONS,
                    option_names=sorted(
                        ["SBD_WATCHDOG_DEV", "SBD_OPTS", "SBD_DEVICE"]
                    ),
                    option_type=None,
                    allowed=self.allowed_sbd_options,
                    allowed_patterns=[],
                ),
            ]
        )
Beispiel #25
0
 def test_watchdog_timeout_is_not_present(self):
     config = {"SBD_DELAY_START": "yes", "SBD_STARTMODE": "clean"}
     self.assertEqual([], cmd_sbd._validate_sbd_options(config))
Beispiel #26
0
 def test_watchdog_timeout_is_not_present(self):
     config = {
         "SBD_DELAY_START": "yes",
         "SBD_STARTMODE": "clean"
     }
     self.assertEqual([], cmd_sbd._validate_sbd_options(config))