Fix work of task() without task name within on-clause cases
Information about current task was removed from context too early.
As a result, it wasn't possible to get needed info from db during
task() yaql function processing without given task name.
Method "remove_current_task_from_context" was renamed to
"remove_internal_data_from_context" to have an ability to
use it in future for more common needs.
Change-Id: I14ba7b791b0ac7055f8c2cec3065833c60589c10
Closes-Bug: #1664625
(cherry picked from commit 7d4fb7dbc2
)
This commit is contained in:
parent
eea496efc0
commit
ce3bec7780
|
@ -229,6 +229,31 @@ class YAQLFunctionsEngineTest(engine_test_base.EngineTestCase):
|
|||
task2_ex.published
|
||||
)
|
||||
|
||||
def test_task_function_no_name_on_complete_case(self):
|
||||
wf_text = """---
|
||||
version: '2.0'
|
||||
|
||||
wf:
|
||||
tasks:
|
||||
task1:
|
||||
action: std.echo output=1
|
||||
on-complete:
|
||||
- fail(msg=<% task() %>)
|
||||
"""
|
||||
|
||||
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)
|
||||
|
||||
self.assertEqual(states.ERROR, wf_ex.state)
|
||||
self.assertIsNotNone(wf_ex.state_info)
|
||||
self.assertIn(wf_ex.id, wf_ex.state_info)
|
||||
|
||||
def test_uuid_function(self):
|
||||
wf_text = """---
|
||||
version: '2.0'
|
||||
|
|
|
@ -224,8 +224,6 @@ def evaluate_task_outbound_context(task_ex):
|
|||
if task_ex.in_context is not None else {}
|
||||
)
|
||||
|
||||
remove_current_task_from_context(in_context)
|
||||
|
||||
return utils.update_dict(in_context, task_ex.published)
|
||||
|
||||
|
||||
|
@ -256,7 +254,7 @@ def add_current_task_to_context(ctx, task_id, task_name):
|
|||
return ctx
|
||||
|
||||
|
||||
def remove_current_task_from_context(ctx):
|
||||
def remove_internal_data_from_context(ctx):
|
||||
if '__task_execution' in ctx:
|
||||
del ctx['__task_execution']
|
||||
|
||||
|
|
|
@ -124,6 +124,8 @@ class DirectWorkflowController(base.WorkflowController):
|
|||
elif not t_s:
|
||||
t_s = self.wf_spec.get_tasks()[task_ex.name]
|
||||
|
||||
data_flow.remove_internal_data_from_context(ctx)
|
||||
|
||||
cmd = commands.create_command(
|
||||
t_n,
|
||||
self.wf_ex,
|
||||
|
@ -164,6 +166,7 @@ class DirectWorkflowController(base.WorkflowController):
|
|||
ctx,
|
||||
data_flow.evaluate_task_outbound_context(t_ex)
|
||||
)
|
||||
data_flow.remove_internal_data_from_context(ctx)
|
||||
|
||||
return ctx
|
||||
|
||||
|
|
Loading…
Reference in New Issue