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
|
@classmethod
|
||||||
def is_expression(cls, s):
|
def is_expression(cls, s):
|
||||||
# TODO(rakhmerov): It should be generalized since it may not be YAQL.
|
# TODO(rakhmerov): It should be generalized since it may not be YAQL.
|
||||||
# If there is at least one dollar sign in the string,
|
# Treat any string as a YAQL expression.
|
||||||
# then treat the string as a YAQL expression.
|
return isinstance(s, six.string_types)
|
||||||
return s and '$' in s
|
|
||||||
|
|
||||||
|
|
||||||
class InlineYAQLEvaluator(YAQLEvaluator):
|
class InlineYAQLEvaluator(YAQLEvaluator):
|
||||||
# This regular expression will look for multiple occurrences of YAQL
|
# This regular expression will look for multiple occurrences of YAQL
|
||||||
# expressions in between curly braces (i.e. {any_symbols_except'}'})
|
# expressions in between curly braces (i.e. {any_symbols_except'}'})
|
||||||
# within a string.
|
# within a string.
|
||||||
regex_yaql_expr = '(\{\.*[^\}]*\}*)'
|
regex_yaql_expr = '(\{[^\s][^}]*\})'
|
||||||
find_expression_pattern = re.compile(regex_yaql_expr)
|
find_expression_pattern = re.compile(regex_yaql_expr)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -93,19 +92,15 @@ class InlineYAQLEvaluator(YAQLEvaluator):
|
|||||||
|
|
||||||
result = expression
|
result = expression
|
||||||
found_expressions = cls.find_inline_expressions(expression)
|
found_expressions = cls.find_inline_expressions(expression)
|
||||||
|
|
||||||
if found_expressions:
|
if found_expressions:
|
||||||
for expr in found_expressions:
|
for expr in found_expressions:
|
||||||
trim_expr = expr.strip("{}")
|
trim_expr = expr.strip("{}")
|
||||||
evaluated = super(InlineYAQLEvaluator,
|
evaluated = super(InlineYAQLEvaluator,
|
||||||
cls).evaluate(trim_expr, data_context)
|
cls).evaluate(trim_expr, data_context)
|
||||||
result = result.replace(expr, str(evaluated))
|
if len(expression) == len(expr):
|
||||||
else:
|
result = evaluated
|
||||||
# If there is no inline YAQL expressions found, then
|
else:
|
||||||
# pass the entire string to the parent YAQL evaluator.
|
result = result.replace(expr, str(evaluated))
|
||||||
if super(InlineYAQLEvaluator, cls).is_expression(expression):
|
|
||||||
return super(InlineYAQLEvaluator,
|
|
||||||
cls).evaluate(expression, data_context)
|
|
||||||
|
|
||||||
LOG.debug("Inline YAQL expression result: %s" % result)
|
LOG.debug("Inline YAQL expression result: %s" % result)
|
||||||
|
|
||||||
|
@ -10,12 +10,12 @@ greeting:
|
|||||||
input:
|
input:
|
||||||
- name
|
- name
|
||||||
output:
|
output:
|
||||||
string: $.output
|
string: "{$.output}"
|
||||||
|
|
||||||
farewell:
|
farewell:
|
||||||
base: std.echo
|
base: std.echo
|
||||||
base-input:
|
base-input:
|
||||||
output: 'Bye!'
|
output: 'Bye!'
|
||||||
output:
|
output:
|
||||||
info: $.output
|
info: "{$.output}"
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ Namespaces:
|
|||||||
base-parameters:
|
base-parameters:
|
||||||
method: GET
|
method: GET
|
||||||
headers:
|
headers:
|
||||||
X-Auth-Token: $.auth_token
|
X-Auth-Token: "{$.auth_token}"
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
async-action:
|
async-action:
|
||||||
|
@ -4,7 +4,7 @@ Namespaces:
|
|||||||
base-parameters:
|
base-parameters:
|
||||||
method: GET
|
method: GET
|
||||||
headers:
|
headers:
|
||||||
X-Auth-Token: $.auth_token
|
X-Auth-Token: "{$.auth_token}"
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
create-vm:
|
create-vm:
|
||||||
|
@ -6,7 +6,7 @@ Namespaces:
|
|||||||
base-parameters:
|
base-parameters:
|
||||||
url: http://path_to_nova/url_for_create
|
url: http://path_to_nova/url_for_create
|
||||||
output:
|
output:
|
||||||
vm_id: $.base_output.server_id
|
vm_id: "{$.base_output.server_id}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
tasks:
|
tasks:
|
||||||
|
@ -9,7 +9,7 @@ Namespaces:
|
|||||||
- left
|
- left
|
||||||
- right
|
- right
|
||||||
output:
|
output:
|
||||||
string: $.output
|
string: "{$.output}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
tasks:
|
tasks:
|
||||||
|
@ -9,13 +9,13 @@ Namespaces:
|
|||||||
- left
|
- left
|
||||||
- right
|
- right
|
||||||
output:
|
output:
|
||||||
string: $.output
|
string: "{$.output}"
|
||||||
start:
|
start:
|
||||||
class: std.echo
|
class: std.echo
|
||||||
base-parameters:
|
base-parameters:
|
||||||
output: 'Starting...'
|
output: 'Starting...'
|
||||||
output:
|
output:
|
||||||
info: $.output
|
info: "{$.output}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
tasks:
|
tasks:
|
||||||
@ -31,4 +31,4 @@ Workflow:
|
|||||||
action: MyActions.concat
|
action: MyActions.concat
|
||||||
parameters:
|
parameters:
|
||||||
left: Greetings
|
left: Greetings
|
||||||
right: {$.string}
|
right: "{$.string}"
|
||||||
|
@ -12,7 +12,7 @@ Namespaces:
|
|||||||
- left
|
- left
|
||||||
- right
|
- right
|
||||||
output:
|
output:
|
||||||
string: $
|
string: "{$}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
# context = {
|
# context = {
|
||||||
@ -31,28 +31,28 @@ Workflow:
|
|||||||
build_full_name:
|
build_full_name:
|
||||||
action: MyService.concat
|
action: MyService.concat
|
||||||
parameters:
|
parameters:
|
||||||
left: $.person.first_name
|
left: "{$.person.first_name}"
|
||||||
right: $.person.last_name
|
right: "{$.person.last_name}"
|
||||||
publish:
|
publish:
|
||||||
full_name: $.string
|
full_name: "{$.string}"
|
||||||
|
|
||||||
build_greeting:
|
build_greeting:
|
||||||
requires: [build_full_name]
|
requires: [build_full_name]
|
||||||
action: MyService.concat
|
action: MyService.concat
|
||||||
parameters:
|
parameters:
|
||||||
left: Dear
|
left: Dear
|
||||||
right: $.full_name
|
right: "{$.full_name}"
|
||||||
publish:
|
publish:
|
||||||
greeting: $.string
|
greeting: "{$.string}"
|
||||||
|
|
||||||
build_address:
|
build_address:
|
||||||
requires: [build_full_name]
|
requires: [build_full_name]
|
||||||
action: MyService.concat
|
action: MyService.concat
|
||||||
parameters:
|
parameters:
|
||||||
left: To
|
left: To
|
||||||
right: $.full_name
|
right: "{$.full_name}"
|
||||||
publish:
|
publish:
|
||||||
address: $.string
|
address: "{$.string}"
|
||||||
|
|
||||||
send_greeting:
|
send_greeting:
|
||||||
requires: [build_address, build_greeting]
|
requires: [build_address, build_greeting]
|
||||||
|
@ -12,14 +12,14 @@ Namespaces:
|
|||||||
- first_name
|
- first_name
|
||||||
- last_name
|
- last_name
|
||||||
output:
|
output:
|
||||||
full_name: $
|
full_name: "{$}"
|
||||||
|
|
||||||
build_greeting:
|
build_greeting:
|
||||||
class: std.echo
|
class: std.echo
|
||||||
base-parameters:
|
base-parameters:
|
||||||
output: Cheers!
|
output: Cheers!
|
||||||
output:
|
output:
|
||||||
greeting: $
|
greeting: "{$}"
|
||||||
|
|
||||||
send_greeting:
|
send_greeting:
|
||||||
class: std.echo
|
class: std.echo
|
||||||
@ -29,7 +29,7 @@ Namespaces:
|
|||||||
- f_name
|
- f_name
|
||||||
- greet_msg
|
- greet_msg
|
||||||
output:
|
output:
|
||||||
greeting_sent: $
|
greeting_sent: "{$}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
# context = {
|
# context = {
|
||||||
@ -48,20 +48,20 @@ Workflow:
|
|||||||
build_full_name:
|
build_full_name:
|
||||||
action: MyService.build_full_name
|
action: MyService.build_full_name
|
||||||
parameters:
|
parameters:
|
||||||
first_name: $.person.first_name
|
first_name: "{$.person.first_name}"
|
||||||
last_name: $.person.last_name
|
last_name: "{$.person.last_name}"
|
||||||
publish:
|
publish:
|
||||||
f_name: $.full_name
|
f_name: "{$.full_name}"
|
||||||
|
|
||||||
build_greeting:
|
build_greeting:
|
||||||
requires: [build_full_name]
|
requires: [build_full_name]
|
||||||
action: MyService.build_greeting
|
action: MyService.build_greeting
|
||||||
publish:
|
publish:
|
||||||
greet_msg: $.greeting
|
greet_msg: "{$.greeting}"
|
||||||
|
|
||||||
send_greeting:
|
send_greeting:
|
||||||
requires: [build_full_name, build_greeting]
|
requires: [build_full_name, build_greeting]
|
||||||
action: MyService.send_greeting
|
action: MyService.send_greeting
|
||||||
parameters:
|
parameters:
|
||||||
f_name: $.f_name
|
f_name: "{$.f_name}"
|
||||||
greet_msg: $.greet_msg
|
greet_msg: "{$.greet_msg}"
|
||||||
|
@ -12,7 +12,7 @@ Namespaces:
|
|||||||
- first_name
|
- first_name
|
||||||
- last_name
|
- last_name
|
||||||
output:
|
output:
|
||||||
full_name: $
|
full_name: "{$}"
|
||||||
|
|
||||||
build_greeting:
|
build_greeting:
|
||||||
class: std.echo
|
class: std.echo
|
||||||
@ -21,7 +21,7 @@ Namespaces:
|
|||||||
parameters:
|
parameters:
|
||||||
- full_name
|
- full_name
|
||||||
output:
|
output:
|
||||||
greeting: $
|
greeting: "{$}"
|
||||||
|
|
||||||
send_greeting:
|
send_greeting:
|
||||||
class: std.echo
|
class: std.echo
|
||||||
@ -30,7 +30,7 @@ Namespaces:
|
|||||||
parameters:
|
parameters:
|
||||||
- greeting
|
- greeting
|
||||||
output:
|
output:
|
||||||
greeting_sent: $
|
greeting_sent: "{$}"
|
||||||
|
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
@ -50,23 +50,23 @@ Workflow:
|
|||||||
build_full_name:
|
build_full_name:
|
||||||
action: MyService.build_full_name
|
action: MyService.build_full_name
|
||||||
parameters:
|
parameters:
|
||||||
first_name: $.person.first_name
|
first_name: "{$.person.first_name}"
|
||||||
last_name: $.person.last_name
|
last_name: "{$.person.last_name}"
|
||||||
publish:
|
publish:
|
||||||
f_name: $.full_name
|
f_name: "{$.full_name}"
|
||||||
on-success: build_greeting
|
on-success: build_greeting
|
||||||
|
|
||||||
build_greeting:
|
build_greeting:
|
||||||
action: MyService.build_greeting
|
action: MyService.build_greeting
|
||||||
parameters:
|
parameters:
|
||||||
full_name: $.f_name
|
full_name: "{$.f_name}"
|
||||||
publish:
|
publish:
|
||||||
greet_msg: $.greeting
|
greet_msg: "{$.greeting}"
|
||||||
on-success: send_greeting
|
on-success: send_greeting
|
||||||
|
|
||||||
send_greeting:
|
send_greeting:
|
||||||
action: MyService.send_greeting
|
action: MyService.send_greeting
|
||||||
parameters:
|
parameters:
|
||||||
greeting: $.task.build_greeting.greeting
|
greeting: "{$.task.build_greeting.greeting}"
|
||||||
publish:
|
publish:
|
||||||
sent: $.greeting_sent
|
sent: "{$.greeting_sent}"
|
||||||
|
@ -12,7 +12,7 @@ Namespaces:
|
|||||||
- first_name
|
- first_name
|
||||||
- last_name
|
- last_name
|
||||||
output:
|
output:
|
||||||
full_name: $
|
full_name: "{$}"
|
||||||
|
|
||||||
build_greeting:
|
build_greeting:
|
||||||
class: std.echo
|
class: std.echo
|
||||||
@ -21,7 +21,7 @@ Namespaces:
|
|||||||
parameters:
|
parameters:
|
||||||
- full_name
|
- full_name
|
||||||
output:
|
output:
|
||||||
greeting: $
|
greeting: "{$}"
|
||||||
|
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
@ -41,13 +41,13 @@ Workflow:
|
|||||||
build_full_name:
|
build_full_name:
|
||||||
action: MyService.build_full_name
|
action: MyService.build_full_name
|
||||||
parameters:
|
parameters:
|
||||||
first_name: $.person.first_name
|
first_name: "{$.person.first_name}"
|
||||||
last_name: $.person.last_name
|
last_name: "{$.person.last_name}"
|
||||||
publish:
|
publish:
|
||||||
f_name: $.full_name
|
f_name: "{$.full_name}"
|
||||||
|
|
||||||
build_greeting:
|
build_greeting:
|
||||||
requires: [build_full_name]
|
requires: [build_full_name]
|
||||||
action: MyService.build_greeting
|
action: MyService.build_greeting
|
||||||
parameters:
|
parameters:
|
||||||
full_name: $.f_name
|
full_name: "{$.f_name}"
|
||||||
|
@ -12,7 +12,7 @@ Namespaces:
|
|||||||
- first_name
|
- first_name
|
||||||
- last_name
|
- last_name
|
||||||
output:
|
output:
|
||||||
full_name: $
|
full_name: "{$}"
|
||||||
|
|
||||||
build_greeting:
|
build_greeting:
|
||||||
class: std.echo
|
class: std.echo
|
||||||
@ -22,7 +22,7 @@ Namespaces:
|
|||||||
- full_name
|
- full_name
|
||||||
output:
|
output:
|
||||||
greeting:
|
greeting:
|
||||||
greet_message: $
|
greet_message: "{$}"
|
||||||
|
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
@ -42,15 +42,15 @@ Workflow:
|
|||||||
build_full_name:
|
build_full_name:
|
||||||
action: MyService.build_full_name
|
action: MyService.build_full_name
|
||||||
parameters:
|
parameters:
|
||||||
first_name: $.person.first_name
|
first_name: "{$.person.first_name}"
|
||||||
last_name: $.person.last_name
|
last_name: "{$.person.last_name}"
|
||||||
publish:
|
publish:
|
||||||
f_name: $.full_name
|
f_name: "{$.full_name}"
|
||||||
on-success: build_greeting
|
on-success: build_greeting
|
||||||
|
|
||||||
build_greeting:
|
build_greeting:
|
||||||
action: MyService.build_greeting
|
action: MyService.build_greeting
|
||||||
parameters:
|
parameters:
|
||||||
full_name: $.f_name
|
full_name: "{$.f_name}"
|
||||||
publish:
|
publish:
|
||||||
greet_msg: $.greeting
|
greet_msg: "{$.greeting}"
|
||||||
|
@ -3,13 +3,13 @@ Workflow:
|
|||||||
image_list:
|
image_list:
|
||||||
action: glance.images_list
|
action: glance.images_list
|
||||||
publish:
|
publish:
|
||||||
image_id: $[0].id
|
image_id: "{$[0].id}"
|
||||||
on-success: image_get
|
on-success: image_get
|
||||||
|
|
||||||
image_get:
|
image_get:
|
||||||
action: glance.images_get
|
action: glance.images_get
|
||||||
parameters:
|
parameters:
|
||||||
image_id: $.image_id
|
image_id: "{$.image_id}"
|
||||||
publish:
|
publish:
|
||||||
image_id: $.id
|
image_id: "{$.id}"
|
||||||
image_name: $.name
|
image_name: "{$.name}"
|
@ -3,4 +3,4 @@ Workflow:
|
|||||||
get_some_endpoint:
|
get_some_endpoint:
|
||||||
action: keystone.service_catalog_get_data
|
action: keystone.service_catalog_get_data
|
||||||
publish:
|
publish:
|
||||||
endpoint_url: $[0].endpoints[0].url
|
endpoint_url: "{$[0].endpoints[0].url}"
|
||||||
|
@ -3,17 +3,17 @@ Workflow:
|
|||||||
server_create:
|
server_create:
|
||||||
action: nova.servers_create
|
action: nova.servers_create
|
||||||
parameters:
|
parameters:
|
||||||
name: $.server_name
|
name: "{$.server_name}"
|
||||||
image: $.image_ref
|
image: "{$.image_ref}"
|
||||||
flavor: $.flavor_ref
|
flavor: "{$.flavor_ref}"
|
||||||
publish:
|
publish:
|
||||||
server_id: $.id
|
server_id: "{$.id}"
|
||||||
on-success: check_server_exists
|
on-success: check_server_exists
|
||||||
|
|
||||||
check_server_exists:
|
check_server_exists:
|
||||||
action: nova.servers_get
|
action: nova.servers_get
|
||||||
parameters:
|
parameters:
|
||||||
server: $.server_id
|
server: "{$.server_id}"
|
||||||
publish:
|
publish:
|
||||||
server_exists: True
|
server_exists: True
|
||||||
on-success:
|
on-success:
|
||||||
@ -25,7 +25,7 @@ Workflow:
|
|||||||
delay: 5
|
delay: 5
|
||||||
count: 15
|
count: 15
|
||||||
parameters:
|
parameters:
|
||||||
id: $.server_id
|
id: "{$.server_id}"
|
||||||
status: 'ACTIVE'
|
status: 'ACTIVE'
|
||||||
publish:
|
publish:
|
||||||
instance_id: $.id
|
instance_id: "{$.id}"
|
||||||
|
@ -7,7 +7,7 @@ Namespaces:
|
|||||||
url: http://path_to_service/action_url
|
url: http://path_to_service/action_url
|
||||||
method: GET
|
method: GET
|
||||||
output:
|
output:
|
||||||
output: $
|
output: "{$}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
tasks:
|
tasks:
|
||||||
|
@ -7,7 +7,7 @@ Namespaces:
|
|||||||
url: http://path_to_service/action_url
|
url: http://path_to_service/action_url
|
||||||
method: GET
|
method: GET
|
||||||
output:
|
output:
|
||||||
output: $
|
output: "{$}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
tasks:
|
tasks:
|
||||||
@ -16,4 +16,4 @@ Workflow:
|
|||||||
retry:
|
retry:
|
||||||
count: 5
|
count: 5
|
||||||
publish:
|
publish:
|
||||||
rt_output: $.output
|
rt_output: "{$.output}"
|
||||||
|
@ -6,7 +6,7 @@ Namespaces:
|
|||||||
base-parameters:
|
base-parameters:
|
||||||
output: Cheers!
|
output: Cheers!
|
||||||
output:
|
output:
|
||||||
greeting: $
|
greeting: "{$}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
tasks:
|
tasks:
|
||||||
@ -15,4 +15,4 @@ Workflow:
|
|||||||
retry:
|
retry:
|
||||||
count: 5
|
count: 5
|
||||||
publish:
|
publish:
|
||||||
st_output: $.greeting
|
st_output: "{$.greeting}"
|
@ -7,14 +7,14 @@ Namespaces:
|
|||||||
url: http://path_to_service/action_url
|
url: http://path_to_service/action_url
|
||||||
method: GET
|
method: GET
|
||||||
output:
|
output:
|
||||||
output: $
|
output: "{$}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
tasks:
|
tasks:
|
||||||
no_retry_task:
|
no_retry_task:
|
||||||
action: MyService.some-action
|
action: MyService.some-action
|
||||||
publish:
|
publish:
|
||||||
n_rt_output: $.output
|
n_rt_output: "{$.output}"
|
||||||
on-success: delay_retry_task
|
on-success: delay_retry_task
|
||||||
|
|
||||||
delay_retry_task:
|
delay_retry_task:
|
||||||
|
@ -4,7 +4,7 @@ Namespaces:
|
|||||||
base-parameters:
|
base-parameters:
|
||||||
method: GET
|
method: GET
|
||||||
headers:
|
headers:
|
||||||
X-Auth-Token: $.auth_token
|
X-Auth-Token: "{$.auth_token}"
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
create-vm:
|
create-vm:
|
||||||
@ -26,7 +26,7 @@ Namespaces:
|
|||||||
- left
|
- left
|
||||||
- right
|
- right
|
||||||
output:
|
output:
|
||||||
string: $
|
string: "{$}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
tasks:
|
tasks:
|
||||||
@ -43,7 +43,7 @@ Workflow:
|
|||||||
left: workflow
|
left: workflow
|
||||||
right: is
|
right: is
|
||||||
publish:
|
publish:
|
||||||
result2: $.string
|
result2: "{$.string}"
|
||||||
on-finish: task3
|
on-finish: task3
|
||||||
|
|
||||||
task3:
|
task3:
|
||||||
@ -56,8 +56,8 @@ Workflow:
|
|||||||
task4:
|
task4:
|
||||||
action: Echo.concat
|
action: Echo.concat
|
||||||
parameters:
|
parameters:
|
||||||
left: $.result2
|
left: "{$.result2}"
|
||||||
right: complete!
|
right: complete!
|
||||||
publish:
|
publish:
|
||||||
result4: $.string
|
result4: "{$.string}"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Namespaces:
|
|||||||
- left
|
- left
|
||||||
- right
|
- right
|
||||||
output:
|
output:
|
||||||
string: $
|
string: "{$}"
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
tasks:
|
tasks:
|
||||||
@ -19,22 +19,22 @@ Workflow:
|
|||||||
left: workflow
|
left: workflow
|
||||||
right: is
|
right: is
|
||||||
publish:
|
publish:
|
||||||
result1: $.string
|
result1: "{$.string}"
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
requires: [task1]
|
requires: [task1]
|
||||||
action: MyService.concat
|
action: MyService.concat
|
||||||
parameters:
|
parameters:
|
||||||
left: $.result1
|
left: "{$.result1}"
|
||||||
right: complete
|
right: complete
|
||||||
publish:
|
publish:
|
||||||
result2: $.string
|
result2: "{$.string}"
|
||||||
on-success: task3
|
on-success: task3
|
||||||
|
|
||||||
task3:
|
task3:
|
||||||
action: MyService.concat
|
action: MyService.concat
|
||||||
parameters:
|
parameters:
|
||||||
left: $.result2
|
left: "{$.result2}"
|
||||||
right: '!'
|
right: '!'
|
||||||
publish:
|
publish:
|
||||||
result3: $.string
|
result3: "{$.string}"
|
||||||
|
@ -10,4 +10,4 @@ workflows:
|
|||||||
hello:
|
hello:
|
||||||
action: std.echo output="Hello"
|
action: std.echo output="Hello"
|
||||||
publish:
|
publish:
|
||||||
result: {$.hello}
|
result: "{$.hello}"
|
||||||
|
@ -10,7 +10,7 @@ wf:
|
|||||||
policies:
|
policies:
|
||||||
wait-before: 1
|
wait-before: 1
|
||||||
publish:
|
publish:
|
||||||
result: {$.hello}
|
result: "{$.hello}"
|
||||||
|
|
||||||
wf1:
|
wf1:
|
||||||
type: reverse
|
type: reverse
|
||||||
@ -21,7 +21,7 @@ wf1:
|
|||||||
addressee:
|
addressee:
|
||||||
action: std.echo output="John"
|
action: std.echo output="John"
|
||||||
publish:
|
publish:
|
||||||
name: $.adressee
|
name: "{$.adressee}"
|
||||||
|
|
||||||
goodbye:
|
goodbye:
|
||||||
action: std.echo output="{$.farewell}, {$.name}"
|
action: std.echo output="{$.farewell}, {$.name}"
|
||||||
|
@ -46,11 +46,11 @@ TASK = {
|
|||||||
'action': 'std.echo',
|
'action': 'std.echo',
|
||||||
'parameters': {
|
'parameters': {
|
||||||
'p1': 'My string',
|
'p1': 'My string',
|
||||||
'p2': '$.param3.param32',
|
'p2': '{$.param3.param32}',
|
||||||
'p3': ''
|
'p3': ''
|
||||||
},
|
},
|
||||||
'publish': {
|
'publish': {
|
||||||
'new_key11': '$.new_key1'
|
'new_key11': '{$.new_key1}'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'in_context': CONTEXT
|
'in_context': CONTEXT
|
||||||
|
@ -52,7 +52,7 @@ wf1:
|
|||||||
task1:
|
task1:
|
||||||
action: std.http url="https://api.library.org/books"
|
action: std.http url="https://api.library.org/books"
|
||||||
publish:
|
publish:
|
||||||
result: $
|
result: "{$}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WORKFLOW2 = """
|
WORKFLOW2 = """
|
||||||
@ -64,7 +64,7 @@ wf2:
|
|||||||
task1:
|
task1:
|
||||||
action: std.http url="https://api.library.org/books" timeout=60
|
action: std.http url="https://api.library.org/books" timeout=60
|
||||||
publish:
|
publish:
|
||||||
result: $
|
result: "{$}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WORKFLOW1_WITH_ITEMS = """
|
WORKFLOW1_WITH_ITEMS = """
|
||||||
@ -76,10 +76,10 @@ wf1_with_items:
|
|||||||
- links
|
- links
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
with-items: link in $.links
|
with-items: link in {$.links}
|
||||||
action: std.http url={$.link}
|
action: std.http url={$.link}
|
||||||
publish:
|
publish:
|
||||||
result: $
|
result: "{$}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WORKFLOW2_WITH_ITEMS = """
|
WORKFLOW2_WITH_ITEMS = """
|
||||||
@ -91,10 +91,10 @@ wf2_with_items:
|
|||||||
- links
|
- links
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
with-items: link in $.links
|
with-items: link in {$.links}
|
||||||
action: std.http url={$.link} timeout=60
|
action: std.http url={$.link} timeout=60
|
||||||
publish:
|
publish:
|
||||||
result: $
|
result: "{$}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,14 +49,14 @@ workflows:
|
|||||||
- str1
|
- str1
|
||||||
- str2
|
- str2
|
||||||
output:
|
output:
|
||||||
workflow_result: $.result # Access to execution context variables
|
workflow_result: "{$.result}" # Access to execution context variables
|
||||||
concat_task_result: $.concat # Access to the same but via task name
|
concat_task_result: "{$.concat}" # Access to the same but via task name
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
concat:
|
concat:
|
||||||
action: concat_twice s1={$.str1} s2={$.str2}
|
action: concat_twice s1={$.str1} s2={$.str2}
|
||||||
publish:
|
publish:
|
||||||
result: $.concat
|
result: "{$.concat}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ workflows:
|
|||||||
task1:
|
task1:
|
||||||
action: std.echo output='1'
|
action: std.echo output='1'
|
||||||
on-complete:
|
on-complete:
|
||||||
- fail: $.my_var = 1
|
- fail: "{$.my_var = 1}"
|
||||||
- succeed: $.my_var = 2
|
- succeed: "{$.my_var = 2}"
|
||||||
- pause: $.my_var = 3
|
- pause: "{$.my_var = 3}"
|
||||||
- task2
|
- task2
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
@ -116,11 +116,11 @@ workflows:
|
|||||||
|
|
||||||
task-defaults:
|
task-defaults:
|
||||||
on-complete:
|
on-complete:
|
||||||
- fail: $.my_var = 1
|
- fail: "{$.my_var = 1}"
|
||||||
- succeed: $.my_var = 2
|
- succeed: "{$.my_var = 2}"
|
||||||
- pause: $.my_var = 3
|
- pause: "{$.my_var = 3}"
|
||||||
- rollback: $.my_var = 3
|
- rollback: "{$.my_var = 3}"
|
||||||
- task2: $.my_var = 4 # (Never happens in this test)
|
- task2: "{$.my_var = 4}" # (Never happens in this test)
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
|
@ -43,14 +43,14 @@ wf:
|
|||||||
task1:
|
task1:
|
||||||
action: std.echo output="Hi"
|
action: std.echo output="Hi"
|
||||||
publish:
|
publish:
|
||||||
hi: $.task1
|
hi: "{$.task1}"
|
||||||
on-success:
|
on-success:
|
||||||
- task2
|
- task2
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output="Morpheus"
|
action: std.echo output="Morpheus"
|
||||||
publish:
|
publish:
|
||||||
to: $.task2
|
to: "{$.task2}"
|
||||||
on-success:
|
on-success:
|
||||||
- task3
|
- task3
|
||||||
|
|
||||||
@ -70,12 +70,12 @@ wf:
|
|||||||
task1:
|
task1:
|
||||||
action: std.echo output=1
|
action: std.echo output=1
|
||||||
publish:
|
publish:
|
||||||
var1: $.task1
|
var1: "{$.task1}"
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output=2
|
action: std.echo output=2
|
||||||
publish:
|
publish:
|
||||||
var2: $.task2
|
var2: "{$.task2}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
VAR_OVERWRITE_WF = """
|
VAR_OVERWRITE_WF = """
|
||||||
@ -89,21 +89,21 @@ wf:
|
|||||||
task1:
|
task1:
|
||||||
action: std.echo output="Hi"
|
action: std.echo output="Hi"
|
||||||
publish:
|
publish:
|
||||||
greeting: $.task1
|
greeting: "{$.task1}"
|
||||||
on-success:
|
on-success:
|
||||||
- task2
|
- task2
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output="Yo"
|
action: std.echo output="Yo"
|
||||||
publish:
|
publish:
|
||||||
greeting: $.task2
|
greeting: "{$.task2}"
|
||||||
on-success:
|
on-success:
|
||||||
- task3
|
- task3
|
||||||
|
|
||||||
task3:
|
task3:
|
||||||
action: std.echo output="Morpheus"
|
action: std.echo output="Morpheus"
|
||||||
publish:
|
publish:
|
||||||
to: $.task3
|
to: "{$.task3}"
|
||||||
on-success:
|
on-success:
|
||||||
- task4
|
- task4
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ class DataFlowTest(test_base.BaseTest):
|
|||||||
|
|
||||||
publish = {
|
publish = {
|
||||||
'v': '{$.var}',
|
'v': '{$.var}',
|
||||||
'e': '$.__env.ekey',
|
'e': '{$.__env.ekey}',
|
||||||
'a': '{$.task1.akey}'
|
'a': '{$.task1.akey}'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ class DataFlowTest(test_base.BaseTest):
|
|||||||
|
|
||||||
Expected to get action error.
|
Expected to get action error.
|
||||||
"""
|
"""
|
||||||
publish = {'foo': '$.akey'}
|
publish = {'foo': '{$.akey}'}
|
||||||
action_output = 'error data'
|
action_output = 'error data'
|
||||||
|
|
||||||
task_db = models.Task(name='task1')
|
task_db = models.Task(name='task1')
|
||||||
|
@ -54,7 +54,7 @@ workflows:
|
|||||||
task1:
|
task1:
|
||||||
action: std.echo output="{$.param1}"
|
action: std.echo output="{$.param1}"
|
||||||
publish:
|
publish:
|
||||||
result: $.task1
|
result: "{$.task1}"
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output="{$.param2}"
|
action: std.echo output="{$.param2}"
|
||||||
@ -139,7 +139,7 @@ class DefaultEngineTest(base.DbTestCase):
|
|||||||
self.assertDictEqual({'output': 'Hey'}, task_db.input)
|
self.assertDictEqual({'output': 'Hey'}, task_db.input)
|
||||||
|
|
||||||
def test_start_workflow_with_adhoc_env(self):
|
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']
|
env = ENVIRONMENT['variables']
|
||||||
|
|
||||||
# Start workflow.
|
# Start workflow.
|
||||||
@ -157,7 +157,7 @@ class DefaultEngineTest(base.DbTestCase):
|
|||||||
|
|
||||||
@mock.patch.object(db_api, "get_environment", MOCK_ENVIRONMENT)
|
@mock.patch.object(db_api, "get_environment", MOCK_ENVIRONMENT)
|
||||||
def test_start_workflow_with_saved_env(self):
|
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']
|
env = ENVIRONMENT['variables']
|
||||||
|
|
||||||
# Start workflow.
|
# Start workflow.
|
||||||
@ -178,7 +178,7 @@ class DefaultEngineTest(base.DbTestCase):
|
|||||||
self.assertRaises(exc.NotFoundException,
|
self.assertRaises(exc.NotFoundException,
|
||||||
self.engine.start_workflow,
|
self.engine.start_workflow,
|
||||||
'wb.wf1',
|
'wb.wf1',
|
||||||
{'param1': '$.__env.key1'},
|
{'param1': '{$.__env.key1}'},
|
||||||
env='foo',
|
env='foo',
|
||||||
task_name='task2')
|
task_name='task2')
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class DefaultEngineTest(base.DbTestCase):
|
|||||||
self.assertRaises(ValueError,
|
self.assertRaises(ValueError,
|
||||||
self.engine.start_workflow,
|
self.engine.start_workflow,
|
||||||
'wb.wf1',
|
'wb.wf1',
|
||||||
{'param1': '$.__env.key1'},
|
{'param1': '{$.__env.key1}'},
|
||||||
env=True,
|
env=True,
|
||||||
task_name='task2')
|
task_name='task2')
|
||||||
|
|
||||||
|
@ -46,34 +46,34 @@ workflows:
|
|||||||
- param2
|
- param2
|
||||||
|
|
||||||
output:
|
output:
|
||||||
final_result: $.final_result
|
final_result: "{$.final_result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output='{$.param1}'
|
action: std.echo output='{$.param1}'
|
||||||
target: $.__env.var1
|
target: "{$.__env.var1}"
|
||||||
publish:
|
publish:
|
||||||
result1: $.task1
|
result1: "{$.task1}"
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
requires: [task1]
|
requires: [task1]
|
||||||
action: std.echo output="'{$.result1} & {$.param2}'"
|
action: std.echo output="'{$.result1} & {$.param2}'"
|
||||||
target: $.__env.var1
|
target: "{$.__env.var1}"
|
||||||
publish:
|
publish:
|
||||||
final_result: $.task2
|
final_result: "{$.task2}"
|
||||||
|
|
||||||
wf2:
|
wf2:
|
||||||
type: direct
|
type: direct
|
||||||
|
|
||||||
output:
|
output:
|
||||||
slogan: $.slogan
|
slogan: "{$.slogan}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
workflow: wf1
|
workflow: wf1
|
||||||
input:
|
input:
|
||||||
param1: $.__env.var2
|
param1: "{$.__env.var2}"
|
||||||
param2: $.__env.var3
|
param2: "{$.__env.var3}"
|
||||||
task_name: task2
|
task_name: task2
|
||||||
publish:
|
publish:
|
||||||
slogan: "{$.task1.final_result} is a cool {$.__env.var4}!"
|
slogan: "{$.task1.final_result} is a cool {$.__env.var4}!"
|
||||||
|
@ -53,10 +53,10 @@ workflows:
|
|||||||
# Skip this '$' sign until bug
|
# Skip this '$' sign until bug
|
||||||
# https://bugs.launchpad.net/mistral/+bug/1415886 is resolved.
|
# https://bugs.launchpad.net/mistral/+bug/1415886 is resolved.
|
||||||
# return $['num'] * 10
|
# return $['num'] * 10
|
||||||
context: $
|
context: "{$}"
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
result: $.task1
|
result: "{$.task1}"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -33,20 +33,20 @@ wf:
|
|||||||
type: direct
|
type: direct
|
||||||
|
|
||||||
output:
|
output:
|
||||||
result: $.result3
|
result: "{$.result3}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output=1
|
action: std.echo output=1
|
||||||
publish:
|
publish:
|
||||||
result1: $.task1
|
result1: "{$.task1}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task3
|
- task3
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output=2
|
action: std.echo output=2
|
||||||
publish:
|
publish:
|
||||||
result2: $.task2
|
result2: "{$.task2}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task3
|
- task3
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ wf:
|
|||||||
join: all
|
join: all
|
||||||
action: std.echo output="{$.result1},{$.result2}"
|
action: std.echo output="{$.result1},{$.result2}"
|
||||||
publish:
|
publish:
|
||||||
result3: $.task3
|
result3: "{$.task3}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -66,13 +66,13 @@ wf:
|
|||||||
type: direct
|
type: direct
|
||||||
|
|
||||||
output:
|
output:
|
||||||
result: $.result3
|
result: "{$.result3}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output=1
|
action: std.echo output=1
|
||||||
publish:
|
publish:
|
||||||
result1: $.task1
|
result1: "{$.task1}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task3
|
- task3
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ wf:
|
|||||||
join: all
|
join: all
|
||||||
action: std.echo output="{$.result1}-{$.result1}"
|
action: std.echo output="{$.result1}-{$.result1}"
|
||||||
publish:
|
publish:
|
||||||
result3: $.task3
|
result3: "{$.task3}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WF_FULL_JOIN_WITH_CONDITIONS = """
|
WF_FULL_JOIN_WITH_CONDITIONS = """
|
||||||
@ -96,34 +96,34 @@ wf:
|
|||||||
type: direct
|
type: direct
|
||||||
|
|
||||||
output:
|
output:
|
||||||
result: $.result4
|
result: "{$.result4}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output=1
|
action: std.echo output=1
|
||||||
publish:
|
publish:
|
||||||
result1: $.task1
|
result1: "{$.task1}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task3
|
- task3
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output=2
|
action: std.echo output=2
|
||||||
publish:
|
publish:
|
||||||
result2: $.task2
|
result2: "{$.task2}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task3: $.result2 = 11111
|
- task3: "{$.result2 = 11111}"
|
||||||
- task4: $.result2 = 2
|
- task4: "{$.result2 = 2}"
|
||||||
|
|
||||||
task3:
|
task3:
|
||||||
join: all
|
join: all
|
||||||
action: std.echo output="{$.result1}-{$.result1}"
|
action: std.echo output="{$.result1}-{$.result1}"
|
||||||
publish:
|
publish:
|
||||||
result3: $.task3
|
result3: "{$.task3}"
|
||||||
|
|
||||||
task4:
|
task4:
|
||||||
action: std.echo output=4
|
action: std.echo output=4
|
||||||
publish:
|
publish:
|
||||||
result4: $.task4
|
result4: "{$.task4}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WF_PARTIAL_JOIN = """
|
WF_PARTIAL_JOIN = """
|
||||||
@ -134,20 +134,20 @@ wf:
|
|||||||
type: direct
|
type: direct
|
||||||
|
|
||||||
output:
|
output:
|
||||||
result: $.result4
|
result: "{$.result4}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output=1
|
action: std.echo output=1
|
||||||
publish:
|
publish:
|
||||||
result1: $.task1
|
result1: "{$.task1}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task4
|
- task4
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output=2
|
action: std.echo output=2
|
||||||
publish:
|
publish:
|
||||||
result2: $.task2
|
result2: "{$.task2}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task4
|
- task4
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ wf:
|
|||||||
join: 2
|
join: 2
|
||||||
action: std.echo output="{$.result1},{$.result2}"
|
action: std.echo output="{$.result1},{$.result2}"
|
||||||
publish:
|
publish:
|
||||||
result4: $.task4
|
result4: "{$.task4}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WF_PARTIAL_JOIN_TRIGGERS_ONCE = """
|
WF_PARTIAL_JOIN_TRIGGERS_ONCE = """
|
||||||
@ -178,7 +178,7 @@ wf:
|
|||||||
type: direct
|
type: direct
|
||||||
|
|
||||||
output:
|
output:
|
||||||
result: $.result4
|
result: "{$.result4}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
@ -213,7 +213,7 @@ wf:
|
|||||||
join: 2
|
join: 2
|
||||||
action: std.echo output="{$.result1},{$.result2},{$.result3},{$.result4}"
|
action: std.echo output="{$.result1},{$.result2},{$.result3},{$.result4}"
|
||||||
publish:
|
publish:
|
||||||
result5: $.task5
|
result5: "{$.task5}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WF_DISCRIMINATOR = """
|
WF_DISCRIMINATOR = """
|
||||||
@ -224,7 +224,7 @@ wf:
|
|||||||
type: direct
|
type: direct
|
||||||
|
|
||||||
output:
|
output:
|
||||||
result: $.result4
|
result: "{$.result4}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
@ -252,7 +252,7 @@ wf:
|
|||||||
join: one
|
join: one
|
||||||
action: std.echo output="{$.result1},{$.result2},{$.result3}"
|
action: std.echo output="{$.result1},{$.result2},{$.result3}"
|
||||||
publish:
|
publish:
|
||||||
result4: $.task4
|
result4: "{$.task4}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,14 +43,14 @@ wf:
|
|||||||
task1:
|
task1:
|
||||||
action: std.echo output={$.num1}
|
action: std.echo output={$.num1}
|
||||||
publish:
|
publish:
|
||||||
result1: $.task1
|
result1: "{$.task1}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task3
|
- task3
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output={$.num2}
|
action: std.echo output={$.num2}
|
||||||
publish:
|
publish:
|
||||||
result2: $.task2
|
result2: "{$.task2}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task3
|
- task3
|
||||||
|
|
||||||
@ -60,18 +60,18 @@ wf:
|
|||||||
task and serves just a decision point in the workflow.
|
task and serves just a decision point in the workflow.
|
||||||
join: all
|
join: all
|
||||||
on-complete:
|
on-complete:
|
||||||
- task4: $.num1 + $.num2 = 2
|
- task4: "{$.num1 + $.num2 = 2}"
|
||||||
- task5: $.num1 + $.num2 = 3
|
- task5: "{$.num1 + $.num2 = 3}"
|
||||||
|
|
||||||
task4:
|
task4:
|
||||||
action: std.echo output=4
|
action: std.echo output=4
|
||||||
publish:
|
publish:
|
||||||
result4: $.task4
|
result4: "{$.task4}"
|
||||||
|
|
||||||
task5:
|
task5:
|
||||||
action: std.echo output=5
|
action: std.echo output=5
|
||||||
publish:
|
publish:
|
||||||
result5: $.task5
|
result5: "{$.task5}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ workflows:
|
|||||||
retry:
|
retry:
|
||||||
count: 5
|
count: 5
|
||||||
delay: 10
|
delay: 10
|
||||||
break-on: $.my_val = 10
|
break-on: "{$.my_val = 10}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ workflows:
|
|||||||
retry:
|
retry:
|
||||||
count: 3
|
count: 3
|
||||||
delay: 1
|
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.assertIsInstance(p, policies.RetryPolicy)
|
||||||
self.assertEqual(5, p.count)
|
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)
|
p = self._assert_single_item(arr, delay=7)
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ wf:
|
|||||||
method. And we need to check that engine handles this situation.
|
method. And we need to check that engine handles this situation.
|
||||||
|
|
||||||
output:
|
output:
|
||||||
result: $.result
|
result: "{$.result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.block
|
action: std.block
|
||||||
publish:
|
publish:
|
||||||
result: $.task1
|
result: "{$.task1}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WF_SHORT_ACTION = """
|
WF_SHORT_ACTION = """
|
||||||
@ -73,13 +73,13 @@ wf:
|
|||||||
methods ends.
|
methods ends.
|
||||||
|
|
||||||
output:
|
output:
|
||||||
result: $.result
|
result: "{$.result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output=1
|
action: std.echo output=1
|
||||||
publish:
|
publish:
|
||||||
result1: $.task1
|
result1: "{$.task1}"
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.block
|
action: std.block
|
||||||
|
@ -44,12 +44,12 @@ workflows:
|
|||||||
task1:
|
task1:
|
||||||
action: std.echo output='{$.param1}'
|
action: std.echo output='{$.param1}'
|
||||||
publish:
|
publish:
|
||||||
result1: $.task1
|
result1: "{$.task1}"
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output="{$.result1} & {$.param2}"
|
action: std.echo output="{$.result1} & {$.param2}"
|
||||||
publish:
|
publish:
|
||||||
result2: $.task2
|
result2: "{$.task2}"
|
||||||
requires: [task1]
|
requires: [task1]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -44,24 +44,24 @@ workflows:
|
|||||||
- param1
|
- param1
|
||||||
- param2
|
- param2
|
||||||
output:
|
output:
|
||||||
final_result: $.final_result
|
final_result: "{$.final_result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output='{$.param1}'
|
action: std.echo output='{$.param1}'
|
||||||
publish:
|
publish:
|
||||||
result1: $.task1
|
result1: "{$.task1}"
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output="'{$.param1} & {$.param2}'"
|
action: std.echo output="'{$.param1} & {$.param2}'"
|
||||||
publish:
|
publish:
|
||||||
final_result: $.task2
|
final_result: "{$.task2}"
|
||||||
requires: [task1]
|
requires: [task1]
|
||||||
|
|
||||||
wf2:
|
wf2:
|
||||||
type: direct
|
type: direct
|
||||||
output:
|
output:
|
||||||
slogan: $.slogan
|
slogan: "{$.slogan}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
|
@ -45,10 +45,10 @@ workflows:
|
|||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
with-items: name_info in $.names_info
|
with-items: name_info in {$.names_info}
|
||||||
action: std.echo output={$.name_info.name}
|
action: std.echo output={$.name_info.name}
|
||||||
publish:
|
publish:
|
||||||
result: $.task1
|
result: "{$.task1}"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -68,10 +68,10 @@ workflows:
|
|||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
with-items: name_info in $.names_info
|
with-items: name_info in {$.names_info}
|
||||||
action: std.echo output="{$.greeting}, {$.name_info.name}!"
|
action: std.echo output="{$.greeting}, {$.name_info.name}!"
|
||||||
publish:
|
publish:
|
||||||
result: $.task1
|
result: "{$.task1}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -92,11 +92,11 @@ workflows:
|
|||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
with-items:
|
with-items:
|
||||||
- itemX in $.arrayI
|
- itemX in {$.arrayI}
|
||||||
- itemY in $.arrayJ
|
- itemY in {$.arrayJ}
|
||||||
action: std.echo output="{$.itemX} {$.itemY}"
|
action: std.echo output="{$.itemX} {$.itemY}"
|
||||||
publish:
|
publish:
|
||||||
result: $.task1
|
result: "{$.task1}"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -113,10 +113,10 @@ workflows:
|
|||||||
- links
|
- links
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
with-items: link in $.links
|
with-items: link in {$.links}
|
||||||
action: std.mistral_http url={$.link}
|
action: std.mistral_http url={$.link}
|
||||||
publish:
|
publish:
|
||||||
result: $.task1
|
result: "{$.task1}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,18 +46,18 @@ workflows:
|
|||||||
input:
|
input:
|
||||||
- param1
|
- param1
|
||||||
output:
|
output:
|
||||||
result: $.result
|
result: "{$.result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output="{$.param1}"
|
action: std.echo output="{$.param1}"
|
||||||
publish:
|
publish:
|
||||||
result: $
|
result: "{$}"
|
||||||
|
|
||||||
wf2:
|
wf2:
|
||||||
type: direct
|
type: direct
|
||||||
output:
|
output:
|
||||||
result: $.result
|
result: "{$.result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
@ -83,7 +83,7 @@ workflows:
|
|||||||
wf1:
|
wf1:
|
||||||
type: direct
|
type: direct
|
||||||
output:
|
output:
|
||||||
result: $.result
|
result: "{$.result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
@ -96,13 +96,13 @@ workflows:
|
|||||||
input:
|
input:
|
||||||
- param1
|
- param1
|
||||||
output:
|
output:
|
||||||
result: $.result
|
result: "{$.result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output="{$.param1}"
|
action: std.echo output="{$.param1}"
|
||||||
publish:
|
publish:
|
||||||
result: $
|
result: "{$}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,18 +37,18 @@ wf1:
|
|||||||
input:
|
input:
|
||||||
- param1
|
- param1
|
||||||
output:
|
output:
|
||||||
result: $.result
|
result: "{$.result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output="{$.param1}"
|
action: std.echo output="{$.param1}"
|
||||||
publish:
|
publish:
|
||||||
result: $
|
result: "{$}"
|
||||||
|
|
||||||
wf2:
|
wf2:
|
||||||
type: direct
|
type: direct
|
||||||
output:
|
output:
|
||||||
result: $.result
|
result: "{$.result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
@ -67,13 +67,13 @@ wf1:
|
|||||||
- param1
|
- param1
|
||||||
- param2
|
- param2
|
||||||
output:
|
output:
|
||||||
result: $.result
|
result: "{$.result}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task1:
|
task1:
|
||||||
action: std.echo output="{$.param1}{$.param2}"
|
action: std.echo output="{$.param1}{$.param2}"
|
||||||
publish:
|
publish:
|
||||||
result: $
|
result: "{$}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,26 +72,28 @@ class YaqlEvaluatorTest(base.BaseTest):
|
|||||||
|
|
||||||
def test_function_length(self):
|
def test_function_length(self):
|
||||||
# Lists.
|
# Lists.
|
||||||
self.assertEqual(0, expr.evaluate('$.length()', []))
|
self.assertEqual(0, self._evaluator.evaluate('$.length()', []))
|
||||||
self.assertEqual(3, expr.evaluate('$.length()', [1, 2, 3]))
|
self.assertEqual(3, self._evaluator.evaluate('$.length()', [1, 2, 3]))
|
||||||
self.assertEqual(2, expr.evaluate('$.length()', ['one', 'two']))
|
self.assertEqual(
|
||||||
self.assertEqual(4, expr.evaluate(
|
2, self._evaluator.evaluate('$.length()', ['one', 'two'])
|
||||||
|
)
|
||||||
|
self.assertEqual(4, self._evaluator.evaluate(
|
||||||
'$.array.length()',
|
'$.array.length()',
|
||||||
{'array': ['1', '2', '3', '4']})
|
{'array': ['1', '2', '3', '4']})
|
||||||
)
|
)
|
||||||
|
|
||||||
# Strings.
|
# Strings.
|
||||||
self.assertEqual(3, expr.evaluate('$.length()', '123'))
|
self.assertEqual(3, self._evaluator.evaluate('$.length()', '123'))
|
||||||
self.assertEqual(2, expr.evaluate('$.length()', '12'))
|
self.assertEqual(2, self._evaluator.evaluate('$.length()', '12'))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
4,
|
4,
|
||||||
expr.evaluate('$.string.length()', {'string': '1234'})
|
self._evaluator.evaluate('$.string.length()', {'string': '1234'})
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generators.
|
# Generators.
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
2,
|
2,
|
||||||
expr.evaluate(
|
self._evaluator.evaluate(
|
||||||
"$[$.state = 'active'].length()",
|
"$[$.state = 'active'].length()",
|
||||||
[
|
[
|
||||||
{'state': 'active'},
|
{'state': 'active'},
|
||||||
@ -103,7 +105,7 @@ class YaqlEvaluatorTest(base.BaseTest):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
0,
|
0,
|
||||||
expr.evaluate("$[$.state = 'active'].length()", [])
|
self._evaluator.evaluate("$[$.state = 'active'].length()", [])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -166,19 +168,19 @@ class ExpressionsTest(base.BaseTest):
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_cases = [
|
test_cases = [
|
||||||
('{$.a + $.b * $.c}', '7'),
|
('{$.a + $.b * $.c}', 7),
|
||||||
('{($.a + $.b) * $.c}', '9'),
|
('{($.a + $.b) * $.c}', 9),
|
||||||
('{$.d and $.e}', 'False'),
|
('{$.d and $.e}', False),
|
||||||
('{$.f > $.g}', 'True'),
|
('{$.f > $.g}', True),
|
||||||
('{$.h.length() >= 5}', 'True'),
|
('{$.h.length() >= 5}', True),
|
||||||
('{$.h.length() >= $.b + $.c}', 'True'),
|
('{$.h.length() >= $.b + $.c}', True),
|
||||||
('{100 in $.h}', 'False'),
|
('{100 in $.h}', False),
|
||||||
('{$.a in $.h}', 'True'),
|
('{$.a in $.h}', True),
|
||||||
('{''OpenStack'' in $.i}', 'True'),
|
('{''OpenStack'' in $.i}', True),
|
||||||
('Hello, {$.j}!', 'Hello, World!'),
|
('Hello, {$.j}!', 'Hello, World!'),
|
||||||
('{$.k} is {$.l}!', 'Mistral is awesome!'),
|
('{$.k} is {$.l}!', 'Mistral is awesome!'),
|
||||||
('This is {$.m}.', 'This is the way we roll.'),
|
('This is {$.m}.', 'This is the way we roll.'),
|
||||||
('{1 + 1 = 3}', 'False')
|
('{1 + 1 = 3}', False)
|
||||||
]
|
]
|
||||||
|
|
||||||
for expression, expected in test_cases:
|
for expression, expected in test_cases:
|
||||||
@ -190,7 +192,7 @@ class ExpressionsTest(base.BaseTest):
|
|||||||
task_spec_dict = {
|
task_spec_dict = {
|
||||||
'parameters': {
|
'parameters': {
|
||||||
'p1': 'My string',
|
'p1': 'My string',
|
||||||
'p2': '$.param2',
|
'p2': '{$.param2}',
|
||||||
'p3': ''
|
'p3': ''
|
||||||
},
|
},
|
||||||
'publish': {
|
'publish': {
|
||||||
@ -226,7 +228,7 @@ class ExpressionsTest(base.BaseTest):
|
|||||||
data = {
|
data = {
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"parameter1": {
|
"parameter1": {
|
||||||
"name1": "$.auth_token",
|
"name1": "{$.auth_token}",
|
||||||
"name2": "val_name2"
|
"name2": "val_name2"
|
||||||
},
|
},
|
||||||
"param2": [
|
"param2": [
|
||||||
@ -235,7 +237,7 @@ class ExpressionsTest(base.BaseTest):
|
|||||||
"/servers/{$.project_id}/bla"
|
"/servers/{$.project_id}/bla"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"token": "$.auth_token"
|
"token": "{$.auth_token}"
|
||||||
}
|
}
|
||||||
|
|
||||||
applied = expr.evaluate_recursively(data, context)
|
applied = expr.evaluate_recursively(data, context)
|
||||||
|
@ -33,13 +33,13 @@ actions:
|
|||||||
base: std.echo
|
base: std.echo
|
||||||
base-input:
|
base-input:
|
||||||
output: Hello {$.name}!
|
output: Hello {$.name}!
|
||||||
output: $
|
output: "{$}"
|
||||||
|
|
||||||
action2:
|
action2:
|
||||||
description: This is a test ad-hoc action with base params
|
description: This is a test ad-hoc action with base params
|
||||||
tags: [test, v2]
|
tags: [test, v2]
|
||||||
base: std.echo output="Echo output"
|
base: std.echo output="Echo output"
|
||||||
output: $
|
output: "{$}"
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
wf1:
|
wf1:
|
||||||
@ -60,7 +60,7 @@ workflows:
|
|||||||
retry:
|
retry:
|
||||||
count: 10
|
count: 10
|
||||||
delay: 30
|
delay: 30
|
||||||
break-on: $.my_val = 10
|
break-on: "{$.my_val = 10}"
|
||||||
concurrency: 3
|
concurrency: 3
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
@ -76,9 +76,9 @@ workflows:
|
|||||||
retry:
|
retry:
|
||||||
count: 10
|
count: 10
|
||||||
delay: 30
|
delay: 30
|
||||||
break-on: $.my_val = 10
|
break-on: "{$.my_val = 10}"
|
||||||
on-error:
|
on-error:
|
||||||
- fail: $.my_val = 0
|
- fail: "{$.my_val = 0}"
|
||||||
on-success:
|
on-success:
|
||||||
- pause
|
- pause
|
||||||
on-complete:
|
on-complete:
|
||||||
@ -88,11 +88,11 @@ workflows:
|
|||||||
task3:
|
task3:
|
||||||
workflow: wf1 name="John Doe" age=32 param1=null param2=false
|
workflow: wf1 name="John Doe" age=32 param1=null param2=false
|
||||||
on-error:
|
on-error:
|
||||||
- task4: $.my_val = 1
|
- task4: "{$.my_val = 1}"
|
||||||
on-success:
|
on-success:
|
||||||
- task5: $.my_val = 2
|
- task5: "{$.my_val = 2}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task6: $.my_val = 3
|
- task6: "{$.my_val = 3}"
|
||||||
|
|
||||||
task4:
|
task4:
|
||||||
action: std.echo output="Task 4 echo"
|
action: std.echo output="Task 4 echo"
|
||||||
@ -104,7 +104,7 @@ workflows:
|
|||||||
action: std.echo output="Task 6 echo"
|
action: std.echo output="Task 6 echo"
|
||||||
|
|
||||||
task7:
|
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"
|
workflow: wf2 is_true=true object_list=[1, null, "str"] is_string="50"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task9
|
- task9
|
||||||
@ -112,9 +112,9 @@ workflows:
|
|||||||
|
|
||||||
task8:
|
task8:
|
||||||
with-items:
|
with-items:
|
||||||
- itemX in $.arrayI
|
- itemX in {$.arrayI}
|
||||||
- itemY in $.arrayJ
|
- itemY in {$.arrayJ}
|
||||||
workflow: wf2 expr_list=["$.value", "{$.key}"] expr={$.value}
|
workflow: wf2 expr_list=["{$.value}", "{$.key}"] expr={$.value}
|
||||||
target: nova
|
target: nova
|
||||||
on-complete:
|
on-complete:
|
||||||
- task9
|
- task9
|
||||||
@ -216,7 +216,7 @@ class DSLv2ModelTest(base.BaseTest):
|
|||||||
action_spec.get_base_input()
|
action_spec.get_base_input()
|
||||||
)
|
)
|
||||||
self.assertListEqual([], action_spec.get_input())
|
self.assertListEqual([], action_spec.get_input())
|
||||||
self.assertEqual('$', action_spec.get_output())
|
self.assertEqual('{$}', action_spec.get_output())
|
||||||
|
|
||||||
# Workflows.
|
# Workflows.
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ class DSLv2ModelTest(base.BaseTest):
|
|||||||
|
|
||||||
self.assertEqual(10, retry_spec.get_count())
|
self.assertEqual(10, retry_spec.get_count())
|
||||||
self.assertEqual(30, retry_spec.get_delay())
|
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')
|
task2_spec = wf1_spec.get_tasks().get('task2')
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ class DSLv2ModelTest(base.BaseTest):
|
|||||||
task_defaults_spec = wf2_spec.get_task_defaults()
|
task_defaults_spec = wf2_spec.get_task_defaults()
|
||||||
|
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
[('fail', '$.my_val = 0')],
|
[('fail', '{$.my_val = 0}')],
|
||||||
task_defaults_spec.get_on_error()
|
task_defaults_spec.get_on_error()
|
||||||
)
|
)
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
@ -309,15 +309,15 @@ class DSLv2ModelTest(base.BaseTest):
|
|||||||
task3_spec.get_input()
|
task3_spec.get_input()
|
||||||
)
|
)
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
[('task4', '$.my_val = 1')],
|
[('task4', '{$.my_val = 1}')],
|
||||||
task3_spec.get_on_error()
|
task3_spec.get_on_error()
|
||||||
)
|
)
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
[('task5', '$.my_val = 2')],
|
[('task5', '{$.my_val = 2}')],
|
||||||
task3_spec.get_on_success()
|
task3_spec.get_on_success()
|
||||||
)
|
)
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
[('task6', '$.my_val = 3')],
|
[('task6', '{$.my_val = 3}')],
|
||||||
task3_spec.get_on_complete()
|
task3_spec.get_on_complete()
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -333,20 +333,20 @@ class DSLv2ModelTest(base.BaseTest):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{'vm_info': '$.vms'},
|
{'vm_info': '{$.vms}'},
|
||||||
task7_spec.get_with_items()
|
task7_spec.get_with_items()
|
||||||
)
|
)
|
||||||
|
|
||||||
task8_spec = wf2_spec.get_tasks().get('task8')
|
task8_spec = wf2_spec.get_tasks().get('task8')
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{"itemX": '$.arrayI', "itemY": '$.arrayJ'},
|
{"itemX": '{$.arrayI}', "itemY": '{$.arrayJ}'},
|
||||||
task8_spec.get_with_items()
|
task8_spec.get_with_items()
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{
|
{
|
||||||
'expr_list': ['$.value', '{$.key}'],
|
'expr_list': ['{$.value}', '{$.key}'],
|
||||||
'expr': '{$.value}',
|
'expr': '{$.value}',
|
||||||
},
|
},
|
||||||
task8_spec.get_input()
|
task8_spec.get_input()
|
||||||
|
@ -38,10 +38,10 @@ workflows:
|
|||||||
task1:
|
task1:
|
||||||
action: std.echo output="Hey"
|
action: std.echo output="Hey"
|
||||||
publish:
|
publish:
|
||||||
res1: $.task1
|
res1: "{$.task1}"
|
||||||
on-complete:
|
on-complete:
|
||||||
- task2: $.res1 = 'Hey'
|
- task2: "{$.res1 = 'Hey'}"
|
||||||
- task3: $.res1 = 'Not Hey'
|
- task3: "{$.res1 = 'Not Hey'}"
|
||||||
|
|
||||||
task2:
|
task2:
|
||||||
action: std.echo output="Hi"
|
action: std.echo output="Hi"
|
||||||
|
@ -27,10 +27,10 @@ TASK_DICT = {
|
|||||||
'version': '2.0',
|
'version': '2.0',
|
||||||
'action': 'std.echo',
|
'action': 'std.echo',
|
||||||
'with-items': [
|
'with-items': [
|
||||||
'item in $.array'
|
'item in {$.array}'
|
||||||
],
|
],
|
||||||
'input': {
|
'input': {
|
||||||
'array': '$.my_array'
|
'array': '{$.my_array}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ TASK_DB = models.Task(
|
|||||||
class WithItemsCalculationsTest(base.BaseTest):
|
class WithItemsCalculationsTest(base.BaseTest):
|
||||||
def test_calculate_output_with_key(self):
|
def test_calculate_output_with_key(self):
|
||||||
task_dict = TASK_DICT.copy()
|
task_dict = TASK_DICT.copy()
|
||||||
task_dict['publish'] = {'result': '$.task1'}
|
task_dict['publish'] = {'result': '{$.task1}'}
|
||||||
|
|
||||||
task_spec = tasks.TaskSpec(task_dict)
|
task_spec = tasks.TaskSpec(task_dict)
|
||||||
raw_result = utils.TaskResult(data='output!')
|
raw_result = utils.TaskResult(data='output!')
|
||||||
|
@ -22,7 +22,7 @@ from mistral import exceptions as exc
|
|||||||
|
|
||||||
CMD_PTRN = re.compile("^[\w\.]+[^=\s\"]*")
|
CMD_PTRN = re.compile("^[\w\.]+[^=\s\"]*")
|
||||||
|
|
||||||
_ALL_IN_BRACES = "\{[^}]*\}\s*"
|
ALL_IN_BRACES = "\{[^}]*\}\s*"
|
||||||
_ALL_IN_BRACKETS = "\[.*\]\s*"
|
_ALL_IN_BRACKETS = "\[.*\]\s*"
|
||||||
_ALL_IN_QUOTES = "\"[^\"]*\"\s*"
|
_ALL_IN_QUOTES = "\"[^\"]*\"\s*"
|
||||||
_ALL_IN_APOSTROPHES = "'[^']*'\s*"
|
_ALL_IN_APOSTROPHES = "'[^']*'\s*"
|
||||||
@ -32,7 +32,7 @@ _FALSE = "false"
|
|||||||
_NULL = "null"
|
_NULL = "null"
|
||||||
|
|
||||||
ALL = (
|
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
|
_ALL_IN_BRACKETS, _TRUE, _FALSE, _NULL, _DIGITS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,7 +21,9 @@ from mistral.workbook import base
|
|||||||
from mistral.workbook.v2 import task_policies
|
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):
|
class TaskSpec(base.BaseSpec):
|
||||||
@ -111,7 +113,7 @@ class TaskSpec(base.BaseSpec):
|
|||||||
|
|
||||||
if not match:
|
if not match:
|
||||||
msg = ("Wrong format of 'with-items' property. Please use "
|
msg = ("Wrong format of 'with-items' property. Please use "
|
||||||
"format 'var in {[some, list] | $.array}: "
|
"format 'var in {[some, list] | {$.array} }: "
|
||||||
"%s" % self._data)
|
"%s" % self._data)
|
||||||
raise exc.InvalidModelException(msg)
|
raise exc.InvalidModelException(msg)
|
||||||
|
|
||||||
|
@ -149,8 +149,8 @@ def calc_input(with_items_input):
|
|||||||
Example:
|
Example:
|
||||||
DSL:
|
DSL:
|
||||||
with_items:
|
with_items:
|
||||||
- itemX in $.arrayI
|
- itemX in {$.arrayI}
|
||||||
- itemY in $.arrayJ
|
- itemY in {$.arrayJ}
|
||||||
|
|
||||||
Assume arrayI = [1, 2], arrayJ = ['a', 'b'].
|
Assume arrayI = [1, 2], arrayJ = ['a', 'b'].
|
||||||
with_items_input = {
|
with_items_input = {
|
||||||
|
Loading…
Reference in New Issue
Block a user