enable DEBUG logs for genius MDSALManager
[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     turn off debugs
149     Close All Connections
150
151 SingleElan SuiteTeardown
152     [Documentation]    Delete network,subnet and port
153     Log    Delete Neutron Ports, Subnet and network
154     : FOR    ${Port}    IN    @{ELAN1_PORT_LIST}
155     \    Delete Port    ${Port}
156     Delete SubNet    ${SUBNETS[0]}
157     Delete Network    ${NETWORKS[0]}
158     Delete SecurityGroup    sg-elanservice
159
160 SingleElan SuiteSetup
161     [Documentation]    Create single ELAN with Multiple DPN
162     Log    Create ELAN1 network, subnet , port and VM
163     Create SecurityGroup    sg-elanservice
164     Create Network    ${NETWORKS[0]}
165     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
166     Create Port    ${NETWORKS[0]}    ${ELAN1_PORT_LIST[0]}    sg=sg-elanservice
167     Create Port    ${NETWORKS[0]}    ${ELAN1_PORT_LIST[1]}    sg=sg-elanservice
168     Create Vm Instance With Port On Compute Node    ${ELAN1_PORT_LIST[0]}    ${VM_INSTANCES_ELAN1[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
169     Create Vm Instance With Port On Compute Node    ${ELAN1_PORT_LIST[1]}    ${VM_INSTANCES_ELAN1[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
170     Log    Verify ELAN1 VM active
171     : FOR    ${VM}    IN    @{VM_INSTANCES_ELAN1}
172     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
173     Log    Get IP address for ELAN1
174     Wait Until Keyword Succeeds    180s    10s    Collect VM IP Addresses    true    @{VM_INSTANCES_ELAN1}
175     ${VM_IP_ELAN1}    ${DHCP_IP_ELAN1}    Collect VM IP Addresses    false    @{VM_INSTANCES_ELAN1}
176     Log    ${VM_IP_ELAN1}
177     Set Suite Variable    ${VM_IP_ELAN1}
178     Log    Get MACAddr for ELAN1
179     ${VM_MACAddr_ELAN1}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN1_PORT_LIST}
180     Log    ${VM_MACAddr_ELAN1}
181     Set Suite Variable    ${VM_MACAddr_ELAN1}
182
183 MultipleElan Testsuite Setup
184     [Documentation]    Create additional ELAN for multipleElan with Multiple DPN test
185     Create Network    ${NETWORKS[1]}
186     Create Network    ${NETWORKS[2]}
187     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNET_CIDR[1]}
188     Create SubNet    ${NETWORKS[2]}    ${SUBNETS[2]}    ${SUBNET_CIDR[2]}
189     Create Port    ${NETWORKS[1]}    ${ELAN2_PORT_LIST[0]}    sg=sg-elanservice
190     Create Port    ${NETWORKS[1]}    ${ELAN2_PORT_LIST[1]}    sg=sg-elanservice
191     Create Port    ${NETWORKS[2]}    ${ELAN3_PORT_LIST[0]}    sg=sg-elanservice
192     Create Port    ${NETWORKS[2]}    ${ELAN3_PORT_LIST[1]}    sg=sg-elanservice
193     Create Vm Instance With Port On Compute Node    ${ELAN2_PORT_LIST[0]}    ${VM_INSTANCES_ELAN2[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
194     Create Vm Instance With Port On Compute Node    ${ELAN2_PORT_LIST[1]}    ${VM_INSTANCES_ELAN2[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
195     Create Vm Instance With Port On Compute Node    ${ELAN3_PORT_LIST[0]}    ${VM_INSTANCES_ELAN3[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
196     Create Vm Instance With Port On Compute Node    ${ELAN3_PORT_LIST[1]}    ${VM_INSTANCES_ELAN3[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
197     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_ELAN2}    @{VM_INSTANCES_ELAN3}
198     : FOR    ${VM}    IN    @{VM_INSTANCES}
199     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
200     ${VM_IP_ELAN2}    ${DHCP_IP_ELAN2}    Wait Until Keyword Succeeds    180s    10s    Collect VM IP Addresses    true
201     ...    @{VM_INSTANCES_ELAN2}
202     Log    ${VM_IP_ELAN2}
203     Set Suite Variable    ${VM_IP_ELAN2}
204     ${VM_IP_ELAN3}    ${DHCP_IP_ELAN3}    Wait Until Keyword Succeeds    180s    10s    Collect VM IP Addresses    true
205     ...    @{VM_INSTANCES_ELAN3}
206     Log    ${VM_IP_ELAN3}
207     Set Suite Variable    ${VM_IP_ELAN3}
208     ${VM_MACAddr_ELAN2}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN2_PORT_LIST}
209     Log    ${VM_MACAddr_ELAN2}
210     Set Suite Variable    ${VM_MACAddr_ELAN2}
211     ${VM_MACAddr_ELAN3}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN3_PORT_LIST}
212     Log    ${VM_MACAddr_ELAN3}
213     Set Suite Variable    ${VM_MACAddr_ELAN3}
214
215 MultipleElan Testsuite Cleanup
216     [Documentation]    Delete ELAN2 network,subnet and port
217     Get Test Teardown Debugs
218     : FOR    ${VmInstance}    IN    @{VM_INSTANCES_ELAN2}    @{VM_INSTANCES_ELAN3}
219     \    Delete Vm Instance    ${VmInstance}
220     : FOR    ${Port}    IN    @{ELAN2_PORT_LIST}    @{ELAN3_PORT_LIST}
221     \    Delete Port    ${Port}
222     Delete SubNet    ${SUBNETS[1]}
223     Delete SubNet    ${SUBNETS[2]}
224     Delete Network    ${NETWORKS[1]}
225     Delete Network    ${NETWORKS[2]}
226
227 Verify Flows Are Present For ELAN Service
228     [Arguments]    ${ip}    ${srcMacAddrs}    ${destMacAddrs}
229     [Documentation]    Verify Flows Are Present For ELAN service
230     ${flow_output} =    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
231     Log    ${flow_output}
232     Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
233     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
234     Log    ${sMac_output}
235     : FOR    ${sMacAddr}    IN    @{srcMacAddrs}
236     \    ${resp}=    Should Contain    ${sMac_output}    ${sMacAddr}
237     Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
238     ${dMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
239     Log    ${dMac_output}
240     : FOR    ${dMacAddr}    IN    @{destMacAddrs}
241     \    ${resp}=    Should Contain    ${dMac_output}    ${dMacAddr}
242     Should Contain    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
243     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
244     Log    ${sMac_output}
245
246 Verify Flows Are Removed For ELAN Service
247     [Arguments]    ${ip}    ${srcMacAddrs}
248     [Documentation]    Verify Flows Are Removed For ELAN Service
249     ${flow_output} =    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
250     Log    ${flow_output}
251     Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
252     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
253     Log    ${sMac_output}
254     : FOR    ${sMacAddr}    IN    @{srcMacAddrs}
255     \    ${resp}=    Should Not Contain    ${sMac_output}    ${sMacAddr}
256     Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
257     ${dMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
258     Log    ${dMac_output}
259     : FOR    ${dMacAddr}    IN    @{srcMacAddrs}
260     \    ${resp}=    Should Not Contain    ${dMac_output}    ${dMacAddr}
261
262 Create SecurityGroup
263     [Arguments]    ${sg_name}
264     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
265     Neutron Security Group Create    ${sg_name}
266     Neutron Security Group Rule Create    ${sg_name}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp
267     Neutron Security Group Rule Create    ${sg_name}    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp
268     Neutron Security Group Rule Create    ${sg_name}    direction=ingress    protocol=icmp
269     Neutron Security Group Rule Create    ${sg_name}    direction=egress    protocol=icmp
270     Neutron Security Group Rule Create    ${sg_name}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp
271     Neutron Security Group Rule Create    ${sg_name}    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp