summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorJordan Borean <jborean93@gmail.com>2018-09-20 11:37:54 +0200
committerGitHub <noreply@github.com>2018-09-20 11:37:54 +0200
commit5c73d4f4bd4c067cd4d1d9f1adfe16090ece4b04 (patch)
tree339eb6d6b39e6bb33b76d83c60438efb9f6a7a99 /test/integration
parentFixing azure_rm_containerregistry_facts (#45897) (diff)
downloadansible-5c73d4f4bd4c067cd4d1d9f1adfe16090ece4b04.tar.xz
ansible-5c73d4f4bd4c067cd4d1d9f1adfe16090ece4b04.zip
async: use async_dir for the async results file directory (#45461)
* win async: use async_dir for the async results file directory * tried to unify POSIX and PowerShell async implementations of async_dir * fix sanity issue
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/targets/async/tasks/main.yml105
-rw-r--r--test/integration/targets/win_async_wrapper/tasks/main.yml37
2 files changed, 138 insertions, 4 deletions
diff --git a/test/integration/targets/async/tasks/main.yml b/test/integration/targets/async/tasks/main.yml
index f8e244eca5..32f13935e0 100644
--- a/test/integration/targets/async/tasks/main.yml
+++ b/test/integration/targets/async/tasks/main.yml
@@ -177,3 +177,108 @@
- non_async_result is changed
- non_async_result is finished
- "'ansible_job_id' not in non_async_result"
+
+- name: set fact of custom tmp dir
+ set_fact:
+ custom_async_tmp: ~/.ansible_async_test
+
+- name: ensure custom async tmp dir is absent
+ file:
+ path: '{{ custom_async_tmp }}'
+ state: absent
+
+- block:
+ - name: run async task with custom dir
+ command: sleep 1
+ register: async_custom_dir
+ async: 5
+ poll: 1
+ vars:
+ ansible_async_dir: '{{ custom_async_tmp }}'
+
+ - name: check if the async temp dir is created
+ stat:
+ path: '{{ custom_async_tmp }}'
+ register: async_custom_dir_result
+
+ - name: assert run async task with custom dir
+ assert:
+ that:
+ - async_custom_dir is successful
+ - async_custom_dir is finished
+ - async_custom_dir_result.stat.exists
+
+ - name: remove custom async dir again
+ file:
+ path: '{{ custom_async_tmp }}'
+ state: absent
+
+ - name: run async task with custom dir - deprecated format
+ command: sleep 1
+ register: async_custom_dir_dep
+ async: 5
+ poll: 1
+ environment:
+ ANSIBLE_ASYNC_DIR: '{{ custom_async_tmp }}'
+
+ - name: check if the async temp dir is created - deprecated format
+ stat:
+ path: '{{ custom_async_tmp }}'
+ register: async_custom_dir_dep_result
+
+ - name: assert run async task with custom dir - deprecated format
+ assert:
+ that:
+ - async_custom_dir_dep is successful
+ - async_custom_dir_dep is finished
+ - async_custom_dir_dep_result.stat.exists
+
+ - name: remove custom async dir after deprecation test
+ file:
+ path: '{{ custom_async_tmp }}'
+ state: absent
+
+ - name: run fire and forget async task with custom dir
+ command: sleep 1
+ register: async_fandf_custom_dir
+ async: 5
+ poll: 0
+ vars:
+ ansible_async_dir: '{{ custom_async_tmp }}'
+
+ - name: fail to get async status with custom dir with defaults
+ async_status:
+ jid: '{{ async_fandf_custom_dir.ansible_job_id }}'
+ register: async_fandf_custom_dir_fail
+ ignore_errors: yes
+
+ - name: get async status with custom dir using newer format
+ async_status:
+ jid: '{{ async_fandf_custom_dir.ansible_job_id }}'
+ register: async_fandf_custom_dir_result
+ vars:
+ ansible_async_dir: '{{ custom_async_tmp }}'
+
+ - name: get async status with custom dir - deprecated format
+ async_status:
+ jid: '{{ async_fandf_custom_dir.ansible_job_id }}'
+ register: async_fandf_custom_dir_dep_result
+ environment:
+ ANSIBLE_ASYNC_DIR: '{{ custom_async_tmp }}'
+
+ - name: assert run fire and forget async task with custom dir
+ assert:
+ that:
+ - async_fandf_custom_dir is successful
+ - async_fandf_custom_dir_fail is failed
+ - async_fandf_custom_dir_fail.msg == "could not find job"
+ - async_fandf_custom_dir_result is successful
+ - async_fandf_custom_dir_result is finished
+ - async_fandf_custom_dir_dep_result is successful
+ - async_fandf_custom_dir_dep_result is finished
+
+ always:
+ - name: remove custom tmp dir after test
+ file:
+ path: '{{ custom_async_tmp }}'
+ state: absent
diff --git a/test/integration/targets/win_async_wrapper/tasks/main.yml b/test/integration/targets/win_async_wrapper/tasks/main.yml
index 20cca10b43..756e3ee780 100644
--- a/test/integration/targets/win_async_wrapper/tasks/main.yml
+++ b/test/integration/targets/win_async_wrapper/tasks/main.yml
@@ -166,17 +166,46 @@
- nonascii_output.stdout_lines[0] == 'über den Fußgängerübergang gehen'
- nonascii_output.stderr == ''
-- name: test async with custom remote_tmp
+- name: test async with custom async dir
win_shell: echo hi
- register: async_custom_tmp
+ register: async_custom_dir
async: 5
vars:
- ansible_remote_tmp: '{{win_output_dir}}'
+ ansible_async_dir: '{{win_output_dir}}'
- name: assert results file is in the remote tmp specified
assert:
that:
- - async_custom_tmp.results_file == win_output_dir + '\\.ansible_async\\' + async_custom_tmp.ansible_job_id
+ - async_custom_dir.results_file == win_output_dir + '\\' + async_custom_dir.ansible_job_id
+
+- name: test async fire and forget with custom async dir
+ win_shell: echo hi
+ register: async_custom_dir_poll
+ async: 5
+ poll: 0
+ vars:
+ ansible_async_dir: '{{win_output_dir}}'
+
+- name: poll with different dir - fail
+ async_status:
+ jid: '{{ async_custom_dir_poll.ansible_job_id }}'
+ register: fail_async_custom_dir_poll
+ ignore_errors: yes
+
+- name: poll with different dir - success
+ async_status:
+ jid: '{{ async_custom_dir_poll.ansible_job_id }}'
+ register: success_async_custom_dir_poll
+ vars:
+ ansible_async_dir: '{{win_output_dir}}'
+
+- name: assert test async fire and forget with custom async dir
+ assert:
+ that:
+ - fail_async_custom_dir_poll.failed
+ - '"could not find job at ''" + nonascii_output.results_file|win_dirname + "''" in fail_async_custom_dir_poll.msg'
+ - not success_async_custom_dir_poll.failed
+ - success_async_custom_dir_poll.results_file == win_output_dir + '\\' + async_custom_dir_poll.ansible_job_id
# FUTURE: figure out why the last iteration of this test often fails on shippable
#- name: loop async success