forked from ansible-collections/community.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
autoscaling_instance_refresh - prepare modules for promotion (ansible…
…-collections#2150) SUMMARY Closes ansible-collections#2120 Closes ansible-collections#2019 Closes ansible-collections#2016 Prepare modules autoscaling_instance_refresh and autoscaling_instance_refresh_info for promotion: Refactor modules to use common code from ansible_collections.amazon.aws.plugins.module_utils.autoscaling Add type hinting Update integration tests ISSUE TYPE Feature Pull Request Reviewed-by: GomathiselviS Reviewed-by: Bikouo Aubin Reviewed-by: Alina Buzachis
- Loading branch information
1 parent
d1a9637
commit 1790f0c
Showing
9 changed files
with
625 additions
and
553 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
changelogs/fragments/20240920-refactor-autoscaling_instance_refresh-modules.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,7 @@ | ||
--- | ||
bugfixes: | ||
- autoscaling_instance_refresh - Fix typo in module ``exit_json`` (https://github.com/ansible-collections/community.aws/issues/2019). | ||
minor_changes: | ||
- autoscaling_instance_refresh - refactor module to use shared code from ``ansible_collections.amazon.aws.plugins.module_utils.autoscaling`` and add type hinting (https://github.com/ansible-collections/community.aws/pull/2150). | ||
- autoscaling_instance_refresh - Add support for ``skip_matching`` and ``max_healthy_percentage`` in ``preference`` (https://github.com/ansible-collections/community.aws/pull/2150). | ||
- autoscaling_instance_refresh_info - refactor module to use shared code from ``ansible_collections.amazon.aws.plugins.module_utils.autoscaling`` and add type hinting (https://github.com/ansible-collections/community.aws/pull/2150). |
Large diffs are not rendered by default.
Oops, something went wrong.
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
99 changes: 99 additions & 0 deletions
99
tests/integration/targets/autoscaling_instance_refresh/tasks/instance_refresh_info.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,99 @@ | ||
--- | ||
- name: Test getting info for an ASG name | ||
autoscaling_instance_refresh_info: | ||
name: "{{ asg_name }}" | ||
register: output | ||
|
||
- name: Assert that the correct number of records are returned | ||
assert: | ||
that: | ||
- output.instance_refreshes | map(attribute='instance_refresh_id') | unique | length == 7 | ||
|
||
- name: Test using fake refresh ID | ||
autoscaling_instance_refresh_info: | ||
name: "{{ asg_name }}" | ||
ids: ['0e367f58-blabla-bla-bla-ca870dc5dbfe'] | ||
register: output | ||
|
||
- name: Assert that no record is returned | ||
assert: | ||
that: | ||
- output.instance_refreshes | length == 0 | ||
|
||
- name: Test using a real refresh ID | ||
autoscaling_instance_refresh_info: | ||
name: "{{ asg_name }}" | ||
ids: [ '{{ refreshout.instance_refreshes.instance_refresh_id }}' ] | ||
register: output | ||
|
||
- name: Assert that the correct record is returned | ||
assert: | ||
that: | ||
- output.instance_refreshes | length == 1 | ||
|
||
- name: Test getting info for an ASG name which doesn't exist | ||
autoscaling_instance_refresh_info: | ||
name: n0n3x1stentname27b | ||
ignore_errors: true | ||
register: output | ||
|
||
- name: Assert that module failed to return record | ||
assert: | ||
that: | ||
- "'Failed to describe InstanceRefreshes: An error occurred (ValidationError) when calling the DescribeInstanceRefreshes operation: AutoScalingGroup name not found - AutoScalingGroup n0n3x1stentname27b not found' in output.msg" | ||
|
||
- name: Retrieve instance refresh info | ||
autoscaling_instance_refresh_info: | ||
name: "{{ asg_name }}" | ||
register: output | ||
|
||
- name: Assert that the correct number of records are returned | ||
assert: | ||
that: | ||
- output.instance_refreshes | length == 7 | ||
|
||
- name: Retrieve instance refresh info using next_token | ||
autoscaling_instance_refresh_info: | ||
name: "{{ asg_name }}" | ||
next_token: "fake-token-123" | ||
ignore_errors: true | ||
register: output | ||
|
||
- name: Assert that valid message with fake-token is returned | ||
assert: | ||
that: | ||
- '"Failed to describe InstanceRefreshes: An error occurred (InvalidNextToken) when calling the DescribeInstanceRefreshes operation: The token ''********'' is invalid." in output.msg' | ||
|
||
- name: Retrieve instance refresh info using max_records | ||
autoscaling_instance_refresh_info: | ||
name: "{{ asg_name }}" | ||
max_records: 1 | ||
register: output_with_token | ||
|
||
- name: Assert that max records=1 returns no more than one record | ||
assert: | ||
that: | ||
- output_with_token.instance_refreshes | length == 1 | ||
|
||
- name: Retrieve instance refresh using valid token | ||
autoscaling_instance_refresh_info: | ||
name: "{{ asg_name }}" | ||
next_token: "{{ output_with_token.next_token }}" | ||
register: output | ||
|
||
- name: Assert that valid message with real-token is returned | ||
assert: | ||
that: | ||
- output.instance_refreshes | length == 6 | ||
|
||
- name: Test using both real nextToken and max_records=1 | ||
autoscaling_instance_refresh_info: | ||
name: "{{ asg_name }}" | ||
max_records: 1 | ||
next_token: "{{ output_with_token.next_token }}" | ||
register: output | ||
|
||
- name: Assert that only one instance refresh is returned | ||
assert: | ||
that: | ||
- output.instance_refreshes | length == 1 |
Oops, something went wrong.