mirror of https://github.com/ansible/ansible.git
Add integration tests for fetch/slurp, make powershell fetch/slurp work as close as possible to existing fetch/slurp modules.
parent
ef968efa8b
commit
243cd877ae
@ -0,0 +1,168 @@
|
||||
# test code for the fetch module when using winrm connection
|
||||
# (c) 2014, Chris Church <chris@ninemoreminutes.com>
|
||||
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: clean out the test directory
|
||||
local_action: file name={{ output_dir|mandatory }} state=absent
|
||||
tags: me
|
||||
|
||||
- name: create the test directory
|
||||
local_action: file name={{ output_dir }} state=directory
|
||||
tags: me
|
||||
|
||||
- name: fetch a small file
|
||||
fetch: src="C:/Windows/win.ini" dest={{ output_dir }}
|
||||
register: fetch_small
|
||||
|
||||
- name: check fetch small result
|
||||
assert:
|
||||
that:
|
||||
- "fetch_small.changed"
|
||||
|
||||
- name: check file created by fetch small
|
||||
local_action: stat path={{ fetch_small.dest }}
|
||||
register: fetch_small_stat
|
||||
|
||||
- name: verify fetched small file exists locally
|
||||
assert:
|
||||
that:
|
||||
- "fetch_small_stat.stat.exists"
|
||||
- "fetch_small_stat.stat.isreg"
|
||||
- "fetch_small_stat.stat.md5 == fetch_small.md5sum"
|
||||
|
||||
- name: fetch the same small file
|
||||
fetch: src="C:/Windows/win.ini" dest={{ output_dir }}
|
||||
register: fetch_small_again
|
||||
|
||||
- name: check fetch small result again
|
||||
assert:
|
||||
that:
|
||||
- "not fetch_small_again.changed"
|
||||
|
||||
- name: fetch a small file to flat namespace
|
||||
fetch: src="C:/Windows/win.ini" dest="{{ output_dir }}/" flat=yes
|
||||
register: fetch_flat
|
||||
|
||||
- name: check fetch flat result
|
||||
assert:
|
||||
that:
|
||||
- "fetch_flat.changed"
|
||||
|
||||
- name: check file created by fetch flat
|
||||
local_action: stat path="{{ output_dir }}/win.ini"
|
||||
register: fetch_flat_stat
|
||||
|
||||
- name: verify fetched file exists locally in output_dir
|
||||
assert:
|
||||
that:
|
||||
- "fetch_flat_stat.stat.exists"
|
||||
- "fetch_flat_stat.stat.isreg"
|
||||
- "fetch_flat_stat.stat.md5 == fetch_flat.md5sum"
|
||||
|
||||
- name: fetch a small file to flat directory (without trailing slash)
|
||||
fetch: src="C:/Windows/win.ini" dest="{{ output_dir }}" flat=yes
|
||||
register: fetch_flat_dir
|
||||
ignore_errors: true
|
||||
|
||||
- name: check fetch flat to directory result
|
||||
assert:
|
||||
that:
|
||||
- "fetch_flat_dir|failed"
|
||||
- "fetch_flat_dir.msg"
|
||||
|
||||
- name: fetch a large binary file
|
||||
fetch: src="C:/Windows/explorer.exe" dest={{ output_dir }}
|
||||
register: fetch_large
|
||||
|
||||
- name: check fetch large binary file result
|
||||
assert:
|
||||
that:
|
||||
- "fetch_large.changed"
|
||||
|
||||
- name: check file created by fetch large binary
|
||||
local_action: stat path={{ fetch_large.dest }}
|
||||
register: fetch_large_stat
|
||||
|
||||
- name: verify fetched large file exists locally
|
||||
assert:
|
||||
that:
|
||||
- "fetch_large_stat.stat.exists"
|
||||
- "fetch_large_stat.stat.isreg"
|
||||
- "fetch_large_stat.stat.md5 == fetch_large.md5sum"
|
||||
|
||||
- name: fetch a large binary file again
|
||||
fetch: src="C:/Windows/explorer.exe" dest={{ output_dir }}
|
||||
register: fetch_large_again
|
||||
|
||||
- name: check fetch large binary file result again
|
||||
assert:
|
||||
that:
|
||||
- "not fetch_large_again.changed"
|
||||
|
||||
- name: fetch a small file using backslashes in src path
|
||||
fetch: src="C:\Windows\system.ini" dest={{ output_dir }}
|
||||
register: fetch_small_bs
|
||||
|
||||
- name: check fetch small result with backslashes
|
||||
assert:
|
||||
that:
|
||||
- "fetch_small_bs.changed"
|
||||
|
||||
- name: check file created by fetch small with backslashes
|
||||
local_action: stat path={{ fetch_small_bs.dest }}
|
||||
register: fetch_small_bs_stat
|
||||
|
||||
- name: verify fetched small file with backslashes exists locally
|
||||
assert:
|
||||
that:
|
||||
- "fetch_small_bs_stat.stat.exists"
|
||||
- "fetch_small_bs_stat.stat.isreg"
|
||||
- "fetch_small_bs_stat.stat.md5 == fetch_small_bs.md5sum"
|
||||
|
||||
- name: attempt to fetch a non-existent file - do not fail on missing
|
||||
fetch: src="C:/this_file_should_not_exist.txt" dest={{ output_dir }}
|
||||
register: fetch_missing_nofail
|
||||
|
||||
- name: check fetch missing no fail result
|
||||
assert:
|
||||
that:
|
||||
- "not fetch_missing_nofail|failed"
|
||||
- "fetch_missing_nofail.msg"
|
||||
- "not fetch_missing_nofail|changed"
|
||||
|
||||
- name: attempt to fetch a non-existent file - fail on missing
|
||||
fetch: src="C:/this_file_should_not_exist.txt" dest={{ output_dir }} fail_on_missing=yes
|
||||
register: fetch_missing
|
||||
ignore_errors: true
|
||||
|
||||
- name: check fetch missing with failure
|
||||
assert:
|
||||
that:
|
||||
- "fetch_missing|failed"
|
||||
- "fetch_missing.msg"
|
||||
- "not fetch_missing|changed"
|
||||
|
||||
- name: attempt to fetch a directory
|
||||
fetch: src="C:\Windows" dest={{ output_dir }}
|
||||
register: fetch_dir
|
||||
ignore_errors: true
|
||||
|
||||
- name: check fetch directory result
|
||||
assert:
|
||||
that:
|
||||
- "fetch_dir|failed"
|
||||
- "fetch_dir.msg"
|
@ -0,0 +1,77 @@
|
||||
# test code for the slurp module when using winrm connection
|
||||
# (c) 2014, Chris Church <chris@ninemoreminutes.com>
|
||||
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: test slurping an existing file
|
||||
slurp: src="C:/Windows/win.ini"
|
||||
register: slurp_existing
|
||||
|
||||
- name: check slurp existing result
|
||||
assert:
|
||||
that:
|
||||
- "slurp_existing.content"
|
||||
- "slurp_existing.encoding == 'base64'"
|
||||
- "not slurp_existing|changed"
|
||||
- "not slurp_existing|failed"
|
||||
|
||||
- name: test slurping a large binary file with path param and backslashes
|
||||
slurp: path="C:\Windows\explorer.exe"
|
||||
register: slurp_path_backslashes
|
||||
|
||||
- name: check slurp result with path param and backslashes
|
||||
assert:
|
||||
that:
|
||||
- "slurp_path_backslashes.content"
|
||||
- "slurp_path_backslashes.encoding == 'base64'"
|
||||
- "not slurp_path_backslashes|changed"
|
||||
- "not slurp_path_backslashes|failed"
|
||||
|
||||
- name: test slurping a non-existent file
|
||||
slurp: src="C:/this_file_should_not_exist.txt"
|
||||
register: slurp_missing
|
||||
ignore_errors: true
|
||||
|
||||
- name: check slurp missing result
|
||||
assert:
|
||||
that:
|
||||
- "slurp_missing|failed"
|
||||
- "slurp_missing.msg"
|
||||
- "not slurp_missing|changed"
|
||||
|
||||
- name: test slurping a directory
|
||||
slurp: src="C:/Windows"
|
||||
register: slurp_dir
|
||||
ignore_errors: true
|
||||
|
||||
- name: check slurp directory result
|
||||
assert:
|
||||
that:
|
||||
- "slurp_dir|failed"
|
||||
- "slurp_dir.msg"
|
||||
- "not slurp_dir|changed"
|
||||
|
||||
- name: test slurp with missing argument
|
||||
action: slurp
|
||||
register: slurp_no_args
|
||||
ignore_errors: true
|
||||
|
||||
- name: check slurp with missing argument result
|
||||
assert:
|
||||
that:
|
||||
- "slurp_no_args|failed"
|
||||
- "slurp_no_args.msg"
|
||||
- "not slurp_no_args|changed"
|
Loading…
Reference in New Issue