Allowing a single string value for "requires" clause
* Making it symmetric to on-success/on-error/on-complete Change-Id: I902649e7ca5615234fab9638e673ff807e7b8113
This commit is contained in:
parent
fa0102354b
commit
c4c0aec7b2
@ -51,6 +51,13 @@ workflows:
|
||||
publish:
|
||||
result2: <% $.task2 %>
|
||||
requires: [task1]
|
||||
|
||||
task3:
|
||||
action: std.noop
|
||||
|
||||
task4:
|
||||
action: std.noop
|
||||
requires: task3
|
||||
"""
|
||||
|
||||
|
||||
@ -127,3 +134,21 @@ class ReverseWorkflowEngineTest(base.EngineTestCase):
|
||||
)
|
||||
|
||||
self.assertDictEqual({'result2': 'a & b'}, task2_ex.published)
|
||||
|
||||
def test_one_line_requires_syntax(self):
|
||||
wf_input = {'param1': 'a', 'param2': 'b'}
|
||||
|
||||
wf_ex = self.engine.start_workflow(
|
||||
'my_wb.wf1',
|
||||
wf_input,
|
||||
task_name='task4'
|
||||
)
|
||||
|
||||
self._await(lambda: self.is_execution_success(wf_ex.id))
|
||||
|
||||
tasks = db_api.get_task_executions()
|
||||
|
||||
self.assertEqual(2, len(tasks))
|
||||
|
||||
self._assert_single_item(tasks, name='task4', state=states.SUCCESS)
|
||||
self._assert_single_item(tasks, name='task3', state=states.SUCCESS)
|
||||
|
@ -283,7 +283,8 @@ class TaskSpecValidation(v2_base.WorkflowSpecValidationTestCase):
|
||||
({'requires': None}, True),
|
||||
({'requires': 12345}, True),
|
||||
({'requires': ['echo']}, False),
|
||||
({'requires': ['echo', 'get']}, False)
|
||||
({'requires': ['echo', 'get']}, False),
|
||||
({'requires': 'echo'}, False),
|
||||
]
|
||||
|
||||
for require, expect_error in tests:
|
||||
|
@ -225,6 +225,7 @@ class WorkflowSpecValidation(base.WorkflowSpecValidationTestCase):
|
||||
({'requires': 12345}, True),
|
||||
({'requires': ['echo']}, False),
|
||||
({'requires': ['echo', 'get']}, False),
|
||||
({'requires': 'echo'}, False),
|
||||
({'retry': {'count': 3, 'delay': 1}}, False),
|
||||
({'retry': {'count': '<% 3 %>', 'delay': 1}}, False),
|
||||
({'retry': {'count': '<% * %>', 'delay': 1}}, True),
|
||||
|
@ -44,7 +44,9 @@ class TaskDefaultsSpec(base.BaseSpec):
|
||||
"on-complete": _on_clause_type,
|
||||
"on-success": _on_clause_type,
|
||||
"on-error": _on_clause_type,
|
||||
"requires": types.UNIQUE_STRING_LIST
|
||||
"requires": {
|
||||
"oneOf": [types.NONEMPTY_STRING, types.UNIQUE_STRING_LIST]
|
||||
}
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
@ -97,4 +99,7 @@ class TaskDefaultsSpec(base.BaseSpec):
|
||||
return self._on_error
|
||||
|
||||
def get_requires(self):
|
||||
if isinstance(self._requires, six.string_types):
|
||||
return [self._requires]
|
||||
|
||||
return self._requires
|
||||
|
@ -276,7 +276,9 @@ class ReverseWorkflowTaskSpec(TaskSpec):
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {"enum": [_type]},
|
||||
"requires": types.UNIQUE_STRING_LIST
|
||||
"requires": {
|
||||
"oneOf": [types.NONEMPTY_STRING, types.UNIQUE_STRING_LIST]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,6 +291,9 @@ class ReverseWorkflowTaskSpec(TaskSpec):
|
||||
self._requires = data.get('requires', [])
|
||||
|
||||
def get_requires(self):
|
||||
if isinstance(self._requires, six.string_types):
|
||||
return [self._requires]
|
||||
|
||||
return self._requires
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user