1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/roles/test_async/tasks/main.yml
Robin Roth c06884eff0 Run tests on ubuntu1604 and opensuseleap (#15936)
* reduce async sleep time in test
* make zypper test less destructive (don't break following uses of zypper)
* fix ca cert on suse
* fix/enable postgres/mysql on opensuseleap
* fix mysql test for mysql versions 5.7.6 and newer
* skip sni_host check on ubuntu1604
* add HTTPTESTER flag for test_uri

ubuntu 16.04 uses dash which drops env variables containing a dot
we work around this by adding an explicit env variable to enable httptester
2016-05-31 14:47:36 -07:00

89 lines
2.3 KiB
YAML

# test code for the async keyword
# (c) 2014, James Tanner <tanner.jc@gmail.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: run a 2 second loop
shell: for i in $(seq 1 2); do echo $i ; sleep 1; done;
async: 10
poll: 1
register: async_result
- debug: var=async_result
- name: validate async returns
assert:
that:
- "'ansible_job_id' in async_result"
- "'changed' in async_result"
- "'cmd' in async_result"
- "'delta' in async_result"
- "'end' in async_result"
- "'finished' in async_result"
- "'rc' in async_result"
- "'start' in async_result"
- "'stderr' in async_result"
- "'stdout' in async_result"
- "'stdout_lines' in async_result"
- "async_result.rc == 0"
- name: test async without polling
command: sleep 5
async: 30
poll: 0
register: async_result
- debug: var=async_result
- name: validate async without polling returns
assert:
that:
- "'ansible_job_id' in async_result"
- "'started' in async_result"
- "'finished' not in async_result"
- name: test skipped task handling
command: /bin/true
async: 15
poll: 0
when: False
# test async "fire and forget, but check later"
- name: 'start a task with "fire-and-forget"'
command: sleep 3
async: 30
poll: 0
register: fnf_task
- name: assert task was successfully started
assert:
that:
- fnf_task.started
- "'ansible_job_id' in fnf_task"
- name: 'check on task started as a "fire-and-forget"'
async_status: jid={{ fnf_task.ansible_job_id }}
register: fnf_result
until: fnf_result.finished
retries: 10
delay: 1
- name: assert task was successfully checked
assert:
that:
- fnf_result.finished