Add dynamic and static include tests. (#68200)
* Add dynamic and static include tests. * Update task names for junit output.
This commit is contained in:
parent
d87d96077f
commit
9126ac53e3
10 changed files with 64 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
shippable/posix/group3
|
||||||
|
skip/python2.6 # include is controller only, and we no longer support Python 2.6 on the controller
|
|
@ -0,0 +1,4 @@
|
||||||
|
- hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- include_tasks: tasks.yml
|
13
test/integration/targets/include_when_parent_is_dynamic/runme.sh
Executable file
13
test/integration/targets/include_when_parent_is_dynamic/runme.sh
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
ansible-playbook playbook.yml "$@" > output.log 2>&1 || true
|
||||||
|
|
||||||
|
if grep "task should always execute" output.log >/dev/null; then
|
||||||
|
echo "Test passed (playbook failed with expected output, output not shown)."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat output.log
|
||||||
|
exit 1
|
|
@ -0,0 +1 @@
|
||||||
|
intentional syntax error which should NOT be encountered
|
|
@ -0,0 +1,12 @@
|
||||||
|
# intentionally stop execution of the play before reaching the include below
|
||||||
|
# if the include is dynamic as expected it will not trigger a syntax error
|
||||||
|
# however, if the include is static a syntax error will occur
|
||||||
|
- name: EXPECTED FAILURE
|
||||||
|
fail:
|
||||||
|
msg:
|
||||||
|
This task should always execute.
|
||||||
|
The playbook would have failed due to a syntax error in 'syntax_error.yml' when attempting a static include of that file.
|
||||||
|
|
||||||
|
# perform an include task which should be static if all of the task's parents are static, otherwise it should be dynamic
|
||||||
|
# this file was loaded using include_tasks, which is dynamic, so this include should also be dynamic
|
||||||
|
- include: syntax_error.yml
|
|
@ -0,0 +1,2 @@
|
||||||
|
shippable/posix/group3
|
||||||
|
skip/python2.6 # include is controller only, and we no longer support Python 2.6 on the controller
|
|
@ -0,0 +1,4 @@
|
||||||
|
- hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- import_tasks: tasks.yml
|
13
test/integration/targets/include_when_parent_is_static/runme.sh
Executable file
13
test/integration/targets/include_when_parent_is_static/runme.sh
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
ansible-playbook playbook.yml "$@" > output.log 2>&1 || true
|
||||||
|
|
||||||
|
if grep "intentional syntax error" output.log >/dev/null; then
|
||||||
|
echo "Test passed (playbook failed with expected output, output not shown)."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat output.log
|
||||||
|
exit 1
|
|
@ -0,0 +1 @@
|
||||||
|
intentional syntax error which SHOULD be encountered
|
|
@ -0,0 +1,12 @@
|
||||||
|
# intentionally stop execution of the play before reaching the include below
|
||||||
|
# if the include is static as expected it will trigger a syntax error
|
||||||
|
# however, if the include is dynamic a syntax error will not occur
|
||||||
|
- name: EXPECTED SUCCESS
|
||||||
|
fail:
|
||||||
|
msg:
|
||||||
|
This task should never execute.
|
||||||
|
The playbook should have failed due to a syntax error in 'syntax_error.yml' when attempting a static include of that file.
|
||||||
|
|
||||||
|
# perform an include task which should be static if all of the task's parents are static, otherwise it should be dynamic
|
||||||
|
# this file was loaded using import_tasks, which is static, so this include should also be static
|
||||||
|
- include: syntax_error.yml
|
Loading…
Reference in a new issue