Esempio n. 1
0
    def test_start_failed(self, mock_net_setup, mock_net_enable,
                          mock_net_start):
        mock_net_start.side_effect = StartServiceError("test service",
                                                       "test error")

        assert_raise_library_error(
            lambda: lib.qdevice_setup(self.lib_env, "net", True, True),
            (severity.ERROR, report_codes.SERVICE_START_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_called_once_with("mock_runner", "corosync-qnetd")
        assert_report_item_list_equal(
            self.mock_reporter.report_item_list,
            [(severity.INFO, report_codes.QDEVICE_INITIALIZATION_SUCCESS, {
                "model": "net",
            }),
             (severity.INFO, report_codes.SERVICE_ENABLE_SUCCESS, {
                 "service": "quorum device",
             }),
             (severity.INFO, report_codes.SERVICE_START_STARTED, {
                 "service": "quorum device",
             })])
Esempio n. 2
0
    def test_failed(self, mock_net_start):
        mock_net_start.side_effect = StartServiceError(
            "test service",
            "test error"
        )

        assert_raise_library_error(
            lambda: lib.qdevice_start(self.lib_env, "net"),
            (
                severity.ERROR,
                report_codes.SERVICE_START_ERROR,
                {
                    "service": "test service",
                    "reason": "test error",
                }
            )
        )
        mock_net_start.assert_called_once_with("mock_runner", "corosync-qnetd")
        assert_report_item_list_equal(
            self.mock_reporter.report_item_list,
            [
                (
                    severity.INFO,
                    report_codes.SERVICE_START_STARTED,
                    {
                        "service": "quorum device",
                    }
                )
            ]
        )
Esempio n. 3
0
    def test_failed(self, mock_net_start, mock_qdevice_initialized):
        mock_net_start.side_effect = StartServiceError("test service",
                                                       "test error")
        mock_qdevice_initialized.return_value = True

        assert_raise_library_error(
            lambda: lib.qdevice_start(self.lib_env, "net"),
            (
                severity.ERROR,
                reports.codes.SERVICE_ACTION_FAILED,
                {
                    "action": reports.const.SERVICE_ACTION_START,
                    "service": "test service",
                    "reason": "test error",
                    "node": "",
                    "instance": "",
                },
            ),
        )
        mock_net_start.assert_called_once_with("mock_runner", "corosync-qnetd")
        mock_qdevice_initialized.assert_called_once_with()
        assert_report_item_list_equal(
            self.mock_reporter.report_item_list,
            [(
                severity.INFO,
                reports.codes.SERVICE_ACTION_STARTED,
                {
                    "action": reports.const.SERVICE_ACTION_START,
                    "service": "quorum device",
                    "instance": "",
                },
            )],
        )
Esempio n. 4
0
 def test_failed(self, mock_start, mock_is_systemctl):
     mock_start.side_effect = StartServiceError("booth", "msg", self.name)
     assert_raise_library_error(
         lambda: commands.start_booth(self.mock_env),
         (Severities.ERROR, report_codes.SERVICE_START_ERROR, {
             "service": "booth",
             "reason": "msg",
             "node": None,
             "instance": self.name,
         }))
     mock_start.assert_called_once_with(self.mock_run, "booth", self.name)
     mock_is_systemctl.assert_called_once_with()