Add debugs and robot karaf logs to elan test case
[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]    Run Keywords    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
93     ...    AND    MultipleElan Testsuite Setup
94     Log    Verify flow table, fib Table and then datapath test
95     ${SRCMAC_CN1} =    Create List    ${VM_MACAddr_ELAN2[0]}    ${VM_MACAddr_ELAN3[0]}
96     ${SRCMAC_CN2} =    Create List    ${VM_MACAddr_ELAN2[1]}    ${VM_MACAddr_ELAN3[1]}
97     ${MAC_LIST} =    Create List    @{VM_MACAddr_ELAN2}    @{VM_MACAddr_ELAN3}
98     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}    ${MAC_LIST}
99     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_2_IP}    ${SRCMAC_CN2}    ${MAC_LIST}
100     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_ELAN2[0]}    ping -c 3 ${VM_IP_ELAN2[1]}
101     Should Contain    ${output}    ${PING_PASS}
102     ${output} =    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_ELAN3[1]}    ping -c 3 ${VM_IP_ELAN3[0]}
103     Should Contain    ${output}    ${PING_PASS}
104     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_ELAN2[0]}    ping -c 3 ${VM_IP_ELAN3[0]}
105     Should Not Contain    ${output}    ${PING_PASS}
106     ${output} =    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_ELAN3[1]}    ping -c 3 ${VM_IP_ELAN2[1]}
107     Should Not Contain    ${output}    ${PING_PASS}
108     Log    Reboot VM instance and verify flow
109     Reboot Nova VM    ${VM_INSTANCES_ELAN2[0]}
110     Wait Until Keyword Succeeds    30s    10s    Verify VM Is ACTIVE    ${VM_INSTANCES_ELAN2[0]}
111     ${VM_IP_ELAN2}    ${DHCP_IP_ELAN2}    Wait Until Keyword Succeeds    30s    10s    Collect VM IP Addresses    true
112     ...    @{VM_INSTANCES_ELAN2}
113     Log    ${VM_IP_ELAN2}
114     Should Not Contain    ${VM_IP_ELAN2}    None
115     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}    ${MAC_LIST}
116     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_ELAN2[1]}    ping -c 3 ${VM_IP_ELAN2[0]}
117     Should Contain    ${output}    ${PING_PASS}
118     [Teardown]    Run Keywords    Get Test Teardown Debugs
119     ...    AND    MultipleElan Testsuite Cleanup
120
121 *** Keywords ***
122 Elan SuiteSetup
123     [Documentation]    Elan suite setup
124     SetupUtils.Setup_Utils_For_Setup_And_Teardown
125     DevstackUtils.Devstack Suite Setup
126     SingleElan SuiteSetup
127
128 Elan SuiteTeardown
129     [Documentation]    Elan suite teardown
130     SingleElan SuiteTeardown
131     Close All Connections
132
133 SingleElan SuiteTeardown
134     [Documentation]    Delete network,subnet and port
135     Log    Delete Neutron Ports, Subnet and network
136     : FOR    ${Port}    IN    @{ELAN1_PORT_LIST}
137     \    Delete Port    ${Port}
138     Delete SubNet    ${SUBNETS[0]}
139     Delete Network    ${NETWORKS[0]}
140     Delete SecurityGroup    sg-elanservice
141
142 SingleElan SuiteSetup
143     [Documentation]    Create single ELAN with Multiple DPN
144     Log    Create ELAN1 network, subnet , port and VM
145     Create SecurityGroup    sg-elanservice
146     Create Network    ${NETWORKS[0]}
147     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
148     Create Port    ${NETWORKS[0]}    ${ELAN1_PORT_LIST[0]}    sg=sg-elanservice
149     Create Port    ${NETWORKS[0]}    ${ELAN1_PORT_LIST[1]}    sg=sg-elanservice
150     Create Vm Instance With Port On Compute Node    ${ELAN1_PORT_LIST[0]}    ${VM_INSTANCES_ELAN1[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
151     Create Vm Instance With Port On Compute Node    ${ELAN1_PORT_LIST[1]}    ${VM_INSTANCES_ELAN1[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
152     Log    Verify ELAN1 VM active
153     : FOR    ${VM}    IN    @{VM_INSTANCES_ELAN1}
154     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
155     Log    Get IP address for ELAN1
156     Wait Until Keyword Succeeds    30s    10s    Collect VM IP Addresses    true    @{VM_INSTANCES_ELAN1}
157     ${VM_IP_ELAN1}    ${DHCP_IP_ELAN1}    Collect VM IP Addresses    false    @{VM_INSTANCES_ELAN1}
158     Log    ${VM_IP_ELAN1}
159     Set Suite Variable    ${VM_IP_ELAN1}
160     Log    Get MACAddr for ELAN1
161     ${VM_MACAddr_ELAN1}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN1_PORT_LIST}
162     Log    ${VM_MACAddr_ELAN1}
163     Set Suite Variable    ${VM_MACAddr_ELAN1}
164
165 MultipleElan Testsuite Setup
166     [Documentation]    Create additional ELAN for multipleElan with Multiple DPN test
167     Create Network    ${NETWORKS[1]}
168     Create Network    ${NETWORKS[2]}
169     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNET_CIDR[1]}
170     Create SubNet    ${NETWORKS[2]}    ${SUBNETS[2]}    ${SUBNET_CIDR[2]}
171     Create Port    ${NETWORKS[1]}    ${ELAN2_PORT_LIST[0]}    sg=sg-elanservice
172     Create Port    ${NETWORKS[1]}    ${ELAN2_PORT_LIST[1]}    sg=sg-elanservice
173     Create Port    ${NETWORKS[2]}    ${ELAN3_PORT_LIST[0]}    sg=sg-elanservice
174     Create Port    ${NETWORKS[2]}    ${ELAN3_PORT_LIST[1]}    sg=sg-elanservice
175     Create Vm Instance With Port On Compute Node    ${ELAN2_PORT_LIST[0]}    ${VM_INSTANCES_ELAN2[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
176     Create Vm Instance With Port On Compute Node    ${ELAN2_PORT_LIST[1]}    ${VM_INSTANCES_ELAN2[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
177     Create Vm Instance With Port On Compute Node    ${ELAN3_PORT_LIST[0]}    ${VM_INSTANCES_ELAN3[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
178     Create Vm Instance With Port On Compute Node    ${ELAN3_PORT_LIST[1]}    ${VM_INSTANCES_ELAN3[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
179     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_ELAN2}    @{VM_INSTANCES_ELAN3}
180     : FOR    ${VM}    IN    @{VM_INSTANCES}
181     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
182     ${VM_IP_ELAN2}    ${DHCP_IP_ELAN2}    Wait Until Keyword Succeeds    30s    10s    Collect VM IP Addresses    true
183     ...    @{VM_INSTANCES_ELAN2}
184     Log    ${VM_IP_ELAN2}
185     Set Suite Variable    ${VM_IP_ELAN2}
186     ${VM_IP_ELAN3}    ${DHCP_IP_ELAN3}    Wait Until Keyword Succeeds    30s    10s    Collect VM IP Addresses    true
187     ...    @{VM_INSTANCES_ELAN3}
188     Log    ${VM_IP_ELAN3}
189     Set Suite Variable    ${VM_IP_ELAN3}
190     ${VM_MACAddr_ELAN2}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN2_PORT_LIST}
191     Log    ${VM_MACAddr_ELAN2}
192     Set Suite Variable    ${VM_MACAddr_ELAN2}
193     ${VM_MACAddr_ELAN3}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN3_PORT_LIST}
194     Log    ${VM_MACAddr_ELAN3}
195     Set Suite Variable    ${VM_MACAddr_ELAN3}
196
197 MultipleElan Testsuite Cleanup
198     [Documentation]    Delete ELAN2 network,subnet and port
199     Get Test Teardown Debugs
200     : FOR    ${VmInstance}    IN    @{VM_INSTANCES_ELAN2}    @{VM_INSTANCES_ELAN3}
201     \    Delete Vm Instance    ${VmInstance}
202     : FOR    ${Port}    IN    @{ELAN2_PORT_LIST}    @{ELAN3_PORT_LIST}
203     \    Delete Port    ${Port}
204     Delete SubNet    ${SUBNETS[1]}
205     Delete SubNet    ${SUBNETS[2]}
206     Delete Network    ${NETWORKS[1]}
207     Delete Network    ${NETWORKS[2]}
208
209 Verify Flows Are Present For ELAN Service
210     [Arguments]    ${ip}    ${srcMacAddrs}    ${destMacAddrs}
211     [Documentation]    Verify Flows Are Present For ELAN service
212     ${flow_output} =    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
213     Log    ${flow_output}
214     Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
215     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
216     Log    ${sMac_output}
217     : FOR    ${sMacAddr}    IN    @{srcMacAddrs}
218     \    ${resp}=    Should Contain    ${sMac_output}    ${sMacAddr}
219     Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
220     ${dMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
221     Log    ${dMac_output}
222     : FOR    ${dMacAddr}    IN    @{destMacAddrs}
223     \    ${resp}=    Should Contain    ${dMac_output}    ${dMacAddr}
224     Should Contain    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
225     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
226     Log    ${sMac_output}
227
228 Verify Flows Are Removed For ELAN Service
229     [Arguments]    ${ip}    ${srcMacAddrs}
230     [Documentation]    Verify Flows Are Removed 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 Not 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    @{srcMacAddrs}
242     \    ${resp}=    Should Not Contain    ${dMac_output}    ${dMacAddr}
243
244 Create SecurityGroup
245     [Arguments]    ${sg_name}
246     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
247     Neutron Security Group Create    ${sg_name}
248     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
249     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
250     Neutron Security Group Rule Create    ${sg_name}    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
251     Neutron Security Group Rule Create    ${sg_name}    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
252     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
253     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