Skip to content

Commit e17eace

Browse files
akinrosslhercot
authored andcommitted
[ignore] added tests for aci_epg_monitoring_policy module
1 parent c824b84 commit e17eace

File tree

2 files changed

+163
-0
lines changed

2 files changed

+163
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# No ACI simulator yet, so not enabled
2+
# unsupported
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Test code for the ACI modules
2+
# Copyright: (c) 2023, Akini Ross ([email protected])
3+
4+
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
5+
6+
- name: Test that we have an ACI APIC host, ACI username and ACI password
7+
ansible.builtin.fail:
8+
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
9+
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
10+
11+
- name: Set vars
12+
ansible.builtin.set_fact:
13+
aci_info: &aci_info
14+
host: "{{ aci_hostname }}"
15+
username: "{{ aci_username }}"
16+
password: "{{ aci_password }}"
17+
validate_certs: '{{ aci_validate_certs | default(false) }}'
18+
use_ssl: '{{ aci_use_ssl | default(true) }}'
19+
use_proxy: '{{ aci_use_proxy | default(true) }}'
20+
output_level: '{{ aci_output_level | default("info") }}'
21+
aci_tenant: ansible_test
22+
23+
- name: Verify Cloud and Non-Cloud Sites in use.
24+
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
25+
26+
- name: Execute tasks only for non-cloud sites
27+
when:
28+
- query_cloud.current == []
29+
block:
30+
31+
# CLEAN TEST ENVIRONMENT
32+
33+
- name: Ensure clean tenant configuration
34+
cisco.aci.aci_tenant:
35+
<<: *aci_info
36+
tenant: "{{ aci_tenant }}"
37+
state: "{{ item }}"
38+
loop:
39+
- absent
40+
- present
41+
42+
# TEST CREATE EPG MONITORING POLICY
43+
44+
- name: Add epg monitoring policy 1 ( check mode )
45+
cisco.aci.aci_epg_monitoring_policy: &add_epg_monitoring_policy_1
46+
<<: *aci_info
47+
tenant: "{{ aci_tenant }}"
48+
monitoring_policy: monitoring_policy_1
49+
state: present
50+
check_mode: true
51+
register: cm_add_epg_monitoring_policy_1
52+
53+
- name: Add epg monitoring policy 1
54+
cisco.aci.aci_epg_monitoring_policy:
55+
<<: *add_epg_monitoring_policy_1
56+
register: nm_add_epg_monitoring_policy_1
57+
58+
- name: Add epg monitoring policy 1 again
59+
cisco.aci.aci_epg_monitoring_policy:
60+
<<: *add_epg_monitoring_policy_1
61+
register: nm_add_epg_monitoring_policy_1_again
62+
63+
- name: Verify add epg monitoring policy 1
64+
ansible.builtin.assert:
65+
that:
66+
- cm_add_epg_monitoring_policy_1 is changed
67+
- cm_add_epg_monitoring_policy_1.current == []
68+
- cm_add_epg_monitoring_policy_1.previous == []
69+
- cm_add_epg_monitoring_policy_1.proposed.monEPGPol.attributes.name == "monitoring_policy_1"
70+
- nm_add_epg_monitoring_policy_1 is changed
71+
- nm_add_epg_monitoring_policy_1.previous == []
72+
- nm_add_epg_monitoring_policy_1.current.0.monEPGPol.attributes.name == "monitoring_policy_1"
73+
- nm_add_epg_monitoring_policy_1.current.0.monEPGPol.attributes.descr == ""
74+
- nm_add_epg_monitoring_policy_1_again is not changed
75+
- nm_add_epg_monitoring_policy_1_again.previous.0.monEPGPol.attributes.name == "monitoring_policy_1"
76+
- nm_add_epg_monitoring_policy_1_again.previous.0.monEPGPol.attributes.descr == ""
77+
- nm_add_epg_monitoring_policy_1_again.current.0.monEPGPol.attributes.name == "monitoring_policy_1"
78+
- nm_add_epg_monitoring_policy_1_again.current.0.monEPGPol.attributes.descr == ""
79+
80+
- name: Change epg monitoring policy 1
81+
cisco.aci.aci_epg_monitoring_policy:
82+
<<: *add_epg_monitoring_policy_1
83+
description: "changed description"
84+
register: nm_change_epg_monitoring_policy_1
85+
86+
- name: Verify change epg monitoring policy 1
87+
ansible.builtin.assert:
88+
that:
89+
- nm_change_epg_monitoring_policy_1 is changed
90+
- nm_change_epg_monitoring_policy_1.previous.0.monEPGPol.attributes.name == "monitoring_policy_1"
91+
- nm_change_epg_monitoring_policy_1.previous.0.monEPGPol.attributes.descr == ""
92+
- nm_change_epg_monitoring_policy_1.current.0.monEPGPol.attributes.name == "monitoring_policy_1"
93+
- nm_change_epg_monitoring_policy_1.current.0.monEPGPol.attributes.descr == "changed description"
94+
95+
- name: Add two more epg monitoring policies
96+
cisco.aci.aci_epg_monitoring_policy:
97+
<<: *aci_info
98+
tenant: "{{ aci_tenant }}"
99+
monitoring_policy: "{{ item }}"
100+
state: present
101+
loop:
102+
- monitoring_policy_2
103+
- monitoring_policy_3
104+
105+
# TEST QUERY EPG MONITORING POLICY
106+
107+
- name: Query epg monitoring policy 1
108+
cisco.aci.aci_epg_monitoring_policy:
109+
<<: *add_epg_monitoring_policy_1
110+
state: query
111+
register: query_one
112+
113+
- name: Query all epg monitoring policies ( class query )
114+
cisco.aci.aci_epg_monitoring_policy:
115+
<<: *aci_info
116+
state: query
117+
register: query_all
118+
119+
- name: Verify query epg monitoring policies
120+
ansible.builtin.assert:
121+
that:
122+
- query_one is not changed
123+
- query_one.current | length == 1
124+
- query_one.current.0.monEPGPol.attributes.name == "monitoring_policy_1"
125+
- query_all is not changed
126+
- query_all.current | length >= 4
127+
- query_all.current.0.monEPGPol.attributes.name == "default"
128+
- query_all.current.1.monEPGPol.attributes.name == "monitoring_policy_1"
129+
- query_all.current.2.monEPGPol.attributes.name == "monitoring_policy_2"
130+
- query_all.current.3.monEPGPol.attributes.name == "monitoring_policy_3"
131+
132+
# TEST REMOVAL EPG MONITORING POLICY
133+
134+
- name: Remove aepg monitoring policy 1 ( check mode )
135+
cisco.aci.aci_epg_monitoring_policy: &remove_epg_monitoring_policy_1
136+
<<: *add_epg_monitoring_policy_1
137+
state: absent
138+
check_mode: true
139+
register: cm_remove_epg_monitoring_policy_1
140+
141+
- name: Remove epg monitoring policy 1
142+
cisco.aci.aci_epg_monitoring_policy:
143+
<<: *remove_epg_monitoring_policy_1
144+
register: nm_remove_epg_monitoring_policy_1
145+
146+
- name: Remove epg monitoring policy 1 again
147+
cisco.aci.aci_epg_monitoring_policy:
148+
<<: *remove_epg_monitoring_policy_1
149+
register: nm_remove_epg_monitoring_policy_1_again
150+
151+
- name: Verify removal epg monitoring policies
152+
ansible.builtin.assert:
153+
that:
154+
- cm_remove_epg_monitoring_policy_1 is changed
155+
- cm_remove_epg_monitoring_policy_1.proposed == {}
156+
- nm_remove_epg_monitoring_policy_1 is changed
157+
- nm_remove_epg_monitoring_policy_1.previous.0.monEPGPol.attributes.name == "monitoring_policy_1"
158+
- nm_remove_epg_monitoring_policy_1.current == []
159+
- nm_remove_epg_monitoring_policy_1_again is not changed
160+
- nm_remove_epg_monitoring_policy_1_again.previous == []
161+
- nm_remove_epg_monitoring_policy_1_again.current == []

0 commit comments

Comments
 (0)