summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorMatt Clay <mclay@redhat.com>2020-03-12 22:34:54 -0700
committerGitHub <noreply@github.com>2020-03-12 22:34:54 -0700
commit7c27ae4702ab6434946c6632a0bf8528b9347e1f (patch)
tree8ae8d3a68c899b317b432fc324d2db7c8d4c5065 /test/integration
parent0971a0dfea2ca097ead3a552978283289c3451f7 (diff)
downloadansible-7c27ae4702ab6434946c6632a0bf8528b9347e1f.tar.gz
Add dynamic and static include tests. (#68200)
* Add dynamic and static include tests. * Update task names for junit output.
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/targets/include_when_parent_is_dynamic/aliases2
-rw-r--r--test/integration/targets/include_when_parent_is_dynamic/playbook.yml4
-rwxr-xr-xtest/integration/targets/include_when_parent_is_dynamic/runme.sh13
-rw-r--r--test/integration/targets/include_when_parent_is_dynamic/syntax_error.yml1
-rw-r--r--test/integration/targets/include_when_parent_is_dynamic/tasks.yml12
-rw-r--r--test/integration/targets/include_when_parent_is_static/aliases2
-rw-r--r--test/integration/targets/include_when_parent_is_static/playbook.yml4
-rwxr-xr-xtest/integration/targets/include_when_parent_is_static/runme.sh13
-rw-r--r--test/integration/targets/include_when_parent_is_static/syntax_error.yml1
-rw-r--r--test/integration/targets/include_when_parent_is_static/tasks.yml12
10 files changed, 64 insertions, 0 deletions
diff --git a/test/integration/targets/include_when_parent_is_dynamic/aliases b/test/integration/targets/include_when_parent_is_dynamic/aliases
new file mode 100644
index 0000000000..41c99f5192
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_dynamic/aliases
@@ -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
diff --git a/test/integration/targets/include_when_parent_is_dynamic/playbook.yml b/test/integration/targets/include_when_parent_is_dynamic/playbook.yml
new file mode 100644
index 0000000000..afdbc54c8e
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_dynamic/playbook.yml
@@ -0,0 +1,4 @@
+- hosts: localhost
+ gather_facts: no
+ tasks:
+ - include_tasks: tasks.yml
diff --git a/test/integration/targets/include_when_parent_is_dynamic/runme.sh b/test/integration/targets/include_when_parent_is_dynamic/runme.sh
new file mode 100755
index 0000000000..b136965f1f
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_dynamic/runme.sh
@@ -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
diff --git a/test/integration/targets/include_when_parent_is_dynamic/syntax_error.yml b/test/integration/targets/include_when_parent_is_dynamic/syntax_error.yml
new file mode 100644
index 0000000000..101a18abfa
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_dynamic/syntax_error.yml
@@ -0,0 +1 @@
+intentional syntax error which should NOT be encountered
diff --git a/test/integration/targets/include_when_parent_is_dynamic/tasks.yml b/test/integration/targets/include_when_parent_is_dynamic/tasks.yml
new file mode 100644
index 0000000000..6831245c92
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_dynamic/tasks.yml
@@ -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
diff --git a/test/integration/targets/include_when_parent_is_static/aliases b/test/integration/targets/include_when_parent_is_static/aliases
new file mode 100644
index 0000000000..41c99f5192
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_static/aliases
@@ -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
diff --git a/test/integration/targets/include_when_parent_is_static/playbook.yml b/test/integration/targets/include_when_parent_is_static/playbook.yml
new file mode 100644
index 0000000000..6189873ece
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_static/playbook.yml
@@ -0,0 +1,4 @@
+- hosts: localhost
+ gather_facts: no
+ tasks:
+ - import_tasks: tasks.yml
diff --git a/test/integration/targets/include_when_parent_is_static/runme.sh b/test/integration/targets/include_when_parent_is_static/runme.sh
new file mode 100755
index 0000000000..33728bdf02
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_static/runme.sh
@@ -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
diff --git a/test/integration/targets/include_when_parent_is_static/syntax_error.yml b/test/integration/targets/include_when_parent_is_static/syntax_error.yml
new file mode 100644
index 0000000000..e1a629ce76
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_static/syntax_error.yml
@@ -0,0 +1 @@
+intentional syntax error which SHOULD be encountered
diff --git a/test/integration/targets/include_when_parent_is_static/tasks.yml b/test/integration/targets/include_when_parent_is_static/tasks.yml
new file mode 100644
index 0000000000..a234a3dd33
--- /dev/null
+++ b/test/integration/targets/include_when_parent_is_static/tasks.yml
@@ -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