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
This commit is contained in:
parent
b09277b42b
commit
d9517333b1
@ -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))
|
||||
if len(expression) == len(expr):
|
||||
result = 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)
|
||||
result = result.replace(expr, str(evaluated))
|
||||
|
||||
LOG.debug("Inline YAQL expression result: %s" % result)
|
||||
|
||||
|
@ -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}"
|
||||
|
||||
|
@ -4,7 +4,7 @@ Namespaces:
|
||||
base-parameters:
|
||||
method: GET
|
||||
headers:
|
||||
X-Auth-Token: $.auth_token
|
||||
X-Auth-Token: "{$.auth_token}"
|
||||
|
||||
actions:
|
||||
async-action:
|
||||
|
@ -4,7 +4,7 @@ Namespaces:
|
||||
base-parameters:
|
||||
method: GET
|
||||
headers:
|
||||
X-Auth-Token: $.auth_token
|
||||
X-Auth-Token: "{$.auth_token}"
|
||||
|
||||
actions:
|
||||
create-vm:
|
||||
|
@ -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:
|
||||
|
@ -9,7 +9,7 @@ Namespaces:
|
||||
- left
|
||||
- right
|
||||
output:
|
||||
string: $.output
|
||||
string: "{$.output}"
|
||||
|
||||
Workflow:
|
||||
tasks:
|
||||
|
@ -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}"
|
||||
|
@ -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]
|
||||
|
@ -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}"
|
||||
|
@ -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}"
|
||||
|
@ -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}"
|
||||
|
@ -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}"
|
||||
|
@ -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
|
||||
image_id: "{$.id}"
|
||||
image_name: "{$.name}"
|
@ -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}"
|
||||
|
@ -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}"
|
||||
|
@ -7,7 +7,7 @@ Namespaces:
|
||||
url: http://path_to_service/action_url
|
||||
method: GET
|
||||
output:
|
||||
output: $
|
||||
output: "{$}"
|
||||
|
||||
Workflow:
|
||||
tasks:
|
||||
|
@ -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}"
|
||||
|
@ -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
|
||||
st_output: "{$.greeting}"
|
@ -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:
|
||||
|
@ -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}"
|
||||
|
||||
|
@ -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}"
|
||||
|
@ -10,4 +10,4 @@ workflows:
|
||||
hello:
|
||||
action: std.echo output="Hello"
|
||||
publish:
|
||||
result: {$.hello}
|
||||
result: "{$.hello}"
|
||||
|
@ -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}"
|
||||
|
@ -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
|
||||
|
@ -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: "{$}"
|
||||
"""
|
||||
|
||||
|
||||
|
@ -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}"
|
||||
"""
|
||||
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
||||
|
@ -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}!"
|
||||
|
@ -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}"
|
||||
|
||||
"""
|
||||
|
||||
|
@ -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}"
|
||||
"""
|
||||
|
||||
|
||||
|
@ -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}"
|
||||
"""
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
"""
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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}"
|
||||
"""
|
||||
|
||||
|
||||
|
@ -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: "{$}"
|
||||
"""
|
||||
|
||||
|
||||
|
@ -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: "{$}"
|
||||
"""
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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"
|
||||
|
@ -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!')
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user