5494e4d96840356e4b2f5e0dc75515f9641be880
[integration/test.git] / csit / suites / netvirt / vnibasedl2switching / vnibasedl2switching.robot
1 *** Settings ***
2 Documentation     Test Suite for vni-based-l2-l3-nat:
3 ...               This feature attempts to realize the use of VxLAN VNI
4 ...               (Virtual Network Identifier) for VxLAN tenant traffic
5 ...               flowing on the cloud data-network. This is applicable
6 ...               to L2 switching, L3 forwarding and NATing for all VxLAN
7 ...               based provider networks. In doing so, it eliminates the
8 ...               presence of LPort tags, ELAN tags and MPLS labels on the
9 ...               wire and instead, replaces them with VNIs supplied by the
10 ...               tenant’s OpenStack.
11 Suite Setup       Start Suite
12 Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
13 Test Setup        Run Keywords    OpenStackOperations.Get DumpFlows And Ovsconfig    ${OS_CMP1_CONN_ID}
14 ...               AND    OpenStackOperations.Get DumpFlows And Ovsconfig    ${OS_CMP2_CONN_ID}
15 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
16 Library           OperatingSystem
17 Library           RequestsLibrary
18 Library           String
19 Resource          ../../../libraries/DevstackUtils.robot
20 Resource          ../../../libraries/KarafKeywords.robot
21 Resource          ../../../variables/netvirt/Variables.robot
22 Resource          ../../../libraries/OpenStackOperations.robot
23 Resource          ../../../libraries/OVSDB.robot
24 Resource          ../../../libraries/SetupUtils.robot
25 Resource          ../../../libraries/Utils.robot
26 Resource          ../../../variables/netvirt/Variables.robot
27 Resource          ../../../variables/Variables.robot
28
29 *** Variables ***
30 ${EGRESS}         Egress
31 ${INGRESS}        Ingress
32 ${VNI_SECURITY_GROUP}    vni_l2_sg
33 @{VNI_NETWORKS}    vni_l2_net_1
34 @{VNI_SUBNETS}    vni_l2_sub_1    vni_l2_sub_2    vni_l2_sub_3
35 @{VNI_SUBNET_CIDRS}    71.1.1.0/24    72.1.1.0/24    73.1.1.0/24
36 @{VNI_NET_1_PORTS}    vni_l2_net_1_port_1    vni_l2_net_1_port_2
37 @{VNI_NET_1_VMS}    vni_l2_net_1_vm_1    vni_l2_net_1_vm_2
38
39 *** Test Cases ***
40 VNI Based L2 Switching
41     [Documentation]    verify VNI id for L2 Unicast frames exchanged over OVS datapaths that are on different hypervisors
42     ${port_mac1} =    OpenStackOperations.Get Port Mac    @{VNI_NET_1_PORTS}[0]
43     ${port_mac2} =    OpenStackOperations.Get Port Mac    @{VNI_NET_1_PORTS}[1]
44     ${segmentation_id} =    OpenStackOperations.Get Network Segmentation Id    @{VNI_NETWORKS}[0]
45     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{VNI_NETWORKS}[0]    @{VNI_NET_1_VM_IPS}[0]    ping -c ${DEFAULT_PING_COUNT} @{VNI_NET_1_VM_IPS}[1]
46     ${egress_tun_id}    ${before_count_egress_port1} =    OVSDB.Get Tunnel Id And Packet Count    ${OS_CMP1_CONN_ID}    ${ELAN_DMACTABLE}    direction=${EGRESS}    tun_id=${segmentation_id}
47     ...    dst_mac=${port_mac2}
48     BuiltIn.Should Be Equal As Numbers    ${segmentation_id}    ${egress_tun_id}
49     ${egress_tun_id}    ${before_count_egress_port2} =    OVSDB.Get Tunnel Id And Packet Count    ${OS_CMP2_CONN_ID}    ${ELAN_DMACTABLE}    direction=${EGRESS}    tun_id=${segmentation_id}
50     ...    dst_mac=${port_mac1}
51     BuiltIn.Should Be Equal As Numbers    ${segmentation_id}    ${egress_tun_id}
52     ${ingress_tun_id}    ${before_count_ingress_port1} =    OVSDB.Get Tunnel Id And Packet Count    ${OS_CMP1_CONN_ID}    ${INTERNAL_TUNNEL_TABLE}    direction=${INGRESS}    tun_id=${segmentation_id}
53     BuiltIn.Should Be Equal As Numbers    ${segmentation_id}    ${ingress_tun_id}
54     ${ingress_tun_id}    ${before_count_ingress_port2} =    OVSDB.Get Tunnel Id And Packet Count    ${OS_CMP2_CONN_ID}    ${INTERNAL_TUNNEL_TABLE}    direction=${INGRESS}    tun_id=${segmentation_id}
55     BuiltIn.Should Be Equal As Numbers    ${segmentation_id}    ${ingress_tun_id}
56     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{VNI_NETWORKS}[0]    @{VNI_NET_1_VM_IPS}[0]    ping -c ${DEFAULT_PING_COUNT} @{VNI_NET_1_VM_IPS}[1]
57     BuiltIn.Should Contain    ${output}    64 bytes
58     ${tun_id}    ${after_count_egress_port1} =    OVSDB.Get Tunnel Id And Packet Count    ${OS_CMP1_CONN_ID}    ${ELAN_DMACTABLE}    direction=${EGRESS}    tun_id=${segmentation_id}
59     ...    dst_mac=${port_mac2}
60     ${tun_id}    ${after_count_ingress_port1} =    OVSDB.Get Tunnel Id And Packet Count    ${OS_CMP1_CONN_ID}    ${INTERNAL_TUNNEL_TABLE}    direction=${INGRESS}    tun_id=${segmentation_id}
61     ${tun_id}    ${after_count_egress_port2} =    OVSDB.Get Tunnel Id And Packet Count    ${OS_CMP2_CONN_ID}    ${ELAN_DMACTABLE}    direction=${EGRESS}    tun_id=${segmentation_id}
62     ...    dst_mac=${port_mac1}
63     ${tun_id}    ${after_count_ingress_port2} =    OVSDB.Get Tunnel Id And Packet Count    ${OS_CMP2_CONN_ID}    ${INTERNAL_TUNNEL_TABLE}    direction=${INGRESS}    tun_id=${segmentation_id}
64     ${diff_count_egress_port1} =    BuiltIn.Evaluate    ${after_count_egress_port1} - ${before_count_egress_port1}
65     ${diff_count_ingress_port1} =    BuiltIn.Evaluate    ${after_count_ingress_port1} - ${before_count_ingress_port1}
66     ${diff_count_egress_port2} =    BuiltIn.Evaluate    ${after_count_egress_port2} - ${before_count_egress_port2}
67     ${diff_count_ingress_port2} =    BuiltIn.Evaluate    ${after_count_ingress_port2} - ${before_count_ingress_port2}
68     BuiltIn.Should Be True    ${diff_count_egress_port1} >= ${DEFAULT_PING_COUNT}
69     BuiltIn.Should Be True    ${diff_count_ingress_port1} >= ${DEFAULT_PING_COUNT}
70     BuiltIn.Should Be True    ${diff_count_egress_port2} >= ${DEFAULT_PING_COUNT}
71     BuiltIn.Should Be True    ${diff_count_ingress_port2} >= ${DEFAULT_PING_COUNT}
72
73 *** Keywords ***
74 Start Suite
75     [Documentation]    Create Basic setup for the feature. Creates single network, subnet, two ports and two VMs.
76     OpenStackOperations.OpenStack Suite Setup
77     OpenStackOperations.Create Allow All SecurityGroup    ${VNI_SECURITY_GROUP}
78     OpenStackOperations.Create Network    @{VNI_NETWORKS}[0]
79     OpenStackOperations.Create SubNet    @{VNI_NETWORKS}[0]    @{VNI_SUBNETS}[0]    @{VNI_SUBNET_CIDRS}[0]
80     OpenStackOperations.Create Port    @{VNI_NETWORKS}[0]    @{VNI_NET_1_PORTS}[0]    sg=${VNI_SECURITY_GROUP}
81     OpenStackOperations.Create Port    @{VNI_NETWORKS}[0]    @{VNI_NET_1_PORTS}[1]    sg=${VNI_SECURITY_GROUP}
82     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${PORT_URL}    ${VNI_NET_1_PORTS}
83     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{VNI_NET_1_PORTS}[0]    @{VNI_NET_1_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${VNI_SECURITY_GROUP}
84     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{VNI_NET_1_PORTS}[1]    @{VNI_NET_1_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${VNI_SECURITY_GROUP}
85     @{VNI_NET_1_VM_IPS}    ${vni_net_1_dhcp_ip} =    OpenStackOperations.Get VM IPs    @{VNI_NET_1_VMS}
86     BuiltIn.Set Suite Variable    @{VNI_NET_1_VM_IPS}
87     BuiltIn.Should Not Contain    ${VNI_NET_1_VM_IPS}    None
88     BuiltIn.Should Not Contain    ${vni_net_1_dhcp_ip}    None