Skip to content

Commit

Permalink
Add testcase to test mutually exclusive values
Browse files Browse the repository at this point in the history
  • Loading branch information
GomathiselviS committed Oct 17, 2022
1 parent 5a96dd3 commit fe01d57
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/integration/targets/cloudwatch_metric_alarm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,43 @@
that:
- 'alarm_info_no_unit.metric_alarms | length == 0'

- name: create ec2 metric alarm by providing mutually exclusive values
ec2_metric_alarm:
dimensions:
InstanceId: '{{ ec2_instance_results.instances[0].instance_id }}'
state: present
name: '{{ alarm_full_name }}'
metric: CPUUtilization
namespace: AWS/EC2
treat_missing_data: missing
statistic: Average
comparison: LessThanOrEqualToThreshold
threshold: 5.0
period: 300
evaluation_periods: 3
description: This will alarm when an instance's cpu usage average is lower than
5% for 15 minutes
metrics:
- id: cpu
metric_stat:
metric:
dimensions:
- name: "InstanceId"
value: "{{ ec2_instance_results.instances[0].instance_id }}"
metric_name: "CPUUtilization"
namespace: "AWS/EC2"
period: 300
stat: "Average"
unit: "Percent"
return_data: true
register: ec2_instance_metric_mutually_exclusive
ignore_errors: true

- assert:
that:
- ec2_instance_metric_mutually_exclusive.failed
- '"parameters are mutually exclusive" in ec2_instance_metric_mutually_exclusive.msg'

always:
- name: try to delete the alarm
ec2_metric_alarm:
Expand Down

0 comments on commit fe01d57

Please sign in to comment.