def test_success_not_used(self, mock_status): mock_status.return_value = "" lib.qdevice_stop(self.lib_env, "net", proceed_if_used=False) self.assertEqual( self.lib_env.service_manager.method_calls, [mock.call.stop("corosync-qnetd")], ) 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": "", }, ), ( severity.INFO, reports.codes.SERVICE_ACTION_SUCCEEDED, { "action": reports.const.SERVICE_ACTION_STOP, "service": "quorum device", "node": "", "instance": "", }, ), ], )
def test_success_used_forced(self, mock_net_stop, mock_status): mock_status.return_value = 'Cluster "a_cluster":\n' lib.qdevice_stop(self.lib_env, "net", proceed_if_used=True) mock_net_stop.assert_called_once_with("mock_runner", "corosync-qnetd") assert_report_item_list_equal( self.mock_reporter.report_item_list, [ ( severity.WARNING, report_codes.QDEVICE_USED_BY_CLUSTERS, { "clusters": ["a_cluster"], } ), ( severity.INFO, report_codes.SERVICE_STOP_STARTED, { "service": "quorum device", } ), ( severity.INFO, report_codes.SERVICE_STOP_SUCCESS, { "service": "quorum device", } ) ] )
def test_success_not_used(self, mock_net_stop, mock_status): mock_status.return_value = "" lib.qdevice_stop(self.lib_env, "net", proceed_if_used=False) 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", } ), ( severity.INFO, report_codes.SERVICE_STOP_SUCCESS, { "service": "quorum device", } ) ] )
def test_failed(self, mock_status): mock_status.return_value = "" self.lib_env.service_manager.stop.side_effect = StopServiceError( "test service", "test error") assert_raise_library_error( lambda: lib.qdevice_stop(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": "", }, ), ) self.assertEqual( self.lib_env.service_manager.method_calls, [mock.call.stop("corosync-qnetd")], ) 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": "", }, )], )
def test_failed(self, mock_net_stop): 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", } ) ] )
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", } ) ] )
def test_used_not_forced(self, mock_net_stop, mock_status): mock_status.return_value = 'Cluster "a_cluster":\n' assert_raise_library_error(lambda: lib.qdevice_stop( self.lib_env, "net", proceed_if_used=False)) assert_report_item_list_equal(self.mock_reporter.report_item_list, [ (severity.ERROR, report_codes.QDEVICE_USED_BY_CLUSTERS, { "clusters": ["a_cluster"], }, report_codes.FORCE_QDEVICE_USED), ]) mock_net_stop.assert_not_called()
def test_success_used_forced(self, mock_status): mock_status.return_value = 'Cluster "a_cluster":\n' lib.qdevice_stop(self.lib_env, "net", proceed_if_used=True) self.assertEqual( self.lib_env.service_manager.method_calls, [mock.call.stop("corosync-qnetd")], ) assert_report_item_list_equal( self.mock_reporter.report_item_list, [ ( severity.WARNING, report_codes.QDEVICE_USED_BY_CLUSTERS, { "clusters": ["a_cluster"], }, ), ( severity.INFO, reports.codes.SERVICE_ACTION_STARTED, { "action": reports.const.SERVICE_ACTION_STOP, "service": "quorum device", "instance": "", }, ), ( severity.INFO, reports.codes.SERVICE_ACTION_SUCCEEDED, { "action": reports.const.SERVICE_ACTION_STOP, "service": "quorum device", "node": "", "instance": "", }, ), ], )
def test_success(self, mock_net_stop): lib.qdevice_stop(self.lib_env, "net") 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", } ), ( severity.INFO, report_codes.SERVICE_STOP_SUCCESS, { "service": "quorum device", } ) ] )
def test_used_not_forced(self, mock_net_stop, mock_status): mock_status.return_value = 'Cluster "a_cluster":\n' assert_raise_library_error( lambda: lib.qdevice_stop( self.lib_env, "net", proceed_if_used=False ), ( severity.ERROR, report_codes.QDEVICE_USED_BY_CLUSTERS, { "clusters": ["a_cluster"], }, report_codes.FORCE_QDEVICE_USED ), ) mock_net_stop.assert_not_called()
def test_stop(self): self.base_test(lambda: lib.qdevice_stop(self.lib_env, "bad model"))
def test_stop(self): self.base_test( lambda: lib.qdevice_stop(self.lib_env, "bad model") )