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