summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/fetch
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2017-04-26 16:24:36 +0200
committerToshio Kuratomi <a.badger@gmail.com>2017-04-26 21:00:01 +0200
commitbffccb53967af4cdd1d29b3a007d2fe7cd7bcb22 (patch)
tree3b6e7db869ccba638f22b8e46e4be4b6368c7184 /test/integration/targets/fetch
parentSet validate_checksum default yes of fetch to match the doc (diff)
downloadansible-bffccb53967af4cdd1d29b3a007d2fe7cd7bcb22.tar.xz
ansible-bffccb53967af4cdd1d29b3a007d2fe7cd7bcb22.zip
fetch idempotence test and deprecate validate_md5
Added an integration test for fetch module idempotence. (Testing that validate_checksum is doing what it's supposed to is harder as we'd have to create a race condition with the downloaded data to trigger it. Probably need to make that a unittest eventually). Also give a deprecation message to the validate_md5 parameter so that we can eventually get rid of it.
Diffstat (limited to 'test/integration/targets/fetch')
-rw-r--r--test/integration/targets/fetch/tasks/main.yml17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/integration/targets/fetch/tasks/main.yml b/test/integration/targets/fetch/tasks/main.yml
index 567032fb45..ed249f7568 100644
--- a/test/integration/targets/fetch/tasks/main.yml
+++ b/test/integration/targets/fetch/tasks/main.yml
@@ -25,6 +25,13 @@
- debug: var=fetched
+- name: Assert that we fetched correctly
+ assert:
+ that:
+ - 'fetched["changed"] == True'
+ - 'fetched["checksum"] == "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"'
+ - 'fetched["remote_checksum"] == "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"'
+
# TODO: check the become and non-become forms of fetch because in one form we'll do
# the get method of the connection plugin and in the become case we'll use the
# fetch module.
@@ -38,6 +45,16 @@
that:
'diff.stdout == ""'
+- name: fetch a second time to show idempotence
+ fetch: src={{ output_dir }}/orig dest={{ output_dir }}/fetched
+ register: fetched
+
+- name: Assert that the file was not fetched the second time
+ assert:
+ that:
+ - 'fetched["changed"] == False'
+ - 'fetched["checksum"] == "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"'
+
- name: attempt to fetch a non-existent file - do not fail on missing
fetch: src={{ output_dir }}/doesnotexist dest={{ output_dir }}/fetched
register: fetch_missing_nofail