Debian Codegraph @

test/integration/targets/win_async_wrapper/tasks/main.yml

raw
1 - name: capture timestamp before fire and forget
2 set_fact:
3 start_timestamp: "{{ lookup('pipe', 'date +%s') }}"
4
5 - name: async fire and forget
6 async_test:
7 sleep_delay_sec: 15
8 async: 20
9 poll: 0
10 register: asyncresult
11
12 - name: validate response
13 assert:
14 that:
15 - asyncresult.ansible_job_id is match('j\d+\.\d+')
16 - asyncresult.started == 1
17 - asyncresult is started
18 - asyncresult.finished == 0
19 - asyncresult is not finished
20 - asyncresult.results_file is search('\.ansible_async.+j\d+\.\d+')
21 # ensure that async is actually async- this test will fail if # hosts > forks or if the target host is VERY slow
22 - (lookup('pipe', 'date +%s') | int) - (start_timestamp | int) < 15
23
24 - name: async poll immediate success
25 async_test:
26 sleep_delay_sec: 0
27 async: 10
28 poll: 1
29 register: asyncresult
30
31 - name: validate response
32 assert:
33 that:
34 - asyncresult.ansible_job_id is match('j\d+\.\d+')
35 - asyncresult.finished == 1
36 - asyncresult is finished
37 - asyncresult is changed
38 - asyncresult.ansible_async_watchdog_pid is number
39 # - asyncresult.module_tempdir is search('ansible-tmp-')
40 - asyncresult.module_pid is number
41
42 # this part of the test is flaky- Windows PIDs are reused aggressively, so this occasionally fails due to a new process with the same ID
43 # FUTURE: consider having the test module hook to a kernel object we can poke at that gets signaled/released on exit
44 #- name: ensure that watchdog and module procs have exited
45 # raw: Get-Process | Where { $_.Id -in ({{ asyncresult.ansible_async_watchdog_pid }}, {{ asyncresult.module_pid }}) }
46 # register: proclist
47 #
48 #- name: validate no running watchdog/module processes were returned
49 # assert:
50 # that:
51 # - proclist.stdout.strip() == ''
52
53 #- name: ensure that module_tempdir was deleted
54 # raw: Test-Path {{ asyncresult.module_tempdir }}
55 # register: tempdircheck
56 #
57 #- name: validate tempdir response
58 # assert:
59 # that:
60 # - tempdircheck.stdout is search('False')
61
62 - name: async poll retry
63 async_test:
64 sleep_delay_sec: 5
65 async: 10
66 poll: 1
67 register: asyncresult
68
69 - name: validate response
70 assert:
71 that:
72 - asyncresult.ansible_job_id is match('j\d+\.\d+')
73 - asyncresult.finished == 1
74 - asyncresult is finished
75 - asyncresult is changed
76 # - asyncresult.module_tempdir is search('ansible-tmp-')
77 - asyncresult.module_pid is number
78
79 # this part of the test is flaky- Windows PIDs are reused aggressively, so this occasionally fails due to a new process with the same ID
80 # FUTURE: consider having the test module hook to a kernel object we can poke at that gets signaled/released on exit
81 #- name: ensure that watchdog and module procs have exited
82 # raw: Get-Process | Where { $_.Id -in ({{ asyncresult.ansible_async_watchdog_pid }}, {{ asyncresult.module_pid }}) }
83 # register: proclist
84 #
85 #- name: validate no running watchdog/module processes were returned
86 # assert:
87 # that:
88 # - proclist.stdout.strip() == ''
89
90 #- name: ensure that module_tempdir was deleted
91 # raw: Test-Path {{ asyncresult.module_tempdir }}
92 # register: tempdircheck
93 #
94 #- name: validate tempdir response
95 # assert:
96 # that:
97 # - tempdircheck.stdout is search('False')
98
99 - name: async poll timeout
100 async_test:
101 sleep_delay_sec: 5
102 async: 3
103 poll: 1
104 register: asyncresult
105 ignore_errors: true
106
107 - name: validate response
108 assert:
109 that:
110 - asyncresult.ansible_job_id is match('j\d+\.\d+')
111 - asyncresult.finished == 1
112 - asyncresult is finished
113 - asyncresult is not changed
114 - asyncresult is failed
115 - asyncresult.msg is search('timed out')
116
117 - name: async poll graceful module failure
118 async_test:
119 fail_mode: graceful
120 async: 5
121 poll: 1
122 register: asyncresult
123 ignore_errors: true
124
125 - name: validate response
126 assert:
127 that:
128 - asyncresult.ansible_job_id is match('j\d+\.\d+')
129 - asyncresult.finished == 1
130 - asyncresult is finished
131 - asyncresult is changed
132 - asyncresult is failed
133 - asyncresult.msg == 'failed gracefully'
134
135 - name: async poll exception module failure
136 async_test:
137 fail_mode: exception
138 async: 5
139 poll: 1
140 register: asyncresult
141 ignore_errors: true
142
143 - name: validate response
144 assert:
145 that:
146 - asyncresult.ansible_job_id is match('j\d+\.\d+')
147 - asyncresult.finished == 1
148 - asyncresult is finished
149 - asyncresult is not changed
150 - asyncresult is failed
151 - 'asyncresult.msg == "Unhandled exception while executing module: failing via exception"'
152
153 - name: echo some non ascii characters
154 win_command: cmd.exe /c echo über den Fußgängerübergang gehen
155 async: 10
156 poll: 1
157 register: nonascii_output
158
159 - name: assert echo some non ascii characters
160 assert:
161 that:
162 - nonascii_output is changed
163 - nonascii_output.rc == 0
164 - nonascii_output.stdout_lines|count == 1
165 - nonascii_output.stdout_lines[0] == 'über den Fußgängerübergang gehen'
166 - nonascii_output.stderr == ''
167
168 - name: test async with custom async dir
169 win_shell: echo hi
170 register: async_custom_dir
171 async: 5
172 vars:
173 ansible_async_dir: '{{win_output_dir}}'
174
175 - name: assert results file is in the remote tmp specified
176 assert:
177 that:
178 - async_custom_dir.results_file == win_output_dir + '\\' + async_custom_dir.ansible_job_id
179
180 - name: test async fire and forget with custom async dir
181 win_shell: echo hi
182 register: async_custom_dir_poll
183 async: 5
184 poll: 0
185 vars:
186 ansible_async_dir: '{{win_output_dir}}'
187
188 - name: poll with different dir - fail
189 async_status:
190 jid: '{{ async_custom_dir_poll.ansible_job_id }}'
191 register: fail_async_custom_dir_poll
192 ignore_errors: yes
193
194 - name: poll with different dir - success
195 async_status:
196 jid: '{{ async_custom_dir_poll.ansible_job_id }}'
197 register: success_async_custom_dir_poll
198 vars:
199 ansible_async_dir: '{{win_output_dir}}'
200
201 - name: assert test async fire and forget with custom async dir
202 assert:
203 that:
204 - fail_async_custom_dir_poll.failed
205 - '"could not find job at ''" + nonascii_output.results_file|win_dirname + "''" in fail_async_custom_dir_poll.msg'
206 - not success_async_custom_dir_poll.failed
207 - success_async_custom_dir_poll.results_file == win_output_dir + '\\' + async_custom_dir_poll.ansible_job_id
208
209 - name: test async with trailing output
210 trailing_output:
211 async: 10
212 poll: 1
213 register: async_trailing_output
214
215 - name: assert test async with trailing output
216 assert:
217 that:
218 - async_trailing_output is not changed
219 - async_trailing_output.test == 123
220 - async_trailing_output.warnings | count == 1
221 - >-
222 async_trailing_output.warnings[0] is search('Module invocation had junk after the JSON data: trailing junk after module result')
223
224 # FUTURE: figure out why the last iteration of this test often fails on shippable
225 #- name: loop async success
226 # async_test:
227 # sleep_delay_sec: 3
228 # async: 10
229 # poll: 0
230 # with_sequence: start=1 end=4
231 # register: async_many
232 #
233 #- name: wait for completion
234 # async_status:
235 # jid: "{{ item }}"
236 # register: asyncout
237 # until: asyncout is finished
238 # retries: 10
239 # delay: 1
240 # with_items: "{{ async_many.results | map(attribute='ansible_job_id') | list }}"
241 #
242 #- name: validate results
243 # assert:
244 # that:
245 # - item.finished == 1
246 # - item is finished
247 # - item.slept_sec == 3
248 # - item is changed
249 # - item.ansible_job_id is match('j\d+\.\d+')
250 # with_items: "{{ asyncout.results }}"
251
252 # this part of the test is flaky- Windows PIDs are reused aggressively, so this occasionally fails due to a new process with the same ID
253 # FUTURE: consider having the test module hook to a kernel object we can poke at that gets signaled/released on exit
254 #- name: ensure that all watchdog and module procs have exited
255 # raw: Get-Process | Where { $_.Id -in ({{ asyncout.results | join(',', attribute='ansible_async_watchdog_pid') }}, {{ asyncout.results | join(',', attribute='module_pid') }}) }
256 # register: proclist
257 #
258 #- name: validate no processes were returned
259 # assert:
260 # that:
261 # - proclist.stdout.strip() == ""
262
263 # FUTURE: test junk before/after JSON
264 # FUTURE: verify tempdir stays through module exec
265 # FUTURE: verify tempdir is deleted after module exec
266 # FUTURE: verify tempdir is permanent with ANSIBLE_KEEP_REMOTE_FILES=1 (how?)
267 # FUTURE: verify binary modules work
268
269 # FUTURE: test status/return
270 # FUTURE: test status/cleanup
271 # FUTURE: test reboot/connection failure
272 # FUTURE: figure out how to ensure that processes and tempdirs are cleaned up in all exceptional cases