mirror of https://github.com/ansible/ansible.git
Add a test case for loop item display
Use test_utils timeout script for compatibility on different platforms Reduce test duration and redistribute timeout to try to avoid race condition Co-authored-by: Matt Davis <6775756+nitzmahone@users.noreply.github.com>pull/81158/head
parent
606e0505b6
commit
28e6736226
@ -1,2 +1,3 @@
|
|||||||
shippable/posix/group4
|
shippable/posix/group4
|
||||||
context/controller
|
context/controller
|
||||||
|
needs/target/test_utils
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
- hosts: all
|
||||||
|
gather_facts: no
|
||||||
|
roles:
|
||||||
|
- ../loops
|
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
ansible-playbook playbook.yml -i ../../inventory "$@"
|
||||||
|
|
||||||
|
rm -f out.txt && touch out.txt
|
||||||
|
|
||||||
|
python ../test_utils/scripts/timeout.py -- 10 'ansible-playbook test_loop_item_display.yml "$@" >> out.txt' &
|
||||||
|
|
||||||
|
echo "waiting for first loop result..."
|
||||||
|
# wait up to 2s for first loop result to appear
|
||||||
|
python ../test_utils/scripts/timeout.py -- 2 tail -f out.txt | grep item=0 -m 1 || (echo "failed to get first loop result in time" && false)
|
||||||
|
|
||||||
|
echo "checking for absence of second loop result..."
|
||||||
|
# fail if the second loop result appeared too early
|
||||||
|
grep item=2 out.txt && (echo "found the second loop result early, failing" && false)
|
||||||
|
|
||||||
|
echo "waiting for second loop result..."
|
||||||
|
# wait up to 3s for second loop result to appear
|
||||||
|
python ../test_utils/scripts/timeout.py -- 3 tail -f out.txt | grep item=2 -m 1 || (echo "failed to get second loop result in time" && false)
|
||||||
|
|
||||||
|
echo "success"
|
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- name: Sleep per loop item
|
||||||
|
shell: sleep {{ item }}
|
||||||
|
loop:
|
||||||
|
- 0
|
||||||
|
- 2
|
Loading…
Reference in New Issue