2017-03-14 23:37:55 +00:00
|
|
|
- name: capture timestamp before fire and forget
|
|
|
|
set_fact:
|
|
|
|
start_timestamp: "{{ lookup('pipe', 'date +%s') }}"
|
|
|
|
|
2016-09-07 00:38:12 +00:00
|
|
|
- name: async fire and forget
|
|
|
|
async_test:
|
2018-08-06 01:30:49 +00:00
|
|
|
sleep_delay_sec: 15
|
2016-09-07 00:38:12 +00:00
|
|
|
async: 20
|
|
|
|
poll: 0
|
|
|
|
register: asyncresult
|
|
|
|
|
|
|
|
- name: validate response
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- asyncresult.ansible_job_id is match('\d+\.\d+')
|
|
|
|
- asyncresult.started == 1
|
2018-08-23 23:29:34 +00:00
|
|
|
- asyncresult is started
|
2016-09-07 00:38:12 +00:00
|
|
|
- asyncresult.finished == 0
|
2018-07-30 08:41:49 +00:00
|
|
|
- asyncresult is not finished
|
2016-09-07 00:38:12 +00:00
|
|
|
- asyncresult.results_file is search('\.ansible_async.+\d+\.\d+')
|
2017-03-14 23:37:55 +00:00
|
|
|
# ensure that async is actually async- this test will fail if # hosts > forks or if the target host is VERY slow
|
2018-08-06 01:30:49 +00:00
|
|
|
- (lookup('pipe', 'date +%s') | int) - (start_timestamp | int) < 15
|
2016-09-07 00:38:12 +00:00
|
|
|
|
|
|
|
- name: async poll immediate success
|
|
|
|
async_test:
|
|
|
|
sleep_delay_sec: 0
|
2018-08-05 23:21:53 +00:00
|
|
|
async: 10
|
2016-09-07 00:38:12 +00:00
|
|
|
poll: 1
|
|
|
|
register: asyncresult
|
|
|
|
|
|
|
|
- name: validate response
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- asyncresult.ansible_job_id is match('\d+\.\d+')
|
|
|
|
- asyncresult.finished == 1
|
2018-07-30 08:41:49 +00:00
|
|
|
- asyncresult is finished
|
|
|
|
- asyncresult is changed
|
2016-09-07 00:38:12 +00:00
|
|
|
- asyncresult.ansible_async_watchdog_pid is number
|
2017-02-17 08:09:56 +00:00
|
|
|
# - asyncresult.module_tempdir is search('ansible-tmp-')
|
2016-09-07 00:38:12 +00:00
|
|
|
- asyncresult.module_pid is number
|
|
|
|
|
|
|
|
# this part of the test is flaky- Windows PIDs are reused aggressively, so this occasionally fails due to a new process with the same ID
|
|
|
|
# FUTURE: consider having the test module hook to a kernel object we can poke at that gets signaled/released on exit
|
|
|
|
#- name: ensure that watchdog and module procs have exited
|
|
|
|
# raw: Get-Process | Where { $_.Id -in ({{ asyncresult.ansible_async_watchdog_pid }}, {{ asyncresult.module_pid }}) }
|
|
|
|
# register: proclist
|
|
|
|
#
|
|
|
|
#- name: validate no running watchdog/module processes were returned
|
|
|
|
# assert:
|
|
|
|
# that:
|
|
|
|
# - proclist.stdout.strip() == ''
|
|
|
|
|
2017-02-17 08:09:56 +00:00
|
|
|
#- name: ensure that module_tempdir was deleted
|
|
|
|
# raw: Test-Path {{ asyncresult.module_tempdir }}
|
|
|
|
# register: tempdircheck
|
|
|
|
#
|
|
|
|
#- name: validate tempdir response
|
|
|
|
# assert:
|
|
|
|
# that:
|
2017-11-27 22:58:08 +00:00
|
|
|
# - tempdircheck.stdout is search('False')
|
2016-09-07 00:38:12 +00:00
|
|
|
|
|
|
|
- name: async poll retry
|
|
|
|
async_test:
|
|
|
|
sleep_delay_sec: 5
|
2018-08-05 23:21:53 +00:00
|
|
|
async: 10
|
2016-09-07 00:38:12 +00:00
|
|
|
poll: 1
|
|
|
|
register: asyncresult
|
|
|
|
|
|
|
|
- name: validate response
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- asyncresult.ansible_job_id is match('\d+\.\d+')
|
|
|
|
- asyncresult.finished == 1
|
2018-07-30 08:41:49 +00:00
|
|
|
- asyncresult is finished
|
|
|
|
- asyncresult is changed
|
2017-02-17 08:09:56 +00:00
|
|
|
# - asyncresult.module_tempdir is search('ansible-tmp-')
|
2016-09-07 00:38:12 +00:00
|
|
|
- asyncresult.module_pid is number
|
|
|
|
|
|
|
|
# this part of the test is flaky- Windows PIDs are reused aggressively, so this occasionally fails due to a new process with the same ID
|
|
|
|
# FUTURE: consider having the test module hook to a kernel object we can poke at that gets signaled/released on exit
|
|
|
|
#- name: ensure that watchdog and module procs have exited
|
|
|
|
# raw: Get-Process | Where { $_.Id -in ({{ asyncresult.ansible_async_watchdog_pid }}, {{ asyncresult.module_pid }}) }
|
|
|
|
# register: proclist
|
|
|
|
#
|
|
|
|
#- name: validate no running watchdog/module processes were returned
|
|
|
|
# assert:
|
|
|
|
# that:
|
|
|
|
# - proclist.stdout.strip() == ''
|
|
|
|
|
2017-02-17 08:09:56 +00:00
|
|
|
#- name: ensure that module_tempdir was deleted
|
|
|
|
# raw: Test-Path {{ asyncresult.module_tempdir }}
|
|
|
|
# register: tempdircheck
|
|
|
|
#
|
|
|
|
#- name: validate tempdir response
|
|
|
|
# assert:
|
|
|
|
# that:
|
2017-11-27 22:58:08 +00:00
|
|
|
# - tempdircheck.stdout is search('False')
|
2016-09-07 00:38:12 +00:00
|
|
|
|
|
|
|
- name: async poll timeout
|
|
|
|
async_test:
|
2018-08-05 23:21:53 +00:00
|
|
|
sleep_delay_sec: 5
|
|
|
|
async: 3
|
2016-09-07 00:38:12 +00:00
|
|
|
poll: 1
|
|
|
|
register: asyncresult
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: validate response
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- asyncresult.ansible_job_id is match('\d+\.\d+')
|
|
|
|
- asyncresult.finished == 1
|
2018-07-30 08:41:49 +00:00
|
|
|
- asyncresult is finished
|
|
|
|
- asyncresult is not changed
|
|
|
|
- asyncresult is failed
|
2016-09-07 00:38:12 +00:00
|
|
|
- asyncresult.msg is search('timed out')
|
|
|
|
|
|
|
|
- name: async poll graceful module failure
|
|
|
|
async_test:
|
|
|
|
fail_mode: graceful
|
|
|
|
async: 5
|
|
|
|
poll: 1
|
|
|
|
register: asyncresult
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: validate response
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- asyncresult.ansible_job_id is match('\d+\.\d+')
|
|
|
|
- asyncresult.finished == 1
|
2018-07-30 08:41:49 +00:00
|
|
|
- asyncresult is finished
|
|
|
|
- asyncresult is changed
|
|
|
|
- asyncresult is failed
|
2016-09-07 00:38:12 +00:00
|
|
|
- asyncresult.msg == 'failed gracefully'
|
|
|
|
|
|
|
|
- name: async poll exception module failure
|
|
|
|
async_test:
|
|
|
|
fail_mode: exception
|
|
|
|
async: 5
|
|
|
|
poll: 1
|
|
|
|
register: asyncresult
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: validate response
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- asyncresult.ansible_job_id is match('\d+\.\d+')
|
|
|
|
- asyncresult.finished == 1
|
2018-07-30 08:41:49 +00:00
|
|
|
- asyncresult is finished
|
|
|
|
- asyncresult is not changed
|
|
|
|
- asyncresult is failed
|
2018-10-02 22:55:53 +00:00
|
|
|
- 'asyncresult.msg == "Unhandled exception while executing module: failing via exception"'
|
2016-09-07 00:38:12 +00:00
|
|
|
|
2018-04-05 21:59:51 +00:00
|
|
|
- name: echo some non ascii characters
|
|
|
|
win_command: cmd.exe /c echo über den Fußgängerübergang gehen
|
2018-08-05 23:21:53 +00:00
|
|
|
async: 10
|
2018-04-05 21:59:51 +00:00
|
|
|
poll: 1
|
|
|
|
register: nonascii_output
|
|
|
|
|
|
|
|
- name: assert echo some non ascii characters
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- nonascii_output is changed
|
|
|
|
- nonascii_output.rc == 0
|
|
|
|
- nonascii_output.stdout_lines|count == 1
|
|
|
|
- nonascii_output.stdout_lines[0] == 'über den Fußgängerübergang gehen'
|
|
|
|
- nonascii_output.stderr == ''
|
2016-11-18 19:38:50 +00:00
|
|
|
|
2018-09-20 09:37:54 +00:00
|
|
|
- name: test async with custom async dir
|
2018-05-22 21:12:32 +00:00
|
|
|
win_shell: echo hi
|
2018-09-20 09:37:54 +00:00
|
|
|
register: async_custom_dir
|
2018-05-22 21:12:32 +00:00
|
|
|
async: 5
|
|
|
|
vars:
|
2018-09-20 09:37:54 +00:00
|
|
|
ansible_async_dir: '{{win_output_dir}}'
|
2018-05-22 21:12:32 +00:00
|
|
|
|
|
|
|
- name: assert results file is in the remote tmp specified
|
|
|
|
assert:
|
|
|
|
that:
|
2018-09-20 09:37:54 +00:00
|
|
|
- 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
|
2018-05-22 21:12:32 +00:00
|
|
|
|
2016-11-18 19:38:50 +00:00
|
|
|
# FUTURE: figure out why the last iteration of this test often fails on shippable
|
|
|
|
#- name: loop async success
|
|
|
|
# async_test:
|
|
|
|
# sleep_delay_sec: 3
|
|
|
|
# async: 10
|
|
|
|
# poll: 0
|
|
|
|
# with_sequence: start=1 end=4
|
|
|
|
# register: async_many
|
|
|
|
#
|
|
|
|
#- name: wait for completion
|
|
|
|
# async_status:
|
|
|
|
# jid: "{{ item }}"
|
|
|
|
# register: asyncout
|
2018-07-30 08:41:49 +00:00
|
|
|
# until: asyncout is finished
|
2016-11-18 19:38:50 +00:00
|
|
|
# retries: 10
|
|
|
|
# delay: 1
|
|
|
|
# with_items: "{{ async_many.results | map(attribute='ansible_job_id') | list }}"
|
|
|
|
#
|
|
|
|
#- name: validate results
|
|
|
|
# assert:
|
|
|
|
# that:
|
|
|
|
# - item.finished == 1
|
2018-07-30 08:41:49 +00:00
|
|
|
# - item is finished
|
2016-11-18 19:38:50 +00:00
|
|
|
# - item.slept_sec == 3
|
2018-07-30 08:41:49 +00:00
|
|
|
# - item is changed
|
2016-11-18 19:38:50 +00:00
|
|
|
# - item.ansible_job_id is match('\d+\.\d+')
|
|
|
|
# with_items: "{{ asyncout.results }}"
|
2016-09-07 00:38:12 +00:00
|
|
|
|
|
|
|
# this part of the test is flaky- Windows PIDs are reused aggressively, so this occasionally fails due to a new process with the same ID
|
|
|
|
# FUTURE: consider having the test module hook to a kernel object we can poke at that gets signaled/released on exit
|
|
|
|
#- name: ensure that all watchdog and module procs have exited
|
|
|
|
# raw: Get-Process | Where { $_.Id -in ({{ asyncout.results | join(',', attribute='ansible_async_watchdog_pid') }}, {{ asyncout.results | join(',', attribute='module_pid') }}) }
|
|
|
|
# register: proclist
|
|
|
|
#
|
|
|
|
#- name: validate no processes were returned
|
|
|
|
# assert:
|
|
|
|
# that:
|
|
|
|
# - proclist.stdout.strip() == ""
|
|
|
|
|
|
|
|
# FUTURE: test junk before/after JSON
|
|
|
|
# FUTURE: verify tempdir stays through module exec
|
|
|
|
# FUTURE: verify tempdir is deleted after module exec
|
|
|
|
# FUTURE: verify tempdir is permanent with ANSIBLE_KEEP_REMOTE_FILES=1 (how?)
|
|
|
|
# FUTURE: verify binary modules work
|
|
|
|
|
|
|
|
# FUTURE: test status/return
|
|
|
|
# FUTURE: test status/cleanup
|
|
|
|
# FUTURE: test reboot/connection failure
|
|
|
|
# FUTURE: figure out how to ensure that processes and tempdirs are cleaned up in all exceptional cases
|