ansible: implment async job time limit.
parent
d2accbce53
commit
3994f1b30a
@ -1,52 +0,0 @@
|
|||||||
# Verify 'async: <timeout>' functions as desired.
|
|
||||||
|
|
||||||
- name: integration/async/runner_job_timeout.yml
|
|
||||||
hosts: test-targets
|
|
||||||
any_errors_fatal: true
|
|
||||||
tasks:
|
|
||||||
|
|
||||||
# Verify async-with-polling-and-timeout behaviour.
|
|
||||||
|
|
||||||
- name: sleep for 7 seconds, but timeout after 1 second.
|
|
||||||
ignore_errors: true
|
|
||||||
shell: sleep 7
|
|
||||||
async: 1
|
|
||||||
poll: 1
|
|
||||||
register: job1
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- job1.changed == False
|
|
||||||
- job1.failed == True
|
|
||||||
- job1.msg == "async task did not complete within the requested time"
|
|
||||||
- job1.keys()|sort == ['changed', 'failed', 'msg']
|
|
||||||
|
|
||||||
# Verify async-with-timeout-then-poll behaviour.
|
|
||||||
# This is broken in upstream Ansible, so disable the tests there.
|
|
||||||
#
|
|
||||||
# TODO: the tests below are totally broken, not clear what Ansible is
|
|
||||||
# supposed to do here, so can't emulate it in Mitogen.
|
|
||||||
|
|
||||||
- name: sleep for 7 seconds, but timeout after 1 second.
|
|
||||||
ignore_errors: true
|
|
||||||
shell: sleep 7
|
|
||||||
async: 1
|
|
||||||
poll: 0
|
|
||||||
register: job2
|
|
||||||
when: false # is_mitogen
|
|
||||||
|
|
||||||
- name: poll up to 10 times.
|
|
||||||
async_status:
|
|
||||||
jid: "{{job2.ansible_job_id}}"
|
|
||||||
register: result2
|
|
||||||
until: result2.finished
|
|
||||||
retries: 10
|
|
||||||
delay: 1
|
|
||||||
when: false # is_mitogen
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- result1.rc == 0
|
|
||||||
- result2.rc == 0
|
|
||||||
- result2.stdout == 'im_alive'
|
|
||||||
when: false # is_mitogen
|
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
# Verify 'async: <timeout>' functions as desired.
|
||||||
|
|
||||||
|
- name: integration/async/runner_timeout_then_polling.yml
|
||||||
|
hosts: test-targets
|
||||||
|
any_errors_fatal: true
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
# Verify async-with-timeout-then-poll behaviour.
|
||||||
|
# This is semi-broken in upstream Ansible, it does not bother to update the
|
||||||
|
# job file on failure. So only test on Mitogen.
|
||||||
|
|
||||||
|
- name: sleep for 7 seconds, but timeout after 1 second.
|
||||||
|
shell: sleep 10
|
||||||
|
async: 1
|
||||||
|
poll: 0
|
||||||
|
register: job
|
||||||
|
when: is_mitogen
|
||||||
|
|
||||||
|
- name: busy-poll up to 500 times
|
||||||
|
async_status:
|
||||||
|
jid: "{{job.ansible_job_id}}"
|
||||||
|
register: result
|
||||||
|
until: result.finished
|
||||||
|
retries: 500
|
||||||
|
delay: 0
|
||||||
|
when: is_mitogen
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.failed == 1
|
||||||
|
- result.finished == 1
|
||||||
|
- result.msg == "Job reached maximum time limit of 1 seconds."
|
||||||
|
when: is_mitogen
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
# Verify 'async: <timeout>' functions as desired.
|
||||||
|
|
||||||
|
- name: integration/async/runner_with_polling_and_timeout.yml
|
||||||
|
hosts: test-targets
|
||||||
|
any_errors_fatal: true
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
# Verify async-with-polling-and-timeout behaviour.
|
||||||
|
|
||||||
|
- name: sleep for 7 seconds, but timeout after 1 second.
|
||||||
|
ignore_errors: true
|
||||||
|
shell: sleep 7
|
||||||
|
async: 1
|
||||||
|
poll: 1
|
||||||
|
register: job1
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- job1.changed == False
|
||||||
|
- job1.failed == True
|
||||||
|
- |
|
||||||
|
job1.msg == "async task did not complete within the requested time" or
|
||||||
|
job1.msg == "Job reached maximum time limit of 1 seconds."
|
||||||
|
|
||||||
Loading…
Reference in New Issue