From 117dc15cf59a88d8ab6b193754e884a7a8218707 Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Wed, 23 Sep 2015 15:08:03 +0300 Subject: [PATCH] Fixing run action when error occurs Closes-Bug: #1498803 Change-Id: I2e47ce5ce80c0d8918f4dc0d060935f321ccd9b9 --- mistral/engine/default_executor.py | 6 ++++-- mistral/tests/unit/engine/test_run_action.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mistral/engine/default_executor.py b/mistral/engine/default_executor.py index 449cb2ef4..f9d4a7403 100644 --- a/mistral/engine/default_executor.py +++ b/mistral/engine/default_executor.py @@ -44,13 +44,15 @@ class DefaultExecutor(base.Executor, coordination.Service): """ def send_error_back(error_msg): + error_result = wf_utils.Result(error=error_msg) + if action_ex_id: self._engine_client.on_action_complete( action_ex_id, - wf_utils.Result(error=error_msg) + error_result ) else: - return error_msg + return error_result action_cls = a_f.construct_action_class(action_class_str, attributes) diff --git a/mistral/tests/unit/engine/test_run_action.py b/mistral/tests/unit/engine/test_run_action.py index 6fcd45eaf..79b28acd5 100644 --- a/mistral/tests/unit/engine/test_run_action.py +++ b/mistral/tests/unit/engine/test_run_action.py @@ -56,6 +56,17 @@ class RunActionEngineTest(base.EngineTestCase): self.assertEqual('Hello!', action_ex.output['result']) + @mock.patch.object( + std_actions.EchoAction, + 'run', + mock.Mock(side_effect=exc.ActionException("some error")) + ) + def test_run_action_error(self): + # Start action and see the result. + action_ex = self.engine.start_action('std.echo', {'output': 'Hello!'}) + + self.assertIn('some error', action_ex.output['result']) + def test_run_action_save_result(self): # Start action. action_ex = self.engine.start_action(