ea7c252564d402caedfe82bcd66f636461b10869
[integration/test.git] / csit / suites / netvirt / elan / elan.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       OpenStackOperations.OpenStack Suite Setup
6 Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
7 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
8 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Library           String
12 Resource          ../../../libraries/KarafKeywords.robot
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          ../../../variables/Variables.robot
19 Resource          ../../../variables/netvirt/Variables.robot
20
21 *** Variables ***
22 ${SECURITY_GROUP}    elan_sg
23 @{NETWORKS}       elan_net_1    elan_net_2    elan_net_3
24 @{SUBNETS}        elan_sub_1    elan_sub_2    elan_sub_3
25 @{SUBNET_CIDRS}    81.1.1.0/24    82.1.1.0/24    83.1.1.0/24
26 @{NET_1_PORTS}    elan_net_1_port_1    elan_net_1_port_2
27 @{NET_2_PORTS}    elan_net_2_port_1    elan_net_2_port_2
28 @{NET_3_PORTS}    elan_net_3_port_1    elan_net_3_port_2
29 @{NET_1_VMS}      elan_net_1_vm_1    elan_net_1_vm_2
30 @{NET_2_VMS}      elan_net_2_vm_1    elan_net_2_vm_2
31 @{NET_3_VMS}      elan_net_3_vm_1    elan_net_3_vm_2
32
33 *** Test Cases ***
34 Create Single Elan
35     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
36     OpenStackOperations.Create Network    @{NETWORKS}[0]
37     OpenStackOperations.Create SubNet    @{NETWORKS}[0]    @{SUBNETS}[0]    ${SUBNET_CIDRS[0]}
38     OpenStackOperations.Create Port    @{NETWORKS}[0]    ${NET_1_PORTS[0]}    sg=${SECURITY_GROUP}
39     OpenStackOperations.Create Port    @{NETWORKS}[0]    ${NET_1_PORTS[1]}    sg=${SECURITY_GROUP}
40     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${PORT_URL}    ${NET_1_PORTS}
41     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${NET_1_PORTS[0]}    ${NET_1_VMS[0]}    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
42     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${NET_1_PORTS[1]}    ${NET_1_VMS[1]}    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
43     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
44     Builtin.Set Suite Variable    @{NET_1_VM_IPS}
45     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
46     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
47     @{NET_1_MACS} =    BuiltIn.Wait Until Keyword Succeeds    30s    10s    OpenStackOperations.Get Ports MacAddr    ${NET_1_PORTS}
48     Builtin.Set Suite Variable    @{NET_1_MACS}
49
50 Verify Datapath for Single ELAN with Multiple DPN
51     [Documentation]    Verify Flow Table and Datapath
52     ${smac_cn1} =    BuiltIn.Create List    @{NET_1_MACS}[0]
53     ${smac_cn2} =    BuiltIn.Create List    @{NET_1_MACS}[1]
54     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${smac_cn1}    ${NET_1_MACS}
55     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_2_IP}    ${smac_cn2}    ${NET_1_MACS}
56     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 3 @{NET_1_VM_IPS}[1]
57     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
58     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ping -c 3 @{NET_1_VM_IPS}[0]
59     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
60
61 Verify Datapath After OVS Restart
62     [Documentation]    Verify datapath after OVS restart
63     OVSDB.Restart OVSDB    ${OS_COMPUTE_1_IP}
64     OVSDB.Restart OVSDB    ${OS_COMPUTE_2_IP}
65     BuiltIn.Wait Until Keyword Succeeds    30s    10s    OVSDB.Verify OVS Reports Connected    tools_system=${OS_COMPUTE_1_IP}
66     BuiltIn.Wait Until Keyword Succeeds    30s    10s    OVSDB.Verify OVS Reports Connected    tools_system=${OS_COMPUTE_2_IP}
67     ${smac_cn1} =    BuiltIn.Create List    @{NET_1_MACS}[0]
68     ${smac_cn2} =    BuiltIn.Create List    @{NET_1_MACS}[1]
69     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${smac_cn1}    ${NET_1_MACS}
70     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_2_IP}    ${smac_cn2}    ${NET_1_MACS}
71     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 3 @{NET_1_VM_IPS}[1]
72     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
73     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ping -c 3 @{NET_1_VM_IPS}[0]
74     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
75
76 Verify Datapath After Recreate VM Instance
77     [Documentation]    Verify datapath after recreating Vm instance
78     OpenStackOperations.Delete Vm Instance    ${NET_1_VMS[0]}
79     ${smac_cn1} =    BuiltIn.Create List    @{NET_1_MACS}[0]
80     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Removed For ELAN Service    ${OS_COMPUTE_1_IP}    ${smac_cn1}
81     OpenStackOperations.Remove RSA Key From KnownHosts    @{NET_1_VM_IPS}[0]
82     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${NET_1_PORTS[0]}    ${NET_1_VMS[0]}    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
83     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
84     Builtin.Set Suite Variable    @{NET_1_VM_IPS}
85     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
86     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
87     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${smac_cn1}    ${NET_1_MACS}
88     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 3 @{NET_1_VM_IPS}[1]
89     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
90     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ping -c 3 @{NET_1_VM_IPS}[0]
91     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
92
93 Delete All elan_net_1 VM And Verify Flow Table Updated
94     [Documentation]    Verify Flow table after all VM instance deleted
95     : FOR    ${vm}    IN    @{NET_1_VMS}
96     \    OpenStackOperations.Delete Vm Instance    ${vm}
97     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Removed For ELAN Service    ${OS_COMPUTE_1_IP}    ${NET_1_MACS}
98     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Removed For ELAN Service    ${OS_COMPUTE_2_IP}    ${NET_1_MACS}
99
100 Verify Datapath for Multiple ELAN with Multiple DPN
101     [Documentation]    Verify Flow Table and Data path for Multiple ELAN with Multiple DPN
102     [Setup]    BuiltIn.Run Keywords    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
103     ...    AND    MultipleElan Testsuite Setup
104     ${smac_cn1} =    BuiltIn.Create List    @{VM_MACAddr_elan_net_2}[0]    @{VM_MACAddr_elan_net_3}[0]
105     ${smac_cn2} =    BuiltIn.Create List    @{VM_MACAddr_elan_net_2}[1]    @{VM_MACAddr_elan_net_3}[1]
106     ${MAC_LIST} =    BuiltIn.Create List    @{VM_MACAddr_elan_net_2}    @{VM_MACAddr_elan_net_3}
107     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${smac_cn1}    ${MAC_LIST}
108     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_2_IP}    ${smac_cn2}    ${MAC_LIST}
109     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ping -c 3 ${NET_2_VM_IPS[1]}
110     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
111     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{NET_3_VM_IPS}[1]    ping -c 3 ${NET_3_VM_IPS[0]}
112     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
113     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ping -c 3 ${NET_3_VM_IPS[0]}
114     BuiltIn.Should Not Contain    ${output}    ${PING_REGEXP}
115     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{NET_3_VM_IPS}[1]    ping -c 3 ${NET_2_VM_IPS[1]}
116     BuiltIn.Should Not Contain    ${output}    ${PING_REGEXP}
117     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
118     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
119     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
120     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${smac_cn1}    ${MAC_LIST}
121     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    ${NET_2_VM_IPS[1]}    ping -c 3 @{NET_2_VM_IPS}[0]
122     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
123     [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Get Test Teardown Debugs
124     ...    AND    MultipleElan Testsuite Cleanup
125
126 *** Keywords ***
127 MultipleElan Testsuite Setup
128     [Documentation]    Create additional ELAN for multipleElan with Multiple DPN test
129     OpenStackOperations.Create Network    @{NETWORKS}[1]
130     OpenStackOperations.Create Network    @{NETWORKS}[2]
131     OpenStackOperations.Create SubNet    @{NETWORKS}[1]    @{SUBNETS}[1]    ${SUBNET_CIDRS[1]}
132     OpenStackOperations.Create SubNet    @{NETWORKS}[2]    @{SUBNETS}[2]    ${SUBNET_CIDRS[2]}
133     OpenStackOperations.Create Port    @{NETWORKS}[1]    ${NET_2_PORTS[0]}    sg=${SECURITY_GROUP}
134     OpenStackOperations.Create Port    @{NETWORKS}[1]    ${NET_2_PORTS[1]}    sg=${SECURITY_GROUP}
135     OpenStackOperations.Create Port    @{NETWORKS}[2]    ${NET_3_PORTS[0]}    sg=${SECURITY_GROUP}
136     OpenStackOperations.Create Port    @{NETWORKS}[2]    ${NET_3_PORTS[1]}    sg=${SECURITY_GROUP}
137     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${PORT_URL}    ${NET_3_PORTS}
138     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${NET_2_PORTS[0]}    ${NET_2_VMS[0]}    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
139     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${NET_2_PORTS[1]}    ${NET_2_VMS[1]}    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
140     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${NET_3_PORTS[0]}    ${NET_3_VMS[0]}    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
141     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${NET_3_PORTS[1]}    ${NET_3_VMS[1]}    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
142     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
143     @{NET_3_VM_IPS}    ${NET_3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_3_VMS}
144     Builtin.Set Suite Variable    @{NET_2_VM_IPS}
145     Builtin.Set Suite Variable    @{NET_3_VM_IPS}
146     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
147     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
148     BuiltIn.Should Not Contain    ${NET_3_VM_IPS}    None
149     BuiltIn.Should Not Contain    ${NET_3_DHCP_IP}    None
150     @{VM_MACAddr_elan_net_2}    BuiltIn.Wait Until Keyword Succeeds    30s    10s    OpenStackOperations.Get Ports MacAddr    ${NET_2_PORTS}
151     Builtin.Set Suite Variable    @{VM_MACAddr_elan_net_2}
152     @{VM_MACAddr_elan_net_3}    BuiltIn.Wait Until Keyword Succeeds    30s    10s    OpenStackOperations.Get Ports MacAddr    ${NET_3_PORTS}
153     Builtin.Set Suite Variable    @{VM_MACAddr_elan_net_3}
154
155 MultipleElan Testsuite Cleanup
156     [Documentation]    Delete elan_net_2 network,subnet and port
157     OpenStackOperations.Get Test Teardown Debugs
158     : FOR    ${vm}    IN    @{NET_2_VMS}    @{NET_3_VMS}
159     \    OpenStackOperations.Delete Vm Instance    ${vm}
160     : FOR    ${Port}    IN    @{NET_2_PORTS}    @{NET_3_PORTS}
161     \    OpenStackOperations.Delete Port    ${Port}
162     OpenStackOperations.Delete SubNet    @{SUBNETS}[1]
163     OpenStackOperations.Delete SubNet    @{SUBNETS}[2]
164     OpenStackOperations.Delete Network    @{NETWORKS}[1]
165     OpenStackOperations.Delete Network    @{NETWORKS}[2]
166
167 Verify Flows Are Present For ELAN Service
168     [Arguments]    ${ip}    ${smacs}    ${dmacs}
169     ${flow_output} =    Utils.Run Command On Remote System And Log    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
170     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
171     ${smac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
172     Builtin.Log    ${smac_output}
173     : FOR    ${smac}    IN    @{smacs}
174     \    ${resp} =    BuiltIn.Should Contain    ${smac_output}    ${smac}
175     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
176     ${dmac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
177     Builtin.Log    ${dmac_output}
178     : FOR    ${dmac}    IN    @{dmacs}
179     \    ${resp} =    BuiltIn.Should Contain    ${dmac_output}    ${dmac}
180     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
181     ${smac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
182     Builtin.Log    ${smac_output}
183
184 Verify Flows Are Removed For ELAN Service
185     [Arguments]    ${ip}    ${smacs}
186     ${flow_output} =    Utils.Run Command On Remote System And Log    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
187     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
188     ${smac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
189     Builtin.Log    ${smac_output}
190     : FOR    ${smac}    IN    @{smacs}
191     \    ${resp} =    BuiltIn.Should Not Contain    ${smac_output}    ${smac}
192     BuiltIn.Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
193     ${dmac_output} =    String.Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
194     Builtin.Log    ${dmac_output}
195     : FOR    ${dmac}    IN    @{smacs}
196     \    ${resp} =    BuiltIn.Should Not Contain    ${dmac_output}    ${dmac}