2 Documentation Test suite to validate network address translation(snat/dnat) functionality in openstack integrated environment.
3 ... All the testcases were written to do flow validation since dc gateway is unavailable in csit environment.
4 ... This suite assumes proper integration bridges and vxlan tunnels are configured in the environment.
7 Library RequestsLibrary
10 Resource ../../../libraries/BgpOperations.robot
11 Resource ../../../libraries/OpenStackOperations.robot
12 Resource ../../../libraries/SetupUtils.robot
13 Resource ../../../libraries/Tcpdump.robot
14 Resource ../../../libraries/Utils.robot
15 Resource ../../../libraries/VpnOperations.robot
16 Resource ../../../variables/Variables.robot
17 Resource ../../../variables/netvirt/Variables.robot
19 Suite Setup Suite Setup
20 Suite Teardown Stop Suite
21 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
22 Test Teardown OpenStackOperations.Get Test Teardown Debugs
26 ${SECURITY_GROUP} nat_sg
28 ${SNAT_ENABLED} "enable_snat": true
29 ${SNAT_DISABLED} "enable_snat": false
32 ${DCGW_SYSTEM_IP} ${TOOLS_SYSTEM_1_IP}
33 ${LOOPBACK_IP} 5.5.5.2
36 ${VPN_INSTANCE_ID} 4ae8cd92-48ca-49b5-94e1-b2921a261442
37 ${ExtIP} 100.100.100.24
38 @{NETWORKS} nat_net_1 nat_net_2
39 @{EXTERNAL_NETWORKS} nat_ext_11 nat_ext_22
40 @{EXTERNAL_SUB_NETWORKS} nat_ext_sub_net_1 nat_ext_sub_net_2
41 @{SUBNETS} nat_sub_net_1 nat_sub_net_2
42 @{SUBNET_CIDRS} 10.1.1.0/24 20.1.1.0/24
43 @{EXT_SUBNET_CIDRS} 100.100.100.0/24 200.200.200.0/24
44 @{PORTS} nat_port_1 nat_port_2 nat_port_3 nat_port_4
45 @{NET_1_VMS} nat_net_1_vm_1 nat_net_1_vm_2 nat_net_1_vm_3 nat_net_1_vm_4
49 Verify Successful Creation Of External Network With Router External Set To TRUE
50 [Documentation] Create external network,enable snat on router and validate the same.
51 OpenStackOperations.Add Router Gateway ${ROUTER} ${EXTERNAL_NETWORKS}[0] --enable-snat
52 ${output} = OpenStackOperations.Show Router ${ROUTER}
53 BuiltIn.Should Contain ${output} ${SNAT_ENABLED}
54 ${output} = OpenStackOperations.Show Network ${EXTERNAL_NETWORKS}[0]
55 BuiltIn.Should Contain ${output} ${EXTERNAL_NETWORKS}[0]
57 Verify Successful Update Of Router With External_gateway_info, Disable SNAT And Enable SNAT
58 [Documentation] Disable snat, enable snat and validate the same.
59 OpenStackOperations.Add Router Gateway ${ROUTER} ${EXTERNAL_NETWORKS}[0] --disable-snat
60 ${output} = OpenStackOperations.Show Router ${ROUTER}
61 BuiltIn.Should Contain ${output} ${SNAT_DISABLED}
62 OpenStackOperations.Add Router Gateway ${ROUTER} ${EXTERNAL_NETWORKS}[0] --enable-snat
63 ${output} = OpenStackOperations.Show Router ${ROUTER}
64 BuiltIn.Should Contain ${output} ${SNAT_ENABLED}
66 Verify Successful Deletion Of External Network
67 [Documentation] Delete the external network and validate the same.
68 OpenStackOperations.Remove Gateway ${ROUTER}
69 ${output} = OpenStackOperations.Show Router ${ROUTER}
70 BuiltIn.Should Not Contain ${output} ${SNAT_ENABLED}
72 Verify Floating Ip Provision And Reachability From External Network Via Neutron Router Through L3vpn
73 [Documentation] Check floating IP should be present in dump flows after creating the floating IP and associating it to external network
74 ... which is associated to L3VPN
75 VpnOperations.VPN Create L3VPN
76 ... vpnid=${VPN_INSTANCE_ID}
79 ... exportrt=["${DCGW_RD}"]
80 ... importrt=["${DCGW_RD}"]
81 ${ext_net_id} = OpenStackOperations.Get Net Id ${EXTERNAL_NETWORKS}[0]
82 VpnOperations.Associate L3VPN To Network networkid=${ext_net_id} vpnid=${VPN_INSTANCE_ID}
83 OpenStackOperations.Add Router Gateway ${ROUTER} ${EXTERNAL_NETWORKS}[0] --disable-snat
84 ${output} = OpenStackOperations.Show Router ${ROUTER}
85 BuiltIn.Should Contain ${output} ${SNAT_DISABLED}
86 ${subnetid} = OpenStackOperations.Get Subnet Id ${EXTERNAL_SUB_NETWORKS}[0]
87 OpenStackOperations.Add Router Gateway
89 ... ${EXTERNAL_NETWORKS}[0]
90 ... --fixed-ip subnet=${subnetid},ip-address=${ExtIP}
91 ${float} = OpenStackOperations.Create And Associate Floating IPs ${EXTERNAL_NETWORKS}[0] ${NET_1_VMS}[0]
92 ${float} = BuiltIn.Set Variable ${float}[0]
93 @{matching_paras} = BuiltIn.Create List nw_dst=${float} goto_table:${DNAT_TABLE}
94 BuiltIn.Wait Until Keyword Succeeds
97 ... OVSDB.Verify Dump Flows For Specific Table
102 ... @{matching_paras}
103 @{matching_paras} = BuiltIn.Create List actions=set_field:${float} goto_table:${SNAT_TABLE}
104 BuiltIn.Wait Until Keyword Succeeds
107 ... OVSDB.Verify Dump Flows For Specific Table
112 ... @{matching_paras}
114 Verify Floating Ip De-provision And Reachability From External Network Via Neutron Router Through L3vpn
115 [Documentation] Check floating IP should not be present in dump flows after deleting the floating IP
116 ... and removing the external gateway from router which is associated to L3VPN
117 OpenStackOperations.Get ControlNode Connection
118 ${output} = OpenStackOperations.OpenStack CLI openstack floating ip list |awk '{print$2}'
119 ${floating_id} = BuiltIn.Should Match Regexp
121 ... [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
122 OpenStackOperations.Delete Floating IP ${floating_id}
123 OpenStackOperations.Remove Gateway ${ROUTER}
124 ${output} = OVSDB.Get Flow Entries On Node ${OS_CMP1_CONN_ID}
125 BuiltIn.Should Not Contain ${output} ${ExtIP}
127 Verify Floating Ip Re-provision And Reachability From External Network Via Neutron Router Through L3vpn
128 [Documentation] Check floating IP should be present in dump flows after creating the floating IP again wnd associating it to external network
129 ... which is associated to L3VPN
130 ${subnetid} = OpenStackOperations.Get Subnet Id ${EXTERNAL_SUB_NETWORKS}[0]
131 OpenStackOperations.Add Router Gateway
133 ... ${EXTERNAL_NETWORKS}[0]
134 ... --fixed-ip subnet=${subnetid},ip-address=${ExtIP}
135 ${float} = OpenStackOperations.Create And Associate Floating IPs ${EXTERNAL_NETWORKS}[0] ${NET_1_VMS}[0]
136 ${float} = BuiltIn.Set Variable ${float}[0]
137 @{matching_paras} = BuiltIn.Create List nw_dst=${float} goto_table:${DNAT_TABLE}
138 BuiltIn.Wait Until Keyword Succeeds
141 ... OVSDB.Verify Dump Flows For Specific Table
146 ... @{matching_paras}
147 @{matching_paras} = BuiltIn.Create List actions=set_field:${float} goto_table:${SNAT_TABLE}
148 BuiltIn.Wait Until Keyword Succeeds
151 ... OVSDB.Verify Dump Flows For Specific Table
156 ... @{matching_paras}
158 Verify Multiple Floating Ip Creation and Association to external network
159 [Documentation] Check Multiple floating IPs should be present in dump flows after creating multiple floating IPs and associating it to external network
160 ... which is associated to L3VPN
161 ${subnetid} = OpenStackOperations.Get Subnet Id ${EXTERNAL_SUB_NETWORKS}[0]
162 OpenStackOperations.Add Router Gateway
164 ... ${EXTERNAL_NETWORKS}[0]
165 ... --fixed-ip subnet=${subnetid},ip-address=${ExtIP}
166 ${FloatIp1} = OpenStackOperations.Create And Associate Floating IPs
167 ... ${EXTERNAL_NETWORKS}[0]
169 ${FloatIp2} = OpenStackOperations.Create And Associate Floating IPs
170 ... ${EXTERNAL_NETWORKS}[0]
172 ${FloatIp3} = OpenStackOperations.Create And Associate Floating IPs
173 ... ${EXTERNAL_NETWORKS}[0]
175 ${output} = OVSDB.Get Flow Entries On Node ${OS_CMP2_CONN_ID}
176 BuiltIn.Should Match Regexp ${output} ${ExtIP}
177 BuiltIn.Should Match Regexp ${output} .*${FloatIp1}.*
178 BuiltIn.Should Match Regexp ${output} .*${FloatIp2}.*
179 BuiltIn.Should Match Regexp ${output} .*${FloatIp3}.*
184 [Documentation] Test Suite for Subnet_Routing_and_Multicast_Deployments.
185 VpnOperations.Basic Suite Setup
186 BgpOperations.Start Quagga Processes On ODL ${ODL_SYSTEM_IP}
187 BgpOperations.Start Quagga Processes On DCGW ${DCGW_SYSTEM_IP}
189 OpenStackOperations.Show Debugs @{NET_1_VMS}
190 OpenStackOperations.Get Suite Debugs
193 Create Neutron Networks
194 Create Neutron Subnets
195 OpenStackOperations.Create SubNet
196 ... ${EXTERNAL_NETWORKS}[0]
197 ... ${EXTERNAL_SUB_NETWORKS}[0]
198 ... ${EXT_SUBNET_CIDRS}[0]
199 OpenStackOperations.Create Allow All SecurityGroup ${SECURITY_GROUP}
202 BgpOperations.Setup BGP Peering On ODL ${ODL_SYSTEM_IP} ${AS_ID} ${DCGW_SYSTEM_IP}
203 BgpOperations.Setup BGP Peering On DCGW
204 ... ${DCGW_SYSTEM_IP}
210 OpenStackOperations.Create Router ${ROUTER}
211 OpenStackOperations.Add Router Interface ${ROUTER} ${SUBNETS}[0]
212 OpenStackOperations.Add Router Interface ${ROUTER} ${SUBNETS}[1]
214 Create Neutron Networks
215 [Documentation] Create required number of networks
216 FOR ${NET} IN @{NETWORKS}
217 OpenStackOperations.Create Network ${NET}
219 OpenStackOperations.Create Network ${EXTERNAL_NETWORKS}[0] --external --provider-network-type ${NETWORK_TYPE}
220 BuiltIn.Wait Until Keyword Succeeds 3s 1s Utils.Check For Elements At URI ${NETWORK_URL} ${NETWORKS}
222 Create Neutron Subnets
223 [Documentation] Create required number of subnets for previously created networks
224 ${num_of_networks} = BuiltIn.Get Length ${NETWORKS}
225 FOR ${index} IN RANGE 0 ${num_of_networks}
226 OpenStackOperations.Create SubNet ${NETWORKS}[${index}] ${SUBNETS}[${index}] ${SUBNET_CIDRS}[${index}]
228 BuiltIn.Wait Until Keyword Succeeds
231 ... Utils.Check For Elements At URI
232 ... ${SUBNETWORK_URL}
236 [Documentation] Create required number of ports under previously created subnets
237 OpenStackOperations.Create Port ${NETWORKS}[0] ${PORTS}[0] sg=${SECURITY_GROUP}
238 OpenStackOperations.Create Port ${NETWORKS}[0] ${PORTS}[1] sg=${SECURITY_GROUP}
239 OpenStackOperations.Create Port ${NETWORKS}[1] ${PORTS}[2] sg=${SECURITY_GROUP}
240 OpenStackOperations.Create Port ${NETWORKS}[1] ${PORTS}[3] sg=${SECURITY_GROUP}
241 BuiltIn.Wait Until Keyword Succeeds
244 ... Utils.Check For Elements At URI
245 ... ${CONFIG_API}/neutron:neutron/ports/
249 [Documentation] Create Vm instances on compute nodes
250 OpenStackOperations.Create Vm Instance With Port On Compute Node
253 ... ${OS_CMP1_HOSTNAME}
254 ... sg=${SECURITY_GROUP}
255 OpenStackOperations.Create Vm Instance With Port On Compute Node
258 ... ${OS_CMP2_HOSTNAME}
259 ... sg=${SECURITY_GROUP}
260 OpenStackOperations.Create Vm Instance With Port On Compute Node
263 ... ${OS_CMP1_HOSTNAME}
264 ... sg=${SECURITY_GROUP}
265 OpenStackOperations.Create Vm Instance With Port On Compute Node
268 ... ${OS_CMP2_HOSTNAME}
269 ... sg=${SECURITY_GROUP}
270 @{NET_1_VM_IPS} ${NET_1_DHCP_IP} = OpenStackOperations.Get VM IPs @{NET_1_VMS}
271 BuiltIn.Set Suite Variable @{NET_1_VM_IPS}
272 BuiltIn.Should Not Contain ${NET_1_VM_IPS} None
273 BuiltIn.Should Not Contain ${NET_1_DHCP_IP} None
276 [Documentation] Test teardown for snat suite.
277 BgpOperations.Delete BGP Configuration On ODL session
278 BgpOperations.Delete BGP Config On Quagga ${DCGW_SYSTEM_IP} ${AS_ID}
279 BgpOperations.Stop BGP Processes On Node ${ODL_SYSTEM_IP}
280 BgpOperations.Stop BGP Processes On Node ${DCGW_SYSTEM_IP}
281 OpenStackOperations.OpenStack Suite Teardown