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