Fixing run action when error occurs

Closes-Bug: #1498803

Change-Id: I2e47ce5ce80c0d8918f4dc0d060935f321ccd9b9
This commit is contained in:
Nikolay Mahotkin 2015-09-23 15:08:03 +03:00
parent ba5b18c5f5
commit 117dc15cf5
2 changed files with 15 additions and 2 deletions

View File

@ -44,13 +44,15 @@ class DefaultExecutor(base.Executor, coordination.Service):
""" """
def send_error_back(error_msg): def send_error_back(error_msg):
error_result = wf_utils.Result(error=error_msg)
if action_ex_id: if action_ex_id:
self._engine_client.on_action_complete( self._engine_client.on_action_complete(
action_ex_id, action_ex_id,
wf_utils.Result(error=error_msg) error_result
) )
else: else:
return error_msg return error_result
action_cls = a_f.construct_action_class(action_class_str, attributes) action_cls = a_f.construct_action_class(action_class_str, attributes)

View File

@ -56,6 +56,17 @@ class RunActionEngineTest(base.EngineTestCase):
self.assertEqual('Hello!', action_ex.output['result']) 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): def test_run_action_save_result(self):
# Start action. # Start action.
action_ex = self.engine.start_action( action_ex = self.engine.start_action(