Debian Codegraph @

test/integration/targets/blocks/runme.sh

raw ◀ ▶
1 Debian patch touch this file
1 #!/usr/bin/env bash
2
3 set -eux
4
5 # This test does not use "$@" to avoid further increasing the verbosity beyond what is required for the test.
6 # Increasing verbosity from -vv to -vvv can increase the line count from ~400 to ~9K on our centos6 test container.
7
8 # remove old output log
9 rm -f block_test.out
10 # run the test and check to make sure the right number of completions was logged
11 ansible-playbook -vv main.yml -i ../../inventory | tee block_test.out
•12 env python3 -c \
13 'import sys, re; sys.stdout.write(re.sub(r"\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
14 <block_test.out >block_test_wo_colors.out
15 [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
16 # cleanup the output log again, to make sure the test is clean
17 rm -f block_test.out block_test_wo_colors.out
18 # run test with free strategy and again count the completions
19 ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=free | tee block_test.out
•20 env python3 -c \
21 'import sys, re; sys.stdout.write(re.sub(r"\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
22 <block_test.out >block_test_wo_colors.out
23 [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
24 # cleanup the output log again, to make sure the test is clean
25 rm -f block_test.out block_test_wo_colors.out
26 # run test with host_pinned strategy and again count the completions
27 ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=host_pinned | tee block_test.out
•28 env python3 -c \
29 'import sys, re; sys.stdout.write(re.sub(r"\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
30 <block_test.out >block_test_wo_colors.out
31 [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
32
33 # run test that includes tasks that fail inside a block with always
34 rm -f block_test.out block_test_wo_colors.out
35 ansible-playbook -vv block_fail.yml -i ../../inventory | tee block_test.out
•36 env python3 -c \
37 'import sys, re; sys.stdout.write(re.sub(r"\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
38 <block_test.out >block_test_wo_colors.out
39 [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
40
41 ansible-playbook -vv block_rescue_vars.yml
42
43 # https://github.com/ansible/ansible/issues/70000
44 set +e
45 exit_code=0
46 ansible-playbook -vv always_failure_with_rescue_rc.yml > rc_test.out || exit_code=$?
47 set -e
48 cat rc_test.out
49 [ $exit_code -eq 2 ]
50 [ "$(grep -c 'Failure in block"' rc_test.out )" -eq 1 ]
51 [ "$(grep -c '"Rescue"' rc_test.out )" -eq 1 ]
52 [ "$(grep -c 'Failure in always"' rc_test.out )" -eq 1 ]
53 [ "$(grep -c 'DID NOT RUN' rc_test.out )" -eq 0 ]
54 rm -f rc_test_out
55
56 set +e
57 exit_code=0
58 ansible-playbook -vv always_no_rescue_rc.yml > rc_test.out || exit_code=$?
59 set -e
60 cat rc_test.out
61 [ $exit_code -eq 2 ]
62 [ "$(grep -c 'Failure in block"' rc_test.out )" -eq 1 ]
63 [ "$(grep -c '"Always"' rc_test.out )" -eq 1 ]
64 [ "$(grep -c 'DID NOT RUN' rc_test.out )" -eq 0 ]
65 rm -f rc_test.out
66
67 set +e
68 exit_code=0
69 ansible-playbook -vv always_failure_no_rescue_rc.yml > rc_test.out || exit_code=$?
70 set -e
71 cat rc_test.out
72 [ $exit_code -eq 2 ]
73 [ "$(grep -c 'Failure in block"' rc_test.out )" -eq 1 ]
74 [ "$(grep -c 'Failure in always"' rc_test.out )" -eq 1 ]
75 [ "$(grep -c 'DID NOT RUN' rc_test.out )" -eq 0 ]
76 rm -f rc_test.out
77
78 # https://github.com/ansible/ansible/issues/29047
79 ansible-playbook -vv issue29047.yml -i ../../inventory
80
81 # https://github.com/ansible/ansible/issues/61253
82 ansible-playbook -vv block_in_rescue.yml -i ../../inventory > rc_test.out
83 cat rc_test.out
84 [ "$(grep -c 'rescued=3' rc_test.out)" -eq 1 ]
85 [ "$(grep -c 'failed=0' rc_test.out)" -eq 1 ]
86 rm -f rc_test.out
87
88 # https://github.com/ansible/ansible/issues/71306
89 set +e
90 exit_code=0
91 ansible-playbook -i host1,host2 -vv issue71306.yml > rc_test.out || exit_code=$?
92 set -e
93 cat rc_test.out
94 [ $exit_code -eq 0 ]
95 rm -f rc_test_out
96
97 # https://github.com/ansible/ansible/issues/69848
98 ansible-playbook -i host1,host2 --tags foo -vv 69848.yml > role_complete_test.out
99 cat role_complete_test.out
100 [ "$(grep -c 'Tagged task' role_complete_test.out)" -eq 2 ]
101 [ "$(grep -c 'Not tagged task' role_complete_test.out)" -eq 0 ]
102 rm -f role_complete_test.out
103
104 # test notify inheritance
105 ansible-playbook inherit_notify.yml "$@"
106
107 ansible-playbook unsafe_failed_task.yml "$@"
108
109 ansible-playbook finalized_task.yml "$@"
110
111 # https://github.com/ansible/ansible/issues/72725
112 ansible-playbook -i host1,host2 -vv 72725.yml
113
114 # https://github.com/ansible/ansible/issues/72781
115 set +e
116 ansible-playbook -i host1,host2 -vv 72781.yml > 72781.out
117 set -e
118 cat 72781.out
119 [ "$(grep -c 'SHOULD NOT HAPPEN' 72781.out)" -eq 0 ]
120 rm -f 72781.out
121
122 set +e
123 ansible-playbook -i host1,host2 -vv 78612.yml | tee 78612.out
124 set -e
125 [ "$(grep -c 'PASSED' 78612.out)" -eq 1 ]
126 rm -f 78612.out
127
128 ansible-playbook -vv 43191.yml
129 ansible-playbook -vv 43191-2.yml
130
131 # https://github.com/ansible/ansible/issues/79711
132 set +e
133 ANSIBLE_FORCE_HANDLERS=0 ansible-playbook -vv 79711.yml | tee 79711.out
134 set -e
135 [ "$(grep -c 'ok=5' 79711.out)" -eq 1 ]
136 [ "$(grep -c 'failed=1' 79711.out)" -eq 1 ]
137 [ "$(grep -c 'rescued=1' 79711.out)" -eq 1 ]
138 rm -f 79711.out