-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration tests for quay_repository_prune
- Loading branch information
Hervé Quatremain
committed
Nov 22, 2024
1 parent
2f71a64
commit 92cc2c5
Showing
3 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
dependencies: | ||
- setup_organization | ||
... |
235 changes: 235 additions & 0 deletions
235
tests/integration/targets/quay_registry_prune/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
--- | ||
# Supporting repository | ||
- name: Ensure repository ansibletestrepo exists | ||
infra.quay_configuration.quay_repository: | ||
name: ansibletestorg/ansibletestrepo | ||
visibility: private | ||
state: present | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
|
||
- name: ERROR EXPECTED Non-existing namespace | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: nonexisting/ansibletestrepo | ||
method: tags | ||
value: 5 | ||
tag_pattern: "unstable" | ||
tag_pattern_matches: true | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
ignore_errors: true | ||
register: result | ||
|
||
- name: Ensure that the task failed | ||
ansible.builtin.assert: | ||
that: result['failed'] | ||
fail_msg: The preceding task should have failed (non-existing organization) | ||
|
||
- name: ERROR EXPECTED Wrong number of tags | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: tags | ||
value: wrong | ||
tag_pattern: "unstable" | ||
tag_pattern_matches: true | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
ignore_errors: true | ||
register: result | ||
|
||
- name: Ensure that the task failed | ||
ansible.builtin.assert: | ||
that: result['failed'] | ||
fail_msg: The preceding task should have failed (wrong number of tags) | ||
|
||
- name: ERROR EXPECTED Wrong date | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: date | ||
value: wrong | ||
tag_pattern: "unstable" | ||
tag_pattern_matches: true | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
ignore_errors: true | ||
register: result | ||
|
||
- name: Ensure that the task failed | ||
ansible.builtin.assert: | ||
that: result['failed'] | ||
fail_msg: The preceding task should have failed (wrong date) | ||
|
||
- name: Ensure a policy does not exist in a non-existing repository (no change) | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/nonexisting | ||
method: tags | ||
value: 5 | ||
tag_pattern: "unstable" | ||
tag_pattern_matches: true | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
state: absent | ||
register: result | ||
|
||
- name: Ensure that the task did not change anything | ||
ansible.builtin.assert: | ||
that: not result['changed'] | ||
fail_msg: The preceding task should not have changed anything | ||
|
||
- name: Ensure a tag auto-pruning policy exists | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: tags | ||
value: 5 | ||
tag_pattern: "unstable" | ||
tag_pattern_matches: false | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
|
||
- name: Ensure a tag auto-pruning policy exists (no change) | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: tags | ||
value: 5 | ||
tag_pattern: "unstable" | ||
tag_pattern_matches: false | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
register: result | ||
|
||
- name: Ensure that the task did not change anything | ||
ansible.builtin.assert: | ||
that: not result['changed'] | ||
fail_msg: The preceding task should not have changed anything | ||
|
||
- name: Ensure a date auto-pruning policy exists 1 | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: date | ||
value: 5d | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
|
||
- name: Ensure a date auto-pruning policy exists 2 | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: date | ||
value: 6w | ||
tag_pattern: "nightly" | ||
tag_pattern_matches: true | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
|
||
- name: Ensure non-existing policy is removed (no change) | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: date | ||
value: 42w | ||
tag_pattern: "nightly" | ||
tag_pattern_matches: false | ||
state: absent | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
register: result | ||
|
||
- name: Ensure that the task did not change anything | ||
ansible.builtin.assert: | ||
that: not result['changed'] | ||
fail_msg: The preceding task should not have changed anything | ||
|
||
- name: Ensure a tag auto-pruning policy is removed | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: tags | ||
value: 5 | ||
tag_pattern: "unstable" | ||
tag_pattern_matches: false | ||
state: absent | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
|
||
- name: Ensure only one tag auto-pruning policy exists | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: tags | ||
value: 50 | ||
tag_pattern: "foobar" | ||
tag_pattern_matches: true | ||
append: false | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
|
||
- name: Ensure only one tag auto-pruning policy exists (no change) | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: tags | ||
value: 50 | ||
tag_pattern: "foobar" | ||
tag_pattern_matches: true | ||
append: false | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
register: result | ||
|
||
- name: Ensure that the task did not change anything | ||
ansible.builtin.assert: | ||
that: not result['changed'] | ||
fail_msg: The preceding task should not have changed anything | ||
|
||
- name: Ensure a date auto-pruning policy exists | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: date | ||
value: 42w | ||
tag_pattern: "nightly" | ||
tag_pattern_matches: false | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
|
||
- name: Ensure only one tag auto-pruning policy is set | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: tags | ||
value: 50 | ||
tag_pattern: "foobar" | ||
tag_pattern_matches: true | ||
append: false | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
|
||
- name: Ensure the tag auto-pruning policy is removed | ||
infra.quay_configuration.quay_repository_prune: | ||
repository: ansibletestorg/ansibletestrepo | ||
method: tags | ||
value: 50 | ||
tag_pattern: "foobar" | ||
tag_pattern_matches: true | ||
append: false | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
state: absent | ||
|
||
- name: Ensure the repository is removed | ||
infra.quay_configuration.quay_repository: | ||
name: ansibletestorg/ansibletestrepo | ||
state: absent | ||
quay_host: "{{ quay_url }}" | ||
quay_token: "{{ quay_token }}" | ||
validate_certs: false | ||
... |