Skip to content

Commit

Permalink
Create extra snapshots for ec2_snapshot_info test - minimum max_resul…
Browse files Browse the repository at this point in the history
…ts is 5 (#786)

Create extra snapshots for ec2_snapshot_info test - minimum max_results is 5

This is a partial backport of PR #356 as merged into main (b7087f4).
SUMMARY
Fixes a bug in the integration test
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_snapshot_info
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
  • Loading branch information
tremble authored Apr 23, 2022
1 parent 83373dd commit 19c23db
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions tests/integration/targets/ec2_snapshot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@
# that:
# - result is changed

# Wait at least 15 seconds between concurrent volume snapshots.
- name: Prevent SnapshotCreationPerVolumeRateExceeded errors
- name: Pause to avoid SnapshotCreationPerVolumeRateExceeded
pause:
seconds: 15
seconds: 20

- name: Take snapshot and tag it
ec2_snapshot:
Expand Down Expand Up @@ -217,12 +216,30 @@
that:
- info_result.snapshots| length == 3

- name: Pause to avoid SnapshotCreationPerVolumeRateExceeded
pause:
seconds: 20

- ec2_snapshot:
volume_id: '{{ volume_id }}'
snapshot_tags:
ResourcePrefix: '{{ resource_prefix }}'
loop: '{{ range(1, 6, 1) | list }}'
loop_control:
# Anything under 15 will trigger SnapshotCreationPerVolumeRateExceeded
pause: 20
label: "Generate extra snapshots - {{ item }}"

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

# 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: 1
max_results: 5
ignore_errors: true
register: info_result

Expand Down Expand Up @@ -250,12 +267,12 @@
ec2_snapshot_info:
filters:
"tag:Name": '{{ resource_prefix }}'
max_results: 1
max_results: 5
register: info_result

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

# Pagination : 2nd request
Expand All @@ -268,8 +285,7 @@

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

# delete the tagged snapshot
- name: Delete the tagged snapshot
Expand All @@ -285,7 +301,7 @@

- assert:
that:
- info_result.snapshots| length == 2
- info_result.snapshots| length == 7
- '"{{ tagged_snapshot_id }}" not in "{{ info_result| community.general.json_query("snapshots[].snapshot_id") }}"'

- name: Delete snapshots
Expand Down

0 comments on commit 19c23db

Please sign in to comment.