refactor dhcp function
[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     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
77     ...    true    @{NET_1_VM_INSTANCES}
78     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
79     ...    true    @{NET_2_VM_INSTANCES}
80     ${NET2_L3_VM_IPS}    ${NET2_DHCP_IP}    Collect VM IP Addresses    false    @{NET_2_VM_INSTANCES}
81     ${NET1_L3_VM_IPS}    ${NET1_DHCP_IP}    Collect VM IP Addresses    false    @{NET_1_VM_INSTANCES}
82     ${VM_INSTANCES}=    Collections.Combine Lists    ${NET_1_VM_INSTANCES}    ${NET_2_VM_INSTANCES}
83     ${VM_IPS}=    Collections.Combine Lists    ${NET1_L3_VM_IPS}    ${NET2_L3_VM_IPS}
84     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES}
85     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
86     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
87     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
88     Set Suite Variable    ${NET1_L3_VM_IPS}
89     Set Suite Variable    ${NET2_L3_VM_IPS}
90     Set Suite Variable    ${NET1_DHCP_IP}
91     Set Suite Variable    ${NET2_DHCP_IP}
92     Should Not Contain    ${NET1_L3_VM_IPS}    None
93     Should Not Contain    ${NET2_L3_VM_IPS}    None
94     Should Not Contain    ${NET1_DHCP_IP}    None
95     Should Not Contain    ${NET2_DHCP_IP}    None
96     [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
97     ...    AND    Get Test Teardown Debugs
98
99 Bring Up ODL2
100     [Documentation]    Bring up ODL2 again
101     ClusterManagement.Start Single Member    2
102
103 Take Down ODL3
104     [Documentation]    Kill the karaf in Third Controller
105     ClusterManagement.Kill Single Member    3
106
107 Create Router router_2
108     [Documentation]    Create Router and Add Interface to the subnets. this fails sometimes.
109     OpenStackOperations.Create Router    router_2
110     [Teardown]    Report_Failure_Due_To_Bug    6117
111
112 Create Router router_3
113     [Documentation]    Create Router and Add Interface to the subnets.
114     OpenStackOperations.Create Router    router_3
115
116 Add Interfaces To Router
117     [Documentation]    Add Interfaces
118     : FOR    ${interface}    IN    @{SUBNETS_NAME}
119     \    OpenStackOperations.Add Router Interface    router_3    ${interface}
120
121 Verify Created Routers
122     [Documentation]    Check created routers using northbound rest calls
123     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
124     Log    ${data}
125     Should Contain    ${data}    router_3
126
127 Bring Up ODL3
128     [Documentation]    Bring up ODL3 again
129     ClusterManagement.Start Single Member    3
130
131 Ping Vm Instance1 In l3_net_2 From l3_net_1
132     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
133     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET2_L3_VM_IPS}[0]
134
135 Ping Vm Instance2 In l3_net_2 From l3_net_1
136     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
137     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET2_L3_VM_IPS}[1]
138
139 Ping Vm Instance3 In l3_net_2 From l3_net_1
140     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
141     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_1    @{NET2_L3_VM_IPS}[2]
142
143 Ping Vm Instance1 In l3_net_1 From l3_net_2
144     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
145     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET1_L3_VM_IPS}[0]
146
147 Ping Vm Instance2 In l3_net_1 From l3_net_2
148     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
149     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET1_L3_VM_IPS}[1]
150
151 Ping Vm Instance3 In l3_net_1 From l3_net_2
152     [Documentation]    Check reachability of vm instances by pinging to them after creating routers.
153     OpenStackOperations.Ping Vm From DHCP Namespace    l3_net_2    @{NET1_L3_VM_IPS}[2]
154
155 Take Down ODL1 and ODL2
156     [Documentation]    Kill the karaf in First and Second Controller
157     ClusterManagement.Kill Members From List Or All    ${odl_1_and_2_down}
158     [Teardown]    Get OvsDebugInfo
159
160 Connectivity Tests From Vm Instance1 In l3_net_1
161     [Documentation]    ssh to the VM instance and test operations.
162     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
163     Log    ${dst_ip_list}
164     OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET1_L3_VM_IPS}[0]    ${dst_ip_list}
165     [Teardown]    Get OvsDebugInfo
166
167 Connectivity Tests From Vm Instance2 In l3_net_1
168     [Documentation]    ssh to the VM instance and test operations.
169     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
170     Log    ${dst_ip_list}
171     OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET1_L3_VM_IPS}[1]    ${dst_ip_list}
172     [Teardown]    Get OvsDebugInfo
173
174 Connectivity Tests From Vm Instance3 In l3_net_1
175     [Documentation]    ssh to the VM instance and test operations.
176     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
177     Log    ${dst_ip_list}
178     OpenStackOperations.Test Operations From Vm Instance    l3_net_1    @{NET1_L3_VM_IPS}[2]    ${dst_ip_list}
179     [Teardown]    Get OvsDebugInfo
180
181 Bring Up ODL1 and ODL2
182     [Documentation]    Bring up ODL1 and ODL2 again
183     ClusterManagement.Start Members From List Or All    ${odl_1_and_2_down}
184
185 Take Down ODL2 and ODL3
186     [Documentation]    Kill the karaf in First and Second Controller
187     ClusterManagement.Kill Members From List Or All    ${odl_2_and_3_down}
188     [Teardown]    Get OvsDebugInfo
189
190 Connectivity Tests From Vm Instance1 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}[0]    ${dst_ip_list}
195     [Teardown]    Get OvsDebugInfo
196
197 Connectivity Tests From Vm Instance2 In l3_net_2
198     [Documentation]    ssh to the VM instance and test operations.
199     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
200     Log    ${dst_ip_list}
201     OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET2_L3_VM_IPS}[1]    ${dst_ip_list}
202     [Teardown]    Get OvsDebugInfo
203
204 Connectivity Tests From Vm Instance3 In l3_net_2
205     [Documentation]    ssh to the VM instance and test operations.
206     ${dst_ip_list}=    Create List    @{NET2_L3_VM_IPS}    @{NET1_L3_VM_IPS}
207     Log    ${dst_ip_list}
208     OpenStackOperations.Test Operations From Vm Instance    l3_net_2    @{NET2_L3_VM_IPS}[2]    ${dst_ip_list}
209     [Teardown]    Get OvsDebugInfo
210
211 Bring Up ODL2 and ODL3
212     [Documentation]    Bring up ODL2 and ODL3 again.
213     ClusterManagement.Start Members From List Or All    ${odl_2_and_3_down}
214
215 Delete Vm Instances In l3_net_1
216     [Documentation]    Delete Vm instances using instance names in l3_net_1.
217     : FOR    ${VmElement}    IN    @{NET_1_VM_INSTANCES}
218     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
219
220 Delete Vm Instances In l3_net_2
221     [Documentation]    Delete Vm instances using instance names in l3_net_2.
222     : FOR    ${VmElement}    IN    @{NET_2_VM_INSTANCES}
223     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
224
225 Delete Router Interfaces
226     [Documentation]    Remove Interface to the subnets.
227     : FOR    ${interface}    IN    @{SUBNETS_NAME}
228     \    OpenStackOperations.Remove Interface    router_3    ${interface}
229
230 Delete Routers
231     [Documentation]    Delete Router and Interface to the subnets.
232     OpenStackOperations.Delete Router    router_2
233     OpenStackOperations.Delete Router    router_3
234
235 Verify Deleted Routers
236     [Documentation]    Check deleted routers using northbound rest calls
237     ${data}    Utils.Get Data From URI    1    ${NEUTRON_ROUTERS_API}
238     Log    ${data}
239     Should Not Contain    ${data}    router_3
240
241 Delete Sub Networks In l3_net_1
242     [Documentation]    Delete Sub Nets for the Networks with neutron request.
243     OpenStackOperations.Delete SubNet    l3_sub_net_1
244
245 Delete Sub Networks In l3_net_2
246     [Documentation]    Delete Sub Nets for the Networks with neutron request.
247     OpenStackOperations.Delete SubNet    l3_sub_net_2
248
249 Delete Networks
250     [Documentation]    Delete Networks with neutron request.
251     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
252     \    OpenStackOperations.Delete Network    ${NetworkElement}