Improve error message for YAQL task function
Improve the error message in case a non existing task name is passed to the "task" YAQL function Change-Id: I93a33365779ba2a5301431c6769697d8b4861fae Closes-Bug: 1520930
This commit is contained in:
parent
b9c7f66345
commit
255fb91ad5
@ -830,7 +830,7 @@ Example:
|
|||||||
- radix: 16
|
- radix: 16
|
||||||
|
|
||||||
output:
|
output:
|
||||||
uuid: <% task(generated_uuid).result %>
|
uuid: <% task(generate_uuid_task).result %>
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
generate_uuid_task:
|
generate_uuid_task:
|
||||||
|
@ -109,3 +109,28 @@ class YAQLFunctionsEngineTest(engine_test_base.EngineTestCase):
|
|||||||
},
|
},
|
||||||
task2.published
|
task2.published
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_task_function_non_existing(self):
|
||||||
|
wf_text = """---
|
||||||
|
version: '2.0'
|
||||||
|
|
||||||
|
wf:
|
||||||
|
type: direct
|
||||||
|
output:
|
||||||
|
task_name: <% task(non_existing_task).name %>
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
task1:
|
||||||
|
action: std.noop
|
||||||
|
"""
|
||||||
|
|
||||||
|
wf_service.create_workflows(wf_text)
|
||||||
|
|
||||||
|
wf_ex = self.engine.start_workflow('wf', {})
|
||||||
|
|
||||||
|
self._await(lambda: self.is_execution_error(wf_ex.id))
|
||||||
|
|
||||||
|
wf_ex = db_api.get_workflow_execution(wf_ex.id)
|
||||||
|
|
||||||
|
self.assertEqual(states.ERROR, wf_ex.state)
|
||||||
|
self.assertIn('non_existing_task', wf_ex.state_info)
|
||||||
|
@ -75,7 +75,7 @@ def task_(context, task_name):
|
|||||||
|
|
||||||
# TODO(rakhmerov): Account for multiple executions (i.e. in case of
|
# TODO(rakhmerov): Account for multiple executions (i.e. in case of
|
||||||
# cycles).
|
# cycles).
|
||||||
task_ex = task_execs[-1]
|
task_ex = task_execs[-1] if len(task_execs) > 0 else None
|
||||||
|
|
||||||
if not task_ex:
|
if not task_ex:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
Loading…
Reference in New Issue
Block a user