Revert "Test for Bug Netvirt-1080"
[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 Create And Associate Floating IPs for VMs
108     [Documentation]    Create and associate a floating IP for the VM
109     ${VM_FLOATING_IPS} =    OpenStackOperations.Create And Associate Floating IPs    ${EXTERNAL_NET_NAME}    @{NET1_FIP_VMS}
110     BuiltIn.Set Suite Variable    ${VM_FLOATING_IPS}
111     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{NET1_FIP_VMS}
112     ...    AND    OpenStackOperations.Get Test Teardown Debugs
113
114 Ping External Gateway From Control Node
115     [Documentation]    Check reachability of external gateway by pinging it from the control node.
116     OpenStackOperations.Ping Vm From Control Node    ${EXTERNAL_GATEWAY}    additional_args=-I ${EXTERNAL_INTERNET_ADDR}
117
118 Ping Vm Instance1 Floating IP From Control Node
119     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
120     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[0]    additional_args=-I ${EXTERNAL_INTERNET_ADDR}
121
122 Ping Vm Instance2 Floating IP From Control Node
123     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
124     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[1]    additional_args=-I ${EXTERNAL_INTERNET_ADDR}
125
126 Ping Vm Instance2 Floating IP From Vm Instance1 With Floating IP (Hairpinning)
127     [Documentation]    Check reachability of VM instance floating IP from another VM instance with FIP (with ttl=1 to make sure no router hops)
128     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[1]
129     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_FIP_VM_IPS}[0]    ${dst_ip}    ttl=1
130
131 Ping Vm Instance1 Floating IP From SNAT VM Instance1
132     [Documentation]    Check reachability of VM instance floating IP from another VM without Floating IP
133     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
134     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[0]
135     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
136     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET2_SNAT_VM_IPS}[0]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
137
138 Ping Vm Instance1 Floating IP From SNAT VM Instance2
139     [Documentation]    Check reachability of VM instance floating IP from another VM without Floating IP
140     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
141     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[0]
142     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
143
144 Ping Vm Instance2 Floating IP From SNAT VM Instance1
145     [Documentation]    Check reachability of VM instance floating IP from another VM without Floating IP
146     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
147     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[1]
148     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
149     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET2_SNAT_VM_IPS}[0]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
150
151 Ping Vm Instance2 Floating IP From SNAT VM Instance2
152     [Documentation]    Check reachability of VM instance floating IP from another VM without Floating IP
153     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
154     ${dst_ip} =    BuiltIn.Create List    @{VM_FLOATING_IPS}[1]
155     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${dst_ip}    ttl=1    ping_should_succeed=${expect_ping_to_work}
156
157 Ping External Network PNF from Vm Instance 1
158     [Documentation]    Check reachability of External Network PNF from VM instance (with ttl=1 to make sure no router hops)
159     ${dst_ip} =    BuiltIn.Create List    ${EXTERNAL_PNF}
160     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_FIP_VM_IPS}[0]    ${dst_ip}    ttl=1
161
162 SNAT - TCP connection to External Gateway From SNAT VM Instance1
163     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
164     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}
165
166 SNAT - UDP connection to External Gateway From SNAT VM Instance1
167     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
168     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}    -u
169
170 SNAT - TCP connection to External Gateway From SNAT VM Instance2
171     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
172     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${EXTERNAL_GATEWAY}
173
174 SNAT - UDP connection to External Gateway From SNAT VM Instance2
175     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
176     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${EXTERNAL_GATEWAY}    -u
177
178 SNAT - TCP connection to External Gateway From SNAT VM Instance3
179     [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
180     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[1]    @{NET2_SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}
181
182 SNAT - UDP connection to External Gateway From SNAT VM Instance3
183     [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
184     OpenStackOperations.Test Netcat Operations From Vm Instance    @{NETWORKS}[1]    @{NET2_SNAT_VM_IPS}[0]    ${EXTERNAL_GATEWAY}    -u
185
186 Ping External Network PNF from SNAT VM Instance1
187     [Documentation]    Check reachability of External Network PNF from SNAT VM Instance1
188     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
189     ${dst_ip} =    BuiltIn.Create List    ${EXTERNAL_PNF}
190     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[0]    ${dst_ip}    ping_should_succeed=${expect_ping_to_work}
191
192 Ping External Network PNF from SNAT VM Instance2
193     [Documentation]    Check reachability of External Network PNF from SNAT VM Instance2
194     ${expect_ping_to_work} =    Set Variable If    "skip_if_controller" in @{TEST_TAGS}    False    True
195     ${dst_ip} =    BuiltIn.Create List    ${EXTERNAL_PNF}
196     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET1_SNAT_VM_IPS}[1]    ${dst_ip}    ping_should_succeed=${expect_ping_to_work}
197
198 Delete Vm Instances
199     [Documentation]    Delete Vm instances using instance names.
200     : FOR    ${vm}    IN    @{NET1_FIP_VMS}
201     \    OpenStackOperations.Delete Vm Instance    ${vm}
202     : FOR    ${vm}    IN    @{SNAT_VMS}
203     \    OpenStackOperations.Delete Vm Instance    ${vm}
204
205 Delete Router Interfaces
206     [Documentation]    Remove Interface to the subnets.
207     : FOR    ${router}    ${interface}    IN ZIP    ${ROUTERS}    ${SUBNETS}
208     \    OpenStackOperations.Remove Interface    ${router}    ${interface}
209
210 Delete Routers
211     [Documentation]    Delete Router and Interface to the subnets.
212     : FOR    ${router}    IN    @{ROUTERS}
213     \    OpenStackOperations.Delete Router    ${router}
214
215 Verify Deleted Router
216     [Documentation]    Check deleted router using northbound rest call
217     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
218     BuiltIn.Log    ${data}
219     : FOR    ${router}    IN    @{ROUTERS}
220     \    BuiltIn.Should Not Contain    ${data}    ${ROUTER}
221
222 Delete Networks
223     [Documentation]    Delete Networks with neutron request.
224     : FOR    ${network}    IN    @{NETWORKS}
225     \    OpenStackOperations.Delete Network    ${network}
226     OpenStackOperations.Delete Network    ${EXTERNAL_NET_NAME}
227
228 Delete Security Group
229     [Documentation]    Delete security groups with neutron request
230     OpenStackOperations.Delete SecurityGroup    ${SECURITY_GROUP}
231
232 Verify Flows Cleanup
233     [Documentation]    Verify that flows have been cleaned up properly after removing all neutron configurations
234     DataModels.Verify Flows Are Cleaned Up On All OpenStack Nodes