Use graceful start and stop
[integration/test.git] / csit / suites / openstack / clustering / ha_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    Close All Connections
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 Library           Collections
11 Resource          ../../../libraries/Utils.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/DevstackUtils.robot
14 Resource          ../../../libraries/OVSDB.robot
15 Resource          ../../../libraries/ClusterOvsdb.robot
16 Resource          ../../../libraries/ClusterManagement.robot
17 Resource          ../../../libraries/SetupUtils.robot
18 Resource          ../../../variables/Variables.robot
19 Resource          ../../../variables/netvirt/Variables.robot
20
21 *** Variables ***
22 ${SECURITY_GROUP}    cl3_sg
23 @{NETWORKS}       cl3_net_1    cl3_net_2
24 @{SUBNETS}        cl3_sub_1    cl3_sub_2
25 @{ROUTERS}        cl3_router_1    cl3_router_2    cl3_router_3
26 @{NET_1_VMS}      cl3_net_1_vm_1    cl3_net_1_vm_2    cl3_net_1_vm_3
27 @{NET_2_VMS}      cl3_net_2_vm_1    cl3_net_2_vm_2    cl3_net_2_vm_3
28 @{SUBNET_CIDRS}    36.0.0.0/24    37.0.0.0/24
29 @{GATEWAY_IPS}    36.0.0.1    37.0.0.1
30 @{ODL_1_AND_2_DOWN}    ${1}    ${2}
31 @{ODL_2_AND_3_DOWN}    ${2}    ${3}
32
33 *** Test Cases ***
34 Create All Controller Sessions
35     [Documentation]    Create sessions for all three controllers.
36     ClusterManagement.ClusterManagement Setup
37
38 Take Down Leader Of Default Shard
39     [Documentation]    Stop the karaf on ODL cluster leader
40     ${cluster_leader}    ${followers} =    ClusterManagement.Get Leader And Followers For Shard    shard_type=config
41     BuiltIn.Set Suite Variable    ${cluster_leader}
42     ${new_cluster_list} =    ClusterManagement.Stop Single Member    ${cluster_leader}    msg=up: ODL1, ODL2, ODL3, down=none
43     BuiltIn.Set Suite Variable    ${new_cluster_list}
44
45 Create Networks
46     [Documentation]    Create Network with neutron request.
47     : FOR    ${NetworkElement}    IN    @{NETWORKS}
48     \    OpenStackOperations.Create Network    ${NetworkElement}
49
50 Create Subnets For net_1
51     [Documentation]    Create Sub Nets for the Networks with neutron request.
52     OpenStackOperations.Create SubNet    @{NETWORKS}[0]    @{SUBNETS}[0]    @{SUBNET_CIDRS}[0]
53
54 Create Subnets For net_2
55     [Documentation]    Create Sub Nets for the Networks with neutron request.
56     OpenStackOperations.Create SubNet    @{NETWORKS}[1]    @{SUBNETS}[1]    @{SUBNET_CIDRS}[1]
57
58 Bring Up Leader Of Default Shard
59     [Documentation]    Bring up on cluster leader
60     ClusterManagement.Start Single Member    ${cluster_leader}    msg=up: ${new_cluster_list}, down: ${cluster_leader}
61
62 Add Ssh Allow All Rule
63     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
64     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
65
66 Take Down ODL1
67     [Documentation]    Stop the karaf in First Controller
68     ClusterManagement.Stop Single Member    1    msg=up: ODL1, ODL2, ODL3, down=none
69
70 Create Vm Instances For net_1
71     [Documentation]    Create Vm instances using flavor and image names for a network.
72     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
73     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_VMS}[1]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
74     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_VMS}[2]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
75
76 Bring Up ODL1
77     [Documentation]    Bring up ODL1 again
78     ClusterManagement.Start Single Member    1    msg=up: ODL2, ODL3, down: ODL1
79
80 Take Down ODL2
81     [Documentation]    Stop the karaf in Second Controller
82     ClusterManagement.Stop Single Member    2    msg=up: ODL1, ODL2, ODL3, down=none
83
84 Create Vm Instances For net_2
85     [Documentation]    Create Vm instances using flavor and image names for a network.
86     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[1]    @{NET_2_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
87     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[1]    @{NET_2_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
88     OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[1]    @{NET_2_VMS}[2]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
89
90 Check Vm Instances Have Ip Address
91     @{NET_1_L3_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
92     @{NET_2_L3_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
93     BuiltIn.Set Suite Variable    @{NET_1_L3_VM_IPS}
94     BuiltIn.Set Suite Variable    @{NET_2_L3_VM_IPS}
95     BuiltIn.Should Not Contain    ${NET_1_L3_VM_IPS}    None
96     BuiltIn.Should Not Contain    ${NET_2_L3_VM_IPS}    None
97     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
98     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
99     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}
100     ...    AND    OpenStackOperations.Get Test Teardown Debugs
101
102 Bring Up ODL2
103     [Documentation]    Bring up ODL2 again
104     ClusterManagement.Start Single Member    2    msg=up: ODL1, ODL3, down: ODL2
105
106 Take Down ODL3
107     [Documentation]    Stop the karaf in Third Controller
108     ClusterManagement.Stop Single Member    3    msg=up: ODL1, ODL2, ODL3, down=none
109
110 Create Router router_2
111     [Documentation]    Create Router and Add Interface to the subnets.
112     OpenStackOperations.Create Router    @{ROUTERS}[1]
113     [Teardown]    Report_Failure_Due_To_Bug    6117
114
115 Create Router router_3
116     [Documentation]    Create Router and Add Interface to the subnets.
117     OpenStackOperations.Create Router    @{ROUTERS}[2]
118
119 Add Interfaces To Router
120     [Documentation]    Add Interfaces
121     : FOR    ${interface}    IN    @{SUBNETS}
122     \    OpenStackOperations.Add Router Interface    @{ROUTERS}[2]    ${interface}
123
124 Verify Created Routers
125     [Documentation]    Check created routers using northbound rest calls
126     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
127     BuiltIn.Log    ${data}
128     Should Contain    ${data}    @{ROUTERS}[2]
129
130 Bring Up ODL3
131     [Documentation]    Bring up ODL3 again
132     ClusterManagement.Start Single Member    3    msg=up: ODL1, ODL2, down: ODL3
133
134 Ping Vm Instance1 In net_2 From net_1
135     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
136     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[0]    @{NET_2_L3_VM_IPS}[0]
137
138 Ping Vm Instance2 In net_2 From net_1
139     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
140     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[0]    @{NET_2_L3_VM_IPS}[1]
141
142 Ping Vm Instance3 In net_2 From net_1
143     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
144     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[0]    @{NET_2_L3_VM_IPS}[2]
145
146 Ping Vm Instance1 In net_1 From net_2
147     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
148     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_1_L3_VM_IPS}[0]
149
150 Ping Vm Instance2 In net_1 From net_2
151     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
152     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_1_L3_VM_IPS}[1]
153
154 Ping Vm Instance3 In net_1 From net_2
155     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
156     OpenStackOperations.Ping Vm From DHCP Namespace    @{NETWORKS}[1]    @{NET_1_L3_VM_IPS}[2]
157
158 Take Down ODL1 and ODL2
159     [Documentation]    Stop the karaf in First and Second Controller
160     ClusterManagement.Stop Single Member    1    msg=up: ODL1, ODL2, ODL3, down=none
161     ClusterManagement.Stop Single Member    2    msg=up: ODL2, ODL3, down=ODL1
162     [Teardown]    OpenStackOperations.Get Test Teardown Debugs    fail=False
163
164 Connectivity Tests From Vm Instance1 In net_1
165     [Documentation]    ssh to the VM instance and test operations.
166     ${dst_list} =    BuiltIn.Create List    @{NET_2_L3_VM_IPS}    @{NET_1_L3_VM_IPS}
167     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_L3_VM_IPS}[0]    ${dst_list}
168     [Teardown]    OpenStackOperations.Get OvsDebugInfo
169
170 Connectivity Tests From Vm Instance2 In net_1
171     [Documentation]    ssh to the VM instance and test operations.
172     ${dst_list} =    BuiltIn.Create List    @{NET_2_L3_VM_IPS}    @{NET_1_L3_VM_IPS}
173     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_L3_VM_IPS}[1]    ${dst_list}
174     [Teardown]    OpenStackOperations.Get OvsDebugInfo
175
176 Connectivity Tests From Vm Instance3 In net_1
177     [Documentation]    ssh to the VM instance and test operations.
178     ${dst_list} =    BuiltIn.Create List    @{NET_2_L3_VM_IPS}    @{NET_1_L3_VM_IPS}
179     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_L3_VM_IPS}[2]    ${dst_list}
180     [Teardown]    OpenStackOperations.Get OvsDebugInfo
181
182 Bring Up ODL1 and ODL2
183     [Documentation]    Bring up ODL1 and ODL2 again. Do not check for cluster sync until all nodes are
184     ...    up. akka will not let nodes join until they are all back up if two were down.
185     ClusterManagement.Start Single Member    1    msg=up: ODL3, down: ODL1, ODL2    wait_for_sync=False
186     ClusterManagement.Start Single Member    2    msg=up: ODL1, ODL3, down: ODL2
187     [Teardown]    OpenStackOperations.Get Test Teardown Debugs    fail=False
188
189 Take Down ODL2 and ODL3
190     [Documentation]    Stop the karaf in First and Second Controller
191     ClusterManagement.Stop Single Member    2    msg=up: ODL1, ODL2, ODL3, down=none
192     ClusterManagement.Stop Single Member    3    msg=up: ODL1, ODL3, down=ODL2
193     [Teardown]    OpenStackOperations.Get Test Teardown Debugs    fail=False
194
195 Connectivity Tests From Vm Instance1 In net_2
196     [Documentation]    ssh to the VM instance and test operations.
197     ${dst_list} =    BuiltIn.Create List    @{NET_2_L3_VM_IPS}    @{NET_1_L3_VM_IPS}
198     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[0]    ${dst_list}
199     [Teardown]    OpenStackOperations.Get OvsDebugInfo
200
201 Connectivity Tests From Vm Instance2 In net_2
202     [Documentation]    ssh to the VM instance and test operations.
203     ${dst_list} =    BuiltIn.Create List    @{NET_2_L3_VM_IPS}    @{NET_1_L3_VM_IPS}
204     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[1]    ${dst_list}
205     [Teardown]    OpenStackOperations.Get OvsDebugInfo
206
207 Connectivity Tests From Vm Instance3 In net_2
208     [Documentation]    ssh to the VM instance and test operations.
209     ${dst_list} =    BuiltIn.Create List    @{NET_2_L3_VM_IPS}    @{NET_1_L3_VM_IPS}
210     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[2]    ${dst_list}
211     [Teardown]    OpenStackOperations.Get OvsDebugInfo
212
213 Bring Up ODL2 and ODL3
214     [Documentation]    Bring up ODL2 and ODL3 again. Do not check for cluster sync until all nodes are
215     ...    up. akka will not let nodes join until they are all back up if two were down.
216     ClusterManagement.Start Single Member    2    msg=up: ODL1, down: ODL2, ODL3    wait_for_sync=False
217     ClusterManagement.Start Single Member    3    msg=up: ODL1, ODL2, down: ODL3
218     [Teardown]    OpenStackOperations.Get Test Teardown Debugs    fail=False
219
220 Take Down All Instances
221     [Documentation]    Stop karaf on all controllers
222     ClusterManagement.Stop Single Member    1    msg=up: ODL1, ODL2, ODL3, down=none
223     ClusterManagement.Stop Single Member    2    msg=up: ODL2, ODL3, down=ODL1
224     ClusterManagement.Stop Single Member    3    msg=up: ODL3, down=ODL1, ODL2
225     [Teardown]    OpenStackOperations.Get Test Teardown Debugs    fail=False
226
227 Bring Up All Instances
228     [Documentation]    Bring up all controllers. Do not check for cluster sync until all nodes are
229     ...    up. akka will not let nodes join until they are all back up if two were down.
230     ClusterManagement.Start Single Member    1    msg=up: none, down: ODL1, ODL2, ODL3    wait_for_sync=False
231     ClusterManagement.Start Single Member    2    msg=up: ~ODL1, down: ODL2, ODL3    wait_for_sync=False
232     ClusterManagement.Start Single Member    3    msg=up: ~ODL1, ~ODL2, down: ODL3
233     [Teardown]    OpenStackOperations.Get Test Teardown Debugs    fail=False
234
235 Connectivity Tests From Vm Instance2 In net_2 after recovering all nodes
236     [Documentation]    ssh to the VM instance and test operations.
237     ${dst_list} =    BuiltIn.Create List    @{NET_2_L3_VM_IPS}    @{NET_1_L3_VM_IPS}
238     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[1]    ${dst_list}
239     [Teardown]    OpenStackOperations.Get OvsDebugInfo
240
241 Connectivity Tests From Vm Instance3 In net_2 after recovering all nodes
242     [Documentation]    ssh to the VM instance and test operations.
243     ${dst_list} =    BuiltIn.Create List    @{NET_2_L3_VM_IPS}    @{NET_1_L3_VM_IPS}
244     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_L3_VM_IPS}[2]    ${dst_list}
245     [Teardown]    OpenStackOperations.Get OvsDebugInfo
246
247 Delete Vm Instances In net_1
248     [Documentation]    Delete Vm instances using instance names in net_1.
249     : FOR    ${vm}    IN    @{NET_1_VMS}
250     \    OpenStackOperations.Delete Vm Instance    ${vm}
251
252 Delete Vm Instances In net_2
253     [Documentation]    Delete Vm instances using instance names in net_2.
254     : FOR    ${vm}    IN    @{NET_2_VMS}
255     \    OpenStackOperations.Delete Vm Instance    ${vm}
256
257 Delete Router Interfaces
258     [Documentation]    Remove Interface to the subnets.
259     : FOR    ${interface}    IN    @{SUBNETS}
260     \    OpenStackOperations.Remove Interface    @{ROUTERS}[2]    ${interface}
261
262 Delete Routers
263     [Documentation]    Delete Router and Interface to the subnets.
264     OpenStackOperations.Delete Router    @{ROUTERS}[1]
265     OpenStackOperations.Delete Router    @{ROUTERS}[2]
266
267 Verify Deleted Routers
268     [Documentation]    Check deleted routers using northbound rest calls
269     ${data} =    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
270     BuiltIn.Log    ${data}
271     BuiltIn.Should Not Contain    ${data}    @{ROUTERS}[2]
272
273 Delete Sub Network In net_1
274     [Documentation]    Delete Sub Nets for the Networks with neutron request.
275     OpenStackOperations.Delete SubNet    @{SUBNETS}[0]
276
277 Delete Sub Network In net_2
278     [Documentation]    Delete Sub Nets for the Networks with neutron request.
279     OpenStackOperations.Delete SubNet    @{SUBNETS}[1]
280
281 Delete Networks
282     [Documentation]    Delete Networks with neutron request.
283     : FOR    ${network}    IN    @{NETWORKS}
284     \    OpenStackOperations.Delete Network    ${network}
285
286 Delete Security Group
287     [Documentation]    Delete security groups with neutron request
288     OpenStackOperations.Delete SecurityGroup    ${SECURITY_GROUP}
289
290 Verify Flows Cleanup
291     [Documentation]    Verify that flows have been cleaned up properly after removing all neutron configurations
292     DataModels.Verify Flows Are Cleaned Up On All OpenStack Nodes