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.
This commit is contained in:
parent
98e7d4b49d
commit
bffccb5396
2 changed files with 21 additions and 0 deletions
|
@ -48,11 +48,15 @@ class ActionModule(ActionBase):
|
||||||
fail_on_missing = boolean(self._task.args.get('fail_on_missing'))
|
fail_on_missing = boolean(self._task.args.get('fail_on_missing'))
|
||||||
validate_checksum = boolean(self._task.args.get('validate_checksum', self._task.args.get('validate_md5', True)))
|
validate_checksum = boolean(self._task.args.get('validate_checksum', self._task.args.get('validate_md5', True)))
|
||||||
|
|
||||||
|
# validate_md5 is the deprecated way to specify validate_checksum
|
||||||
if 'validate_md5' in self._task.args and 'validate_checksum' in self._task.args:
|
if 'validate_md5' in self._task.args and 'validate_checksum' in self._task.args:
|
||||||
result['failed'] = True
|
result['failed'] = True
|
||||||
result['msg'] = "validate_checksum and validate_md5 cannot both be specified"
|
result['msg'] = "validate_checksum and validate_md5 cannot both be specified"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
if 'validate_md5' in self._task.args:
|
||||||
|
display.deprecated('Use validate_checksum instead of validate_md5', version='2.8')
|
||||||
|
|
||||||
if source is None or dest is None:
|
if source is None or dest is None:
|
||||||
result['failed'] = True
|
result['failed'] = True
|
||||||
result['msg'] = "src and dest are required"
|
result['msg'] = "src and dest are required"
|
||||||
|
|
|
@ -25,6 +25,13 @@
|
||||||
|
|
||||||
- debug: var=fetched
|
- 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
|
# 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
|
# the get method of the connection plugin and in the become case we'll use the
|
||||||
# fetch module.
|
# fetch module.
|
||||||
|
@ -38,6 +45,16 @@
|
||||||
that:
|
that:
|
||||||
'diff.stdout == ""'
|
'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
|
- name: attempt to fetch a non-existent file - do not fail on missing
|
||||||
fetch: src={{ output_dir }}/doesnotexist dest={{ output_dir }}/fetched
|
fetch: src={{ output_dir }}/doesnotexist dest={{ output_dir }}/fetched
|
||||||
register: fetch_missing_nofail
|
register: fetch_missing_nofail
|
||||||
|
|
Loading…
Reference in a new issue