Fix error message format in other task handler methods

Change-Id: I98d1c9251bf40fb628225b868962ab03cc0f6d38
This commit is contained in:
Renat Akhmerov 2016-11-10 14:48:34 +07:00
parent 07039d3ab3
commit 88047afc96
3 changed files with 72 additions and 6 deletions

View File

@ -106,9 +106,9 @@ def _on_action_complete(action_ex):
except exc.MistralException as e:
wf_ex = task_ex.workflow_execution
msg = ("Failed to handle action completion [wf=%s, task=%s,"
" action=%s]: %s\n%s" %
(wf_ex.name, task_ex.name, action_ex.name, e, tb.format_exc()))
msg = ("Failed to handle action completion [error=%s, wf=%s, task=%s,"
" action=%s]:\n%s" %
(e, wf_ex.name, task_ex.name, action_ex.name, tb.format_exc()))
LOG.error(msg)
@ -184,8 +184,8 @@ def complete_task(task_ex, state, state_info):
wf_ex = task_ex.workflow_execution
msg = (
"Failed to complete task [wf=%s, task=%s]: %s\n%s" %
(wf_ex, task_ex.name, e, tb.format_exc())
"Failed to complete task [error=%s, wf=%s, task=%s]:\n%s" %
(e, wf_ex, task_ex.name, tb.format_exc())
)
LOG.error(msg)

View File

@ -474,3 +474,67 @@ class ErrorHandlingEngineTest(base.EngineTestCase):
self.assertIsNotNone(state_info)
self.assertTrue(state_info.find('error=') > 0)
self.assertTrue(state_info.find('error=') < state_info.find('wf='))
def test_error_message_format_on_action_complete(self):
wf_text = """
version: '2.0'
wf:
tasks:
task1:
action: std.noop
publish:
my_var: <% invalid_yaql_function() %>
"""
wf_service.create_workflows(wf_text)
wf_ex = self.engine.start_workflow('wf', {})
self.await_workflow_error(wf_ex.id)
with db_api.transaction():
wf_ex = db_api.get_workflow_execution(wf_ex.id)
task_ex = wf_ex.task_executions[0]
state_info = task_ex.state_info
print(state_info)
self.assertIsNotNone(state_info)
self.assertTrue(state_info.find('error=') > 0)
self.assertTrue(state_info.find('error=') < state_info.find('wf='))
def test_error_message_format_complete_task(self):
wf_text = """
version: '2.0'
wf:
tasks:
task1:
action: std.noop
wait-after: 1
on-success:
- task2: <% invalid_yaql_function() %>
task2:
action: std.noop
"""
wf_service.create_workflows(wf_text)
wf_ex = self.engine.start_workflow('wf', {})
self.await_workflow_error(wf_ex.id)
with db_api.transaction():
wf_ex = db_api.get_workflow_execution(wf_ex.id)
task_ex = wf_ex.task_executions[0]
state_info = task_ex.state_info
self.assertIsNotNone(state_info)
self.assertTrue(state_info.find('error=') > 0)
self.assertTrue(state_info.find('error=') < state_info.find('wf='))

View File

@ -195,10 +195,12 @@ class ExecutionFieldsSizeLimitTest(base.EngineTestCase):
wf_ex = db_api.get_workflow_execution(wf_ex.id)
self.assertIn(
'Failed to handle action completion [wf=wf, task=task1',
'Failed to handle action completion [error=Size of',
wf_ex.state_info
)
self.assertIn('wf=wf, task=task1', wf_ex.state_info)
task_ex = self._assert_single_item(wf_ex.task_executions, name='task1')
self.assertIn(