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