summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/wait_for
diff options
context:
space:
mode:
authorBjörn <dev@bjoern.mosler.ch>2018-11-20 20:19:17 +0100
committerBrian Coca <bcoca@users.noreply.github.com>2018-11-20 20:19:17 +0100
commit9c71f176f3d2e76109c3d5f29b3d1ce1671abb8d (patch)
treea6d650f842f7d1db9dec057616a2bedb6a1a8cce /test/integration/targets/wait_for
parentinfluxdb_user - Allows updates to user privileges (#46667) (diff)
downloadansible-9c71f176f3d2e76109c3d5f29b3d1ce1671abb8d.tar.xz
ansible-9c71f176f3d2e76109c3d5f29b3d1ce1671abb8d.zip
Make wait_for return matched groups defined in search_regex. Closes #… (#47690)
* Make wait_for return matched groups defined in search_regex. Closes #25020. * Fix formatting issues. * Fix issues raised in review. - Use output_dir instead of hardcoded /tmp for temp files - Sleep for only 3s instead of 10s - Revert indent change
Diffstat (limited to 'test/integration/targets/wait_for')
-rw-r--r--test/integration/targets/wait_for/tasks/main.yml61
1 files changed, 42 insertions, 19 deletions
diff --git a/test/integration/targets/wait_for/tasks/main.yml b/test/integration/targets/wait_for/tasks/main.yml
index 908d2d8d03..4d1c9f319d 100644
--- a/test/integration/targets/wait_for/tasks/main.yml
+++ b/test/integration/targets/wait_for/tasks/main.yml
@@ -11,17 +11,17 @@
- name: setup a path
file:
- path: /tmp/wait_for_file
+ path: "{{ output_dir }}/wait_for_file"
state: touch
-- name: setup remove a file after 10s
- shell: sleep 10 && rm /tmp/wait_for_file
+- name: setup remove a file after 3s
+ shell: sleep 3 && rm {{ output_dir }}/wait_for_file
async: 20
poll: 0
- name: test for absent path
wait_for:
- path: /tmp/wait_for_file
+ path: "{{ output_dir }}/wait_for_file"
state: absent
timeout: 20
register: waitfor
@@ -29,47 +29,70 @@
assert:
that:
- waitfor is successful
- - "waitfor.path == '/tmp/wait_for_file'"
- - waitfor.elapsed >= 5
+ - waitfor.path == "{{ output_dir | expanduser }}/wait_for_file"
+ - waitfor.elapsed >= 2
- waitfor.elapsed <= 15
-- name: setup create a file after 10s
- shell: sleep 10 && touch /tmp/wait_for_file
+- name: setup create a file after 3s
+ shell: sleep 3 && touch {{ output_dir }}/wait_for_file
async: 20
poll: 0
- name: test for present path
wait_for:
- path: /tmp/wait_for_file
- timeout: 20
+ path: "{{ output_dir }}/wait_for_file"
+ timeout: 5
register: waitfor
- name: verify test for absent path
assert:
that:
- waitfor is successful
- - "waitfor.path == '/tmp/wait_for_file'"
- - waitfor.elapsed >= 5
+ - waitfor.path == "{{ output_dir | expanduser }}/wait_for_file"
+ - waitfor.elapsed >= 2
- waitfor.elapsed <= 15
-- name: setup write keyword to file after 10s
- shell: rm -f /tmp/wait_for_keyword && sleep 10 && echo completed > /tmp/wait_for_keyword
+- name: setup write keyword to file after 3s
+ shell: sleep 3 && echo completed > {{output_dir}}/wait_for_keyword
async: 20
poll: 0
- name: test wait for keyword in file
wait_for:
- path: /tmp/wait_for_keyword
+ path: "{{output_dir}}/wait_for_keyword"
search_regex: completed
- timeout: 20
+ timeout: 5
register: waitfor
-- name: verify test wait for port timeout
+
+- name: verify test wait for keyword in file
assert:
that:
- waitfor is successful
- "waitfor.search_regex == 'completed'"
- - waitfor.elapsed >= 5
+ - waitfor.elapsed >= 2
- waitfor.elapsed <= 15
+- name: setup write keyword to file after 3s
+ shell: sleep 3 && echo "completed data 123" > {{output_dir}}/wait_for_keyword
+ async: 20
+ poll: 0
+
+- name: test wait for keyword in file with match groups
+ wait_for:
+ path: "{{output_dir}}/wait_for_keyword"
+ search_regex: completed (?P<foo>\w+) ([0-9]+)
+ timeout: 5
+ register: waitfor
+
+- name: verify test wait for keyword in file with match groups
+ assert:
+ that:
+ - waitfor is successful
+ - waitfor.elapsed >= 2
+ - waitfor.elapsed <= 15
+ - waitfor['match_groupdict'] | length == 1
+ - waitfor['match_groupdict']['foo'] == 'data'
+ - waitfor['match_groups'] == ['data', '123']
+
- name: test wait for port timeout
wait_for:
port: 12121
@@ -98,7 +121,7 @@
- "waitfor.msg == 'fail with custom message'"
- name: setup start SimpleHTTPServer
- shell: sleep 10 && cd {{ files_dir }} && {{ ansible_python.executable }} {{ output_dir}}/testserver.py {{ http_port }}
+ shell: sleep 3 && cd {{ files_dir }} && {{ ansible_python.executable }} {{ output_dir}}/testserver.py {{ http_port }}
async: 120 # this test set can take ~1m to run on FreeBSD (via Shippable)
poll: 0