Remove unintended line which breaks suite teardown
[integration/test.git] / csit / suites / netvirt / ElanService / ElanService.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 Suite Setup       BuiltIn.Run Keywords    Get OvsDebugInfo
6 ...               AND    Elan SuiteSetup
7 ...               AND    Get OvsDebugInfo
8 Suite Teardown    Elan SuiteTeardown
9 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
10 Test Teardown     Get Test Teardown Debugs
11 Library           OperatingSystem
12 Library           RequestsLibrary
13 Resource          ../../../libraries/KarafKeywords.robot
14 Resource          ../../../libraries/Utils.robot
15 Resource          ../../../libraries/OVSDB.robot
16 Resource          ../../../libraries/OpenStackOperations.robot
17 Resource          ../../../libraries/DevstackUtils.robot
18 Resource          ../../../libraries/SetupUtils.robot
19 Resource          ../../../libraries/Tcpdump.robot
20 Resource          ../../../variables/Variables.robot
21 Resource          ../../../variables/netvirt/Variables.robot
22
23 *** Variables ***
24 @{NETWORKS}       ELAN1    ELAN2    ELAN3
25 @{SUBNETS}        ELANSUBNET1    ELANSUBNET2    ELANSUBNET3
26 @{SUBNET_CIDR}    1.1.1.0/24    2.1.1.0/24    3.1.1.0/24
27 @{ELAN1_PORT_LIST}    ELANPORT11    ELANPORT12
28 @{ELAN2_PORT_LIST}    ELANPORT21    ELANPORT22
29 @{ELAN3_PORT_LIST}    ELANPORT31    ELANPORT32
30 @{VM_INSTANCES_ELAN1}    ELANVM11    ELANVM12
31 @{VM_INSTANCES_ELAN2}    ELANVM21    ELANVM22
32 @{VM_INSTANCES_ELAN3}    ELANVM31    ELANVM32
33 ${PING_PASS}      , 0% packet loss
34
35 *** Test Cases ***
36 Verify Datapath for Single ELAN with Multiple DPN
37     [Documentation]    Verify Flow Table and Datapath
38     ${SRCMAC_CN1} =    Create List    ${VM_MACAddr_ELAN1[0]}
39     ${SRCMAC_CN2} =    Create List    ${VM_MACAddr_ELAN1[1]}
40     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}    ${VM_MACAddr_ELAN1}
41     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_2_IP}    ${SRCMAC_CN2}    ${VM_MACAddr_ELAN1}
42     Log    Verify Datapath Test
43     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_ELAN1[0]}    ping -c 3 ${VM_IP_ELAN1[1]}
44     Should Contain    ${output}    ${PING_PASS}
45     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_ELAN1[1]}    ping -c 3 ${VM_IP_ELAN1[0]}
46     Should Contain    ${output}    ${PING_PASS}
47
48 Verify Datapath After OVS Restart
49     [Documentation]    Verify datapath after OVS restart
50     Log    Restarting OVS1 and OVS2
51     Restart OVSDB    ${OS_COMPUTE_1_IP}
52     Restart OVSDB    ${OS_COMPUTE_2_IP}
53     Log    Checking the OVS state and Flow table after restart
54     Wait Until Keyword Succeeds    30s    10s    Verify OVS Reports Connected    tools_system=${OS_COMPUTE_1_IP}
55     Wait Until Keyword Succeeds    30s    10s    Verify OVS Reports Connected    tools_system=${OS_COMPUTE_2_IP}
56     ${SRCMAC_CN1} =    Create List    ${VM_MACAddr_ELAN1[0]}
57     ${SRCMAC_CN2} =    Create List    ${VM_MACAddr_ELAN1[1]}
58     Wait Until Keyword Succeeds    60s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}    ${VM_MACAddr_ELAN1}
59     Wait Until Keyword Succeeds    60s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_2_IP}    ${SRCMAC_CN2}    ${VM_MACAddr_ELAN1}
60     Log    Verify Data path test
61     ${output} =    Execute Command on VM Instance    ${NETWORKS[0]}    ${VM_IP_ELAN1[0]}    ping -c 3 ${VM_IP_ELAN1[1]}
62     Should Contain    ${output}    ${PING_PASS}
63     ${output} =    Execute Command on VM Instance    ${NETWORKS[0]}    ${VM_IP_ELAN1[1]}    ping -c 3 ${VM_IP_ELAN1[0]}
64     Should Contain    ${output}    ${PING_PASS}
65
66 Verify Datapath After Recreate VM Instance
67     [Documentation]    Verify datapath after recreating Vm instance
68     Log    Delete VM and verify flows updated
69     Delete Vm Instance    ${VM_INSTANCES_ELAN1[0]}
70     ${SRCMAC_CN1} =    Create List    ${VM_MACAddr_ELAN1[0]}
71     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Removed For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}
72     Remove RSA Key From KnowHosts    ${VM_IP_ELAN1[0]}
73     Log    ReCreate VM and verify flow updated
74     Create Vm Instance With Port On Compute Node    ${ELAN1_PORT_LIST[0]}    ${VM_INSTANCES_ELAN1[0]}    ${OS_COMPUTE_1_IP}
75     Wait Until Keyword Succeeds    30s    10s    Verify VM Is ACTIVE    ${VM_INSTANCES_ELAN1[0]}
76     ${VM_IP_ELAN1}    ${DHCP_IP_ELAN1}    Wait Until Keyword Succeeds    180s    10s    Collect VM IP Addresses    true
77     ...    @{VM_INSTANCES_ELAN1}
78     Log    ${VM_IP_ELAN1}
79     Set Suite Variable    ${VM_IP_ELAN1}
80     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}    ${VM_MACAddr_ELAN1}
81     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_ELAN1[0]}    ping -c 3 ${VM_IP_ELAN1[1]}
82     Should Contain    ${output}    ${PING_PASS}
83     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_ELAN1[1]}    ping -c 3 ${VM_IP_ELAN1[0]}
84     Should Contain    ${output}    ${PING_PASS}
85
86 Delete All ELAN1 VM And Verify Flow Table Updated
87     [Documentation]    Verify Flow table after all VM instance deleted
88     Log    Delete VM instances
89     : FOR    ${VmInstance}    IN    @{VM_INSTANCES_ELAN1}
90     \    Delete Vm Instance    ${VmInstance}
91     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Removed For ELAN Service    ${OS_COMPUTE_1_IP}    ${VM_MACAddr_ELAN1}
92     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Removed For ELAN Service    ${OS_COMPUTE_2_IP}    ${VM_MACAddr_ELAN1}
93
94 Verify Datapath for Multiple ELAN with Multiple DPN
95     [Documentation]    Verify Flow Table and Data path for Multiple ELAN with Multiple DPN
96     [Setup]    Run Keywords    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
97     ...    AND    MultipleElan Testsuite Setup
98     Log    Verify flow table, fib Table and then datapath test
99     ${SRCMAC_CN1} =    Create List    ${VM_MACAddr_ELAN2[0]}    ${VM_MACAddr_ELAN3[0]}
100     ${SRCMAC_CN2} =    Create List    ${VM_MACAddr_ELAN2[1]}    ${VM_MACAddr_ELAN3[1]}
101     ${MAC_LIST} =    Create List    @{VM_MACAddr_ELAN2}    @{VM_MACAddr_ELAN3}
102     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}    ${MAC_LIST}
103     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_2_IP}    ${SRCMAC_CN2}    ${MAC_LIST}
104     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_ELAN2[0]}    ping -c 3 ${VM_IP_ELAN2[1]}
105     Should Contain    ${output}    ${PING_PASS}
106     ${output} =    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_ELAN3[1]}    ping -c 3 ${VM_IP_ELAN3[0]}
107     Should Contain    ${output}    ${PING_PASS}
108     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_ELAN2[0]}    ping -c 3 ${VM_IP_ELAN3[0]}
109     Should Not Contain    ${output}    ${PING_PASS}
110     ${output} =    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_ELAN3[1]}    ping -c 3 ${VM_IP_ELAN2[1]}
111     Should Not Contain    ${output}    ${PING_PASS}
112     Log    Reboot VM instance and verify flow
113     Get Test Teardown Debugs
114     ${filename_prefix}    Replace String    ${TEST_NAME}    ${SPACE}    _
115     ${cn1_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_1_IP}    file_Name=${filename_prefix}_CN1
116     ${cn2_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_2_IP}    file_Name=${filename_prefix}_CN2
117     ${os_conn_id} =    Start Packet Capture on Node    ${OS_CONTROL_NODE_IP}    file_Name=${filename_prefix}_OS
118     # Because of bug 8389 which is infrequently happening, it's requested to add these extra debugs just before and after the
119     # nova reboot step. Once 8389 is resolved, we can remove this line to get debugs before nova reboot. The debugs will be
120     # collected immediately after when that step fails, as is the nature of robot test cases.
121     Reboot Nova VM    ${VM_INSTANCES_ELAN2[0]}
122     Wait Until Keyword Succeeds    30s    10s    Verify VM Is ACTIVE    ${VM_INSTANCES_ELAN2[0]}
123     ${VM_IP_ELAN2}    ${DHCP_IP_ELAN2}    Wait Until Keyword Succeeds    180s    10s    Collect VM IP Addresses    true
124     ...    @{VM_INSTANCES_ELAN2}
125     Log    ${VM_IP_ELAN2}
126     Should Not Contain    ${VM_IP_ELAN2}    None
127     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}    ${MAC_LIST}
128     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_ELAN2[1]}    ping -c 3 ${VM_IP_ELAN2[0]}
129     Should Contain    ${output}    ${PING_PASS}
130     [Teardown]    Run Keywords    Get Test Teardown Debugs
131     ...    AND    MultipleElan Testsuite Cleanup
132     ...    AND    Stop Packet Capture on Node    ${cn1_conn_id}
133     ...    AND    Stop Packet Capture on Node    ${cn2_conn_id}
134     ...    AND    Stop Packet Capture on Node    ${os_conn_id}
135
136 *** Keywords ***
137 Elan SuiteSetup
138     [Documentation]    Elan suite setup
139     SetupUtils.Setup_Utils_For_Setup_And_Teardown
140     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set DEBUG org.opendaylight.genius.mdsalutil.internal.MDSALManager
141     DevstackUtils.Devstack Suite Setup
142     SingleElan SuiteSetup
143
144 Elan SuiteTeardown
145     [Documentation]    Elan suite teardown
146     Get OvsDebugInfo
147     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set DEBUG org.opendaylight.genius.mdsalutil.internal.MDSALManager
148     Close All Connections
149
150 SingleElan SuiteTeardown
151     [Documentation]    Delete network,subnet and port
152     Log    Delete Neutron Ports, Subnet and network
153     : FOR    ${Port}    IN    @{ELAN1_PORT_LIST}
154     \    Delete Port    ${Port}
155     Delete SubNet    ${SUBNETS[0]}
156     Delete Network    ${NETWORKS[0]}
157     Delete SecurityGroup    sg-elanservice
158
159 SingleElan SuiteSetup
160     [Documentation]    Create single ELAN with Multiple DPN
161     Log    Create ELAN1 network, subnet , port and VM
162     Create SecurityGroup    sg-elanservice
163     Create Network    ${NETWORKS[0]}
164     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
165     Create Port    ${NETWORKS[0]}    ${ELAN1_PORT_LIST[0]}    sg=sg-elanservice
166     Create Port    ${NETWORKS[0]}    ${ELAN1_PORT_LIST[1]}    sg=sg-elanservice
167     Create Vm Instance With Port On Compute Node    ${ELAN1_PORT_LIST[0]}    ${VM_INSTANCES_ELAN1[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
168     Create Vm Instance With Port On Compute Node    ${ELAN1_PORT_LIST[1]}    ${VM_INSTANCES_ELAN1[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
169     Log    Verify ELAN1 VM active
170     : FOR    ${VM}    IN    @{VM_INSTANCES_ELAN1}
171     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
172     Log    Get IP address for ELAN1
173     Wait Until Keyword Succeeds    180s    10s    Collect VM IP Addresses    true    @{VM_INSTANCES_ELAN1}
174     ${VM_IP_ELAN1}    ${DHCP_IP_ELAN1}    Collect VM IP Addresses    false    @{VM_INSTANCES_ELAN1}
175     Log    ${VM_IP_ELAN1}
176     Set Suite Variable    ${VM_IP_ELAN1}
177     Log    Get MACAddr for ELAN1
178     ${VM_MACAddr_ELAN1}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN1_PORT_LIST}
179     Log    ${VM_MACAddr_ELAN1}
180     Set Suite Variable    ${VM_MACAddr_ELAN1}
181
182 MultipleElan Testsuite Setup
183     [Documentation]    Create additional ELAN for multipleElan with Multiple DPN test
184     Create Network    ${NETWORKS[1]}
185     Create Network    ${NETWORKS[2]}
186     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNET_CIDR[1]}
187     Create SubNet    ${NETWORKS[2]}    ${SUBNETS[2]}    ${SUBNET_CIDR[2]}
188     Create Port    ${NETWORKS[1]}    ${ELAN2_PORT_LIST[0]}    sg=sg-elanservice
189     Create Port    ${NETWORKS[1]}    ${ELAN2_PORT_LIST[1]}    sg=sg-elanservice
190     Create Port    ${NETWORKS[2]}    ${ELAN3_PORT_LIST[0]}    sg=sg-elanservice
191     Create Port    ${NETWORKS[2]}    ${ELAN3_PORT_LIST[1]}    sg=sg-elanservice
192     Create Vm Instance With Port On Compute Node    ${ELAN2_PORT_LIST[0]}    ${VM_INSTANCES_ELAN2[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
193     Create Vm Instance With Port On Compute Node    ${ELAN2_PORT_LIST[1]}    ${VM_INSTANCES_ELAN2[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
194     Create Vm Instance With Port On Compute Node    ${ELAN3_PORT_LIST[0]}    ${VM_INSTANCES_ELAN3[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
195     Create Vm Instance With Port On Compute Node    ${ELAN3_PORT_LIST[1]}    ${VM_INSTANCES_ELAN3[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
196     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_ELAN2}    @{VM_INSTANCES_ELAN3}
197     : FOR    ${VM}    IN    @{VM_INSTANCES}
198     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
199     ${VM_IP_ELAN2}    ${DHCP_IP_ELAN2}    Wait Until Keyword Succeeds    180s    10s    Collect VM IP Addresses    true
200     ...    @{VM_INSTANCES_ELAN2}
201     Log    ${VM_IP_ELAN2}
202     Set Suite Variable    ${VM_IP_ELAN2}
203     ${VM_IP_ELAN3}    ${DHCP_IP_ELAN3}    Wait Until Keyword Succeeds    180s    10s    Collect VM IP Addresses    true
204     ...    @{VM_INSTANCES_ELAN3}
205     Log    ${VM_IP_ELAN3}
206     Set Suite Variable    ${VM_IP_ELAN3}
207     ${VM_MACAddr_ELAN2}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN2_PORT_LIST}
208     Log    ${VM_MACAddr_ELAN2}
209     Set Suite Variable    ${VM_MACAddr_ELAN2}
210     ${VM_MACAddr_ELAN3}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN3_PORT_LIST}
211     Log    ${VM_MACAddr_ELAN3}
212     Set Suite Variable    ${VM_MACAddr_ELAN3}
213
214 MultipleElan Testsuite Cleanup
215     [Documentation]    Delete ELAN2 network,subnet and port
216     Get Test Teardown Debugs
217     : FOR    ${VmInstance}    IN    @{VM_INSTANCES_ELAN2}    @{VM_INSTANCES_ELAN3}
218     \    Delete Vm Instance    ${VmInstance}
219     : FOR    ${Port}    IN    @{ELAN2_PORT_LIST}    @{ELAN3_PORT_LIST}
220     \    Delete Port    ${Port}
221     Delete SubNet    ${SUBNETS[1]}
222     Delete SubNet    ${SUBNETS[2]}
223     Delete Network    ${NETWORKS[1]}
224     Delete Network    ${NETWORKS[2]}
225
226 Verify Flows Are Present For ELAN Service
227     [Arguments]    ${ip}    ${srcMacAddrs}    ${destMacAddrs}
228     [Documentation]    Verify Flows Are Present For ELAN service
229     ${flow_output} =    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
230     Log    ${flow_output}
231     Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
232     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
233     Log    ${sMac_output}
234     : FOR    ${sMacAddr}    IN    @{srcMacAddrs}
235     \    ${resp}=    Should Contain    ${sMac_output}    ${sMacAddr}
236     Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
237     ${dMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
238     Log    ${dMac_output}
239     : FOR    ${dMacAddr}    IN    @{destMacAddrs}
240     \    ${resp}=    Should Contain    ${dMac_output}    ${dMacAddr}
241     Should Contain    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
242     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
243     Log    ${sMac_output}
244
245 Verify Flows Are Removed For ELAN Service
246     [Arguments]    ${ip}    ${srcMacAddrs}
247     [Documentation]    Verify Flows Are Removed For ELAN Service
248     ${flow_output} =    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
249     Log    ${flow_output}
250     Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
251     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
252     Log    ${sMac_output}
253     : FOR    ${sMacAddr}    IN    @{srcMacAddrs}
254     \    ${resp}=    Should Not Contain    ${sMac_output}    ${sMacAddr}
255     Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
256     ${dMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
257     Log    ${dMac_output}
258     : FOR    ${dMacAddr}    IN    @{srcMacAddrs}
259     \    ${resp}=    Should Not Contain    ${dMac_output}    ${dMacAddr}
260
261 Create SecurityGroup
262     [Arguments]    ${sg_name}
263     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
264     Neutron Security Group Create    ${sg_name}
265     Neutron Security Group Rule Create    ${sg_name}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp
266     Neutron Security Group Rule Create    ${sg_name}    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp
267     Neutron Security Group Rule Create    ${sg_name}    direction=ingress    protocol=icmp
268     Neutron Security Group Rule Create    ${sg_name}    direction=egress    protocol=icmp
269     Neutron Security Group Rule Create    ${sg_name}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp
270     Neutron Security Group Rule Create    ${sg_name}    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp