Update Robot Framework format - step 11
[integration/test.git] / csit / suites / netvirt / elan / elan.robot
1 *** Settings ***
2 Documentation       Test suite to validate elan service functionality in ODL environment.
3 ...                 The assumption of this suite is that the environment is already configured with the proper
4 ...                 integration bridges and vxlan tunnels.
5
6 Library             OperatingSystem
7 Library             RequestsLibrary
8 Library             String
9 Resource            ../../../libraries/KarafKeywords.robot
10 Resource            ../../../libraries/Utils.robot
11 Resource            ../../../libraries/OVSDB.robot
12 Resource            ../../../libraries/OpenStackOperations.robot
13 Resource            ../../../libraries/DevstackUtils.robot
14 Resource            ../../../libraries/SetupUtils.robot
15 Resource            ../../../variables/Variables.robot
16 Resource            ../../../variables/netvirt/Variables.robot
17
18 Suite Setup         Suite Setup
19 Suite Teardown      OpenStackOperations.OpenStack Suite Teardown
20 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
21 Test Teardown       OpenStackOperations.Get Test Teardown Debugs
22
23
24 *** Variables ***
25 ${SECURITY_GROUP}       elan_sg
26 @{NETWORKS}             elan_net_1    elan_net_2    elan_net_3
27 @{SUBNETS}              elan_sub_1    elan_sub_2    elan_sub_3
28 @{SUBNET_CIDRS}         81.1.1.0/24    82.1.1.0/24    83.1.1.0/24
29 @{NET_1_PORTS}          elan_net_1_port_1    elan_net_1_port_2
30 @{NET_2_PORTS}          elan_net_2_port_1    elan_net_2_port_2
31 @{NET_3_PORTS}          elan_net_3_port_1    elan_net_3_port_2
32 @{NET_1_VMS}            elan_net_1_vm_1    elan_net_1_vm_2
33 @{NET_2_VMS}            elan_net_2_vm_1    elan_net_2_vm_2
34 @{NET_3_VMS}            elan_net_3_vm_1    elan_net_3_vm_2
35
36
37 *** Test Cases ***
38 Verify Datapath for Single ELAN with Multiple DPN
39     [Documentation]    Verify Flow Table and Datapath
40     ${smac_cn1} =    BuiltIn.Create List    ${NET_1_MACS}[0]
41     ${smac_cn2} =    BuiltIn.Create List    ${NET_1_MACS}[1]
42     BuiltIn.Wait Until Keyword Succeeds
43     ...    30s
44     ...    10s
45     ...    Verify Flows Are Present For ELAN Service
46     ...    ${OS_CMP1_IP}
47     ...    ${smac_cn1}
48     ...    ${NET_1_MACS}
49     BuiltIn.Wait Until Keyword Succeeds
50     ...    30s
51     ...    10s
52     ...    Verify Flows Are Present For ELAN Service
53     ...    ${OS_CMP2_IP}
54     ...    ${smac_cn2}
55     ...    ${NET_1_MACS}
56     ${output} =    OpenStackOperations.Execute Command on VM Instance
57     ...    ${NETWORKS}[0]
58     ...    ${NET_1_VM_IPS}[0]
59     ...    ping -c 3 ${NET_1_VM_IPS}[1]
60     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
61     ${output} =    OpenStackOperations.Execute Command on VM Instance
62     ...    ${NETWORKS}[0]
63     ...    ${NET_1_VM_IPS}[1]
64     ...    ping -c 3 ${NET_1_VM_IPS}[0]
65     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
66
67 Verify Datapath After OVS Restart
68     [Documentation]    Verify datapath after OVS restart
69     FOR    ${ip}    IN    @{OS_CMP_IPS}
70         OVSDB.Restart OVSDB    ${ip}
71     END
72     FOR    ${ip}    IN    @{OS_CMP_IPS}
73         BuiltIn.Wait Until Keyword Succeeds    30s    10s    OVSDB.Verify OVS Reports Connected    tools_system=${ip}
74     END
75     ${smac_cn1} =    BuiltIn.Create List    ${NET_1_MACS}[0]
76     ${smac_cn2} =    BuiltIn.Create List    ${NET_1_MACS}[1]
77     BuiltIn.Wait Until Keyword Succeeds
78     ...    60s
79     ...    10s
80     ...    Verify Flows Are Present For ELAN Service
81     ...    ${OS_CMP1_IP}
82     ...    ${smac_cn1}
83     ...    ${NET_1_MACS}
84     BuiltIn.Wait Until Keyword Succeeds
85     ...    60s
86     ...    10s
87     ...    Verify Flows Are Present For ELAN Service
88     ...    ${OS_CMP2_IP}
89     ...    ${smac_cn2}
90     ...    ${NET_1_MACS}
91     ${output} =    OpenStackOperations.Execute Command on VM Instance
92     ...    ${NETWORKS}[0]
93     ...    ${NET_1_VM_IPS}[0]
94     ...    ping -c 3 ${NET_1_VM_IPS}[1]
95     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
96     ${output} =    OpenStackOperations.Execute Command on VM Instance
97     ...    ${NETWORKS}[0]
98     ...    ${NET_1_VM_IPS}[1]
99     ...    ping -c 3 ${NET_1_VM_IPS}[0]
100     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
101
102 Verify Datapath After Recreate VM Instance
103     [Documentation]    Verify datapath after recreating Vm instance
104     OpenStackOperations.Delete Vm Instance    ${NET_1_VMS[0]}
105     ${smac_cn1} =    BuiltIn.Create List    ${NET_1_MACS}[0]
106     BuiltIn.Wait Until Keyword Succeeds
107     ...    30s
108     ...    10s
109     ...    Verify Flows Are Removed For ELAN Service
110     ...    ${OS_CMP1_IP}
111     ...    ${smac_cn1}
112     OpenStackOperations.Remove RSA Key From KnownHosts    ${NET_1_VM_IPS}[0]
113     OpenStackOperations.Create Vm Instance With Port On Compute Node
114     ...    ${NET_1_PORTS[0]}
115     ...    ${NET_1_VMS[0]}
116     ...    ${OS_CMP1_HOSTNAME}
117     ...    sg=${SECURITY_GROUP}
118     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
119     Builtin.Set Suite Variable    @{NET_1_VM_IPS}
120     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
121     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
122     BuiltIn.Wait Until Keyword Succeeds
123     ...    30s
124     ...    10s
125     ...    Verify Flows Are Present For ELAN Service
126     ...    ${OS_CMP1_IP}
127     ...    ${smac_cn1}
128     ...    ${NET_1_MACS}
129     ${output} =    OpenStackOperations.Execute Command on VM Instance
130     ...    ${NETWORKS}[0]
131     ...    ${NET_1_VM_IPS}[0]
132     ...    ping -c 3 ${NET_1_VM_IPS}[1]
133     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
134     ${output} =    OpenStackOperations.Execute Command on VM Instance
135     ...    ${NETWORKS}[0]
136     ...    ${NET_1_VM_IPS}[1]
137     ...    ping -c 3 ${NET_1_VM_IPS}[0]
138     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
139
140 Delete All elan_net_1 VM And Verify Flow Table Updated
141     [Documentation]    Verify Flow table after all VM instance deleted
142     FOR    ${vm}    IN    @{NET_1_VMS}
143         OpenStackOperations.Delete Vm Instance    ${vm}
144     END
145     Verify Flows Are Removed For ELAN Service On All compute Nodes    ${NET_1_MACS}
146
147 Verify Datapath for Multiple ELAN with Multiple DPN
148     [Documentation]    Verify Flow Table and Data path for Multiple ELAN with Multiple DPN
149     [Setup]    BuiltIn.Run Keywords    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
150     ...    AND    MultipleElan Testsuite Setup
151     ${smac_cn1} =    BuiltIn.Create List    ${VM_MACAddr_elan_net_2}[0]    ${VM_MACAddr_elan_net_3}[0]
152     ${smac_cn2} =    BuiltIn.Create List    ${VM_MACAddr_elan_net_2}[1]    ${VM_MACAddr_elan_net_3}[1]
153     ${MAC_LIST} =    BuiltIn.Create List    @{VM_MACAddr_elan_net_2}    @{VM_MACAddr_elan_net_3}
154     BuiltIn.Wait Until Keyword Succeeds
155     ...    30s
156     ...    10s
157     ...    Verify Flows Are Present For ELAN Service
158     ...    ${OS_CMP1_IP}
159     ...    ${smac_cn1}
160     ...    ${MAC_LIST}
161     BuiltIn.Wait Until Keyword Succeeds
162     ...    30s
163     ...    10s
164     ...    Verify Flows Are Present For ELAN Service
165     ...    ${OS_CMP2_IP}
166     ...    ${smac_cn2}
167     ...    ${MAC_LIST}
168     ${output} =    OpenStackOperations.Execute Command on VM Instance
169     ...    ${NETWORKS}[1]
170     ...    ${NET_2_VM_IPS}[0]
171     ...    ping -c 3 ${NET_2_VM_IPS[1]}
172     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
173     ${output} =    OpenStackOperations.Execute Command on VM Instance
174     ...    ${NETWORKS}[2]
175     ...    ${NET_3_VM_IPS}[1]
176     ...    ping -c 3 ${NET_3_VM_IPS[0]}
177     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
178     ${output} =    OpenStackOperations.Execute Command on VM Instance
179     ...    ${NETWORKS}[1]
180     ...    ${NET_2_VM_IPS}[0]
181     ...    ping -c 3 ${NET_3_VM_IPS[0]}
182     BuiltIn.Should Not Contain    ${output}    ${PING_REGEXP}
183     ${output} =    OpenStackOperations.Execute Command on VM Instance
184     ...    ${NETWORKS}[2]
185     ...    ${NET_3_VM_IPS}[1]
186     ...    ping -c 3 ${NET_2_VM_IPS[1]}
187     BuiltIn.Should Not Contain    ${output}    ${PING_REGEXP}
188     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
189     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
190     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
191     BuiltIn.Wait Until Keyword Succeeds
192     ...    30s
193     ...    10s
194     ...    Verify Flows Are Present For ELAN Service
195     ...    ${OS_CMP1_IP}
196     ...    ${smac_cn1}
197     ...    ${MAC_LIST}
198     ${output} =    OpenStackOperations.Execute Command on VM Instance
199     ...    ${NETWORKS}[1]
200     ...    ${NET_2_VM_IPS[1]}
201     ...    ping -c 3 ${NET_2_VM_IPS}[0]
202     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
203
204
205 *** Keywords ***
206 Suite Setup
207     OpenStackOperations.OpenStack Suite Setup
208     Create Single Elan
209     OpenStackOperations.Show Debugs    @{NET_1_VMS}
210     OpenStackOperations.Get Suite Debugs
211
212 Create Single Elan
213     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
214     OpenStackOperations.Create Network    ${NETWORKS}[0]
215     OpenStackOperations.Create SubNet    ${NETWORKS}[0]    ${SUBNETS}[0]    ${SUBNET_CIDRS[0]}
216     OpenStackOperations.Create Port    ${NETWORKS}[0]    ${NET_1_PORTS[0]}    sg=${SECURITY_GROUP}
217     OpenStackOperations.Create Port    ${NETWORKS}[0]    ${NET_1_PORTS[1]}    sg=${SECURITY_GROUP}
218     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${PORT_URL}    ${NET_1_PORTS}
219     OpenStackOperations.Create Vm Instance With Port On Compute Node
220     ...    ${NET_1_PORTS[0]}
221     ...    ${NET_1_VMS[0]}
222     ...    ${OS_CMP1_HOSTNAME}
223     ...    sg=${SECURITY_GROUP}
224     OpenStackOperations.Create Vm Instance With Port On Compute Node
225     ...    ${NET_1_PORTS[1]}
226     ...    ${NET_1_VMS[1]}
227     ...    ${OS_CMP2_HOSTNAME}
228     ...    sg=${SECURITY_GROUP}
229     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
230     Builtin.Set Suite Variable    @{NET_1_VM_IPS}
231     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
232     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
233     @{NET_1_MACS} =    BuiltIn.Wait Until Keyword Succeeds
234     ...    30s
235     ...    10s
236     ...    OpenStackOperations.Get Ports MacAddr
237     ...    ${NET_1_PORTS}
238     Builtin.Set Suite Variable    @{NET_1_MACS}
239
240 MultipleElan Testsuite Setup
241     [Documentation]    Create additional ELAN for multipleElan with Multiple DPN test
242     OpenStackOperations.Create Network    ${NETWORKS}[1]
243     OpenStackOperations.Create Network    ${NETWORKS}[2]
244     OpenStackOperations.Create SubNet    ${NETWORKS}[1]    ${SUBNETS}[1]    ${SUBNET_CIDRS[1]}
245     OpenStackOperations.Create SubNet    ${NETWORKS}[2]    ${SUBNETS}[2]    ${SUBNET_CIDRS[2]}
246     OpenStackOperations.Create Port    ${NETWORKS}[1]    ${NET_2_PORTS[0]}    sg=${SECURITY_GROUP}
247     OpenStackOperations.Create Port    ${NETWORKS}[1]    ${NET_2_PORTS[1]}    sg=${SECURITY_GROUP}
248     OpenStackOperations.Create Port    ${NETWORKS}[2]    ${NET_3_PORTS[0]}    sg=${SECURITY_GROUP}
249     OpenStackOperations.Create Port    ${NETWORKS}[2]    ${NET_3_PORTS[1]}    sg=${SECURITY_GROUP}
250     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${PORT_URL}    ${NET_3_PORTS}
251     OpenStackOperations.Create Vm Instance With Port On Compute Node
252     ...    ${NET_2_PORTS[0]}
253     ...    ${NET_2_VMS[0]}
254     ...    ${OS_CMP1_HOSTNAME}
255     ...    sg=${SECURITY_GROUP}
256     OpenStackOperations.Create Vm Instance With Port On Compute Node
257     ...    ${NET_2_PORTS[1]}
258     ...    ${NET_2_VMS[1]}
259     ...    ${OS_CMP2_HOSTNAME}
260     ...    sg=${SECURITY_GROUP}
261     OpenStackOperations.Create Vm Instance With Port On Compute Node
262     ...    ${NET_3_PORTS[0]}
263     ...    ${NET_3_VMS[0]}
264     ...    ${OS_CMP1_HOSTNAME}
265     ...    sg=${SECURITY_GROUP}
266     OpenStackOperations.Create Vm Instance With Port On Compute Node
267     ...    ${NET_3_PORTS[1]}
268     ...    ${NET_3_VMS[1]}
269     ...    ${OS_CMP2_HOSTNAME}
270     ...    sg=${SECURITY_GROUP}
271     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
272     @{NET_3_VM_IPS}    ${NET_3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_3_VMS}
273     Builtin.Set Suite Variable    @{NET_2_VM_IPS}
274     Builtin.Set Suite Variable    @{NET_3_VM_IPS}
275     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
276     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
277     BuiltIn.Should Not Contain    ${NET_3_VM_IPS}    None
278     BuiltIn.Should Not Contain    ${NET_3_DHCP_IP}    None
279     @{VM_MACAddr_elan_net_2} =    BuiltIn.Wait Until Keyword Succeeds
280     ...    30s
281     ...    10s
282     ...    OpenStackOperations.Get Ports MacAddr
283     ...    ${NET_2_PORTS}
284     Builtin.Set Suite Variable    @{VM_MACAddr_elan_net_2}
285     @{VM_MACAddr_elan_net_3} =    BuiltIn.Wait Until Keyword Succeeds
286     ...    30s
287     ...    10s
288     ...    OpenStackOperations.Get Ports MacAddr
289     ...    ${NET_3_PORTS}
290     Builtin.Set Suite Variable    @{VM_MACAddr_elan_net_3}
291     OpenStackOperations.Show Debugs    @{NET_2_VMS}    @{NET_3_VMS}
292     OpenStackOperations.Get Suite Debugs
293
294 Verify Flows Are Present For ELAN Service
295     [Arguments]    ${ip}    ${smacs}    ${dmacs}
296     ${flow_output} =    Utils.Run Command On Remote System And Log
297     ...    ${ip}
298     ...    sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
299     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
300     ${smac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
301     Builtin.Log    ${smac_output}
302     FOR    ${smac}    IN    @{smacs}
303         ${resp} =    BuiltIn.Should Contain    ${smac_output}    ${smac}
304     END
305     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
306     ${dmac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
307     Builtin.Log    ${dmac_output}
308     FOR    ${dmac}    IN    @{dmacs}
309         ${resp} =    BuiltIn.Should Contain    ${dmac_output}    ${dmac}
310     END
311     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
312     ${smac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
313     Builtin.Log    ${smac_output}
314
315 Verify Flows Are Removed For ELAN Service
316     [Arguments]    ${ip}    ${smacs}
317     ${flow_output} =    Utils.Run Command On Remote System And Log
318     ...    ${ip}
319     ...    sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
320     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
321     ${smac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
322     Builtin.Log    ${smac_output}
323     FOR    ${smac}    IN    @{smacs}
324         ${resp} =    BuiltIn.Should Not Contain    ${smac_output}    ${smac}
325     END
326     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
327     ${dmac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
328     Builtin.Log    ${dmac_output}
329     FOR    ${dmac}    IN    @{smacs}
330         ${resp} =    BuiltIn.Should Not Contain    ${dmac_output}    ${dmac}
331     END
332
333 Verify Flows Are Removed For ELAN Service On All compute Nodes
334     [Arguments]    ${smacs}
335     FOR    ${ip}    IN    @{OS_CMP_IPS}
336         BuiltIn.Wait Until Keyword Succeeds
337         ...    30s
338         ...    10s
339         ...    Verify Flows Are Removed For ELAN Service
340         ...    ${ip}
341         ...    ${smacs}
342     END