cleanup connections
[integration/test.git] / csit / suites / openstack / connectivity / l3.robot
1 *** Settings ***
2 Documentation     Test suite to check connectivity in L3 using routers.
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 Library           SSHLibrary
8 Library           OperatingSystem
9 Library           RequestsLibrary
10 Resource          ../../../libraries/DevstackUtils.robot
11 Resource          ../../../libraries/DataModels.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/SetupUtils.robot
14 Resource          ../../../libraries/Utils.robot
15 Resource          ../../../variables/netvirt/Variables.robot
16
17 *** Variables ***
18 ${SECURITY_GROUP}    l3_sg
19 @{NETWORKS}       l3_net_1    l3_net_2    l3_net_3
20 @{SUBNETS}        l3_sub_1    l3_sub_2    l3_sub_3
21 ${ROUTER}         l3_router
22 @{NET_1_VMS}      l3_net_1_vm_1    l3_net_1_vm_2    l3_net_1_vm_3
23 @{NET_2_VMS}      l3_net_2_vm_1    l3_net_2_vm_2    l3_net_2_vm_3
24 @{NET_3_VMS}      l3_net_3_vm_1    l3_net_3_vm_2    l3_net_3_vm_3
25 @{SUBNET_CIDRS}    31.0.0.0/24    32.0.0.0/24    33.0.0.0/24
26 ${NET_1_VLAN_ID}    1131
27
28 *** Test Cases ***
29 Create VLAN Network net_1
30     [Documentation]    Create Network with neutron request.
31     # in the case that the controller under test is using legacy netvirt features, vlan segmentation is not supported,
32     # and we cannot create a vlan network. If those features are installed we will instead stick with vxlan.
33     ${feature_check_status} =    OpenStackOperations.Is Feature Installed    ${legacy_feature_list}
34     Run Keyword If    '${feature_check_status}' == 'True'    OpenStackOperations.Create Network    @{NETWORKS}[0]
35     ...    ELSE    OpenStackOperations.Create Network    @{NETWORKS}[0]    --provider-network-type vlan --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK} --provider-segment ${NET_1_VLAN_ID}
36
37 Create Subnet For net_1
38     [Documentation]    Create Sub Nets for the Networks with neutron request.
39     OpenStackOperations.Create SubNet    @{NETWORKS}[0]    @{SUBNETS}[0]    @{SUBNET_CIDRS}[0]
40
41 Create VXLAN Network net_2
42     [Documentation]    Create Network with neutron request.
43     OpenStackOperations.Create Network    @{NETWORKS}[1]
44
45 Create Subnet For net_2
46     [Documentation]    Create Sub Nets for the Networks with neutron request.
47     OpenStackOperations.Create SubNet    @{NETWORKS}[1]    @{SUBNETS}[1]    @{SUBNET_CIDRS}[1]
48
49 Create VXLAN Network net_3
50     [Documentation]    Create Network with neutron request.
51     OpenStackOperations.Create Network    @{NETWORKS}[2]
52
53 Create Subnet For net_3
54     [Documentation]    Create Sub Nets for the Networks with neutron request.
55     OpenStackOperations.Create SubNet    @{NETWORKS}[2]    @{SUBNETS}[2]    @{SUBNET_CIDRS}[2]
56
57 Add Ssh Allow All Rule
58     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
59     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
60
61 Create Vm Instances For net_1
62     [Documentation]    Create Vm instances using flavor and image names for a network.
63     OpenStackOperations.Create Vm Instances    @{NETWORKS}[0]    ${NET_1_VMS}    sg=${SECURITY_GROUP}
64
65 Create Vm Instances For net_2
66     [Documentation]    Create Vm instances using flavor and image names for a network.
67     OpenStackOperations.Create Vm Instances    @{NETWORKS}[1]    ${NET_2_VMS}    sg=${SECURITY_GROUP}
68
69 Create Vm Instances For net_3
70     [Documentation]    Create Vm instances using flavor and image names for a network.
71     OpenStackOperations.Create Vm Instances    @{NETWORKS}[2]    ${NET_3_VMS}    sg=${SECURITY_GROUP}
72
73 Check Vm Instances Have Ip Address
74     @{NET_1_L3_VM_IPS}    ${NET_1_L3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
75     @{NET_2_L3_VM_IPS}    ${NET_2_L3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
76     @{NET_3_L3_VM_IPS}    ${NET_3_L3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_3_VMS}
77     BuiltIn.Set Suite Variable    ${NET_1_L3_VM_IPS}
78     BuiltIn.Set Suite Variable    ${NET_2_L3_VM_IPS}
79     BuiltIn.Set Suite Variable    ${NET_3_L3_VM_IPS}
80     BuiltIn.Should Not Contain    ${NET_1_L3_VM_IPS}    None
81     BuiltIn.Should Not Contain    ${NET_2_L3_VM_IPS}    None
82     BuiltIn.Should Not Contain    ${NET_3_L3_VM_IPS}    None
83     BuiltIn.Should Not Contain    ${NET_1_L3_DHCP_IP}    None
84     BuiltIn.Should Not Contain    ${NET_2_L3_DHCP_IP}    None
85     BuiltIn.Should Not Contain    ${NET_3_L3_DHCP_IP}    None
86     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}    @{NET_3_VMS}
87     ...    AND    OpenStackOperations.Get Test Teardown Debugs
88
89 Create Routers
90     [Documentation]    Create Router
91     OpenStackOperations.Create Router    ${ROUTER}
92
93 Add Interfaces To Router
94     [Documentation]    Add Interfaces
95     : FOR    ${interface}    IN    @{SUBNETS}
96     \    OpenStackOperations.Add Router Interface    ${ROUTER}    ${interface}
97
98 Ping Vm Instance1 In net_2 From net_1 (vxlan to vlan)
99     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
100     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[0]    @{NET_2_L3_VM_IPS}[0]
101
102 Ping Vm Instance2 In net_2 From net_1 (vxlan to vlan)
103     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
104     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[0]    @{NET_2_L3_VM_IPS}[1]
105
106 Ping Vm Instance3 In net_2 From net_1 (vxlan to vlan)
107     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
108     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[0]    @{NET_2_L3_VM_IPS}[2]
109
110 Ping Vm Instance1 In net_1 From net_2 (vlan to vxlan)
111     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
112     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_1_L3_VM_IPS}[0]
113
114 Ping Vm Instance2 In net_1 From net_2 (vlan to vxlan)
115     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
116     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_1_L3_VM_IPS}[1]
117
118 Ping Vm Instance3 In net_1 From net_2 (vlan to vxlan)
119     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
120     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_1_L3_VM_IPS}[2]
121
122 Ping Vm Instance1 In net_3 From net_2 (vxlan to vxlan)
123     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
124     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_3_L3_VM_IPS}[0]
125
126 Ping Vm Instance2 In net_3 From net_2 (vxlan to vxlan)
127     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
128     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_3_L3_VM_IPS}[1]
129
130 Ping Vm Instance3 In net_3 From net_2 (vxlan to vxlan)
131     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
132     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_3_L3_VM_IPS}[2]
133
134 Connectivity Tests From Vm Instance1 In net_1
135     [Documentation]    Login to the VM instance and test operations
136     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
137     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_L3_VM_IPS}[0]    ${dst_list}
138
139 Connectivity Tests From Vm Instance2 In net_1
140     [Documentation]    Login to the vm instance and test operations
141     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
142     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_L3_VM_IPS}[1]    ${dst_list}
143
144 Connectivity Tests From Vm Instance3 In net_1
145     [Documentation]    Login to the vm instance and test operations
146     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
147     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_L3_VM_IPS}[2]    ${dst_list}
148
149 Connectivity Tests From Vm Instance1 In net_2
150     [Documentation]    Login to the vm instance and test operations
151     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
152     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[0]    ${dst_list}
153
154 Connectivity Tests From Vm Instance2 In net_2
155     [Documentation]    Logging to the vm instance using generated key pair.
156     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
157     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[1]    ${dst_list}
158
159 Connectivity Tests From Vm Instance3 In net_2
160     [Documentation]    Logging to the vm instance using generated key pair.
161     ${dst_list} =    BuiltIn.Create List    @{NET_1_L3_VM_IPS}    @{NET_2_L3_VM_IPS}
162     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[2]    ${dst_list}
163
164 Delete Vm Instances In net_1
165     [Documentation]    Delete Vm instances using instance names in net_1.
166     : FOR    ${vm}    IN    @{NET_1_VMS}
167     \    OpenStackOperations.Delete Vm Instance    ${vm}
168
169 Delete Vm Instances In net_2
170     [Documentation]    Delete Vm instances using instance names in net_2.
171     : FOR    ${vm}    IN    @{NET_2_VMS}
172     \    OpenStackOperations.Delete Vm Instance    ${vm}
173
174 Delete Vm Instances In net_3
175     [Documentation]    Delete Vm instances using instance names in net_3.
176     : FOR    ${vm}    IN    @{NET_3_VMS}
177     \    OpenStackOperations.Delete Vm Instance    ${vm}
178
179 Delete Router Interfaces
180     [Documentation]    Remove Interface to the subnets.
181     : FOR    ${interface}    IN    @{SUBNETS}
182     \    OpenStackOperations.Remove Interface    ${ROUTER}    ${interface}
183
184 Delete Router
185     [Documentation]    Delete Router and Interface to the subnets.
186     OpenStackOperations.Delete Router    ${ROUTER}
187
188 Delete Sub Network In net_1
189     [Documentation]    Delete Sub Net for the Network with neutron request.
190     OpenStackOperations.Delete SubNet    l3_sub_1
191
192 Delete Sub Network In net_2
193     [Documentation]    Delete Sub Net for the Network with neutron request.
194     OpenStackOperations.Delete SubNet    l3_sub_2
195
196 Delete Sub Network In net_3
197     [Documentation]    Delete Sub Net for the Network with neutron request.
198     OpenStackOperations.Delete SubNet    l3_sub_3
199
200 Delete Networks
201     [Documentation]    Delete Networks with neutron request.
202     : FOR    ${network}    IN    @{NETWORKS}
203     \    OpenStackOperations.Delete Network    ${network}
204
205 Delete Security Group
206     [Documentation]    Delete security group with neutron request
207     OpenStackOperations.Delete SecurityGroup    ${SECURITY_GROUP}
208
209 Verify Flows Cleanup
210     [Documentation]    Verify that flows have been cleaned up properly after removing all neutron configurations
211     DataModels.Verify Flows Are Cleaned Up On All OpenStack Nodes