Example #1
0
    def test_launch_action_plan_with_error(self, m_get_action_plan, m_execute):
        m_get_action_plan.return_value = self.action_plan
        m_execute.side_effect = self.FakeApplierException
        command = default.DefaultActionPlanHandler(self.context,
                                                   mock.MagicMock(),
                                                   self.action_plan.uuid)
        command.execute()

        expected_calls = [
            mock.call(self.context,
                      self.action_plan,
                      action=objects.fields.NotificationAction.EXECUTION,
                      phase=objects.fields.NotificationPhase.START),
            mock.call(self.context,
                      self.action_plan,
                      action=objects.fields.NotificationAction.EXECUTION,
                      priority=objects.fields.NotificationPriority.ERROR,
                      phase=objects.fields.NotificationPhase.ERROR)
        ]

        self.assertEqual(ap_objects.State.FAILED, self.action_plan.state)

        self.assertEqual(
            expected_calls, self.m_action_plan_notifications.
            send_action_notification.call_args_list)
Example #2
0
 def do_launch_action_plan(self, context, action_plan_uuid):
     try:
         cmd = default.DefaultActionPlanHandler(context,
                                                self.applier_manager,
                                                action_plan_uuid)
         cmd.execute()
     except Exception as e:
         LOG.exception(e)
Example #3
0
 def test_launch_action_plan(self):
     command = default.DefaultActionPlanHandler(self.context,
                                                mock.MagicMock(),
                                                self.action_plan.uuid)
     command.execute()
     action_plan = ap_objects.ActionPlan.get_by_uuid(
         self.context, self.action_plan.uuid)
     self.assertEqual(ap_objects.State.SUCCEEDED, action_plan.state)
Example #4
0
 def test_cancel_action_plan_with_exception(self, m_get_action_plan,
                                            m_execute):
     m_get_action_plan.return_value = self.action_plan
     m_execute.side_effect = exception.ActionPlanCancelled(
         self.action_plan.uuid)
     command = default.DefaultActionPlanHandler(
         self.context, mock.MagicMock(), self.action_plan.uuid)
     command.execute()
     self.assertEqual(ap_objects.State.CANCELLED, self.action_plan.state)
Example #5
0
 def test_cancel_action_plan(self, m_get_action_plan):
     m_get_action_plan.return_value = self.action_plan
     self.action_plan.state = ap_objects.State.CANCELLED
     self.action_plan.save()
     command = default.DefaultActionPlanHandler(
         self.context, mock.MagicMock(), self.action_plan.uuid)
     command.execute()
     action = self.action.get_by_uuid(self.context, self.action.uuid)
     self.assertEqual(ap_objects.State.CANCELLED, self.action_plan.state)
     self.assertEqual(objects.action.State.CANCELLED, action.state)
    def test_trigger_audit_send_notification(self):
        messaging = mock.MagicMock()
        command = default.DefaultActionPlanHandler(self.context, messaging,
                                                   self.action_plan.uuid)
        command.execute()

        call_on_going = mock.call(ev.EventTypes.LAUNCH_ACTION_PLAN.name, {
            'action_plan_state': ap_objects.State.ONGOING,
            'action_plan__uuid': self.action_plan.uuid})
        call_succeeded = mock.call(ev.EventTypes.LAUNCH_ACTION_PLAN.name, {
            'action_plan_state': ap_objects.State.SUCCEEDED,
            'action_plan__uuid': self.action_plan.uuid})

        calls = [call_on_going, call_succeeded]
        messaging.status_topic_handler.publish_event.assert_has_calls(calls)
        self.assertEqual(
            2, messaging.status_topic_handler.publish_event.call_count)
Example #7
0
    def test_launch_action_plan(self, m_get_action_plan):
        m_get_action_plan.return_value = self.action_plan
        command = default.DefaultActionPlanHandler(
            self.context, mock.MagicMock(), self.action_plan.uuid)
        command.execute()

        expected_calls = [
            mock.call(self.context, self.action_plan,
                      action=objects.fields.NotificationAction.EXECUTION,
                      phase=objects.fields.NotificationPhase.START),
            mock.call(self.context, self.action_plan,
                      action=objects.fields.NotificationAction.EXECUTION,
                      phase=objects.fields.NotificationPhase.END)]

        self.assertEqual(ap_objects.State.SUCCEEDED, self.action_plan.state)

        self.assertEqual(
            expected_calls,
            self.m_action_plan_notifications
                .send_action_notification
                .call_args_list)