Skip to content

Commit

Permalink
ec2_snapshot/tests: wait until the snapshot are available (ansible-co…
Browse files Browse the repository at this point in the history
…llections#1272)

ec2_snapshot/tests: wait until the snapshots are available

Until this patch we were unconditionally waiting 3 minutes. We now query the
status until we've got our 5 snapshots available.
This will resolve failure like this one:
See: https://ansible.softwarefactory-project.io/zuul/build/e49e7dc231ac4f5990bb6c231096ded8

Reviewed-by: Mark Chappell <None>
  • Loading branch information
goneri committed Nov 16, 2022
1 parent b1d684d commit 863a2a7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- "ec2_snapshot - Improve the reliability of the functional tests(https://github.com/ansible-collections/amazon.aws/pull/1272)."
64 changes: 31 additions & 33 deletions tests/integration/targets/ec2_snapshot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,49 +236,19 @@
pause: 15
label: "Generate extra snapshots - {{ item }}"

- name: Pause to allow creation to finish
pause:
minutes: 3

# check that snapshot_ids and max_results are mutually exclusive
- name: Check that max_results and snapshot_ids are mutually exclusive
ec2_snapshot_info:
snapshot_ids:
- '{{ tagged_snapshot_id }}'
max_results: 5
ignore_errors: true
register: info_result

- name: assert that operation failed
assert:
that:
- info_result is failed

# check that snapshot_ids and next_token_id are mutually exclusive
- name: Check that snapshot_ids and next_token_id are mutually exclusive
ec2_snapshot_info:
snapshot_ids:
- '{{ tagged_snapshot_id }}'
next_token_id: 'random_value_token'
ignore_errors: true
register: info_result

- name: assert that operation failed
assert:
that:
- info_result is failed

# Retrieve snapshots in paginated mode
- name: Get snapshots in paginated mode using max_results option
ec2_snapshot_info:
filters:
"tag:Name": '{{ resource_prefix }}'
max_results: 5
register: info_result
until: "info_result.snapshots | length == 5"
retries: 10
delay: 30

- assert:
that:
- info_result.snapshots | length == 5
- info_result.next_token_id is defined

# Pagination : 2nd request
Expand All @@ -305,6 +275,34 @@
that:
- delete_result_check_mode is changed

# check that snapshot_ids and max_results are mutually exclusive
- name: Check that max_results and snapshot_ids are mutually exclusive
ec2_snapshot_info:
snapshot_ids:
- '{{ tagged_snapshot_id }}'
max_results: 5
ignore_errors: true
register: info_result

- name: assert that operation failed
assert:
that:
- info_result is failed

# check that snapshot_ids and next_token_id are mutually exclusive
- name: Check that snapshot_ids and next_token_id are mutually exclusive
ec2_snapshot_info:
snapshot_ids:
- '{{ tagged_snapshot_id }}'
next_token_id: 'random_value_token'
ignore_errors: true
register: info_result

- name: assert that operation failed
assert:
that:
- info_result is failed

# delete the tagged snapshot
- name: Delete the tagged snapshot
ec2_snapshot:
Expand Down

0 comments on commit 863a2a7

Please sign in to comment.