mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 07:31:23 -07:00
archive - staging idempotency fix (#2987)
* Initial Commit * Fixing PY26 filter * Adding changelog fragment * Removing checksum related code * Removing list comparisons due to Jinja errors * Applying review suggestions * Applying review suggestions - typos
This commit is contained in:
parent
7b9687f758
commit
9fd2ba60df
5 changed files with 179 additions and 19 deletions
|
@ -121,6 +121,13 @@
|
|||
loop_control:
|
||||
loop_var: format
|
||||
|
||||
- name: Run Idempotency tests
|
||||
include_tasks:
|
||||
file: ../tests/idempotency.yml
|
||||
loop: "{{ formats }}"
|
||||
loop_control:
|
||||
loop_var: format
|
||||
|
||||
# Test cleanup
|
||||
- name: Remove backports.lzma if previously installed (pip)
|
||||
pip: name=backports.lzma state=absent
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
- archive_no_options is changed
|
||||
- "archive_no_options.dest_state == 'archive'"
|
||||
- "{{ archive_no_options.archived | length }} == 3"
|
||||
-
|
||||
|
||||
- name: Remove the archive - no options ({{ format }})
|
||||
file:
|
||||
path: "{{ output_dir }}/archive_no_options.{{ format }}"
|
||||
|
|
141
tests/integration/targets/archive/tests/idempotency.yml
Normal file
141
tests/integration/targets/archive/tests/idempotency.yml
Normal file
|
@ -0,0 +1,141 @@
|
|||
---
|
||||
- name: Archive - file content idempotency ({{ format }})
|
||||
archive:
|
||||
path: "{{ output_dir }}/*.txt"
|
||||
dest: "{{ output_dir }}/archive_file_content_idempotency.{{ format }}"
|
||||
format: "{{ format }}"
|
||||
register: file_content_idempotency_before
|
||||
|
||||
- name: Modify file - file content idempotency ({{ format }})
|
||||
lineinfile:
|
||||
line: bar.txt
|
||||
regexp: "^foo.txt$"
|
||||
path: "{{ output_dir }}/foo.txt"
|
||||
|
||||
- name: Archive second time - file content idempotency ({{ format }})
|
||||
archive:
|
||||
path: "{{ output_dir }}/*.txt"
|
||||
dest: "{{ output_dir }}/archive_file_content_idempotency.{{ format }}"
|
||||
format: "{{ format }}"
|
||||
register: file_content_idempotency_after
|
||||
|
||||
# After idempotency fix result will be reliably changed for all formats
|
||||
- name: Assert task status is changed - file content idempotency ({{ format }})
|
||||
assert:
|
||||
that:
|
||||
- file_content_idempotency_after is not changed
|
||||
when: "format in ('tar', 'zip')"
|
||||
|
||||
- name: Remove archive - file content idempotency ({{ format }})
|
||||
file:
|
||||
path: "{{ output_dir }}/archive_file_content_idempotency.{{ format }}"
|
||||
state: absent
|
||||
|
||||
- name: Modify file back - file content idempotency ({{ format }})
|
||||
lineinfile:
|
||||
line: foo.txt
|
||||
regexp: "^bar.txt$"
|
||||
path: "{{ output_dir }}/foo.txt"
|
||||
|
||||
- name: Archive - file name idempotency ({{ format }})
|
||||
archive:
|
||||
path: "{{ output_dir }}/*.txt"
|
||||
dest: "{{ output_dir }}/archive_file_name_idempotency.{{ format }}"
|
||||
format: "{{ format }}"
|
||||
register: file_name_idempotency_before
|
||||
|
||||
- name: Rename file - file name idempotency ({{ format }})
|
||||
command: "mv {{ output_dir}}/foo.txt {{ output_dir }}/fii.txt"
|
||||
|
||||
- name: Archive again - file name idempotency ({{ format }})
|
||||
archive:
|
||||
path: "{{ output_dir }}/*.txt"
|
||||
dest: "{{ output_dir }}/archive_file_name_idempotency.{{ format }}"
|
||||
format: "{{ format }}"
|
||||
register: file_name_idempotency_after
|
||||
|
||||
# After idempotency fix result will be reliably changed for all formats
|
||||
- name: Check task status - file name idempotency ({{ format }})
|
||||
assert:
|
||||
that:
|
||||
- file_name_idempotency_after is not changed
|
||||
when: "format in ('tar', 'zip')"
|
||||
|
||||
- name: Remove archive - file name idempotency ({{ format }})
|
||||
file:
|
||||
path: "{{ output_dir }}/archive_file_name_idempotency.{{ format }}"
|
||||
state: absent
|
||||
|
||||
- name: Rename file back - file name idempotency ({{ format }})
|
||||
command: "mv {{ output_dir }}/fii.txt {{ output_dir }}/foo.txt"
|
||||
|
||||
- name: Archive - single file content idempotency ({{ format }})
|
||||
archive:
|
||||
path: "{{ output_dir }}/foo.txt"
|
||||
dest: "{{ output_dir }}/archive_single_file_content_idempotency.{{ format }}"
|
||||
format: "{{ format }}"
|
||||
register: single_file_content_idempotency_before
|
||||
|
||||
- name: Modify file - single file content idempotency ({{ format }})
|
||||
lineinfile:
|
||||
line: bar.txt
|
||||
regexp: "^foo.txt$"
|
||||
path: "{{ output_dir }}/foo.txt"
|
||||
|
||||
- name: Archive second time - single file content idempotency ({{ format }})
|
||||
archive:
|
||||
path: "{{ output_dir }}/foo.txt"
|
||||
dest: "{{ output_dir }}/archive_single_file_content_idempotency.{{ format }}"
|
||||
format: "{{ format }}"
|
||||
register: single_file_content_idempotency_after
|
||||
|
||||
# After idempotency fix result will be reliably changed for all formats
|
||||
- name: Assert task status is changed - single file content idempotency ({{ format }})
|
||||
assert:
|
||||
that:
|
||||
- single_file_content_idempotency_after is not changed
|
||||
when: "format in ('tar', 'zip')"
|
||||
|
||||
- name: Remove archive - single file content idempotency ({{ format }})
|
||||
file:
|
||||
path: "{{ output_dir }}/archive_single_file_content_idempotency.{{ format }}"
|
||||
state: absent
|
||||
|
||||
- name: Modify file back - single file content idempotency ({{ format }})
|
||||
lineinfile:
|
||||
line: foo.txt
|
||||
regexp: "^bar.txt$"
|
||||
path: "{{ output_dir }}/foo.txt"
|
||||
|
||||
- name: Archive - single file name idempotency ({{ format }})
|
||||
archive:
|
||||
path: "{{ output_dir }}/foo.txt"
|
||||
dest: "{{ output_dir }}/archive_single_file_name_idempotency.{{ format }}"
|
||||
format: "{{ format }}"
|
||||
register: single_file_name_idempotency_before
|
||||
|
||||
- name: Rename file - single file name idempotency ({{ format }})
|
||||
command: "mv {{ output_dir}}/foo.txt {{ output_dir }}/fii.txt"
|
||||
|
||||
- name: Archive again - single file name idempotency ({{ format }})
|
||||
archive:
|
||||
path: "{{ output_dir }}/fii.txt"
|
||||
dest: "{{ output_dir }}/archive_single_file_name_idempotency.{{ format }}"
|
||||
format: "{{ format }}"
|
||||
register: single_file_name_idempotency_after
|
||||
|
||||
|
||||
# After idempotency fix result will be reliably changed for all formats
|
||||
- name: Check task status - single file name idempotency ({{ format }})
|
||||
assert:
|
||||
that:
|
||||
- single_file_name_idempotency_after is not changed
|
||||
when: "format in ('tar', 'zip')"
|
||||
|
||||
- name: Remove archive - single file name idempotency ({{ format }})
|
||||
file:
|
||||
path: "{{ output_dir }}/archive_single_file_name_idempotency.{{ format }}"
|
||||
state: absent
|
||||
|
||||
- name: Rename file back - single file name idempotency ({{ format }})
|
||||
command: "mv {{ output_dir }}/fii.txt {{ output_dir }}/foo.txt"
|
Loading…
Add table
Add a link
Reference in a new issue