Debian Codegraph @

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

raw
1 # test code for the async keyword failing in the middle of output
2 # (c) 2018, Ansible Project
3
4 # This file is part of Ansible
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18
19 # This uses a special copy of the normal action plugin which simulates
20 # a transient failure in the module
21 - name: test that we can recover from initial failures to read
22 async_test:
23 fail_mode: recovered_fail
24 async: 10
25 poll: 1
26 register: async_result
27
28 - name: validate that by the end of the retry interval, we succeeded
29 assert:
30 that:
31 - async_result.ansible_job_id is match('j\d+\.\d+')
32 - async_result.finished == 1
33 - async_result is finished
34 - async_result is changed
35 - async_result is successful
36 - async_result.msg is search('succeeded')
37
38 - name: run an action with async that fails to return a job id
39 no_jid:
40 async: 10
41 poll: 1
42 register: no_jid
43 ignore_errors: yes
44
45 - name: validate the missing jid was handled properly
46 assert:
47 that:
48 - no_jid is failed
49 - no_jid.msg == "No job id was returned by the async task"
50
51 - name: run slow action with async timeout
52 command: sleep 3
53 async: 1
54 poll: 1
55 register: timeout_jid
56 ignore_errors: yes
57
58 - assert:
59 that:
60 - timeout_jid is failed
61 - timeout_jid.msg == "async task did not complete within the requested time - 1s"