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