Merge "Disable key sorting in workflow definition"

This commit is contained in:
Zuul 2020-01-23 09:13:07 +00:00 committed by Gerrit Code Review
commit d5ae8ad1bc
4 changed files with 37 additions and 3 deletions

View File

@ -135,7 +135,7 @@ python-zaqarclient==1.0.0
python-zunclient==3.4.0 python-zunclient==3.4.0
python-qinlingclient==1.0.0 python-qinlingclient==1.0.0
pytz==2013.6 pytz==2013.6
PyYAML==3.12 PyYAML==5.1
reno==2.5.0 reno==2.5.0
repoze.lru==0.7 repoze.lru==0.7
requests-mock==1.2.0 requests-mock==1.2.0

View File

@ -208,4 +208,4 @@ def _cut_wf_definition_from_all(wfs_yaml, wf_name):
return safe_yaml.dump({ return safe_yaml.dump({
'version': wfs_yaml['version'], 'version': wfs_yaml['version'],
wf_name: wfs_yaml[wf_name] wf_name: wfs_yaml[wf_name]
}) }, sort_keys=False)

View File

@ -144,6 +144,23 @@ test_workflow:
""" """
WORKFLOWS_WITH_KEY_ORDER = """
---
version: '2.0'
wf1:
tasks:
task1:
publish:
we: 1
dont_want: 2
to_be_sorted: 3
wf2:
tasks:
task1:
action: std.noop
"""
class WorkflowServiceTest(base.DbTestCase): class WorkflowServiceTest(base.DbTestCase):
def test_create_workflows(self): def test_create_workflows(self):
@ -166,6 +183,23 @@ class WorkflowServiceTest(base.DbTestCase):
self.assertEqual('wf2', wf2_spec.get_name()) self.assertEqual('wf2', wf2_spec.get_name())
self.assertEqual('direct', wf2_spec.get_type()) self.assertEqual('direct', wf2_spec.get_type())
def test_preserve_key_ordering_in_workflow_definition(self):
db_wfs = wf_service.create_workflows(WORKFLOWS_WITH_KEY_ORDER)
self.assertEqual(2, len(db_wfs))
wf1_db = self._assert_single_item(db_wfs, name='wf1')
wf1_def = wf1_db.definition
published_values = wf1_def.splitlines()[-3:]
wf1_publish = [
item.strip()
for item in published_values
]
self.assertEqual(
['we: 1', 'dont_want: 2', 'to_be_sorted: 3'],
wf1_publish
)
def test_engine_commands_are_valid_task_names(self): def test_engine_commands_are_valid_task_names(self):
for name in workflows.ENGINE_COMMANDS: for name in workflows.ENGINE_COMMANDS:
wf_text = WORKFLOW_WITH_VAR_TASK_NAME.format(task_name=name) wf_text = WORKFLOW_WITH_VAR_TASK_NAME.format(task_name=name)

View File

@ -57,7 +57,7 @@ python-vitrageclient>=2.0.0 # Apache-2.0
python-zunclient>=3.4.0 # Apache-2.0 python-zunclient>=3.4.0 # Apache-2.0
python-qinlingclient>=1.0.0 # Apache-2.0 python-qinlingclient>=1.0.0 # Apache-2.0
PyJWT>=1.5 # MIT PyJWT>=1.5 # MIT
PyYAML>=3.12 # MIT PyYAML>=5.1 # MIT
requests>=2.14.2 # Apache-2.0 requests>=2.14.2 # Apache-2.0
tenacity>=5.0.1 # Apache-2.0 tenacity>=5.0.1 # Apache-2.0
six>=1.10.0 # MIT six>=1.10.0 # MIT