Esempio n. 1
0
 def test_notify_about_action_state_calc(self, mock_error, mock_info):
     action = fakes.make_reaper_action(
         event=ra.ActionEvent.STATE_CALCULATION)
     self.notifier.notify_about_action(action)
     msg = "State calculation %s, state: %s"
     mock_info.assert_called_once_with(msg, action.uuid,
                                       action.state.value.lower())
     mock_error.assert_not_called()
Esempio n. 2
0
 def test_notify_about_action(self, mock_error, mock_info):
     action = fakes.make_reaper_action()
     self.notifier.notify_about_action(action)
     msg = ("Reaper request %s, state: %s, "
            "requested instances: %s, event: %s")
     mock_info.assert_called_once_with(msg, action.uuid,
                                       action.state.value.lower(),
                                       action.requested_instances,
                                       action.event.value.lower())
     mock_error.assert_not_called()
Esempio n. 3
0
 def test_notify_about_action_success(self, mock_error, mock_info):
     action = fakes.make_reaper_action(state=ra.ActionState.SUCCESS)
     self.notifier.notify_about_action(action)
     msg = ("Reaper request %s, state: %s, requested instances: %s,"
            " event: %s, victims: %s")
     mock_info.assert_called_once_with(msg, action.uuid,
                                       action.state.value.lower(),
                                       action.requested_instances,
                                       action.event.value.lower(),
                                       action.victims)
     mock_error.assert_not_called()
Esempio n. 4
0
 def test_notify_about_action_state_calc_fail(self, mock_error, mock_info):
     action = fakes.make_reaper_action(
         event=ra.ActionEvent.STATE_CALCULATION,
         state=ra.ActionState.FAILED,
         fault_reason="Action failed")
     self.notifier.notify_about_action(action)
     msg = "State calculation %s, state: %s, fault reason: %s"
     mock_error.assert_called_once_with(msg, action.uuid,
                                        action.state.value.lower(),
                                        action.fault_reason)
     mock_info.assert_not_called()
Esempio n. 5
0
 def test_notify_about_action_fail(self, mock_error, mock_info):
     action = fakes.make_reaper_action(state=ra.ActionState.FAILED,
                                       fault_reason="Action failed")
     self.notifier.notify_about_action(action)
     msg = ("Reaper request %s, state: %s, requested instances: %s,"
            " event: %s, fault reason: %s")
     mock_error.assert_called_once_with(msg, action.uuid,
                                        action.state.value.lower(),
                                        action.requested_instances,
                                        action.event.value.lower(),
                                        action.fault_reason)
     mock_info.assert_not_called()
Esempio n. 6
0
 def test_notify_about_action_state_calculation(self):
     mock_notifier = mock.Mock()
     self.notifier.oslo_notifier = mock_notifier
     action = fakes.make_reaper_action(
         event=ra.ActionEvent.STATE_CALCULATION)
     expected_event = "reaper_action.ongoing"
     expected_payload = {
         'state': action.state.value.lower(),
         'event': action.event.value.lower(),
         'uuid': action.uuid
     }
     self.notifier.notify_about_action(action)
     mock_notifier.error.assert_not_called()
     mock_notifier.info.assert_called_once_with(self.mock_context,
                                                expected_event,
                                                expected_payload)
Esempio n. 7
0
 def test_notify_about_action(self):
     mock_notifier = mock.Mock()
     self.notifier.oslo_notifier = mock_notifier
     action = fakes.make_reaper_action()
     expected_event = "reaper_action.ongoing"
     expected_payload = {
         'state': action.state.value.lower(),
         'requested_instances': action.requested_instances,
         'event': action.event.value.lower(),
         'uuid': action.uuid
     }
     self.notifier.notify_about_action(action)
     mock_notifier.error.assert_not_called()
     mock_notifier.info.assert_called_once_with(self.mock_context,
                                                expected_event,
                                                expected_payload)
Esempio n. 8
0
 def test_notify_about_action_canceled(self):
     mock_notifier = mock.Mock()
     self.notifier.oslo_notifier = mock_notifier
     action = fakes.make_reaper_action(state=ra.ActionState.CANCELED,
                                       fault_reason="action canceled")
     expected_event = "reaper_action.canceled"
     expected_payload = {
         'state': action.state.value.lower(),
         'requested_instances': action.requested_instances,
         'event': action.event.value.lower(),
         'uuid': action.uuid,
         'fault_reason': action.fault_reason
     }
     self.notifier.notify_about_action(action)
     mock_notifier.info.assert_not_called()
     mock_notifier.error.assert_called_once_with(self.mock_context,
                                                 expected_event,
                                                 expected_payload)