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