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