tests: better runner_two_simultaneous_jobs.yml.

This commit is contained in:
David Wilson 2018-06-10 05:00:42 +00:00
parent 1d96d80e8d
commit ffc7306cf8
1 changed files with 17 additions and 14 deletions

View File

@ -6,16 +6,20 @@
# Start 2 duplicate jobs, verify they run concurrently. # Start 2 duplicate jobs, verify they run concurrently.
- file:
path: /tmp/flurp
state: absent
- name: create semaphore file and sleep for 5 seconds. - name: create semaphore file and sleep for 5 seconds.
shell: | shell: |
exec 2>/dev/null; exec 2>/dev/null;
bash -c ' bash -c '
echo im_alive $$ > /tmp/flurp echo im_alive $$ > /tmp/flurp;
sleep 60; sleep 60;
'; ';
rm -f /tmp/flurp; rm -f /tmp/flurp;
echo alldone echo alldone
async: 1000 async: 30
poll: 0 poll: 0
register: job1 register: job1
@ -24,30 +28,29 @@
# below compltes quickly. # below compltes quickly.
- name: verify semaphore file exists while this job exists. - name: verify semaphore file exists while this job exists.
shell: | shell: |
[ -f /tmp/flurp ] && { while [ ! -f /tmp/flurp ]; do sleep 0.1; done;
read im_alive pid < /tmp/flurp read im_alive pid < /tmp/flurp
echo $im_alive echo $im_alive
kill $pid &>/dev/null kill $pid &>/dev/null
} async: 30
async: 1000
poll: 0 poll: 0
register: job2 register: job2
- name: (job1) busy-poll up to 100000 times - name: (job1) poll
async_status: async_status:
jid: "{{job1.ansible_job_id}}" jid: "{{job1.ansible_job_id}}"
register: result1 register: result1
until: result1.finished until: result1.finished
retries: 100000 retries: 5
delay: 0 delay: 1
- name: (job2) busy-poll up to 100000 times - name: (job2) poll
async_status: async_status:
jid: "{{job2.ansible_job_id}}" jid: "{{job2.ansible_job_id}}"
register: result2 register: result2
until: result2.finished until: result2.finished
retries: 100000 retries: 5
delay: 0 delay: 1
- assert: - assert:
that: that: