From d9517333b1fc9697d4847df33d3b774f881a111b Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Tue, 10 Feb 2015 19:45:08 +0300 Subject: [PATCH] Changing InlineYAQLEvaluator: treat only {yaql} as YAQL * Fixed unit tests * Fixed YAQL regexp * Now single expression keeps data type, e.g. {$.num} returns numerical data type instead of string. Change-Id: I2a8d4a1c38b75ce667781ec49702aaf3253e5761 --- mistral/expressions.py | 19 +++----- mistral/tests/resources/action_v2.yaml | 4 +- .../resources/control_flow/direct_flow.yaml | 2 +- .../control_flow/one_async_task.yaml | 2 +- .../resources/control_flow/one_std_task.yaml | 2 +- .../resources/control_flow/one_sync_task.yaml | 2 +- .../resources/control_flow/require_flow.yaml | 6 +-- .../task_with_diamond_dependencies.yaml | 16 +++---- .../data_flow/task_with_two_dependencies.yaml | 18 ++++---- .../data_flow/three_subsequent_tasks.yaml | 20 ++++---- .../data_flow/two_dependent_tasks.yaml | 12 ++--- .../data_flow/two_subsequent_tasks.yaml | 14 +++--- .../resources/openstack/glance_actions.yaml | 8 ++-- .../resources/openstack/keystone_actions.yaml | 2 +- .../resources/openstack/nova_actions.yaml | 14 +++--- .../retry_task/delay_retry_task.yaml | 2 +- .../resources/retry_task/retry_task.yaml | 4 +- .../tests/resources/retry_task/sync_task.yaml | 4 +- .../tests/resources/retry_task/two_tasks.yaml | 4 +- .../test_direct_flow_all_keywords.yaml | 10 ++-- mistral/tests/resources/test_mixed_flow.yaml | 12 ++--- mistral/tests/resources/wb_v2.yaml | 2 +- mistral/tests/resources/wf_v2.yaml | 4 +- .../unit/engine/test_data_flow_module.py | 4 +- .../unit/engine1/test_action_defaults.py | 12 ++--- .../tests/unit/engine1/test_adhoc_actions.py | 6 +-- mistral/tests/unit/engine1/test_commands.py | 16 +++---- mistral/tests/unit/engine1/test_dataflow.py | 18 ++++---- .../tests/unit/engine1/test_default_engine.py | 10 ++-- .../tests/unit/engine1/test_environment.py | 16 +++---- .../unit/engine1/test_javascript_action.py | 4 +- mistral/tests/unit/engine1/test_join.py | 44 +++++++++--------- mistral/tests/unit/engine1/test_noop_task.py | 12 ++--- mistral/tests/unit/engine1/test_policies.py | 6 +-- .../tests/unit/engine1/test_race_condition.py | 8 ++-- .../unit/engine1/test_reverse_workflow.py | 4 +- .../tests/unit/engine1/test_subworkflows.py | 8 ++-- mistral/tests/unit/engine1/test_with_items.py | 18 ++++---- .../unit/services/test_workbook_service.py | 12 ++--- .../unit/services/test_workflow_service.py | 10 ++-- mistral/tests/unit/test_expressions.py | 46 ++++++++++--------- .../unit/workbook/v2/test_dsl_specs_v2.py | 42 ++++++++--------- .../unit/workflow/test_direct_workflow.py | 6 +-- .../tests/unit/workflow/test_with_items.py | 6 +-- mistral/workbook/base.py | 4 +- mistral/workbook/v2/tasks.py | 6 ++- mistral/workflow/with_items.py | 4 +- 47 files changed, 252 insertions(+), 253 deletions(-) diff --git a/mistral/expressions.py b/mistral/expressions.py index 376ffa859..e3d98f025 100644 --- a/mistral/expressions.py +++ b/mistral/expressions.py @@ -72,16 +72,15 @@ class YAQLEvaluator(Evaluator): @classmethod def is_expression(cls, s): # TODO(rakhmerov): It should be generalized since it may not be YAQL. - # If there is at least one dollar sign in the string, - # then treat the string as a YAQL expression. - return s and '$' in s + # Treat any string as a YAQL expression. + return isinstance(s, six.string_types) class InlineYAQLEvaluator(YAQLEvaluator): # This regular expression will look for multiple occurrences of YAQL # expressions in between curly braces (i.e. {any_symbols_except'}'}) # within a string. - regex_yaql_expr = '(\{\.*[^\}]*\}*)' + regex_yaql_expr = '(\{[^\s][^}]*\})' find_expression_pattern = re.compile(regex_yaql_expr) @classmethod @@ -93,19 +92,15 @@ class InlineYAQLEvaluator(YAQLEvaluator): result = expression found_expressions = cls.find_inline_expressions(expression) - if found_expressions: for expr in found_expressions: trim_expr = expr.strip("{}") evaluated = super(InlineYAQLEvaluator, cls).evaluate(trim_expr, data_context) - result = result.replace(expr, str(evaluated)) - else: - # If there is no inline YAQL expressions found, then - # pass the entire string to the parent YAQL evaluator. - if super(InlineYAQLEvaluator, cls).is_expression(expression): - return super(InlineYAQLEvaluator, - cls).evaluate(expression, data_context) + if len(expression) == len(expr): + result = evaluated + else: + result = result.replace(expr, str(evaluated)) LOG.debug("Inline YAQL expression result: %s" % result) diff --git a/mistral/tests/resources/action_v2.yaml b/mistral/tests/resources/action_v2.yaml index ccca02c4a..6ceaf685e 100644 --- a/mistral/tests/resources/action_v2.yaml +++ b/mistral/tests/resources/action_v2.yaml @@ -10,12 +10,12 @@ greeting: input: - name output: - string: $.output + string: "{$.output}" farewell: base: std.echo base-input: output: 'Bye!' output: - info: $.output + info: "{$.output}" diff --git a/mistral/tests/resources/control_flow/direct_flow.yaml b/mistral/tests/resources/control_flow/direct_flow.yaml index 80a66f312..afd014a61 100644 --- a/mistral/tests/resources/control_flow/direct_flow.yaml +++ b/mistral/tests/resources/control_flow/direct_flow.yaml @@ -4,7 +4,7 @@ Namespaces: base-parameters: method: GET headers: - X-Auth-Token: $.auth_token + X-Auth-Token: "{$.auth_token}" actions: async-action: diff --git a/mistral/tests/resources/control_flow/one_async_task.yaml b/mistral/tests/resources/control_flow/one_async_task.yaml index dd15c3728..25aa57a5e 100644 --- a/mistral/tests/resources/control_flow/one_async_task.yaml +++ b/mistral/tests/resources/control_flow/one_async_task.yaml @@ -4,7 +4,7 @@ Namespaces: base-parameters: method: GET headers: - X-Auth-Token: $.auth_token + X-Auth-Token: "{$.auth_token}" actions: create-vm: diff --git a/mistral/tests/resources/control_flow/one_std_task.yaml b/mistral/tests/resources/control_flow/one_std_task.yaml index c93a10e6a..073c3a95d 100644 --- a/mistral/tests/resources/control_flow/one_std_task.yaml +++ b/mistral/tests/resources/control_flow/one_std_task.yaml @@ -6,7 +6,7 @@ Namespaces: base-parameters: url: http://path_to_nova/url_for_create output: - vm_id: $.base_output.server_id + vm_id: "{$.base_output.server_id}" Workflow: tasks: diff --git a/mistral/tests/resources/control_flow/one_sync_task.yaml b/mistral/tests/resources/control_flow/one_sync_task.yaml index d93c3ded6..ec36ba8e4 100644 --- a/mistral/tests/resources/control_flow/one_sync_task.yaml +++ b/mistral/tests/resources/control_flow/one_sync_task.yaml @@ -9,7 +9,7 @@ Namespaces: - left - right output: - string: $.output + string: "{$.output}" Workflow: tasks: diff --git a/mistral/tests/resources/control_flow/require_flow.yaml b/mistral/tests/resources/control_flow/require_flow.yaml index 3d4df4f5b..e172e86d0 100644 --- a/mistral/tests/resources/control_flow/require_flow.yaml +++ b/mistral/tests/resources/control_flow/require_flow.yaml @@ -9,13 +9,13 @@ Namespaces: - left - right output: - string: $.output + string: "{$.output}" start: class: std.echo base-parameters: output: 'Starting...' output: - info: $.output + info: "{$.output}" Workflow: tasks: @@ -31,4 +31,4 @@ Workflow: action: MyActions.concat parameters: left: Greetings - right: {$.string} + right: "{$.string}" diff --git a/mistral/tests/resources/data_flow/task_with_diamond_dependencies.yaml b/mistral/tests/resources/data_flow/task_with_diamond_dependencies.yaml index 8f15a5367..5d44c5cec 100644 --- a/mistral/tests/resources/data_flow/task_with_diamond_dependencies.yaml +++ b/mistral/tests/resources/data_flow/task_with_diamond_dependencies.yaml @@ -12,7 +12,7 @@ Namespaces: - left - right output: - string: $ + string: "{$}" Workflow: # context = { @@ -31,28 +31,28 @@ Workflow: build_full_name: action: MyService.concat parameters: - left: $.person.first_name - right: $.person.last_name + left: "{$.person.first_name}" + right: "{$.person.last_name}" publish: - full_name: $.string + full_name: "{$.string}" build_greeting: requires: [build_full_name] action: MyService.concat parameters: left: Dear - right: $.full_name + right: "{$.full_name}" publish: - greeting: $.string + greeting: "{$.string}" build_address: requires: [build_full_name] action: MyService.concat parameters: left: To - right: $.full_name + right: "{$.full_name}" publish: - address: $.string + address: "{$.string}" send_greeting: requires: [build_address, build_greeting] diff --git a/mistral/tests/resources/data_flow/task_with_two_dependencies.yaml b/mistral/tests/resources/data_flow/task_with_two_dependencies.yaml index 337c8ad1a..0fa0a9dcc 100644 --- a/mistral/tests/resources/data_flow/task_with_two_dependencies.yaml +++ b/mistral/tests/resources/data_flow/task_with_two_dependencies.yaml @@ -12,14 +12,14 @@ Namespaces: - first_name - last_name output: - full_name: $ + full_name: "{$}" build_greeting: class: std.echo base-parameters: output: Cheers! output: - greeting: $ + greeting: "{$}" send_greeting: class: std.echo @@ -29,7 +29,7 @@ Namespaces: - f_name - greet_msg output: - greeting_sent: $ + greeting_sent: "{$}" Workflow: # context = { @@ -48,20 +48,20 @@ Workflow: build_full_name: action: MyService.build_full_name parameters: - first_name: $.person.first_name - last_name: $.person.last_name + first_name: "{$.person.first_name}" + last_name: "{$.person.last_name}" publish: - f_name: $.full_name + f_name: "{$.full_name}" build_greeting: requires: [build_full_name] action: MyService.build_greeting publish: - greet_msg: $.greeting + greet_msg: "{$.greeting}" send_greeting: requires: [build_full_name, build_greeting] action: MyService.send_greeting parameters: - f_name: $.f_name - greet_msg: $.greet_msg + f_name: "{$.f_name}" + greet_msg: "{$.greet_msg}" diff --git a/mistral/tests/resources/data_flow/three_subsequent_tasks.yaml b/mistral/tests/resources/data_flow/three_subsequent_tasks.yaml index c7a1874d4..d3b2e1ea6 100644 --- a/mistral/tests/resources/data_flow/three_subsequent_tasks.yaml +++ b/mistral/tests/resources/data_flow/three_subsequent_tasks.yaml @@ -12,7 +12,7 @@ Namespaces: - first_name - last_name output: - full_name: $ + full_name: "{$}" build_greeting: class: std.echo @@ -21,7 +21,7 @@ Namespaces: parameters: - full_name output: - greeting: $ + greeting: "{$}" send_greeting: class: std.echo @@ -30,7 +30,7 @@ Namespaces: parameters: - greeting output: - greeting_sent: $ + greeting_sent: "{$}" Workflow: @@ -50,23 +50,23 @@ Workflow: build_full_name: action: MyService.build_full_name parameters: - first_name: $.person.first_name - last_name: $.person.last_name + first_name: "{$.person.first_name}" + last_name: "{$.person.last_name}" publish: - f_name: $.full_name + f_name: "{$.full_name}" on-success: build_greeting build_greeting: action: MyService.build_greeting parameters: - full_name: $.f_name + full_name: "{$.f_name}" publish: - greet_msg: $.greeting + greet_msg: "{$.greeting}" on-success: send_greeting send_greeting: action: MyService.send_greeting parameters: - greeting: $.task.build_greeting.greeting + greeting: "{$.task.build_greeting.greeting}" publish: - sent: $.greeting_sent + sent: "{$.greeting_sent}" diff --git a/mistral/tests/resources/data_flow/two_dependent_tasks.yaml b/mistral/tests/resources/data_flow/two_dependent_tasks.yaml index d32c6ead6..a6d2e9c61 100644 --- a/mistral/tests/resources/data_flow/two_dependent_tasks.yaml +++ b/mistral/tests/resources/data_flow/two_dependent_tasks.yaml @@ -12,7 +12,7 @@ Namespaces: - first_name - last_name output: - full_name: $ + full_name: "{$}" build_greeting: class: std.echo @@ -21,7 +21,7 @@ Namespaces: parameters: - full_name output: - greeting: $ + greeting: "{$}" Workflow: @@ -41,13 +41,13 @@ Workflow: build_full_name: action: MyService.build_full_name parameters: - first_name: $.person.first_name - last_name: $.person.last_name + first_name: "{$.person.first_name}" + last_name: "{$.person.last_name}" publish: - f_name: $.full_name + f_name: "{$.full_name}" build_greeting: requires: [build_full_name] action: MyService.build_greeting parameters: - full_name: $.f_name + full_name: "{$.f_name}" diff --git a/mistral/tests/resources/data_flow/two_subsequent_tasks.yaml b/mistral/tests/resources/data_flow/two_subsequent_tasks.yaml index 3a7b99c9d..affcc241b 100644 --- a/mistral/tests/resources/data_flow/two_subsequent_tasks.yaml +++ b/mistral/tests/resources/data_flow/two_subsequent_tasks.yaml @@ -12,7 +12,7 @@ Namespaces: - first_name - last_name output: - full_name: $ + full_name: "{$}" build_greeting: class: std.echo @@ -22,7 +22,7 @@ Namespaces: - full_name output: greeting: - greet_message: $ + greet_message: "{$}" Workflow: @@ -42,15 +42,15 @@ Workflow: build_full_name: action: MyService.build_full_name parameters: - first_name: $.person.first_name - last_name: $.person.last_name + first_name: "{$.person.first_name}" + last_name: "{$.person.last_name}" publish: - f_name: $.full_name + f_name: "{$.full_name}" on-success: build_greeting build_greeting: action: MyService.build_greeting parameters: - full_name: $.f_name + full_name: "{$.f_name}" publish: - greet_msg: $.greeting + greet_msg: "{$.greeting}" diff --git a/mistral/tests/resources/openstack/glance_actions.yaml b/mistral/tests/resources/openstack/glance_actions.yaml index 724d66897..b1472f437 100644 --- a/mistral/tests/resources/openstack/glance_actions.yaml +++ b/mistral/tests/resources/openstack/glance_actions.yaml @@ -3,13 +3,13 @@ Workflow: image_list: action: glance.images_list publish: - image_id: $[0].id + image_id: "{$[0].id}" on-success: image_get image_get: action: glance.images_get parameters: - image_id: $.image_id + image_id: "{$.image_id}" publish: - image_id: $.id - image_name: $.name \ No newline at end of file + image_id: "{$.id}" + image_name: "{$.name}" \ No newline at end of file diff --git a/mistral/tests/resources/openstack/keystone_actions.yaml b/mistral/tests/resources/openstack/keystone_actions.yaml index 1189017de..8fb5b316f 100644 --- a/mistral/tests/resources/openstack/keystone_actions.yaml +++ b/mistral/tests/resources/openstack/keystone_actions.yaml @@ -3,4 +3,4 @@ Workflow: get_some_endpoint: action: keystone.service_catalog_get_data publish: - endpoint_url: $[0].endpoints[0].url + endpoint_url: "{$[0].endpoints[0].url}" diff --git a/mistral/tests/resources/openstack/nova_actions.yaml b/mistral/tests/resources/openstack/nova_actions.yaml index b0be48e70..b670f34ba 100644 --- a/mistral/tests/resources/openstack/nova_actions.yaml +++ b/mistral/tests/resources/openstack/nova_actions.yaml @@ -3,17 +3,17 @@ Workflow: server_create: action: nova.servers_create parameters: - name: $.server_name - image: $.image_ref - flavor: $.flavor_ref + name: "{$.server_name}" + image: "{$.image_ref}" + flavor: "{$.flavor_ref}" publish: - server_id: $.id + server_id: "{$.id}" on-success: check_server_exists check_server_exists: action: nova.servers_get parameters: - server: $.server_id + server: "{$.server_id}" publish: server_exists: True on-success: @@ -25,7 +25,7 @@ Workflow: delay: 5 count: 15 parameters: - id: $.server_id + id: "{$.server_id}" status: 'ACTIVE' publish: - instance_id: $.id + instance_id: "{$.id}" diff --git a/mistral/tests/resources/retry_task/delay_retry_task.yaml b/mistral/tests/resources/retry_task/delay_retry_task.yaml index 350dbd653..6ccb3b8d4 100644 --- a/mistral/tests/resources/retry_task/delay_retry_task.yaml +++ b/mistral/tests/resources/retry_task/delay_retry_task.yaml @@ -7,7 +7,7 @@ Namespaces: url: http://path_to_service/action_url method: GET output: - output: $ + output: "{$}" Workflow: tasks: diff --git a/mistral/tests/resources/retry_task/retry_task.yaml b/mistral/tests/resources/retry_task/retry_task.yaml index 0e248eb3f..10ca322a9 100644 --- a/mistral/tests/resources/retry_task/retry_task.yaml +++ b/mistral/tests/resources/retry_task/retry_task.yaml @@ -7,7 +7,7 @@ Namespaces: url: http://path_to_service/action_url method: GET output: - output: $ + output: "{$}" Workflow: tasks: @@ -16,4 +16,4 @@ Workflow: retry: count: 5 publish: - rt_output: $.output + rt_output: "{$.output}" diff --git a/mistral/tests/resources/retry_task/sync_task.yaml b/mistral/tests/resources/retry_task/sync_task.yaml index 8ca213f3c..beeaf36c3 100644 --- a/mistral/tests/resources/retry_task/sync_task.yaml +++ b/mistral/tests/resources/retry_task/sync_task.yaml @@ -6,7 +6,7 @@ Namespaces: base-parameters: output: Cheers! output: - greeting: $ + greeting: "{$}" Workflow: tasks: @@ -15,4 +15,4 @@ Workflow: retry: count: 5 publish: - st_output: $.greeting \ No newline at end of file + st_output: "{$.greeting}" \ No newline at end of file diff --git a/mistral/tests/resources/retry_task/two_tasks.yaml b/mistral/tests/resources/retry_task/two_tasks.yaml index d82b72de8..b00bdb573 100644 --- a/mistral/tests/resources/retry_task/two_tasks.yaml +++ b/mistral/tests/resources/retry_task/two_tasks.yaml @@ -7,14 +7,14 @@ Namespaces: url: http://path_to_service/action_url method: GET output: - output: $ + output: "{$}" Workflow: tasks: no_retry_task: action: MyService.some-action publish: - n_rt_output: $.output + n_rt_output: "{$.output}" on-success: delay_retry_task delay_retry_task: diff --git a/mistral/tests/resources/test_direct_flow_all_keywords.yaml b/mistral/tests/resources/test_direct_flow_all_keywords.yaml index 7ea485f92..47a2a59a5 100644 --- a/mistral/tests/resources/test_direct_flow_all_keywords.yaml +++ b/mistral/tests/resources/test_direct_flow_all_keywords.yaml @@ -4,7 +4,7 @@ Namespaces: base-parameters: method: GET headers: - X-Auth-Token: $.auth_token + X-Auth-Token: "{$.auth_token}" actions: create-vm: @@ -26,7 +26,7 @@ Namespaces: - left - right output: - string: $ + string: "{$}" Workflow: tasks: @@ -43,7 +43,7 @@ Workflow: left: workflow right: is publish: - result2: $.string + result2: "{$.string}" on-finish: task3 task3: @@ -56,8 +56,8 @@ Workflow: task4: action: Echo.concat parameters: - left: $.result2 + left: "{$.result2}" right: complete! publish: - result4: $.string + result4: "{$.string}" diff --git a/mistral/tests/resources/test_mixed_flow.yaml b/mistral/tests/resources/test_mixed_flow.yaml index 8e54838ef..8088888fd 100644 --- a/mistral/tests/resources/test_mixed_flow.yaml +++ b/mistral/tests/resources/test_mixed_flow.yaml @@ -9,7 +9,7 @@ Namespaces: - left - right output: - string: $ + string: "{$}" Workflow: tasks: @@ -19,22 +19,22 @@ Workflow: left: workflow right: is publish: - result1: $.string + result1: "{$.string}" task2: requires: [task1] action: MyService.concat parameters: - left: $.result1 + left: "{$.result1}" right: complete publish: - result2: $.string + result2: "{$.string}" on-success: task3 task3: action: MyService.concat parameters: - left: $.result2 + left: "{$.result2}" right: '!' publish: - result3: $.string + result3: "{$.string}" diff --git a/mistral/tests/resources/wb_v2.yaml b/mistral/tests/resources/wb_v2.yaml index c4640d214..a9ce8ae28 100644 --- a/mistral/tests/resources/wb_v2.yaml +++ b/mistral/tests/resources/wb_v2.yaml @@ -10,4 +10,4 @@ workflows: hello: action: std.echo output="Hello" publish: - result: {$.hello} + result: "{$.hello}" diff --git a/mistral/tests/resources/wf_v2.yaml b/mistral/tests/resources/wf_v2.yaml index c736cecba..c87fa13e1 100644 --- a/mistral/tests/resources/wf_v2.yaml +++ b/mistral/tests/resources/wf_v2.yaml @@ -10,7 +10,7 @@ wf: policies: wait-before: 1 publish: - result: {$.hello} + result: "{$.hello}" wf1: type: reverse @@ -21,7 +21,7 @@ wf1: addressee: action: std.echo output="John" publish: - name: $.adressee + name: "{$.adressee}" goodbye: action: std.echo output="{$.farewell}, {$.name}" diff --git a/mistral/tests/unit/engine/test_data_flow_module.py b/mistral/tests/unit/engine/test_data_flow_module.py index 314338f32..ffb60ddca 100644 --- a/mistral/tests/unit/engine/test_data_flow_module.py +++ b/mistral/tests/unit/engine/test_data_flow_module.py @@ -46,11 +46,11 @@ TASK = { 'action': 'std.echo', 'parameters': { 'p1': 'My string', - 'p2': '$.param3.param32', + 'p2': '{$.param3.param32}', 'p3': '' }, 'publish': { - 'new_key11': '$.new_key1' + 'new_key11': '{$.new_key1}' } }, 'in_context': CONTEXT diff --git a/mistral/tests/unit/engine1/test_action_defaults.py b/mistral/tests/unit/engine1/test_action_defaults.py index 04a9cb4f3..e08dae274 100644 --- a/mistral/tests/unit/engine1/test_action_defaults.py +++ b/mistral/tests/unit/engine1/test_action_defaults.py @@ -52,7 +52,7 @@ wf1: task1: action: std.http url="https://api.library.org/books" publish: - result: $ + result: "{$}" """ WORKFLOW2 = """ @@ -64,7 +64,7 @@ wf2: task1: action: std.http url="https://api.library.org/books" timeout=60 publish: - result: $ + result: "{$}" """ WORKFLOW1_WITH_ITEMS = """ @@ -76,10 +76,10 @@ wf1_with_items: - links tasks: task1: - with-items: link in $.links + with-items: link in {$.links} action: std.http url={$.link} publish: - result: $ + result: "{$}" """ WORKFLOW2_WITH_ITEMS = """ @@ -91,10 +91,10 @@ wf2_with_items: - links tasks: task1: - with-items: link in $.links + with-items: link in {$.links} action: std.http url={$.link} timeout=60 publish: - result: $ + result: "{$}" """ diff --git a/mistral/tests/unit/engine1/test_adhoc_actions.py b/mistral/tests/unit/engine1/test_adhoc_actions.py index ef39fc9ca..21ef2b5e3 100644 --- a/mistral/tests/unit/engine1/test_adhoc_actions.py +++ b/mistral/tests/unit/engine1/test_adhoc_actions.py @@ -49,14 +49,14 @@ workflows: - str1 - str2 output: - workflow_result: $.result # Access to execution context variables - concat_task_result: $.concat # Access to the same but via task name + workflow_result: "{$.result}" # Access to execution context variables + concat_task_result: "{$.concat}" # Access to the same but via task name tasks: concat: action: concat_twice s1={$.str1} s2={$.str2} publish: - result: $.concat + result: "{$.concat}" """ diff --git a/mistral/tests/unit/engine1/test_commands.py b/mistral/tests/unit/engine1/test_commands.py index ccd9d4063..e94072ab9 100644 --- a/mistral/tests/unit/engine1/test_commands.py +++ b/mistral/tests/unit/engine1/test_commands.py @@ -43,9 +43,9 @@ workflows: task1: action: std.echo output='1' on-complete: - - fail: $.my_var = 1 - - succeed: $.my_var = 2 - - pause: $.my_var = 3 + - fail: "{$.my_var = 1}" + - succeed: "{$.my_var = 2}" + - pause: "{$.my_var = 3}" - task2 task2: @@ -116,11 +116,11 @@ workflows: task-defaults: on-complete: - - fail: $.my_var = 1 - - succeed: $.my_var = 2 - - pause: $.my_var = 3 - - rollback: $.my_var = 3 - - task2: $.my_var = 4 # (Never happens in this test) + - fail: "{$.my_var = 1}" + - succeed: "{$.my_var = 2}" + - pause: "{$.my_var = 3}" + - rollback: "{$.my_var = 3}" + - task2: "{$.my_var = 4}" # (Never happens in this test) tasks: task1: diff --git a/mistral/tests/unit/engine1/test_dataflow.py b/mistral/tests/unit/engine1/test_dataflow.py index c25e8fd81..3d0ac4350 100644 --- a/mistral/tests/unit/engine1/test_dataflow.py +++ b/mistral/tests/unit/engine1/test_dataflow.py @@ -43,14 +43,14 @@ wf: task1: action: std.echo output="Hi" publish: - hi: $.task1 + hi: "{$.task1}" on-success: - task2 task2: action: std.echo output="Morpheus" publish: - to: $.task2 + to: "{$.task2}" on-success: - task3 @@ -70,12 +70,12 @@ wf: task1: action: std.echo output=1 publish: - var1: $.task1 + var1: "{$.task1}" task2: action: std.echo output=2 publish: - var2: $.task2 + var2: "{$.task2}" """ VAR_OVERWRITE_WF = """ @@ -89,21 +89,21 @@ wf: task1: action: std.echo output="Hi" publish: - greeting: $.task1 + greeting: "{$.task1}" on-success: - task2 task2: action: std.echo output="Yo" publish: - greeting: $.task2 + greeting: "{$.task2}" on-success: - task3 task3: action: std.echo output="Morpheus" publish: - to: $.task3 + to: "{$.task3}" on-success: - task4 @@ -247,7 +247,7 @@ class DataFlowTest(test_base.BaseTest): publish = { 'v': '{$.var}', - 'e': '$.__env.ekey', + 'e': '{$.__env.ekey}', 'a': '{$.task1.akey}' } @@ -279,7 +279,7 @@ class DataFlowTest(test_base.BaseTest): Expected to get action error. """ - publish = {'foo': '$.akey'} + publish = {'foo': '{$.akey}'} action_output = 'error data' task_db = models.Task(name='task1') diff --git a/mistral/tests/unit/engine1/test_default_engine.py b/mistral/tests/unit/engine1/test_default_engine.py index 6d21a2501..d77ffc99a 100644 --- a/mistral/tests/unit/engine1/test_default_engine.py +++ b/mistral/tests/unit/engine1/test_default_engine.py @@ -54,7 +54,7 @@ workflows: task1: action: std.echo output="{$.param1}" publish: - result: $.task1 + result: "{$.task1}" task2: action: std.echo output="{$.param2}" @@ -139,7 +139,7 @@ class DefaultEngineTest(base.DbTestCase): self.assertDictEqual({'output': 'Hey'}, task_db.input) def test_start_workflow_with_adhoc_env(self): - wf_input = {'param1': '$.__env.key1', 'param2': '$.__env.key2'} + wf_input = {'param1': '{$.__env.key1}', 'param2': '{$.__env.key2}'} env = ENVIRONMENT['variables'] # Start workflow. @@ -157,7 +157,7 @@ class DefaultEngineTest(base.DbTestCase): @mock.patch.object(db_api, "get_environment", MOCK_ENVIRONMENT) def test_start_workflow_with_saved_env(self): - wf_input = {'param1': '$.__env.key1', 'param2': '$.__env.key2'} + wf_input = {'param1': '{$.__env.key1}', 'param2': '{$.__env.key2}'} env = ENVIRONMENT['variables'] # Start workflow. @@ -178,7 +178,7 @@ class DefaultEngineTest(base.DbTestCase): self.assertRaises(exc.NotFoundException, self.engine.start_workflow, 'wb.wf1', - {'param1': '$.__env.key1'}, + {'param1': '{$.__env.key1}'}, env='foo', task_name='task2') @@ -186,7 +186,7 @@ class DefaultEngineTest(base.DbTestCase): self.assertRaises(ValueError, self.engine.start_workflow, 'wb.wf1', - {'param1': '$.__env.key1'}, + {'param1': '{$.__env.key1}'}, env=True, task_name='task2') diff --git a/mistral/tests/unit/engine1/test_environment.py b/mistral/tests/unit/engine1/test_environment.py index 8366fb0ba..969d756a7 100644 --- a/mistral/tests/unit/engine1/test_environment.py +++ b/mistral/tests/unit/engine1/test_environment.py @@ -46,34 +46,34 @@ workflows: - param2 output: - final_result: $.final_result + final_result: "{$.final_result}" tasks: task1: action: std.echo output='{$.param1}' - target: $.__env.var1 + target: "{$.__env.var1}" publish: - result1: $.task1 + result1: "{$.task1}" task2: requires: [task1] action: std.echo output="'{$.result1} & {$.param2}'" - target: $.__env.var1 + target: "{$.__env.var1}" publish: - final_result: $.task2 + final_result: "{$.task2}" wf2: type: direct output: - slogan: $.slogan + slogan: "{$.slogan}" tasks: task1: workflow: wf1 input: - param1: $.__env.var2 - param2: $.__env.var3 + param1: "{$.__env.var2}" + param2: "{$.__env.var3}" task_name: task2 publish: slogan: "{$.task1.final_result} is a cool {$.__env.var4}!" diff --git a/mistral/tests/unit/engine1/test_javascript_action.py b/mistral/tests/unit/engine1/test_javascript_action.py index c867905a6..63c8ff691 100644 --- a/mistral/tests/unit/engine1/test_javascript_action.py +++ b/mistral/tests/unit/engine1/test_javascript_action.py @@ -53,10 +53,10 @@ workflows: # Skip this '$' sign until bug # https://bugs.launchpad.net/mistral/+bug/1415886 is resolved. # return $['num'] * 10 - context: $ + context: "{$}" publish: - result: $.task1 + result: "{$.task1}" """ diff --git a/mistral/tests/unit/engine1/test_join.py b/mistral/tests/unit/engine1/test_join.py index 15ff8f5dd..8e14ec822 100644 --- a/mistral/tests/unit/engine1/test_join.py +++ b/mistral/tests/unit/engine1/test_join.py @@ -33,20 +33,20 @@ wf: type: direct output: - result: $.result3 + result: "{$.result3}" tasks: task1: action: std.echo output=1 publish: - result1: $.task1 + result1: "{$.task1}" on-complete: - task3 task2: action: std.echo output=2 publish: - result2: $.task2 + result2: "{$.task2}" on-complete: - task3 @@ -54,7 +54,7 @@ wf: join: all action: std.echo output="{$.result1},{$.result2}" publish: - result3: $.task3 + result3: "{$.task3}" """ @@ -66,13 +66,13 @@ wf: type: direct output: - result: $.result3 + result: "{$.result3}" tasks: task1: action: std.echo output=1 publish: - result1: $.task1 + result1: "{$.task1}" on-complete: - task3 @@ -85,7 +85,7 @@ wf: join: all action: std.echo output="{$.result1}-{$.result1}" publish: - result3: $.task3 + result3: "{$.task3}" """ WF_FULL_JOIN_WITH_CONDITIONS = """ @@ -96,34 +96,34 @@ wf: type: direct output: - result: $.result4 + result: "{$.result4}" tasks: task1: action: std.echo output=1 publish: - result1: $.task1 + result1: "{$.task1}" on-complete: - task3 task2: action: std.echo output=2 publish: - result2: $.task2 + result2: "{$.task2}" on-complete: - - task3: $.result2 = 11111 - - task4: $.result2 = 2 + - task3: "{$.result2 = 11111}" + - task4: "{$.result2 = 2}" task3: join: all action: std.echo output="{$.result1}-{$.result1}" publish: - result3: $.task3 + result3: "{$.task3}" task4: action: std.echo output=4 publish: - result4: $.task4 + result4: "{$.task4}" """ WF_PARTIAL_JOIN = """ @@ -134,20 +134,20 @@ wf: type: direct output: - result: $.result4 + result: "{$.result4}" tasks: task1: action: std.echo output=1 publish: - result1: $.task1 + result1: "{$.task1}" on-complete: - task4 task2: action: std.echo output=2 publish: - result2: $.task2 + result2: "{$.task2}" on-complete: - task4 @@ -167,7 +167,7 @@ wf: join: 2 action: std.echo output="{$.result1},{$.result2}" publish: - result4: $.task4 + result4: "{$.task4}" """ WF_PARTIAL_JOIN_TRIGGERS_ONCE = """ @@ -178,7 +178,7 @@ wf: type: direct output: - result: $.result4 + result: "{$.result4}" tasks: task1: @@ -213,7 +213,7 @@ wf: join: 2 action: std.echo output="{$.result1},{$.result2},{$.result3},{$.result4}" publish: - result5: $.task5 + result5: "{$.task5}" """ WF_DISCRIMINATOR = """ @@ -224,7 +224,7 @@ wf: type: direct output: - result: $.result4 + result: "{$.result4}" tasks: task1: @@ -252,7 +252,7 @@ wf: join: one action: std.echo output="{$.result1},{$.result2},{$.result3}" publish: - result4: $.task4 + result4: "{$.task4}" """ diff --git a/mistral/tests/unit/engine1/test_noop_task.py b/mistral/tests/unit/engine1/test_noop_task.py index 072c1e00b..8cfa1d095 100644 --- a/mistral/tests/unit/engine1/test_noop_task.py +++ b/mistral/tests/unit/engine1/test_noop_task.py @@ -43,14 +43,14 @@ wf: task1: action: std.echo output={$.num1} publish: - result1: $.task1 + result1: "{$.task1}" on-complete: - task3 task2: action: std.echo output={$.num2} publish: - result2: $.task2 + result2: "{$.task2}" on-complete: - task3 @@ -60,18 +60,18 @@ wf: task and serves just a decision point in the workflow. join: all on-complete: - - task4: $.num1 + $.num2 = 2 - - task5: $.num1 + $.num2 = 3 + - task4: "{$.num1 + $.num2 = 2}" + - task5: "{$.num1 + $.num2 = 3}" task4: action: std.echo output=4 publish: - result4: $.task4 + result4: "{$.task4}" task5: action: std.echo output=5 publish: - result5: $.task5 + result5: "{$.task5}" """ diff --git a/mistral/tests/unit/engine1/test_policies.py b/mistral/tests/unit/engine1/test_policies.py index 2b5b61a35..2e6e0ec51 100644 --- a/mistral/tests/unit/engine1/test_policies.py +++ b/mistral/tests/unit/engine1/test_policies.py @@ -48,7 +48,7 @@ workflows: retry: count: 5 delay: 10 - break-on: $.my_val = 10 + break-on: "{$.my_val = 10}" """ @@ -133,7 +133,7 @@ workflows: retry: count: 3 delay: 1 - break-on: $.my_val = 10 + break-on: "{$.my_val = 10}" """ @@ -248,7 +248,7 @@ class PoliciesTest(base.EngineTestCase): self.assertIsInstance(p, policies.RetryPolicy) self.assertEqual(5, p.count) - self.assertEqual('$.my_val = 10', p.break_on) + self.assertEqual('{$.my_val = 10}', p.break_on) p = self._assert_single_item(arr, delay=7) diff --git a/mistral/tests/unit/engine1/test_race_condition.py b/mistral/tests/unit/engine1/test_race_condition.py index b85ac7b71..09838cc9b 100644 --- a/mistral/tests/unit/engine1/test_race_condition.py +++ b/mistral/tests/unit/engine1/test_race_condition.py @@ -43,13 +43,13 @@ wf: method. And we need to check that engine handles this situation. output: - result: $.result + result: "{$.result}" tasks: task1: action: std.block publish: - result: $.task1 + result: "{$.task1}" """ WF_SHORT_ACTION = """ @@ -73,13 +73,13 @@ wf: methods ends. output: - result: $.result + result: "{$.result}" tasks: task1: action: std.echo output=1 publish: - result1: $.task1 + result1: "{$.task1}" task2: action: std.block diff --git a/mistral/tests/unit/engine1/test_reverse_workflow.py b/mistral/tests/unit/engine1/test_reverse_workflow.py index 139a0cea9..227fb69ab 100644 --- a/mistral/tests/unit/engine1/test_reverse_workflow.py +++ b/mistral/tests/unit/engine1/test_reverse_workflow.py @@ -44,12 +44,12 @@ workflows: task1: action: std.echo output='{$.param1}' publish: - result1: $.task1 + result1: "{$.task1}" task2: action: std.echo output="{$.result1} & {$.param2}" publish: - result2: $.task2 + result2: "{$.task2}" requires: [task1] """ diff --git a/mistral/tests/unit/engine1/test_subworkflows.py b/mistral/tests/unit/engine1/test_subworkflows.py index 9e7b50f72..9bacdbec6 100644 --- a/mistral/tests/unit/engine1/test_subworkflows.py +++ b/mistral/tests/unit/engine1/test_subworkflows.py @@ -44,24 +44,24 @@ workflows: - param1 - param2 output: - final_result: $.final_result + final_result: "{$.final_result}" tasks: task1: action: std.echo output='{$.param1}' publish: - result1: $.task1 + result1: "{$.task1}" task2: action: std.echo output="'{$.param1} & {$.param2}'" publish: - final_result: $.task2 + final_result: "{$.task2}" requires: [task1] wf2: type: direct output: - slogan: $.slogan + slogan: "{$.slogan}" tasks: task1: diff --git a/mistral/tests/unit/engine1/test_with_items.py b/mistral/tests/unit/engine1/test_with_items.py index 3ebcc7e5f..aca92f337 100644 --- a/mistral/tests/unit/engine1/test_with_items.py +++ b/mistral/tests/unit/engine1/test_with_items.py @@ -45,10 +45,10 @@ workflows: tasks: task1: - with-items: name_info in $.names_info + with-items: name_info in {$.names_info} action: std.echo output={$.name_info.name} publish: - result: $.task1 + result: "{$.task1}" """ @@ -68,10 +68,10 @@ workflows: tasks: task1: - with-items: name_info in $.names_info + with-items: name_info in {$.names_info} action: std.echo output="{$.greeting}, {$.name_info.name}!" publish: - result: $.task1 + result: "{$.task1}" """ @@ -92,11 +92,11 @@ workflows: tasks: task1: with-items: - - itemX in $.arrayI - - itemY in $.arrayJ + - itemX in {$.arrayI} + - itemY in {$.arrayJ} action: std.echo output="{$.itemX} {$.itemY}" publish: - result: $.task1 + result: "{$.task1}" """ @@ -113,10 +113,10 @@ workflows: - links tasks: task1: - with-items: link in $.links + with-items: link in {$.links} action: std.mistral_http url={$.link} publish: - result: $.task1 + result: "{$.task1}" """ diff --git a/mistral/tests/unit/services/test_workbook_service.py b/mistral/tests/unit/services/test_workbook_service.py index 240c8f6bd..6b8d7efe7 100644 --- a/mistral/tests/unit/services/test_workbook_service.py +++ b/mistral/tests/unit/services/test_workbook_service.py @@ -46,18 +46,18 @@ workflows: input: - param1 output: - result: $.result + result: "{$.result}" tasks: task1: action: std.echo output="{$.param1}" publish: - result: $ + result: "{$}" wf2: type: direct output: - result: $.result + result: "{$.result}" tasks: task1: @@ -83,7 +83,7 @@ workflows: wf1: type: direct output: - result: $.result + result: "{$.result}" tasks: task1: @@ -96,13 +96,13 @@ workflows: input: - param1 output: - result: $.result + result: "{$.result}" tasks: task1: action: std.echo output="{$.param1}" publish: - result: $ + result: "{$}" """ diff --git a/mistral/tests/unit/services/test_workflow_service.py b/mistral/tests/unit/services/test_workflow_service.py index da55afa26..f2a8d7fee 100644 --- a/mistral/tests/unit/services/test_workflow_service.py +++ b/mistral/tests/unit/services/test_workflow_service.py @@ -37,18 +37,18 @@ wf1: input: - param1 output: - result: $.result + result: "{$.result}" tasks: task1: action: std.echo output="{$.param1}" publish: - result: $ + result: "{$}" wf2: type: direct output: - result: $.result + result: "{$.result}" tasks: task1: @@ -67,13 +67,13 @@ wf1: - param1 - param2 output: - result: $.result + result: "{$.result}" tasks: task1: action: std.echo output="{$.param1}{$.param2}" publish: - result: $ + result: "{$}" """ diff --git a/mistral/tests/unit/test_expressions.py b/mistral/tests/unit/test_expressions.py index b31f44f2e..965a7fac7 100644 --- a/mistral/tests/unit/test_expressions.py +++ b/mistral/tests/unit/test_expressions.py @@ -72,26 +72,28 @@ class YaqlEvaluatorTest(base.BaseTest): def test_function_length(self): # Lists. - self.assertEqual(0, expr.evaluate('$.length()', [])) - self.assertEqual(3, expr.evaluate('$.length()', [1, 2, 3])) - self.assertEqual(2, expr.evaluate('$.length()', ['one', 'two'])) - self.assertEqual(4, expr.evaluate( + self.assertEqual(0, self._evaluator.evaluate('$.length()', [])) + self.assertEqual(3, self._evaluator.evaluate('$.length()', [1, 2, 3])) + self.assertEqual( + 2, self._evaluator.evaluate('$.length()', ['one', 'two']) + ) + self.assertEqual(4, self._evaluator.evaluate( '$.array.length()', {'array': ['1', '2', '3', '4']}) ) # Strings. - self.assertEqual(3, expr.evaluate('$.length()', '123')) - self.assertEqual(2, expr.evaluate('$.length()', '12')) + self.assertEqual(3, self._evaluator.evaluate('$.length()', '123')) + self.assertEqual(2, self._evaluator.evaluate('$.length()', '12')) self.assertEqual( 4, - expr.evaluate('$.string.length()', {'string': '1234'}) + self._evaluator.evaluate('$.string.length()', {'string': '1234'}) ) # Generators. self.assertEqual( 2, - expr.evaluate( + self._evaluator.evaluate( "$[$.state = 'active'].length()", [ {'state': 'active'}, @@ -103,7 +105,7 @@ class YaqlEvaluatorTest(base.BaseTest): self.assertEqual( 0, - expr.evaluate("$[$.state = 'active'].length()", []) + self._evaluator.evaluate("$[$.state = 'active'].length()", []) ) @@ -166,19 +168,19 @@ class ExpressionsTest(base.BaseTest): } test_cases = [ - ('{$.a + $.b * $.c}', '7'), - ('{($.a + $.b) * $.c}', '9'), - ('{$.d and $.e}', 'False'), - ('{$.f > $.g}', 'True'), - ('{$.h.length() >= 5}', 'True'), - ('{$.h.length() >= $.b + $.c}', 'True'), - ('{100 in $.h}', 'False'), - ('{$.a in $.h}', 'True'), - ('{''OpenStack'' in $.i}', 'True'), + ('{$.a + $.b * $.c}', 7), + ('{($.a + $.b) * $.c}', 9), + ('{$.d and $.e}', False), + ('{$.f > $.g}', True), + ('{$.h.length() >= 5}', True), + ('{$.h.length() >= $.b + $.c}', True), + ('{100 in $.h}', False), + ('{$.a in $.h}', True), + ('{''OpenStack'' in $.i}', True), ('Hello, {$.j}!', 'Hello, World!'), ('{$.k} is {$.l}!', 'Mistral is awesome!'), ('This is {$.m}.', 'This is the way we roll.'), - ('{1 + 1 = 3}', 'False') + ('{1 + 1 = 3}', False) ] for expression, expected in test_cases: @@ -190,7 +192,7 @@ class ExpressionsTest(base.BaseTest): task_spec_dict = { 'parameters': { 'p1': 'My string', - 'p2': '$.param2', + 'p2': '{$.param2}', 'p3': '' }, 'publish': { @@ -226,7 +228,7 @@ class ExpressionsTest(base.BaseTest): data = { "parameters": { "parameter1": { - "name1": "$.auth_token", + "name1": "{$.auth_token}", "name2": "val_name2" }, "param2": [ @@ -235,7 +237,7 @@ class ExpressionsTest(base.BaseTest): "/servers/{$.project_id}/bla" ] }, - "token": "$.auth_token" + "token": "{$.auth_token}" } applied = expr.evaluate_recursively(data, context) diff --git a/mistral/tests/unit/workbook/v2/test_dsl_specs_v2.py b/mistral/tests/unit/workbook/v2/test_dsl_specs_v2.py index dd4f47b06..4bee27dee 100644 --- a/mistral/tests/unit/workbook/v2/test_dsl_specs_v2.py +++ b/mistral/tests/unit/workbook/v2/test_dsl_specs_v2.py @@ -33,13 +33,13 @@ actions: base: std.echo base-input: output: Hello {$.name}! - output: $ + output: "{$}" action2: description: This is a test ad-hoc action with base params tags: [test, v2] base: std.echo output="Echo output" - output: $ + output: "{$}" workflows: wf1: @@ -60,7 +60,7 @@ workflows: retry: count: 10 delay: 30 - break-on: $.my_val = 10 + break-on: "{$.my_val = 10}" concurrency: 3 task2: @@ -76,9 +76,9 @@ workflows: retry: count: 10 delay: 30 - break-on: $.my_val = 10 + break-on: "{$.my_val = 10}" on-error: - - fail: $.my_val = 0 + - fail: "{$.my_val = 0}" on-success: - pause on-complete: @@ -88,11 +88,11 @@ workflows: task3: workflow: wf1 name="John Doe" age=32 param1=null param2=false on-error: - - task4: $.my_val = 1 + - task4: "{$.my_val = 1}" on-success: - - task5: $.my_val = 2 + - task5: "{$.my_val = 2}" on-complete: - - task6: $.my_val = 3 + - task6: "{$.my_val = 3}" task4: action: std.echo output="Task 4 echo" @@ -104,7 +104,7 @@ workflows: action: std.echo output="Task 6 echo" task7: - with-items: vm_info in $.vms + with-items: vm_info in {$.vms} workflow: wf2 is_true=true object_list=[1, null, "str"] is_string="50" on-complete: - task9 @@ -112,9 +112,9 @@ workflows: task8: with-items: - - itemX in $.arrayI - - itemY in $.arrayJ - workflow: wf2 expr_list=["$.value", "{$.key}"] expr={$.value} + - itemX in {$.arrayI} + - itemY in {$.arrayJ} + workflow: wf2 expr_list=["{$.value}", "{$.key}"] expr={$.value} target: nova on-complete: - task9 @@ -216,7 +216,7 @@ class DSLv2ModelTest(base.BaseTest): action_spec.get_base_input() ) self.assertListEqual([], action_spec.get_input()) - self.assertEqual('$', action_spec.get_output()) + self.assertEqual('{$}', action_spec.get_output()) # Workflows. @@ -255,7 +255,7 @@ class DSLv2ModelTest(base.BaseTest): self.assertEqual(10, retry_spec.get_count()) self.assertEqual(30, retry_spec.get_delay()) - self.assertEqual('$.my_val = 10', retry_spec.get_break_on()) + self.assertEqual('{$.my_val = 10}', retry_spec.get_break_on()) task2_spec = wf1_spec.get_tasks().get('task2') @@ -280,7 +280,7 @@ class DSLv2ModelTest(base.BaseTest): task_defaults_spec = wf2_spec.get_task_defaults() self.assertListEqual( - [('fail', '$.my_val = 0')], + [('fail', '{$.my_val = 0}')], task_defaults_spec.get_on_error() ) self.assertListEqual( @@ -309,15 +309,15 @@ class DSLv2ModelTest(base.BaseTest): task3_spec.get_input() ) self.assertListEqual( - [('task4', '$.my_val = 1')], + [('task4', '{$.my_val = 1}')], task3_spec.get_on_error() ) self.assertListEqual( - [('task5', '$.my_val = 2')], + [('task5', '{$.my_val = 2}')], task3_spec.get_on_success() ) self.assertListEqual( - [('task6', '$.my_val = 3')], + [('task6', '{$.my_val = 3}')], task3_spec.get_on_complete() ) @@ -333,20 +333,20 @@ class DSLv2ModelTest(base.BaseTest): ) self.assertEqual( - {'vm_info': '$.vms'}, + {'vm_info': '{$.vms}'}, task7_spec.get_with_items() ) task8_spec = wf2_spec.get_tasks().get('task8') self.assertEqual( - {"itemX": '$.arrayI', "itemY": '$.arrayJ'}, + {"itemX": '{$.arrayI}', "itemY": '{$.arrayJ}'}, task8_spec.get_with_items() ) self.assertEqual( { - 'expr_list': ['$.value', '{$.key}'], + 'expr_list': ['{$.value}', '{$.key}'], 'expr': '{$.value}', }, task8_spec.get_input() diff --git a/mistral/tests/unit/workflow/test_direct_workflow.py b/mistral/tests/unit/workflow/test_direct_workflow.py index 62d566b69..4a6ca137d 100644 --- a/mistral/tests/unit/workflow/test_direct_workflow.py +++ b/mistral/tests/unit/workflow/test_direct_workflow.py @@ -38,10 +38,10 @@ workflows: task1: action: std.echo output="Hey" publish: - res1: $.task1 + res1: "{$.task1}" on-complete: - - task2: $.res1 = 'Hey' - - task3: $.res1 = 'Not Hey' + - task2: "{$.res1 = 'Hey'}" + - task3: "{$.res1 = 'Not Hey'}" task2: action: std.echo output="Hi" diff --git a/mistral/tests/unit/workflow/test_with_items.py b/mistral/tests/unit/workflow/test_with_items.py index e92abeefc..e8232fb49 100644 --- a/mistral/tests/unit/workflow/test_with_items.py +++ b/mistral/tests/unit/workflow/test_with_items.py @@ -27,10 +27,10 @@ TASK_DICT = { 'version': '2.0', 'action': 'std.echo', 'with-items': [ - 'item in $.array' + 'item in {$.array}' ], 'input': { - 'array': '$.my_array' + 'array': '{$.my_array}' } } @@ -45,7 +45,7 @@ TASK_DB = models.Task( class WithItemsCalculationsTest(base.BaseTest): def test_calculate_output_with_key(self): task_dict = TASK_DICT.copy() - task_dict['publish'] = {'result': '$.task1'} + task_dict['publish'] = {'result': '{$.task1}'} task_spec = tasks.TaskSpec(task_dict) raw_result = utils.TaskResult(data='output!') diff --git a/mistral/workbook/base.py b/mistral/workbook/base.py index a56a3aec3..5d7faf01f 100644 --- a/mistral/workbook/base.py +++ b/mistral/workbook/base.py @@ -22,7 +22,7 @@ from mistral import exceptions as exc CMD_PTRN = re.compile("^[\w\.]+[^=\s\"]*") -_ALL_IN_BRACES = "\{[^}]*\}\s*" +ALL_IN_BRACES = "\{[^}]*\}\s*" _ALL_IN_BRACKETS = "\[.*\]\s*" _ALL_IN_QUOTES = "\"[^\"]*\"\s*" _ALL_IN_APOSTROPHES = "'[^']*'\s*" @@ -32,7 +32,7 @@ _FALSE = "false" _NULL = "null" ALL = ( - _ALL_IN_QUOTES, _ALL_IN_APOSTROPHES, _ALL_IN_BRACES, + _ALL_IN_QUOTES, _ALL_IN_APOSTROPHES, ALL_IN_BRACES, _ALL_IN_BRACKETS, _TRUE, _FALSE, _NULL, _DIGITS ) diff --git a/mistral/workbook/v2/tasks.py b/mistral/workbook/v2/tasks.py index c640ab0ac..458680b80 100644 --- a/mistral/workbook/v2/tasks.py +++ b/mistral/workbook/v2/tasks.py @@ -21,7 +21,9 @@ from mistral.workbook import base from mistral.workbook.v2 import task_policies -WITH_ITEMS_PTRN = re.compile("\s*([\w\d_\-]+)\s*in\s*(\[.+\]|\$\..+)") +WITH_ITEMS_PTRN = re.compile( + "\s*([\w\d_\-]+)\s*in\s*(\[.+\]|%s)" % base.ALL_IN_BRACES +) class TaskSpec(base.BaseSpec): @@ -111,7 +113,7 @@ class TaskSpec(base.BaseSpec): if not match: msg = ("Wrong format of 'with-items' property. Please use " - "format 'var in {[some, list] | $.array}: " + "format 'var in {[some, list] | {$.array} }: " "%s" % self._data) raise exc.InvalidModelException(msg) diff --git a/mistral/workflow/with_items.py b/mistral/workflow/with_items.py index 599f4637a..dc9c4bb64 100644 --- a/mistral/workflow/with_items.py +++ b/mistral/workflow/with_items.py @@ -149,8 +149,8 @@ def calc_input(with_items_input): Example: DSL: with_items: - - itemX in $.arrayI - - itemY in $.arrayJ + - itemX in {$.arrayI} + - itemY in {$.arrayJ} Assume arrayI = [1, 2], arrayJ = ['a', 'b']. with_items_input = {