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