2 Documentation Test suite to verify security groups basic and advanced functionalities, including negative tests.
3 ... These test cases are not so relevant for transparent mode, so each test case will be tagged with
4 ... "skip_if_transparent" to allow any underlying keywords to return with a PASS without risking
5 ... a false failure. The real value of this suite will be in stateful mode.
7 Library OperatingSystem
8 Library RequestsLibrary
10 Resource ../../../libraries/DevstackUtils.robot
11 Resource ../../../libraries/KarafKeywords.robot
12 Resource ../../../libraries/OpenStackOperations.robot
13 Resource ../../../libraries/SetupUtils.robot
14 Resource ../../../libraries/Utils.robot
15 Resource ../../../libraries/RemoteBash.robot
17 Suite Setup Suite Setup
18 Suite Teardown OpenStackOperations.OpenStack Suite Teardown
19 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
20 Test Teardown OpenStackOperations.Get Test Teardown Debugs
22 Force Tags skip_if_${security_group_mode}
26 ${SECURITY_GROUP} sg_sg
27 @{NETWORKS} sg_net_1 sg_net_2
28 @{SUBNETS} sg_sub_1 sg_sub_2
30 @{NET_1_VMS} sg_net_1_vm_1 sg_net_1_vm_2
31 @{NET_2_VMS} sg_net_2_vm_1
32 @{SUBNET_CIDRS} 51.0.0.0/24 52.0.0.0/24
36 No Ping From DHCP To Vm Instance1
37 [Documentation] Check non-reachability of vm instances by pinging to them.
38 OpenStackOperations.Ping From DHCP Should Not Succeed ${NETWORKS}[0] ${NET_1_VM_IPS}[1]
40 No Ping From Vm Instance1 To Vm Instance2
41 [Documentation] Login to the vm instance and test some operations
42 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[1]
43 OpenStackOperations.Test Operations From Vm Instance
45 ... ${NET_1_VM_IPS}[0]
47 ... ping_should_succeed=False
49 No Ping From Vm Instance2 To Vm Instance1
50 [Documentation] Login to the vm instance and test operations
51 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[0]
52 OpenStackOperations.Test Operations From Vm Instance
54 ... ${NET_1_VM_IPS}[1]
56 ... ping_should_succeed=False
58 Add Ping Allow Rules With Remote SG (only between VMs)
59 OpenStackOperations.Neutron Security Group Rule Create
63 ... remote_group_id=${SECURITY_GROUP}
64 OpenStackOperations.Neutron Security Group Rule Create
68 ... remote_group_id=${SECURITY_GROUP}
69 OpenStackOperations.Neutron Security Group Show ${SECURITY_GROUP}
71 Verify No Ping From DHCP To Vm Instance1
72 [Documentation] Check non-reachability of vm instances by pinging to them.
73 OpenStackOperations.Ping From DHCP Should Not Succeed ${NETWORKS}[0] ${NET_1_VM_IPS}[0]
75 Verify No Ping From DHCP To Vm Instance2
76 [Documentation] Check non-reachability of vm instances by pinging to them.
77 OpenStackOperations.Ping From DHCP Should Not Succeed ${NETWORKS}[0] ${NET_1_VM_IPS}[1]
79 Ping From Vm Instance1 To Vm Instance2
80 [Documentation] Login to the vm instance and test some operations
81 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[1]
82 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[0] ${vm_ips}
84 Ping From Vm Instance2 To Vm Instance1
85 [Documentation] Login to the vm instance and test operations
86 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[0]
87 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[1] ${vm_ips}
90 [Documentation] Create Router and Add Interface to the subnets.
91 OpenStackOperations.Create Router ${ROUTER}
93 Add Interfaces To Router
94 FOR ${interface} IN @{SUBNETS}
95 OpenStackOperations.Add Router Interface ${ROUTER} ${interface}
98 Ping From Vm Instance1 To Vm Instance3
99 [Documentation] Login to the vm instance and test some operations
100 ${vm_ips} = BuiltIn.Create List ${NET_2_VM_IPS}[0]
101 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[0] ${vm_ips}
103 Repeat Ping From Vm Instance1 To Vm Instance2 With a Router
104 [Documentation] Login to the vm instance and test some operations
105 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[1]
106 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[0] ${vm_ips}
108 Repeat Ping From Vm Instance2 To Vm Instance1 With a Router
109 [Documentation] Login to the vm instance and test operations
110 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[0]
111 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[1] ${vm_ips}
113 Add Additional Security Group To VMs
114 [Documentation] Add an additional security group to the VMs - this is done to test a different logic put in place for ports with multiple SGs
115 OpenStackOperations.Security Group Create Without Default Security Rules additional-sg
116 #TODO Remove this after the Newton jobs are removed, Openstack CLI with Newton lacks support to configure rule with remote_ip_prefix
117 OpenStackOperations.Neutron Security Group Rule Create
119 ... direction=ingress
121 ... remote_ip_prefix=${NET_1_DHCP_IP}/32
122 OpenStackOperations.Neutron Security Group Show additional-sg
123 FOR ${vm} IN @{NET_1_VMS}
124 OpenStackOperations.Add Security Group To VM ${vm} additional-sg
127 Ping From DHCP To Vm Instance1
128 [Documentation] Check reachability of vm instances by pinging to them from DHCP.
129 OpenStackOperations.Ping Vm From DHCP Namespace ${NETWORKS}[0] ${NET_1_VM_IPS}[0]
131 Ping From DHCP To Vm Instance2
132 [Documentation] Check reachability of vm instances by pinging to them from DHCP.
133 OpenStackOperations.Ping Vm From DHCP Namespace ${NETWORKS}[0] ${NET_1_VM_IPS}[1]
135 Repeat Ping From Vm Instance1 To Vm Instance2 With additional SG
136 [Documentation] Login to the vm instance and test some operations
137 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[1]
138 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[0] ${vm_ips}
140 Repeat Ping From Vm Instance2 To Vm Instance1 With additional SG
141 [Documentation] Login to the vm instance and test operations
142 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[0]
143 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[1] ${vm_ips}
145 Test Connection when Rules Change Dynamically
146 [Documentation] Initiate ping from DHCP to VM instance and remove security rules
147 ... dynamically check the communication has stopped after removing the security group rules.
148 ${net_id} = OpenstackOperations.Get Net Id ${NETWORKS}[0]
149 Get ControlNode Connection
150 ${output} = SSHLibrary.Write sudo ip netns exec qdhcp-${net_id} ping ${NET_1_VM_IPS}[0]
151 Delete All Security Group Rules additional-sg
154 ${output} = Read Until packet loss
155 Should Not Contain ${output} ${PING_REGEXP}
157 No Ping From DHCP To Vm Instance1 With Additional Security Group Rules Removed
158 [Documentation] Check non-reachability of vm instances by pinging to them.
159 OpenStackOperations.Ping From DHCP Should Not Succeed ${NETWORKS}[0] ${NET_1_VM_IPS}[0]
161 No Ping From DHCP To Vm Instance2 With Additional Security Group Rules Removed
162 [Documentation] Check non-reachability of vm instances by pinging to them.
163 OpenStackOperations.Ping From DHCP Should Not Succeed ${NETWORKS}[0] ${NET_1_VM_IPS}[1]
165 Add The Rules To Additional Security Group Again
166 OpenStackOperations.Neutron Security Group Rule Create
168 ... direction=ingress
170 ... remote_ip_prefix=${NET_1_DHCP_IP}/32
172 Ping From DHCP To Vm Instance1 After Rules Are Added Again
173 [Documentation] Check reachability of vm instances by pinging to them from DHCP.
174 OpenStackOperations.Ping Vm From DHCP Namespace ${NETWORKS}[0] ${NET_1_VM_IPS}[0]
176 Ping From DHCP To Vm Instance2 After Rules Are Added Again
177 [Documentation] Check reachability of vm instances by pinging to them from DHCP.
178 OpenStackOperations.Ping Vm From DHCP Namespace ${NETWORKS}[0] ${NET_1_VM_IPS}[1]
180 Remove the additional Security Group from First Vm
181 OpenStackOperations.Remove Security Group From VM ${NET_1_VMS}[0] additional-sg
183 Repeat Ping From Vm Instance1 To Vm Instance2 With Additional SG Removed From Vm1
184 [Documentation] Login to the vm instance and test some operations
185 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[1]
186 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[0] ${vm_ips}
188 Repeat Ping From Vm Instance2 To Vm Instance1 With Additional SG Removed From Vm1
189 [Documentation] Login to the vm instance and test operations
190 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[0]
191 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[1] ${vm_ips}
193 Remove Router Interfaces
194 FOR ${interface} IN @{SUBNETS}
195 OpenStackOperations.Remove Interface ${ROUTER} ${interface}
199 OpenStackOperations.Delete Router ${ROUTER}
201 Repeat Ping From Vm Instance1 To Vm Instance2 With Router Removed
202 [Documentation] Login to the vm instance and test some operations
203 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[1]
204 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[0] ${vm_ips}
206 Repeat Ping From Vm Instance2 To Vm Instance1 With Router Removed
207 [Documentation] Login to the vm instance and test operations
208 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[0]
209 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[1] ${vm_ips}
211 Delete Vm Instances In net_2
212 FOR ${vm} IN @{NET_2_VMS}
213 OpenStackOperations.Delete Vm Instance ${vm}
216 Repeat Ping From Vm Instance1 To Vm Instance2 With net_2 VM Deleted
217 [Documentation] Login to the vm instance and test some operations
218 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[1]
219 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[0] ${vm_ips}
221 Repeat Ping From Vm Instance2 To Vm Instance1 With net_2 VM Deleted
222 [Documentation] Login to the vm instance and test operations
223 ${vm_ips} = BuiltIn.Create List ${NET_1_VM_IPS}[0]
224 OpenStackOperations.Test Operations From Vm Instance ${NETWORKS}[0] ${NET_1_VM_IPS}[1] ${vm_ips}
229 OpenStackOperations.OpenStack Suite Setup
230 OpenStackOperations.Create Network ${NETWORKS}[0]
231 OpenStackOperations.Create Network ${NETWORKS}[1]
232 BuiltIn.Wait Until Keyword Succeeds
235 ... Utils.Check For Elements At URI
238 OpenStackOperations.Create SubNet ${NETWORKS}[0] ${SUBNETS}[0] ${SUBNET_CIDRS}[0]
239 OpenStackOperations.Create SubNet ${NETWORKS}[1] ${SUBNETS}[1] ${SUBNET_CIDRS}[1]
240 BuiltIn.Wait Until Keyword Succeeds
243 ... Utils.Check For Elements At URI
244 ... ${SUBNETWORK_URL}
246 OpenStackOperations.Security Group Create Without Default Security Rules ${SECURITY_GROUP}
247 OpenStackOperations.Neutron Security Group Rule Create
248 ... ${SECURITY_GROUP}
249 ... direction=ingress
250 ... port_range_max=65535
253 OpenStackOperations.Neutron Security Group Rule Create
254 ... ${SECURITY_GROUP}
256 ... port_range_max=65535
259 OpenStackOperations.Neutron Security Group Show ${SECURITY_GROUP}
260 OpenStackOperations.Create Vm Instance On Compute Node
263 ... ${OS_CMP1_HOSTNAME}
264 ... sg=${SECURITY_GROUP}
265 OpenStackOperations.Create Vm Instance On Compute Node
268 ... ${OS_CMP2_HOSTNAME}
269 ... sg=${SECURITY_GROUP}
270 OpenStackOperations.Create Vm Instance On Compute Node
273 ... ${OS_CMP1_HOSTNAME}
274 ... sg=${SECURITY_GROUP}
275 @{NET_1_VM_IPS} ${NET_1_DHCP_IP} = OpenStackOperations.Get VM IPs @{NET_1_VMS}
276 @{NET_2_VM_IPS} ${NET_2_DHCP_IP} = OpenStackOperations.Get VM IPs @{NET_2_VMS}
277 BuiltIn.Set Suite Variable @{NET_1_VM_IPS}
278 BuiltIn.Set Suite Variable ${NET_1_DHCP_IP}
279 BuiltIn.Set Suite Variable @{NET_2_VM_IPS}
280 BuiltIn.Should Not Contain ${NET_1_VM_IPS} None
281 BuiltIn.Should Not Contain ${NET_2_VM_IPS} None
282 BuiltIn.Should Not Contain ${NET_1_DHCP_IP} None
283 BuiltIn.Should Not Contain ${NET_2_DHCP_IP} None
284 OpenStackOperations.Show Debugs @{NET_1_VMS} @{NET_2_VMS}
285 OpenStackOperations.Get Suite Debugs