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