Expand documentation of SetupUtils
[integration/test.git] / csit / suites / openstack / clustering / 02_l3_tests.robot
1 *** Settings ***
2 Documentation     Test suite to check connectivity in L3 using routers.
3 Suite Setup       Devstack Suite Setup    source_pwd=yes
4 Suite Teardown    Close All Connections
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown     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 Variables         ../../../variables/Variables.py
19
20 *** Variables ***
21 @{NETWORKS_NAME}    l3_net_1    l3_net_2
22 @{SUBNETS_NAME}    l3_sub_net_1    l3_sub_net_2
23 @{NET_1_VM_INSTANCES}    VmInstance1_net_1    VmInstance2_net_1    VmInstance3_net_1
24 @{NET_2_VM_INSTANCES}    VmInstance1_net_2    VmInstance2_net_2    VmInstance3_net_2
25 @{GATEWAY_IPS}    90.0.0.1    100.0.0.1
26 @{SUBNETS_RANGE}    90.0.0.0/24    100.0.0.0/24
27 @{odl_1_and_2_down}    ${1}    ${2}
28 @{odl_2_and_3_down}    ${2}    ${3}
29
30 *** Test Cases ***
31 Create All Controller Sessions
32     [Documentation]    Create sessions for all three contorllers.
33     ClusterManagement.ClusterManagement Setup
34
35 Create Networks
36     [Documentation]    Create Network with neutron request.
37     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
38     \    OpenStackOperations.Create Network    ${NetworkElement}
39
40 Create Subnets For l3_net_1
41     [Documentation]    Create Sub Nets for the Networks with neutron request.
42     OpenStackOperations.Create SubNet    l3_net_1    l3_sub_net_1    @{SUBNETS_RANGE}[0]
43
44 Create Subnets For l3_net_2
45     [Documentation]    Create Sub Nets for the Networks with neutron request.
46     OpenStackOperations.Create SubNet    l3_net_2    l3_sub_net_2    @{SUBNETS_RANGE}[1]
47
48 Take Down ODL1
49     [Documentation]    Kill the karaf in First Controller
50     ClusterManagement.Kill Single Member    1
51
52 Create Vm Instances For l3_net_1
53     [Documentation]    Create Four Vm instances using flavor and image names for a network.
54     OpenStackOperations.Create Vm Instances    l3_net_1    ${NET_1_VM_INSTANCES}    sg=csit
55
56 Bring Up ODL1
57     [Documentation]    Bring up ODL1 again
58     ClusterManagement.Start Single Member    1
59
60 Take Down ODL2
61     [Documentation]    Kill the karaf in Second Controller
62     ClusterManagement.Kill Single Member    2
63
64 Create Vm Instances For l3_net_2
65     [Documentation]    Create Four Vm instances using flavor and image names for a network.
66     OpenStackOperations.Create Vm Instances    l3_net_2    ${NET_2_VM_INSTANCES}    sg=csit
67
68 Check Vm Instances Have Ip Address
69     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
70     ...    We are polling first and longest on the last VM created assuming that if it's received it's address
71     ...    already the other instances should have theirs already or at least shortly thereafter.
72     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
73     # for dhcp addresses
74     : FOR    ${vm}    IN    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
75     \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
76     ${NET1_VM_COUNT}    Get Length    ${NET_1_VM_INSTANCES}
77     ${NET2_VM_COUNT}    Get Length    ${NET_2_VM_INSTANCES}
78     ${LOOP_COUNT}    Evaluate    ${NET1_VM_COUNT}+${NET2_VM_COUNT}
79     : FOR    ${index}    IN RANGE    1    ${LOOP_COUNT}
80     \    ${NET1_L3_VM_IPS}    ${NET1_DHCP_IP}    Verify VMs Received DHCP Lease    @{NET_1_VM_INSTANCES}
81     \    ${NET2_L3_VM_IPS}    ${NET2_DHCP_IP}    Verify VMs Received DHCP Lease    @{NET_2_VM_INSTANCES}
82     \    ${NET1_VM_LIST_LENGTH}=    Get Length    ${NET1_L3_VM_IPS}
83     \    ${NET2_VM_LIST_LENGTH}=    Get Length    ${NET2_L3_VM_IPS}
84     \    Exit For Loop If    ${NET1_VM_LIST_LENGTH}==${NET1_VM_COUNT} and ${NET2_VM_LIST_LENGTH}==${NET2_VM_COUNT}
85     Set Suite Variable    ${NET1_L3_VM_IPS}
86     Set Suite Variable    ${NET1_DHCP_IP}
87     Set Suite Variable    ${NET2_L3_VM_IPS}
88     Set Suite Variable    ${NET2_DHCP_IP}
89     [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
90     ...    AND    Get Test Teardown Debugs
91
92 Bring Up ODL2
93     [Documentation]    Bring up ODL2 again
94     ClusterManagement.Start Single Member    2
95
96 Take Down ODL3
97     [Documentation]    Kill the karaf in Third Controller
98     ClusterManagement.Kill Single Member    3
99
100 Create Router router_2
101     [Documentation]    Create Router and Add Interface to the subnets. this fails sometimes.
102     OpenStackOperations.Create Router    router_2
103     [Teardown]    Report_Failure_Due_To_Bug    6117
104
105 Create Router router_3
106     [Documentation]    Create Router and Add Interface to the subnets.
107     OpenStackOperations.Create Router    router_3
108
109 Add Interfaces To Router
110     [Documentation]    Add Interfaces
111     : FOR    ${interface}    IN    @{SUBNETS_NAME}
112     \    OpenStackOperations.Add Router Interface    router_3    ${interface}
113
114 Verify Created Routers
115     [Documentation]    Check created routers using northbound rest calls
116     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
117     Log    ${data}
118     Should Contain    ${data}    router_3
119
120 Bring Up ODL3
121     [Documentation]    Bring up ODL3 again
122     ClusterManagement.Start Single Member    3
123
124 Ping Vm Instance1 In l3_net_2 From l3_net_1
125     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
126     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET2_L3_VM_IPS}[0]
127
128 Ping Vm Instance2 In l3_net_2 From l3_net_1
129     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
130     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET2_L3_VM_IPS}[1]
131
132 Ping Vm Instance3 In l3_net_2 From l3_net_1
133     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
134     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET2_L3_VM_IPS}[2]
135
136 Ping Vm Instance1 In l3_net_1 From l3_net_2
137     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
138     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET1_L3_VM_IPS}[0]
139
140 Ping Vm Instance2 In l3_net_1 From l3_net_2
141     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
142     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET1_L3_VM_IPS}[1]
143
144 Ping Vm Instance3 In l3_net_1 From l3_net_2
145     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
146     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET1_L3_VM_IPS}[2]
147
148 Take Down ODL1 and ODL2
149     [Documentation]    Kill the karaf in First and Second Controller
150     ClusterManagement.Kill Members From List Or All    ${odl_1_and_2_down}
151
152 Connectivity Tests From Vm Instance1 In l3_net_1
153     [Documentation]    ssh to the VM instance and test operations.
154     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
155     Log    ${dst_ip_list}
156     OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET1_L3_VM_IPS}[0]    ${dst_ip_list}
157
158 Connectivity Tests From Vm Instance2 In l3_net_1
159     [Documentation]    ssh to the VM instance and test operations.
160     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
161     Log    ${dst_ip_list}
162     OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET1_L3_VM_IPS}[1]    ${dst_ip_list}
163
164 Connectivity Tests From Vm Instance3 In l3_net_1
165     [Documentation]    ssh to the VM instance and test operations.
166     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
167     Log    ${dst_ip_list}
168     OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET1_L3_VM_IPS}[2]    ${dst_ip_list}
169
170 Bring Up ODL1 and ODL2
171     [Documentation]    Bring up ODL1 and ODL2 again
172     ClusterManagement.Start Members From List Or All    ${odl_1_and_2_down}
173
174 Take Down ODL2 and ODL3
175     [Documentation]    Kill the karaf in First and Second Controller
176     ClusterManagement.Kill Members From List Or All    ${odl_2_and_3_down}
177
178 Connectivity Tests From Vm Instance1 In l3_net_2
179     [Documentation]    ssh to the VM instance and test operations.
180     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
181     Log    ${dst_ip_list}
182     OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET2_L3_VM_IPS}[0]    ${dst_ip_list}
183
184 Connectivity Tests From Vm Instance2 In l3_net_2
185     [Documentation]    ssh to the VM instance and test operations.
186     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
187     Log    ${dst_ip_list}
188     OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET2_L3_VM_IPS}[1]    ${dst_ip_list}
189
190 Connectivity Tests From Vm Instance3 In l3_net_2
191     [Documentation]    ssh to the VM instance and test operations.
192     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
193     Log    ${dst_ip_list}
194     OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET2_L3_VM_IPS}[2]    ${dst_ip_list}
195
196 Bring Up ODL2 and ODL3
197     [Documentation]    Bring up ODL2 and ODL3 again.
198     ClusterManagement.Start Members From List Or All    ${odl_2_and_3_down}
199
200 Delete Vm Instances In l3_net_1
201     [Documentation]    Delete Vm instances using instance names in l3_net_1.
202     : FOR    ${VmElement}    IN    @{NET_1_VM_INSTANCES}
203     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
204
205 Delete Vm Instances In l3_net_2
206     [Documentation]    Delete Vm instances using instance names in l3_net_2.
207     : FOR    ${VmElement}    IN    @{NET_2_VM_INSTANCES}
208     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
209
210 Delete Router Interfaces
211     [Documentation]    Remove Interface to the subnets.
212     : FOR    ${interface}    IN    @{SUBNETS_NAME}
213     \    OpenStackOperations.Remove Interface    router_3    ${interface}
214
215 Delete Routers
216     [Documentation]    Delete Router and Interface to the subnets.
217     OpenStackOperations.Delete Router    router_2
218     OpenStackOperations.Delete Router    router_3
219
220 Verify Deleted Routers
221     [Documentation]    Check deleted routers using northbound rest calls
222     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
223     Log    ${data}
224     Should Not Contain    ${data}    router_3
225
226 Delete Sub Networks In l3_net_1
227     [Documentation]    Delete Sub Nets for the Networks with neutron request.
228     OpenStackOperations.Delete SubNet    l3_sub_net_1
229
230 Delete Sub Networks In l3_net_2
231     [Documentation]    Delete Sub Nets for the Networks with neutron request.
232     OpenStackOperations.Delete SubNet    l3_sub_net_2
233
234 Delete Networks
235     [Documentation]    Delete Networks with neutron request.
236     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
237     \    OpenStackOperations.Delete Network    ${NetworkElement}