Exemple #1
0
    def test_execute_with_failed(self):
        nova_util = nova_helper.NovaHelper()
        instance = "31b9dd5c-b1fd-4f61-9b68-a47096326dac"
        nova_util.nova.servers.get.return_value = instance
        action_plan = obj_utils.create_test_action_plan(
            self.context,
            audit_id=self.audit.id,
            strategy_id=self.strategy.id,
            state=objects.action.State.ONGOING)

        action = obj_utils.create_test_action(
            self.context,
            action_plan_id=action_plan.id,
            state=objects.action.State.ONGOING,
            action_type='migrate',
            input_parameters={
                "resource_id": instance,
                "migration_type": "live",
                "destination_node": "host2",
                "source_node": "host1"
            })
        action_container = tflow.TaskFlowActionContainer(db_action=action,
                                                         engine=self.engine)

        result = action_container.execute()
        self.assertFalse(result)

        self.assertTrue(action.state, objects.action.State.FAILED)
Exemple #2
0
    def test_execute(self):
        action_plan = obj_utils.create_test_action_plan(
            self.context,
            audit_id=self.audit.id,
            strategy_id=self.strategy.id,
            state=objects.action.State.ONGOING)

        action = obj_utils.create_test_action(
            self.context,
            action_plan_id=action_plan.id,
            state=objects.action.State.ONGOING,
            action_type='nop',
            input_parameters={'message': 'hello World'})
        action_container = tflow.TaskFlowActionContainer(db_action=action,
                                                         engine=self.engine)
        action_container.execute()

        self.assertTrue(action.state, objects.action.State.SUCCEEDED)
Exemple #3
0
    def test_execute_with_cancel_action_plan(self, mock_eventlet_spawn):
        action_plan = obj_utils.create_test_action_plan(
            self.context,
            audit_id=self.audit.id,
            strategy_id=self.strategy.id,
            state=objects.action_plan.State.CANCELLING)

        action = obj_utils.create_test_action(
            self.context,
            action_plan_id=action_plan.id,
            state=objects.action.State.ONGOING,
            action_type='nop',
            input_parameters={'message': 'hello World'})
        action_container = tflow.TaskFlowActionContainer(db_action=action,
                                                         engine=self.engine)

        def empty_test():
            pass

        et = eventlet.spawn(empty_test)
        mock_eventlet_spawn.return_value = et
        action_container.execute()
        et.kill.assert_called_with()