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