Skip to content

Commit 00c90bb

Browse files
akinrosslhercot
authored andcommitted
[ignore] added tests for aci_l3out_extepg module
1 parent e17eace commit 00c90bb

File tree

2 files changed

+190
-0
lines changed

2 files changed

+190
-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: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
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+
- name: Ensure clean vrf configuration
43+
cisco.aci.aci_vrf:
44+
<<: *aci_info
45+
tenant: "{{ aci_tenant }}"
46+
vrf: vrf_1
47+
48+
- name: Ensure clean l3out configuration
49+
cisco.aci.aci_l3out:
50+
<<: *aci_info
51+
tenant: "{{ aci_tenant }}"
52+
l3out: "{{ item }}"
53+
vrf: vrf_1
54+
domain: dom_1
55+
loop:
56+
- l3out_1
57+
- l3out_2
58+
59+
# TEST CREATE L3OUT EXTERNAL EPG
60+
61+
- name: Add l3out external epg 1 ( check mode )
62+
cisco.aci.aci_l3out_extepg: &add_l3out_extepg_1
63+
<<: *aci_info
64+
tenant: "{{ aci_tenant }}"
65+
l3out: l3out_1
66+
extepg: extepg_1
67+
state: present
68+
check_mode: true
69+
register: cm_add_l3out_extepg_1
70+
71+
- name: Add l3out external epg 1
72+
cisco.aci.aci_l3out_extepg:
73+
<<: *add_l3out_extepg_1
74+
register: nm_add_l3out_extepg_1
75+
76+
- name: Add l3out external epg 1 again
77+
cisco.aci.aci_l3out_extepg:
78+
<<: *add_l3out_extepg_1
79+
register: nm_add_l3out_extepg_1_again
80+
81+
- name: Verify add l3out external epg 1
82+
ansible.builtin.assert:
83+
that:
84+
- cm_add_l3out_extepg_1 is changed
85+
- cm_add_l3out_extepg_1.current == []
86+
- cm_add_l3out_extepg_1.previous == []
87+
- cm_add_l3out_extepg_1.proposed.l3extInstP.attributes.name == "extepg_1"
88+
- nm_add_l3out_extepg_1 is changed
89+
- nm_add_l3out_extepg_1.previous == []
90+
- nm_add_l3out_extepg_1.current.0.l3extInstP.attributes.name == "extepg_1"
91+
- nm_add_l3out_extepg_1.current.0.l3extInstP.attributes.descr == ""
92+
- nm_add_l3out_extepg_1.current.0.l3extInstP.attributes.prefGrMemb == "exclude"
93+
- nm_add_l3out_extepg_1.current.0.l3extInstP.attributes.targetDscp == "unspecified"
94+
- nm_add_l3out_extepg_1_again is not changed
95+
- nm_add_l3out_extepg_1_again.previous.0.l3extInstP.attributes.name == "extepg_1"
96+
- nm_add_l3out_extepg_1_again.previous.0.l3extInstP.attributes.descr == ""
97+
- nm_add_l3out_extepg_1_again.previous.0.l3extInstP.attributes.prefGrMemb == "exclude"
98+
- nm_add_l3out_extepg_1_again.previous.0.l3extInstP.attributes.targetDscp == "unspecified"
99+
- nm_add_l3out_extepg_1_again.current.0.l3extInstP.attributes.name == "extepg_1"
100+
- nm_add_l3out_extepg_1_again.current.0.l3extInstP.attributes.descr == ""
101+
- nm_add_l3out_extepg_1_again.current.0.l3extInstP.attributes.prefGrMemb == "exclude"
102+
- nm_add_l3out_extepg_1_again.current.0.l3extInstP.attributes.targetDscp == "unspecified"
103+
104+
- name: Change l3out external epg 1
105+
cisco.aci.aci_l3out_extepg:
106+
<<: *add_l3out_extepg_1
107+
description: "changed description"
108+
preferred_group: true
109+
dscp: AF12
110+
register: nm_change_l3out_extepg_1
111+
112+
- name: Verify change l3out external epg 1
113+
ansible.builtin.assert:
114+
that:
115+
- nm_change_l3out_extepg_1 is changed
116+
- nm_change_l3out_extepg_1.previous.0.l3extInstP.attributes.name == "extepg_1"
117+
- nm_change_l3out_extepg_1.previous.0.l3extInstP.attributes.descr == ""
118+
- nm_change_l3out_extepg_1.previous.0.l3extInstP.attributes.prefGrMemb == "exclude"
119+
- nm_change_l3out_extepg_1.previous.0.l3extInstP.attributes.targetDscp == "unspecified"
120+
- nm_change_l3out_extepg_1.current.0.l3extInstP.attributes.name == "extepg_1"
121+
- nm_change_l3out_extepg_1.current.0.l3extInstP.attributes.descr == "changed description"
122+
- nm_change_l3out_extepg_1.current.0.l3extInstP.attributes.prefGrMemb == "include"
123+
- nm_change_l3out_extepg_1.current.0.l3extInstP.attributes.targetDscp == "AF12"
124+
125+
- name: Add two more l3out external epgs
126+
cisco.aci.aci_l3out_extepg:
127+
<<: *aci_info
128+
tenant: "{{ aci_tenant }}"
129+
l3out: "{{ item.l3out }}"
130+
extepg: "{{ item.extepg }}"
131+
state: present
132+
loop:
133+
- {l3out: l3out_1, extepg: extepg_2}
134+
- {l3out: l3out_2, extepg: extepg_3}
135+
136+
# TEST QUERY L3OUT EXTERNAL EPG
137+
138+
- name: Query l3out external epg 1
139+
cisco.aci.aci_l3out_extepg:
140+
<<: *add_l3out_extepg_1
141+
state: query
142+
register: query_one
143+
144+
- name: Query all l3out external epgs ( class query )
145+
cisco.aci.aci_l3out_extepg:
146+
<<: *aci_info
147+
state: query
148+
register: query_all
149+
150+
- name: Verify query l3out external epgs
151+
ansible.builtin.assert:
152+
that:
153+
- query_one is not changed
154+
- query_one.current | length == 1
155+
- query_one.current.0.l3extInstP.attributes.name == "extepg_1"
156+
- query_all is not changed
157+
- query_all.current | length >= 3
158+
159+
# TEST REMOVAL L3OUT EXTERNAL EPG
160+
161+
- name: Remove l3out external epg 1 ( check mode )
162+
cisco.aci.aci_l3out_extepg: &remove_l3out_extepg_1
163+
<<: *add_l3out_extepg_1
164+
state: absent
165+
check_mode: true
166+
register: cm_remove_l3out_extepg_1
167+
168+
- name: Remove l3out external epg 1
169+
cisco.aci.aci_l3out_extepg:
170+
<<: *remove_l3out_extepg_1
171+
register: nm_remove_l3out_extepg_1
172+
173+
- name: Remove l3out external epg 1 again
174+
cisco.aci.aci_l3out_extepg:
175+
<<: *remove_l3out_extepg_1
176+
register: nm_remove_l3out_extepg_1_again
177+
178+
- name: Verify removal epg monitoring policies
179+
ansible.builtin.assert:
180+
that:
181+
- cm_remove_l3out_extepg_1 is changed
182+
- cm_remove_l3out_extepg_1.proposed == {}
183+
- nm_remove_l3out_extepg_1 is changed
184+
- nm_remove_l3out_extepg_1.previous.0.l3extInstP.attributes.name == "extepg_1"
185+
- nm_remove_l3out_extepg_1.current == []
186+
- nm_remove_l3out_extepg_1_again is not changed
187+
- nm_remove_l3out_extepg_1_again.previous == []
188+
- nm_remove_l3out_extepg_1_again.current == []

0 commit comments

Comments
 (0)