Cleanup DHCP IP collection, don't mix with VM IPs
[integration/test.git] / csit / suites / openstack / clustering / 01_l2_tests.robot
1 *** Settings ***
2 Documentation     Test suite to verify packet flows between vm instances.
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}    l2_net_1    l2_net_2
22 @{SUBNETS_NAME}    l2_sub_net_1    l2_sub_net_2
23 @{NET_1_VM_INSTANCES}    VmInstance1_l2_net_1    VmInstance2_net_1    VmInstance3_net_1
24 @{NET_2_VM_INSTANCES}    VmInstance1_l2_net_2    VmInstance2_net_2    VmInstance3_net_2
25 @{VM_IPS_NOT_DELETED}    70.0.0.4
26 @{cluster_down_list}    ${1}    ${2}
27 @{SUBNETS_RANGE}    70.0.0.0/24    80.0.0.0/24
28
29 *** Test Cases ***
30 Create All Controller Sessions
31     [Documentation]    Create sessions for all three contorllers.
32     ClusterManagement.ClusterManagement Setup
33
34 Create Networks
35     [Documentation]    Create Network with neutron request.
36     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
37     \    OpenStackOperations.Create Network    ${NetworkElement}
38
39 Create Subnets For l2_net_1
40     [Documentation]    Create Sub Nets for the Networks with neutron request.
41     OpenStackOperations.Create SubNet    l2_net_1    l2_sub_net_1    @{SUBNETS_RANGE}[0]
42
43 Create Subnets For l2_net_2
44     [Documentation]    Create Sub Nets for the Networks with neutron request.
45     OpenStackOperations.Create SubNet    l2_net_2    l2_sub_net_2    @{SUBNETS_RANGE}[1]
46
47 Create Bridge Manually and Verify Before Fail
48     [Documentation]    Create bridge with OVS command and verify it gets applied from all instances.
49     ClusterOvsdb.Create Sample Bridge Manually And Verify    ${OS_CONTROL_NODE_IP}
50
51 Add Tap Device Manually and Verify Before Fail
52     [Documentation]    Add tap devices to the bridge with OVS command and verify it gets applied from all instances.
53     ClusterOvsdb.Add Sample Tap Device To The Manual Bridge And Verify    ${OS_CONTROL_NODE_IP}
54
55 Delete the Bridge Manually and Verify Before Fail
56     [Documentation]    Delete bridge with OVS command and verify it gets deleted from all instances.
57     ClusterOvsdb.Delete Sample Bridge Manually And Verify    ${OS_CONTROL_NODE_IP}
58
59 Take Down ODL1
60     [Documentation]    Kill the karaf in First Controller
61     ${new_cluster_list} =    ClusterManagement.Kill Single Member    1
62     Set Suite Variable    ${new_cluster_list}
63
64 Create Bridge Manually and Verify After Fail
65     [Documentation]    Create bridge with OVS command and verify it gets applied from all instances.
66     ClusterOvsdb.Create Sample Bridge Manually And Verify    ${OS_CONTROL_NODE_IP}    ${new_cluster_list}
67
68 Add Tap Device Manually and Verify After Fail
69     [Documentation]    Add tap devices to the bridge with OVS command and verify it gets applied from all instances.
70     ClusterOvsdb.Add Sample Tap Device To The Manual Bridge And Verify    ${OS_CONTROL_NODE_IP}    ${new_cluster_list}
71
72 Delete the Bridge Manually and Verify After Fail
73     [Documentation]    Delete bridge with OVS command and verify it gets deleted from all instances.
74     ClusterOvsdb.Delete Sample Bridge Manually And Verify    ${OS_CONTROL_NODE_IP}    ${new_cluster_list}
75
76 Bring Up ODL1
77     [Documentation]    Bring up ODL1 again
78     ClusterManagement.Start Single Member    1
79
80 Create Bridge Manually and Verify After Recover
81     [Documentation]    Create bridge with OVS command and verify it gets applied from all instances.
82     ClusterOvsdb.Create Sample Bridge Manually And Verify    ${OS_CONTROL_NODE_IP}
83
84 Add Tap Device Manually and Verify After Recover
85     [Documentation]    Add tap devices to the bridge with OVS command and verify it gets applied from all instances.
86     ClusterOvsdb.Add Sample Tap Device To The Manual Bridge And Verify    ${OS_CONTROL_NODE_IP}
87
88 Delete the Bridge Manually and Verify After Recover
89     [Documentation]    Delete bridge with OVS command and verify it gets deleted from all instances.
90     ClusterOvsdb.Delete Sample Bridge Manually And Verify    ${OS_CONTROL_NODE_IP}
91
92 Take Down ODL2
93     [Documentation]    Kill the karaf in Second Controller
94     ClusterManagement.Kill Single Member    2
95
96 Create Vm Instances For l2_net_2
97     [Documentation]    Create Vm instances using flavor and image names for a network.
98     OpenStackOperations.Create Vm Instances    l2_net_2    ${NET_2_VM_INSTANCES}    sg=csit
99
100 Create Vm Instances For l2_net_1
101     [Documentation]    Create Vm instances using flavor and image names for a network.
102     Log    ${devstack_conn_id}
103     OpenStackOperations.Create Vm Instances    l2_net_1    ${NET_1_VM_INSTANCES}    sg=csit
104
105 Check Vm Instances Have Ip Address
106     [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
107     ...    We are polling first and longest on the last VM created assuming that if it's received it's address
108     ...    already the other instances should have theirs already or at least shortly thereafter.
109     # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
110     # for dhcp addresses
111     : FOR    ${vm}    IN    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
112     \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
113     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
114     ...    true    @{NET_1_VM_INSTANCES}
115     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
116     ...    true    @{NET_2_VM_INSTANCES}
117     ${NET1_VM_IPS}    ${NET1_DHCP_IP}    Collect VM IP Addresses    false    @{NET_1_VM_INSTANCES}
118     ${NET2_VM_IPS}    ${NET2_DHCP_IP}    Collect VM IP Addresses    false    @{NET_2_VM_INSTANCES}
119     ${VM_INSTANCES}=    Collections.Combine Lists    ${NET_1_VM_INSTANCES}    ${NET_2_VM_INSTANCES}
120     ${VM_IPS}=    Collections.Combine Lists    ${NET1_VM_IPS}    ${NET2_VM_IPS}
121     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES}
122     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
123     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
124     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
125     Set Suite Variable    ${NET1_VM_IPS}
126     Set Suite Variable    ${NET2_VM_IPS}
127     Should Not Contain    ${NET1_VM_IPS}    None
128     Should Not Contain    ${NET2_VM_IPS}    None
129     Should Not Contain    ${NET1_DHCP_IP}    None
130     Should Not Contain    ${NET2_DHCP_IP}    None
131     [Teardown]    Run Keywords    Show Debugs    @{NET_1_VM_INSTANCES}    @{NET_2_VM_INSTANCES}
132     ...    AND    Get Test Teardown Debugs
133
134 Bring Up ODL2
135     [Documentation]    Bring up ODL2 again
136     ClusterManagement.Start Single Member    2
137
138 Ping Vm Instance1 In l2_net_1
139     [Documentation]    Check reachability of vm instances by pinging to them.
140     Get OvsDebugInfo
141     OpenStackOperations.Ping Vm From DHCP Namespace    l2_net_1    @{NET_1_VM_IPS}[0]
142
143 Ping Vm Instance2 In l2_net_1
144     [Documentation]    Check reachability of vm instances by pinging to them.
145     Get OvsDebugInfo
146     OpenStackOperations.Ping Vm From DHCP Namespace    l2_net_1    @{NET_1_VM_IPS}[1]
147
148 Ping Vm Instance3 In l2_net_1
149     [Documentation]    Check reachability of vm instances by pinging to them.
150     Get OvsDebugInfo
151     OpenStackOperations.Ping Vm From DHCP Namespace    l2_net_1    @{NET_1_VM_IPS}[2]
152
153 Ping Vm Instance1 In l2_net_2
154     [Documentation]    Check reachability of vm instances by pinging to them.
155     Get OvsDebugInfo
156     OpenStackOperations.Ping Vm From DHCP Namespace    l2_net_2    @{NET_2_VM_IPS}[0]
157
158 Ping Vm Instance2 In l2_net_2
159     [Documentation]    Check reachability of vm instances by pinging to them.
160     Get OvsDebugInfo
161     OpenStackOperations.Ping Vm From DHCP Namespace    l2_net_2    @{NET_2_VM_IPS}[1]
162
163 Ping Vm Instance3 In l2_net_2
164     [Documentation]    Check reachability of vm instances by pinging to them.
165     Get OvsDebugInfo
166     OpenStackOperations.Ping Vm From DHCP Namespace    l2_net_2    @{NET_2_VM_IPS}[2]
167
168 Take Down ODL3
169     [Documentation]    Kill the karaf in Third Controller
170     ClusterManagement.Kill Single Member    3
171
172 Connectivity Tests From Vm Instance1 In l2_net_1
173     [Documentation]    Logging to the vm instance using generated key pair.
174     OpenStackOperations.Test Operations From Vm Instance    l2_net_1    @{NET_1_VM_IPS}[0]    ${NET_1_VM_IPS}
175
176 Connectivity Tests From Vm Instance2 In l2_net_1
177     [Documentation]    Logging to the vm instance using generated key pair.
178     OpenStackOperations.Test Operations From Vm Instance    l2_net_1    @{NET_1_VM_IPS}[1]    ${NET_1_VM_IPS}
179
180 Connectivity Tests From Vm Instance3 In l2_net_1
181     [Documentation]    Logging to the vm instance using generated key pair.
182     OpenStackOperations.Test Operations From Vm Instance    l2_net_1    @{NET_1_VM_IPS}[2]    ${NET_1_VM_IPS}
183
184 Bring Up ODL3
185     [Documentation]    Bring up ODL3 again
186     ClusterManagement.Start Single Member    3
187
188 Take Down ODL1 and ODL2
189     [Documentation]    Kill the karaf in First and Second Controller
190     ClusterManagement.Kill Members From List Or All    ${cluster_down_list}
191
192 Connectivity Tests From Vm Instance1 In l2_net_2
193     [Documentation]    Logging to the vm instance using generated key pair.
194     OpenStackOperations.Test Operations From Vm Instance    l2_net_2    @{NET_2_VM_IPS}[0]    ${NET_2_VM_IPS}
195
196 Connectivity Tests From Vm Instance2 In l2_net_2
197     [Documentation]    Logging to the vm instance using generated key pair.
198     OpenStackOperations.Test Operations From Vm Instance    l2_net_2    @{NET_2_VM_IPS}[1]    ${NET_2_VM_IPS}
199
200 Connectivity Tests From Vm Instance3 In l2_net_2
201     [Documentation]    Logging to the vm instance using generated key pair.
202     OpenStackOperations.Test Operations From Vm Instance    l2_net_2    @{NET_2_VM_IPS}[2]    ${NET_2_VM_IPS}
203
204 Bring Up ODL1 and ODL2
205     [Documentation]    Bring up ODL1 and ODL2 again.
206     ClusterManagement.Start Members From List Or All    ${cluster_down_list}
207
208 Delete Vm Instance
209     [Documentation]    Delete Vm instances using instance names.
210     OpenStackOperations.Delete Vm Instance    VmInstance1_l2_net_1
211
212 No Ping For Deleted Vm
213     [Documentation]    Check non reachability of deleted vm instances by pinging to them.
214     ${output}=    OpenStackOperations.Ping From DHCP Should Not Succeed    l2_network_1    @{NET_1_VM_IPS}[0]
215
216 Delete Vm Instances In network_1
217     [Documentation]    Delete Vm instances using instance names in network_1.
218     : FOR    ${VmElement}    IN    @{NET_1_VM_INSTANCES}
219     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
220
221 Delete Vm Instances In network_2
222     [Documentation]    Delete Vm instances using instance names in network_2.
223     : FOR    ${VmElement}    IN    @{NET_2_VM_INSTANCES}
224     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
225
226 Delete Sub Networks In network_1
227     [Documentation]    Delete Sub Nets for the Networks with neutron request.
228     OpenStackOperations.Delete SubNet    l2_sub_net_1
229
230 Delete Sub Networks In network_2
231     [Documentation]    Delete Sub Nets for the Networks with neutron request.
232     OpenStackOperations.Delete SubNet    l2_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}