Make use of Jinja tests 'finished' (#43233)

And also used 'changed' and 'failed' tests while we are at it.
This commit is contained in:
Dag Wieers 2018-07-30 10:41:49 +02:00 committed by GitHub
parent 1bab901966
commit 12e7e9650e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 21 deletions

View file

@ -75,7 +75,7 @@
- name: assert task was successfully started
assert:
that:
- fnf_task.started
- fnf_task.started == 1
- "'ansible_job_id' in fnf_task"
- name: 'check on task started as a "fire-and-forget"'

View file

@ -30,6 +30,7 @@
that:
- async_result.ansible_job_id is match('\d+\.\d+')
- async_result.finished == 1
- async_result.changed == true
- async_result is finished
- async_result is changed
- async_result is successful
- async_result.msg is search('succeeded')

View file

@ -336,19 +336,19 @@
- name: wait for async job 1
async_status: jid={{ async_1.ansible_job_id }}
register: job_result
until: job_result.finished
until: job_result is finished
retries: 30
- name: wait for async job 2
async_status: jid={{ async_1.ansible_job_id }}
register: job_result
until: job_result.finished
until: job_result is finished
retries: 30
- name: wait for async job 3
async_status: jid={{ async_3.ansible_job_id }}
register: job_result
until: job_result.finished
until: job_result is finished
retries: 30
@ -407,19 +407,19 @@
- name: wait for async job 1
async_status: jid={{ async_1.ansible_job_id }}
register: job_result
until: job_result.finished
until: job_result is finished
retries: 30
- name: wait for async job 2
async_status: jid={{ async_1.ansible_job_id }}
register: job_result
until: job_result.finished
until: job_result is finished
retries: 30
- name: wait for async job 3
async_status: jid={{ async_3.ansible_job_id }}
register: job_result
until: job_result.finished
until: job_result is finished
retries: 30

View file

@ -93,7 +93,7 @@
async_status:
jid: "{{ test_async.ansible_job_id }}"
register: status
until: status.finished
until: status is finished
retries: 10
- name: check that roles file lookups work as expected

View file

@ -435,7 +435,7 @@
- name: Ensure ec2_asg task completes
async_status: jid="{{ asg_job.ansible_job_id }}"
register: status
until: status.finished
until: status is finished
retries: 200
delay: 15
@ -497,7 +497,7 @@
- name: Ensure ec2_asg task completes
async_status: jid="{{ asg_job.ansible_job_id }}"
register: status
until: status.finished
until: status is finished
retries: 200
delay: 15

View file

@ -15,6 +15,7 @@
- asyncresult.ansible_job_id is match('\d+\.\d+')
- asyncresult.started == 1
- asyncresult.finished == 0
- asyncresult is not finished
- asyncresult.results_file is search('\.ansible_async.+\d+\.\d+')
# ensure that async is actually async- this test will fail if # hosts > forks or if the target host is VERY slow
- (lookup('pipe', 'date +%s') | int) - (start_timestamp | int) < 8
@ -31,7 +32,8 @@
that:
- asyncresult.ansible_job_id is match('\d+\.\d+')
- asyncresult.finished == 1
- asyncresult.changed == true
- asyncresult is finished
- asyncresult is changed
- asyncresult.ansible_async_watchdog_pid is number
# - asyncresult.module_tempdir is search('ansible-tmp-')
- asyncresult.module_pid is number
@ -68,7 +70,8 @@
that:
- asyncresult.ansible_job_id is match('\d+\.\d+')
- asyncresult.finished == 1
- asyncresult.changed == true
- asyncresult is finished
- asyncresult is changed
# - asyncresult.module_tempdir is search('ansible-tmp-')
- asyncresult.module_pid is number
@ -105,8 +108,9 @@
that:
- asyncresult.ansible_job_id is match('\d+\.\d+')
- asyncresult.finished == 1
- asyncresult.changed == false
- asyncresult is failed == true
- asyncresult is finished
- asyncresult is not changed
- asyncresult is failed
- asyncresult.msg is search('timed out')
- name: async poll graceful module failure
@ -122,8 +126,9 @@
that:
- asyncresult.ansible_job_id is match('\d+\.\d+')
- asyncresult.finished == 1
- asyncresult.changed == true
- asyncresult is failed == true
- asyncresult is finished
- asyncresult is changed
- asyncresult is failed
- asyncresult.msg == 'failed gracefully'
- name: async poll exception module failure
@ -139,8 +144,9 @@
that:
- asyncresult.ansible_job_id is match('\d+\.\d+')
- asyncresult.finished == 1
- asyncresult.changed == false
- asyncresult is failed == true
- asyncresult is finished
- asyncresult is not changed
- asyncresult is failed
# TODO: re-enable after catastrophic failure behavior is cleaned up
# - asyncresult.msg is search('failing via exception')
@ -184,7 +190,7 @@
# async_status:
# jid: "{{ item }}"
# register: asyncout
# until: asyncout.finished == 1
# until: asyncout is finished
# retries: 10
# delay: 1
# with_items: "{{ async_many.results | map(attribute='ansible_job_id') | list }}"
@ -193,8 +199,9 @@
# assert:
# that:
# - item.finished == 1
# - item is finished
# - item.slept_sec == 3
# - item.changed == true
# - item is changed
# - item.ansible_job_id is match('\d+\.\d+')
# with_items: "{{ asyncout.results }}"