diff options
Diffstat (limited to 'test/integration/targets/assert')
-rw-r--r-- | test/integration/targets/assert/aliases | 2 | ||||
-rw-r--r-- | test/integration/targets/assert/assert_quiet.out.quiet.stderr | 2 | ||||
-rw-r--r-- | test/integration/targets/assert/assert_quiet.out.quiet.stdout | 17 | ||||
-rw-r--r-- | test/integration/targets/assert/inventory | 3 | ||||
-rw-r--r-- | test/integration/targets/assert/quiet.yml | 16 | ||||
-rwxr-xr-x | test/integration/targets/assert/runme.sh | 71 |
6 files changed, 111 insertions, 0 deletions
diff --git a/test/integration/targets/assert/aliases b/test/integration/targets/assert/aliases new file mode 100644 index 0000000..a1b27a8 --- /dev/null +++ b/test/integration/targets/assert/aliases @@ -0,0 +1,2 @@ +shippable/posix/group5 +context/controller # this is a controller-only action, the module is just for documentation diff --git a/test/integration/targets/assert/assert_quiet.out.quiet.stderr b/test/integration/targets/assert/assert_quiet.out.quiet.stderr new file mode 100644 index 0000000..bd973b0 --- /dev/null +++ b/test/integration/targets/assert/assert_quiet.out.quiet.stderr @@ -0,0 +1,2 @@ ++ ansible-playbook -i localhost, -c local quiet.yml +++ set +x diff --git a/test/integration/targets/assert/assert_quiet.out.quiet.stdout b/test/integration/targets/assert/assert_quiet.out.quiet.stdout new file mode 100644 index 0000000..b62aac6 --- /dev/null +++ b/test/integration/targets/assert/assert_quiet.out.quiet.stdout @@ -0,0 +1,17 @@ + +PLAY [localhost] *************************************************************** + +TASK [assert] ****************************************************************** +ok: [localhost] => (item=item_A) + +TASK [assert] ****************************************************************** +ok: [localhost] => (item=item_A) => { + "ansible_loop_var": "item", + "changed": false, + "item": "item_A", + "msg": "All assertions passed" +} + +PLAY RECAP ********************************************************************* +localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 + diff --git a/test/integration/targets/assert/inventory b/test/integration/targets/assert/inventory new file mode 100644 index 0000000..1618200 --- /dev/null +++ b/test/integration/targets/assert/inventory @@ -0,0 +1,3 @@ +[all] +localhost + diff --git a/test/integration/targets/assert/quiet.yml b/test/integration/targets/assert/quiet.yml new file mode 100644 index 0000000..6834712 --- /dev/null +++ b/test/integration/targets/assert/quiet.yml @@ -0,0 +1,16 @@ +--- +- hosts: localhost + gather_facts: False + vars: + item_A: yes + tasks: + - assert: + that: "{{ item }} is defined" + quiet: True + with_items: + - item_A + - assert: + that: "{{ item }} is defined" + quiet: False + with_items: + - item_A diff --git a/test/integration/targets/assert/runme.sh b/test/integration/targets/assert/runme.sh new file mode 100755 index 0000000..ca0a858 --- /dev/null +++ b/test/integration/targets/assert/runme.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# This test compares "known good" output with various settings against output +# with the current code. It's brittle by nature, but this is probably the +# "best" approach possible. +# +# Notes: +# * options passed to this script (such as -v) are ignored, as they would change +# the output and break the test +# * the number of asterisks after a "banner" differs is forced to 79 by +# redirecting stdin from /dev/null + +set -eux + +run_test() { + # testname is playbook name + local testname=$1 + + # The shenanigans with redirection and 'tee' are to capture STDOUT and + # STDERR separately while still displaying both to the console + { ansible-playbook -i 'localhost,' -c local "${testname}.yml" \ + > >(set +x; tee "${OUTFILE}.${testname}.stdout"); } \ + 2> >(set +x; tee "${OUTFILE}.${testname}.stderr" >&2) 0</dev/null + + sed -i -e 's/ *$//' "${OUTFILE}.${testname}.stdout" + sed -i -e 's/ *$//' "${OUTFILE}.${testname}.stderr" + + # Scrub deprication warning that shows up in Python 2.6 on CentOS 6 + sed -i -e '/RandomPool_DeprecationWarning/d' "${OUTFILE}.${testname}.stderr" + + diff -u "${ORIGFILE}.${testname}.stdout" "${OUTFILE}.${testname}.stdout" || diff_failure + diff -u "${ORIGFILE}.${testname}.stderr" "${OUTFILE}.${testname}.stderr" || diff_failure +} + +diff_failure() { + if [[ $INIT = 0 ]]; then + echo "FAILURE...diff mismatch!" + exit 1 + fi +} + +cleanup() { + if [[ $INIT = 0 ]]; then + rm -f "${OUTFILE}."* + fi +} + +BASEFILE=assert_quiet.out + +ORIGFILE="${BASEFILE}" +OUTFILE="${BASEFILE}.new" + +trap 'cleanup' EXIT + +# The --init flag will (re)generate the "good" output files used by the tests +INIT=0 +if [[ ${1:-} == "--init" ]]; then + shift + OUTFILE=$ORIGFILE + INIT=1 +fi + +# Force the 'default' callback plugin +export ANSIBLE_STDOUT_CALLBACK=default +# Disable color in output for consistency +export ANSIBLE_FORCE_COLOR=0 +export ANSIBLE_NOCOLOR=1 +# Disable retry files +export ANSIBLE_RETRY_FILES_ENABLED=0 + +run_test quiet |