Exemplo n.º 1
0
 def test_failed(self, mock_enable, mock_is_systemctl):
     mock_enable.side_effect = EnableServiceError("booth", "msg", self.name)
     assert_raise_library_error(
         lambda: commands.enable_booth(self.mock_env),
         (
             Severities.ERROR,
             report_codes.SERVICE_ENABLE_ERROR,
             {
                 "service": "booth",
                 "reason": "msg",
                 "node": None,
                 "instance": self.name,
             }
         )
     )
     mock_enable.assert_called_once_with(self.mock_run, "booth", self.name)
     mock_is_systemctl.assert_called_once_with()
Exemplo n.º 2
0
    def test_failed(self, mock_net_enable):
        mock_net_enable.side_effect = EnableServiceError(
            "test service",
            "test error"
        )

        assert_raise_library_error(
            lambda: lib.qdevice_enable(self.lib_env, "net"),
            (
                severity.ERROR,
                report_codes.SERVICE_ENABLE_ERROR,
                {
                    "service": "test service",
                    "reason": "test error",
                }
            )
        )
        mock_net_enable.assert_called_once_with("mock_runner", "corosync-qnetd")
Exemplo n.º 3
0
    def test_failed(self, mock_net_enable):
        mock_net_enable.side_effect = EnableServiceError(
            "test service", "test error")

        assert_raise_library_error(
            lambda: lib.qdevice_enable(self.lib_env, "net"),
            (
                severity.ERROR,
                reports.codes.SERVICE_ACTION_FAILED,
                {
                    "action": reports.const.SERVICE_ACTION_ENABLE,
                    "service": "test service",
                    "reason": "test error",
                    "node": "",
                    "instance": "",
                },
            ),
        )
        mock_net_enable.assert_called_once_with("mock_runner",
                                                "corosync-qnetd")
Exemplo n.º 4
0
    def test_enable_failed(self, mock_net_setup, mock_net_enable,
                           mock_net_start):
        mock_net_enable.side_effect = EnableServiceError(
            "test service", "test error")

        assert_raise_library_error(
            lambda: lib.qdevice_setup(self.lib_env, "net", True, True),
            (severity.ERROR, report_codes.SERVICE_ENABLE_ERROR, {
                "service": "test service",
                "reason": "test error",
            }))

        mock_net_setup.assert_called_once_with("mock_runner")
        mock_net_enable.assert_called_once_with("mock_runner",
                                                "corosync-qnetd")
        mock_net_start.assert_not_called()
        assert_report_item_list_equal(
            self.mock_reporter.report_item_list,
            [(severity.INFO, report_codes.QDEVICE_INITIALIZATION_SUCCESS, {
                "model": "net",
            })])