Additional Gateway MAC Table Validation in VPNservice
[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
21 @{SUBNETS}        ELANSUBNET1
22 @{SUBNET_CIDR}    1.1.1.0/24
23 @{ELAN1_PORT_LIST}    ELANPORT11    ELANPORT12
24 @{VM_INSTANCES_ELAN1}    ELANVM11    ELANVM12
25 ${PING_PASS}      , 0% packet loss
26
27 *** Test Cases ***
28 Verify Datapath for Single ELAN with Multiple DPN
29     [Documentation]    Verify Flow Table and Datapath
30     ${SRCMAC_CN1} =    Create List    ${VM_MACAddr_ELAN1[0]}
31     ${SRCMAC_CN2} =    Create List    ${VM_MACAddr_ELAN1[1]}
32     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}    ${VM_MACAddr_ELAN1}
33     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_2_IP}    ${SRCMAC_CN2}    ${VM_MACAddr_ELAN1}
34     Log    Verify Datapath Test
35     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_ELAN1[0]}    ping -c 3 ${VM_IP_ELAN1[1]}
36     Should Contain    ${output}    ${PING_PASS}
37     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_ELAN1[1]}    ping -c 3 ${VM_IP_ELAN1[0]}
38     Should Contain    ${output}    ${PING_PASS}
39
40 Verify Datapath After OVS Restart
41     [Documentation]    Verify datapath after OVS restart
42     Log    Restarting OVS1 and OVS2
43     Restart OVSDB    ${OS_COMPUTE_1_IP}
44     Restart OVSDB    ${OS_COMPUTE_2_IP}
45     Log    Checking the OVS state and Flow table after restart
46     Wait Until Keyword Succeeds    30s    10s    Verify OVS Reports Connected    tools_system=${OS_COMPUTE_1_IP}
47     Wait Until Keyword Succeeds    30s    10s    Verify OVS Reports Connected    tools_system=${OS_COMPUTE_2_IP}
48     ${SRCMAC_CN1} =    Create List    ${VM_MACAddr_ELAN1[0]}
49     ${SRCMAC_CN2} =    Create List    ${VM_MACAddr_ELAN1[1]}
50     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_1_IP}    ${SRCMAC_CN1}    ${VM_MACAddr_ELAN1}
51     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For ELAN Service    ${OS_COMPUTE_2_IP}    ${SRCMAC_CN2}    ${VM_MACAddr_ELAN1}
52     Log    Verify Data path test
53     ${output} =    Execute Command on VM Instance    ${NETWORKS[0]}    ${VM_IP_ELAN1[0]}    ping -c 3 ${VM_IP_ELAN1[1]}
54     Should Contain    ${output}    ${PING_PASS}
55     ${output} =    Execute Command on VM Instance    ${NETWORKS[0]}    ${VM_IP_ELAN1[1]}    ping -c 3 ${VM_IP_ELAN1[0]}
56     Should Contain    ${output}    ${PING_PASS}
57
58 Delete All ELAN1 VM And Verify Flow Table Updated
59     [Documentation]    Verify Flow table after all VM instance deleted
60     Log    Delete VM instances
61     : FOR    ${VmInstance}    IN    @{VM_INSTANCES_ELAN1}
62     \    Delete Vm Instance    ${VmInstance}
63     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Removed For ELAN Service    ${OS_COMPUTE_1_IP}    ${VM_MACAddr_ELAN1}
64     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Removed For ELAN Service    ${OS_COMPUTE_2_IP}    ${VM_MACAddr_ELAN1}
65
66 *** Keywords ***
67 Elan SuiteSetup
68     [Documentation]    Elan suite setup
69     SetupUtils.Setup_Utils_For_Setup_And_Teardown
70     DevstackUtils.Devstack Suite Setup
71     SingleElan SuiteSetup
72
73 Elan SuiteTeardown
74     [Documentation]    Elan suite teardown
75     SingleElan SuiteTeardown
76     Close All Connections
77
78 SingleElan SuiteTeardown
79     [Documentation]    Delete network,subnet and port
80     Log    Delete Neutron Ports, Subnet and network
81     : FOR    ${Port}    IN    @{ELAN1_PORT_LIST}
82     \    Delete Port    ${Port}
83     Delete SubNet    ${SUBNETS[0]}
84     Delete Network    ${NETWORKS[0]}
85     Delete SecurityGroup    sg-elanservice
86
87 SingleElan SuiteSetup
88     [Documentation]    Create single ELAN with Multiple DPN
89     Log    Create ELAN1 network, subnet , port and VM
90     Create SecurityGroup    sg-elanservice
91     Create Network    ${NETWORKS[0]}
92     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
93     Create Port    ${NETWORKS[0]}    ${ELAN1_PORT_LIST[0]}    sg=sg-elanservice
94     Create Port    ${NETWORKS[0]}    ${ELAN1_PORT_LIST[1]}    sg=sg-elanservice
95     Create Vm Instance With Port On Compute Node    ${ELAN1_PORT_LIST[0]}    ${VM_INSTANCES_ELAN1[0]}    ${OS_COMPUTE_1_IP}    sg=sg-elanservice
96     Create Vm Instance With Port On Compute Node    ${ELAN1_PORT_LIST[1]}    ${VM_INSTANCES_ELAN1[1]}    ${OS_COMPUTE_2_IP}    sg=sg-elanservice
97     Log    Verify ELAN1 VM active
98     : FOR    ${VM}    IN    @{VM_INSTANCES_ELAN1}
99     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
100     Log    Get IP address for ELAN1
101     ${VM_IP_ELAN1}    Wait Until Keyword Succeeds    30s    10s    Verify VMs received IP    ${VM_INSTANCES_ELAN1}
102     Log    ${VM_IP_ELAN1}
103     Set Suite Variable    ${VM_IP_ELAN1}
104     Log    Get MACAddr for ELAN1
105     ${VM_MACAddr_ELAN1}    Wait Until Keyword Succeeds    30s    10s    Get Ports MacAddr    ${ELAN1_PORT_LIST}
106     Log    ${VM_MACAddr_ELAN1}
107     Set Suite Variable    ${VM_MACAddr_ELAN1}
108
109 Verify Flows Are Present For ELAN Service
110     [Arguments]    ${ip}    ${srcMacAddrs}    ${destMacAddrs}
111     [Documentation]    Verify Flows Are Present For ELAN service
112     ${flow_output} =    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
113     Log    ${flow_output}
114     Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
115     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
116     Log    ${sMac_output}
117     : FOR    ${sMacAddr}    IN    @{srcMacAddrs}
118     \    ${resp}=    Should Contain    ${sMac_output}    ${sMacAddr}
119     Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
120     ${dMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
121     Log    ${dMac_output}
122     : FOR    ${dMacAddr}    IN    @{destMacAddrs}
123     \    ${resp}=    Should Contain    ${dMac_output}    ${dMacAddr}
124     Should Contain    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
125     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_UNKNOWNMACTABLE}
126     Log    ${sMac_output}
127
128 Verify Flows Are Removed For ELAN Service
129     [Arguments]    ${ip}    ${srcMacAddrs}
130     [Documentation]    Verify Flows Are Removed For ELAN Service
131     ${flow_output} =    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
132     Log    ${flow_output}
133     Should Contain    ${flow_output}    table=${ELAN_SMACTABLE}
134     ${sMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_SMACTABLE}
135     Log    ${sMac_output}
136     : FOR    ${sMacAddr}    IN    @{srcMacAddrs}
137     \    ${resp}=    Should Not Contain    ${sMac_output}    ${sMacAddr}
138     Should Contain    ${flow_output}    table=${ELAN_DMACTABLE}
139     ${dMac_output} =    Get Lines Containing String    ${flow_output}    table=${ELAN_DMACTABLE}
140     Log    ${dMac_output}
141     : FOR    ${dMacAddr}    IN    @{srcMacAddrs}
142     \    ${resp}=    Should Not Contain    ${dMac_output}    ${dMacAddr}
143
144 Create SecurityGroup
145     [Arguments]    ${sg_name}
146     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
147     Neutron Security Group Create    ${sg_name}
148     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
149     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
150     Neutron Security Group Rule Create    ${sg_name}    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
151     Neutron Security Group Rule Create    ${sg_name}    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
152     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
153     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
154
155 Verify VMs received IP
156     [Arguments]    ${VM_INSTANCES}
157     [Documentation]    Verify VM received IP
158     ${VM_IP}    ${DHCP_IP}    Verify VMs Received DHCP Lease    @{VM_INSTANCES}
159     Log    ${VM_IP}
160     Should Not Contain    ${VM_IP}    None
161     [Return]    ${VM_IP}