diff --git a/changelogs/fragments/ec2_snapshot_tests_improve_reliability.yaml b/changelogs/fragments/ec2_snapshot_tests_improve_reliability.yaml new file mode 100644 index 00000000000..298bf76c2e1 --- /dev/null +++ b/changelogs/fragments/ec2_snapshot_tests_improve_reliability.yaml @@ -0,0 +1,3 @@ +--- +trivial: +- "ec2_snapshot - Improve the reliability of the functional tests(https://github.com/ansible-collections/amazon.aws/pull/1272)." diff --git a/tests/integration/targets/ec2_snapshot/tasks/main.yml b/tests/integration/targets/ec2_snapshot/tasks/main.yml index 5feff2012c6..3f05cedbf02 100644 --- a/tests/integration/targets/ec2_snapshot/tasks/main.yml +++ b/tests/integration/targets/ec2_snapshot/tasks/main.yml @@ -236,38 +236,6 @@ 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: @@ -275,10 +243,12 @@ "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 @@ -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: