mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-22 08:10:20 -07:00
Inject attempts into result earlier for retry logic (#34148)
* Add integration test for missing attempts in until with failed/changed_when * Extend tests to validate additional known behaviors of do-until loops * Inject attempts into result earlier
This commit is contained in:
parent
6d3fafa2d5
commit
3d0da8f093
2 changed files with 51 additions and 3 deletions
|
@ -29,4 +29,43 @@
|
|||
- assert:
|
||||
that: runcount.stdout | int == 6 # initial + 5 retries
|
||||
|
||||
- file: path="{{ until_tempfile_path }}" state=absent
|
||||
- file:
|
||||
path: "{{ until_tempfile_path }}"
|
||||
state: absent
|
||||
|
||||
- name: Test failed_when impacting until
|
||||
shell: 'true'
|
||||
register: failed_when_until
|
||||
failed_when: True
|
||||
until: failed_when_until is successful
|
||||
retries: 3
|
||||
delay: 0.5
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- failed_when_until.attempts == 3
|
||||
|
||||
- name: Test changed_when impacting until
|
||||
shell: 'true'
|
||||
register: changed_when_until
|
||||
changed_when: False
|
||||
until: changed_when_until is changed
|
||||
retries: 3
|
||||
delay: 0.5
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- changed_when_until.attempts == 3
|
||||
|
||||
# This task shouldn't fail, previously .attempts was not available to changed_when/failed_when
|
||||
# and would cause the conditional to fail due to ``'dict object' has no attribute 'attempts'``
|
||||
# https://github.com/ansible/ansible/issues/34139
|
||||
- name: Test access to attempts in changed_when/failed_when
|
||||
shell: 'true'
|
||||
register: changed_when_attempts
|
||||
until: 1 == 0
|
||||
retries: 5
|
||||
delay: 0.5
|
||||
failed_when: changed_when_attempts.attempts > 6
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue