Exemple #1
0
    def test_failed(self, mock_net_stop, mock_status):
        mock_status.return_value = ""
        mock_net_stop.side_effect = StopServiceError(
            "test service",
            "test error"
        )

        assert_raise_library_error(
            lambda: lib.qdevice_stop(self.lib_env, "net"),
            (
                severity.ERROR,
                report_codes.SERVICE_STOP_ERROR,
                {
                    "service": "test service",
                    "reason": "test error",
                }
            )
        )
        mock_net_stop.assert_called_once_with("mock_runner", "corosync-qnetd")
        assert_report_item_list_equal(
            self.mock_reporter.report_item_list,
            [
                (
                    severity.INFO,
                    report_codes.SERVICE_STOP_STARTED,
                    {
                        "service": "quorum device",
                    }
                )
            ]
        )
Exemple #2
0
 def test_failed(self, mock_stop, mock_is_systemctl):
     mock_stop.side_effect = StopServiceError("booth", "msg", self.name)
     assert_raise_library_error(
         lambda: commands.stop_booth(self.mock_env),
         (Severities.ERROR, report_codes.SERVICE_STOP_ERROR, {
             "service": "booth",
             "reason": "msg",
             "node": None,
             "instance": self.name,
         }))
     mock_stop.assert_called_once_with(self.mock_run, "booth", self.name)
     mock_is_systemctl.assert_called_once_with()
Exemple #3
0
    def test_stop_failed(
        self, mock_net_destroy, mock_net_disable, mock_net_stop, mock_status
    ):
        mock_status.return_value = ""
        mock_net_stop.side_effect = StopServiceError(
            "test service", "test error"
        )

        assert_raise_library_error(
            lambda: lib.qdevice_destroy(self.lib_env, "net"),
            (
                severity.ERROR,
                reports.codes.SERVICE_ACTION_FAILED,
                {
                    "action": reports.const.SERVICE_ACTION_STOP,
                    "service": "test service",
                    "reason": "test error",
                    "node": "",
                    "instance": "",
                },
            ),
        )

        mock_net_stop.assert_called_once_with("mock_runner", "corosync-qnetd")
        mock_net_disable.assert_not_called()
        mock_net_destroy.assert_not_called()
        assert_report_item_list_equal(
            self.mock_reporter.report_item_list,
            [
                (
                    severity.INFO,
                    reports.codes.SERVICE_ACTION_STARTED,
                    {
                        "action": reports.const.SERVICE_ACTION_STOP,
                        "service": "quorum device",
                        "instance": "",
                    },
                )
            ],
        )