503064ccf50c36851209d9cda1b81522913d6ad7
[integration/test.git] / csit / suites / openstack / connectivity / external_network.robot
1 *** Settings ***
2 Documentation     Test suite to check North-South connectivity in L3 using a router and an external network
3 Suite Setup       OpenStackOperations.OpenStack Suite Setup
4 Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
7 Force Tags        skip_if_${ODL_SNAT_MODE}
8 Library           Collections
9 Library           SSHLibrary
10 Library           OperatingSystem
11 Library           RequestsLibrary
12 Resource          ../../../libraries/DevstackUtils.robot
13 Resource          ../../../libraries/DataModels.robot
14 Resource          ../../../libraries/OpenStackOperations.robot
15 Resource          ../../../libraries/SetupUtils.robot
16 Resource          ../../../libraries/Utils.robot
17 Resource          ../../../variables/netvirt/Variables.robot
18
19 *** Variables ***
20 ${SECURITY_GROUP}    l3_ext_sg
21 @{NETWORKS}       l3_ext_net_1    l3_ext_net_2
22 @{SUBNETS}        l3_ext_sub_1    l3_ext_sub_2
23 @{ROUTERS}        l3_ext_router_1    l3_ext_router_2
24 @{NET1_FIP_VMS}    l3_ext_net_1_fip_vm_1    l3_ext_net_1_fip_vm_2
25 @{NET1_SNAT_VMS}    l3_ext_net_1_snat_vm_1    l3_ext_net_1_snat_vm_2
26 @{NET2_SNAT_VMS}    l3_ext_net_2_snat_vm_3
27 @{SNAT_VMS}       @{NET1_SNAT_VMS}    @{NET2_SNAT_VMS}
28 @{SUBNET_CIDRS}    41.0.0.0/24    42.0.0.0/24
29 # Parameter values below are based on releng/builder - changing them requires updates in releng/builder as well
30 ${EXTERNAL_GATEWAY}    10.10.10.250
31 ${EXTERNAL_PNF}    10.10.10.253
32 ${EXTERNAL_SUBNET}    10.10.10.0/24
33 ${EXTERNAL_SUBNET_ALLOCATION_POOL}    start=10.10.10.2,end=10.10.10.249
34 ${EXTERNAL_INTERNET_ADDR}    10.9.9.9
35
36 *** Test Cases ***
37 Create All Controller Sessions
38     [Documentation]    Create sessions for all three controllers
39     ClusterManagement.ClusterManagement Setup
40
41 Create Private Networks
42     [Documentation]    Create Network with neutron request.
43     : FOR    ${network}    IN    @{NETWORKS}
44     \    OpenStackOperations.Create Network    ${network}
45
46 Create Subnets For Private Networks
47     [Documentation]    Create Sub Net for the Network with neutron request.
48     : FOR    ${network}    ${subnet}    ${cidr}    IN ZIP    ${NETWORKS}    ${SUBNETS}
49     ...    ${SUBNET_CIDRS}
50     \    OpenStackOperations.Create SubNet    ${network}    ${subnet}    ${cidr}
51
52 Add Ssh Allow Rule
53     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
54     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
55
56 Create Vm Instances
57     [Documentation]    Create VM instances using flavor and image names for a network.
58     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET1_FIP_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
59     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET1_FIP_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
60     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_SNAT_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
61     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_SNAT_VMS}[1]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
62     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[1]    @{NET_2_SNAT_VMS}[0]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
63
64 Check Vm Instances Have Ip Address
65     @{NET1_FIP_VM_IPS}    ${NET1_FIP_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET1_FIP_VMS}
66     @{NET1_SNAT_VM_IPS}    ${NET1_SNAT_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET1_SNAT_VMS}
67     @{NET2_SNAT_VM_IPS}    ${NET2_SNAT_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET2_SNAT_VMS}
68     BuiltIn.Set Suite Variable    @{NET1_FIP_VM_IPS}
69     BuiltIn.Set Suite Variable    @{NET1_SNAT_VM_IPS}
70     BuiltIn.Set Suite Variable    @{NET2_SNAT_VM_IPS}
71     BuiltIn.Should Not Contain    ${NET1_FIP_VM_IPS}    None
72     BuiltIn.Should Not Contain    ${NET1_SNAT_VM_IPS}    None
73     BuiltIn.Should Not Contain    ${NET2_SNAT_VM_IPS}    None
74     BuiltIn.Should Not Contain    ${NET1_FIP_DHCP_IP}    None
75     BuiltIn.Should Not Contain    ${NET1_SNAT_DHCP_IP}    None
76     BuiltIn.Should Not Contain    ${NET2_SNAT_DHCP_IP}    None
77     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{NET1_FIP_VMS}    @{SNAT_VMS}
78     ...    AND    OpenStackOperations.Get Test Teardown Debugs
79
80 Create External Network And Subnet
81     OpenStackOperations.Create Network    ${EXTERNAL_NET_NAME}    --provider-network-type flat --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK}
82     OpenStackOperations.Update Network    ${EXTERNAL_NET_NAME}    --external
83     OpenStackOperations.Create Subnet    ${EXTERNAL_NET_NAME}    ${EXTERNAL_SUBNET_NAME}    ${EXTERNAL_SUBNET}    --gateway ${EXTERNAL_GATEWAY} --allocation-pool ${EXTERNAL_SUBNET_ALLOCATION_POOL}
84
85 Create Routers
86     [Documentation]    Create Router and Add Interface to the subnets.
87     : FOR    ${router}    IN    @{ROUTERS}
88     \    OpenStackOperations.Create Router    ${router}
89
90 Add Interfaces To Router
91     [Documentation]    Add Interfaces
92     : FOR    ${router}    ${interface}    IN ZIP    ${ROUTERS}    ${SUBNETS}
93     \    OpenStackOperations.Add Router Interface    ${router}    ${interface}
94
95 Add Router Gateway To Router
96     [Documentation]    OpenStackOperations.Add Router Gateway
97     : FOR    ${router}    IN    @{ROUTERS}
98     \    OpenStackOperations.Add Router Gateway    ${router}    ${EXTERNAL_NET_NAME}
99
100 Verify Created Routers
101     [Documentation]    Check created routers using northbound rest calls
102     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
103     BuiltIn.Log    ${data}
104     : FOR    ${router}    IN    @{ROUTERS}
105     \    Should Contain    ${data}    ${router}
106
107 Ping External Network PNF from Vm Instance 1
108     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
109     ${dst_ip}=    BuiltIn.Create List    ${EXTERNAL_PNF}
110     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_FIP_VM_IPS}[0]    ${dst_ip}    ttl=1
111
112 Ping External Network PNF from Vm Instance 2
113     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
114     ${dst_ip}=    BuiltIn.Create List    ${EXTERNAL_PNF}
115     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_FIP_VM_IPS}[1]    ${dst_ip}    ttl=1
116
117 Create And Associate Floating IPs for VMs
118     [Documentation]    Create and associate a floating IP for the VM
119     ${VM_FLOATING_IPS} =    OpenStackOperations.Create And Associate Floating IPs    ${EXTERNAL_NET_NAME}    @{NET1_FIP_VMS}
120     BuiltIn.Set Suite Variable    ${VM_FLOATING_IPS}
121     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{NET1_FIP_VMS}
122     ...    AND    OpenStackOperations.Get Test Teardown Debugs
123
124 Ping External Gateway From Control Node
125     [Documentation]    Check reachability of external gateway by pinging it from the control node.
126     OpenStackOperations.Ping Vm From Control Node    ${EXTERNAL_GATEWAY}    additional_args=-I ${EXTERNAL_INTERNET_ADDR}
127
128 Ping Vm Instance1 Floating IP From Control Node
129     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
130     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[0]    additional_args=-I ${EXTERNAL_INTERNET_ADDR}
131
132 Ping Vm Instance2 Floating IP From Control Node
133     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
134     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[1]    additional_args=-I ${EXTERNAL_INTERNET_ADDR}
135
136 Ping Vm Instance2 Floating IP From Vm Instance1 With Floating IP (Hairpinning)
137     [Documentation]    Check reachability of VM instance floating IP from another VM instance with FIP (with ttl=1 to make sure no router hops)
138     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[1]
139     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_FIP_VM_IPS}[0]    ${dst_ip}    ttl=1
140
141 Ping Vm Instance1 Floating IP From SNAT VM Instance1
142     [Documentation]    Check reachability of VM instance floating IP from another VM without Floating IP
143     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
144     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[0]
145     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
146     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET2_SNAT_VM_IPS}[0]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
147
148 Ping Vm Instance1 Floating IP From SNAT VM Instance2
149     [Documentation]    Check reachability of VM instance floating IP from another VM without Floating IP
150     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
151     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[0]
152     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
153
154 Ping Vm Instance2 Floating IP From SNAT VM Instance1
155     [Documentation]    Check reachability of VM instance floating IP from another VM without Floating IP
156     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
157     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[1]
158     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
159     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET2_SNAT_VM_IPS}[0]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
160
161 Ping Vm Instance2 Floating IP From SNAT VM Instance2
162     [Documentation]    Check reachability of VM instance floating IP from another VM without Floating IP
163     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
164     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[1]
165     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
166
167 Ping External Network PNF from Vm Instance 1
168     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
169     ${dst_ip} =    BuiltIn.Create List    ${EXTERNAL_PNF}
170     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_FIP_VM_IPS}[0]    ${dst_ip}    ttl=1
171
172 SNAT - TCP connection to External Gateway From SNAT VM Instance1
173     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
174     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}
175
176 SNAT - UDP connection to External Gateway From SNAT VM Instance1
177     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
178     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}    -u
179
180 SNAT - TCP connection to External Gateway From SNAT VM Instance2
181     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
182     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${EXTERNAL_GATEWAY}
183
184 SNAT - UDP connection to External Gateway From SNAT VM Instance2
185     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
186     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${EXTERNAL_GATEWAY}    -u
187
188 SNAT - TCP connection to External Gateway From SNAT VM Instance3
189     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
190     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[1]    @{NET2_SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}
191
192 SNAT - UDP connection to External Gateway From SNAT VM Instance3
193     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
194     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[1]    @{NET2_SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}    -u
195
196 Ping External Network PNF from SNAT VM Instance1
197     [Documentation]    Check reachability of External Network PNF from SNAT VM Instance1
198     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
199     ${dst_ip} =    BuiltIn.Create List    ${EXTERNAL_PNF}
200     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${dst_ip}    ping_should_succeed=${expect_ping_to_work}
201
202 Ping External Network PNF from SNAT VM Instance2
203     [Documentation]    Check reachability of External Network PNF from SNAT VM Instance2
204     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
205     ${dst_ip} =    BuiltIn.Create List    ${EXTERNAL_PNF}
206     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${dst_ip}    ping_should_succeed=${expect_ping_to_work}
207
208 Remove Floating Ip from VM Instance 1
209     [Documentation]    Delete FIP from VM Instance 1
210     OpenStackOperations.Remove Floating Ip From Vm    @{NET1_FIP_VMS}[0]    @{VM_FLOATING_IPS}[0]
211
212 Remove Floating Ip from VM Instance 2
213     [Documentation]    Delete FIP from VM Instance 2
214     OpenStackOperations.Remove Floating Ip From Vm    @{NET1_FIP_VMS}[1]    @{VM_FLOATING_IPS}[1]
215
216 Ping External Network PNF from Vm Instance 1
217     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
218     ${dst_ip} =    BuiltIn.Create List    ${EXTERNAL_PNF}
219     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_FIP_VM_IPS}[0]    ${dst_ip}    ttl=1
220
221 Ping External Network PNF from Vm Instance 2
222     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
223     ${dst_ip} =    BuiltIn.Create List    ${EXTERNAL_PNF}
224     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_FIP_VM_IPS}[1]    ${dst_ip}    ttl=1
225
226 Delete Vm Instances
227     [Documentation]    Delete Vm instances using instance names.
228     : FOR    ${vm}    IN    @{NET1_FIP_VMS}
229     \    OpenStackOperations.Delete Vm Instance    ${vm}
230     : FOR    ${vm}    IN    @{SNAT_VMS}
231     \    OpenStackOperations.Delete Vm Instance    ${vm}
232
233 Delete Router Interfaces
234     [Documentation]    Remove Interface to the subnets.
235     : FOR    ${router}    ${interface}    IN ZIP    ${ROUTERS}    ${SUBNETS}
236     \    OpenStackOperations.Remove Interface    ${router}    ${interface}
237
238 Delete Routers
239     [Documentation]    Delete Router and Interface to the subnets.
240     : FOR    ${router}    IN    @{ROUTERS}
241     \    OpenStackOperations.Delete Router    ${router}
242
243 Verify Deleted Router
244     [Documentation]    Check deleted router using northbound rest call
245     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
246     BuiltIn.Log    ${data}
247     : FOR    ${router}    IN    @{ROUTERS}
248     \    BuiltIn.Should Not Contain    ${data}    ${ROUTER}
249
250 Delete Networks
251     [Documentation]    Delete Networks with neutron request.
252     : FOR    ${network}    IN    @{NETWORKS}
253     \    OpenStackOperations.Delete Network    ${network}
254     OpenStackOperations.Delete Network    ${EXTERNAL_NET_NAME}
255
256 Delete Security Group
257     [Documentation]    Delete security groups with neutron request
258     OpenStackOperations.Delete SecurityGroup    ${SECURITY_GROUP}
259
260 Verify Flows Cleanup
261     [Documentation]    Verify that flows have been cleaned up properly after removing all neutron configurations
262     DataModels.Verify Flows Are Cleaned Up On All OpenStack Nodes