Debian Codegraph @

test/integration/targets/roles_arg_spec/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 # This effectively disables junit callback output by directing the output to
6 # a directory ansible-test will not look at.
7 #
8 # Since the failures in these tests are on the role arg spec validation and the
9 # name for those tasks is fixed (we cannot add "EXPECTED FAILURE" to the name),
10 # disabling the junit callback output is the easiest way to prevent these from
11 # showing up in test run output.
12 #
13 # Longer term, an option can be added to the junit callback allowing a custom
14 # regexp to be supplied rather than the hard coded "EXPECTED FAILURE".
15 export JUNIT_OUTPUT_DIR="${OUTPUT_DIR}"
16
17 # Various simple role scenarios
18 set -o pipefail
19 ansible-playbook test.yml -i ../../inventory "$@" | tee "${OUTPUT_DIR}/out.txt"
20 set +o pipefail
21 [ "$(grep -c "SECRET" "${OUTPUT_DIR}/out.txt")" = "0" ]
22 [ "$(grep -cF "\$REDACTED\$ \$REDACTED\$" "${OUTPUT_DIR}/out.txt")" = 1 ]
23
24 # More complex role test
25 ansible-playbook test_complex_role_fails.yml -i ../../inventory "$@"
26
27 # Test play level role will fail
28 set +e
29 ansible-playbook test_play_level_role_fails.yml -i ../../inventory "$@"
30 test $? -ne 0
31 set -e
32
33 # Test the validation task is tagged with 'always' by specifying an unused tag.
34 # The task is tagged with 'foo' but we use 'bar' in the call below and expect
35 # the validation task to run anyway since it is tagged 'always'.
36 ansible-playbook test_tags.yml -i ../../inventory "$@" --tags bar | grep "a : Validating arguments against arg spec 'main' - Main entry point for role A."