forked from ansible-collections/amazon.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.
cloudwatchlogs: Condense cloudwatch tests (ansible-collections#1395)
cloudwatchlogs: Condense cloudwatch tests SUMMARY Merging tests for cloudwatchlogs and cloudwatchlogs_log_group into combined suite cloudwatchlogs. There are 2 test suites in community.aws with substantially overlapping functionality - cloudwatchlogs and cloudwatch_log_group. The cloudwatchlogs runs for changes to the cloudwatchlogs_log_group and cloudwatchlogs_log_group_metric_filter modules, and the cloudwatch_log_group only runs for cloudwatchlogs_log_group_info. Merging the 2 test suites to create a combined suite for testing the overlapping functionalities could be a good idea. ISSUE TYPE Feature Pull Request COMPONENT NAME cloudwatchlogs cloudwatchlogs_log_group Reviewed-by: Mike Graves <[email protected]> Reviewed-by: Jill R <None>
- Loading branch information
Showing
9 changed files
with
335 additions
and
334 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
changelogs/fragments/1395-cloudwatchlogs-condense-integration-tests.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,3 @@ | ||
minor_changes: | ||
- cloudwatchlogs_log_group - Condensed integration test suites `cloudwatchlogs` and `cloudwatchlogs_log_group` into combined suite `cloudwatchlogs` (https://github.com/ansible-collections/community.aws/pull/1395). | ||
- cloudwatchlogs - This combined integration test suite covers tests for `cloudwatchlogs_log_group`, `cloudwatchlogs_log_group_info`, and `cloudwatchlogs_log_group_metric_filter` (https://github.com/ansible-collections/community.aws/pull/1395). |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
cloud/aws | ||
|
||
cloudwatchlogs_log_group | ||
cloudwatchlogs_log_group_info | ||
cloudwatchlogs_log_group_metric_filter |
152 changes: 152 additions & 0 deletions
152
tests/integration/targets/cloudwatchlogs/tasks/cloudwatchlogs_tests.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,152 @@ | ||
--- | ||
# Tests for changes to the cloudwatchlogs_log_group and cloudwatchlogs_log_group_metric_filter | ||
|
||
- block: | ||
|
||
- name: create cloudwatch log group for integration test | ||
cloudwatchlogs_log_group: | ||
state: present | ||
log_group_name: '{{ log_group_name }}' | ||
retention: 1 | ||
|
||
- name: check_mode set metric filter on '{{ log_group_name }}' | ||
cloudwatchlogs_log_group_metric_filter: | ||
log_group_name: '{{ log_group_name }}' | ||
filter_name: '{{ filter_name }}' | ||
filter_pattern: '{ ($.value = *) && ($.hostname = "box")}' | ||
state: present | ||
metric_transformation: | ||
metric_name: box_free_space | ||
metric_namespace: fluentd_metrics | ||
metric_value: "$.value" | ||
check_mode: yes | ||
register: out | ||
|
||
- name: check_mode state must be changed | ||
assert: | ||
that: | ||
- out is changed | ||
- out.metric_filters | count == 1 | ||
|
||
- name: set metric filter on '{{ log_group_name }}' | ||
cloudwatchlogs_log_group_metric_filter: | ||
log_group_name: '{{ log_group_name }}' | ||
filter_name: '{{ filter_name }}' | ||
filter_pattern: '{ ($.value = *) && ($.hostname = "box")}' | ||
state: present | ||
metric_transformation: | ||
metric_name: box_free_space | ||
metric_namespace: fluentd_metrics | ||
metric_value: "$.value" | ||
register: out | ||
|
||
- name: create metric filter | ||
assert: | ||
that: | ||
- out is changed | ||
- out.metric_filters | count == 1 | ||
|
||
- name: re-set metric filter on '{{ log_group_name }}' | ||
cloudwatchlogs_log_group_metric_filter: | ||
log_group_name: '{{ log_group_name }}' | ||
filter_name: '{{ filter_name }}' | ||
filter_pattern: '{ ($.value = *) && ($.hostname = "box")}' | ||
state: present | ||
metric_transformation: | ||
metric_name: box_free_space | ||
metric_namespace: fluentd_metrics | ||
metric_value: "$.value" | ||
register: out | ||
|
||
- name: metric filter must not change | ||
assert: | ||
that: | ||
- out is not changed | ||
|
||
- name: update metric transformation on '{{ log_group_name }}' | ||
cloudwatchlogs_log_group_metric_filter: | ||
log_group_name: '{{ log_group_name }}' | ||
filter_name: '{{ filter_name }}' | ||
filter_pattern: '{ ($.value = *) && ($.hostname = "box")}' | ||
state: present | ||
metric_transformation: | ||
metric_name: box_free_space | ||
metric_namespace: made_with_ansible | ||
metric_value: "$.value" | ||
default_value: 3.1415 | ||
register: out | ||
|
||
- name: update metric filter | ||
assert: | ||
that: | ||
- out is changed | ||
- out.metric_filters[0].metric_namespace == "made_with_ansible" | ||
- out.metric_filters[0].default_value == 3.1415 | ||
|
||
- name: update filter_pattern on '{{ log_group_name }}' | ||
cloudwatchlogs_log_group_metric_filter: | ||
log_group_name: '{{ log_group_name }}' | ||
filter_name: '{{ filter_name }}' | ||
filter_pattern: '{ ($.value = *) && ($.hostname = "ansible")}' | ||
state: present | ||
metric_transformation: | ||
metric_name: box_free_space | ||
metric_namespace: made_with_ansible | ||
metric_value: "$.value" | ||
register: out | ||
|
||
- name: update metric filter | ||
assert: | ||
that: | ||
- out is changed | ||
- out.metric_filters[0].metric_namespace == "made_with_ansible" | ||
|
||
- name: checkmode delete metric filter on '{{ log_group_name }}' | ||
cloudwatchlogs_log_group_metric_filter: | ||
log_group_name: '{{ log_group_name }}' | ||
filter_name: '{{ filter_name }}' | ||
state: absent | ||
check_mode: yes | ||
register: out | ||
|
||
- name: check_mode state must be changed | ||
assert: | ||
that: | ||
- out is changed | ||
|
||
- name: delete metric filter on '{{ log_group_name }}' | ||
cloudwatchlogs_log_group_metric_filter: | ||
log_group_name: '{{ log_group_name }}' | ||
filter_name: '{{ filter_name }}' | ||
state: absent | ||
register: out | ||
|
||
- name: delete metric filter | ||
assert: | ||
that: | ||
- out is changed | ||
|
||
- name: delete metric filter on '{{ log_group_name }}' which does not exist | ||
cloudwatchlogs_log_group_metric_filter: | ||
log_group_name: '{{ log_group_name }}' | ||
filter_name: '{{ filter_name }}' | ||
state: absent | ||
register: out | ||
|
||
- name: delete metric filter | ||
assert: | ||
that: | ||
- out is not changed | ||
|
||
always: | ||
- name: delete metric filter | ||
cloudwatchlogs_log_group_metric_filter: | ||
log_group_name: '{{ log_group_name }}' | ||
filter_name: '{{ filter_name }}' | ||
state: absent | ||
|
||
- name: delete cloudwatch log group for integration test | ||
cloudwatchlogs_log_group: | ||
state: absent | ||
log_group_name: '{{ log_group_name }}' | ||
ignore_errors: true |
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
Oops, something went wrong.