Add Mac Based L2L3 seggragation suite.
[integration/test.git] / csit / suites / netvirt / l2l3_gatewaymac_arp.robot
1 *** Settings ***
2 Documentation     Test Suite for Gateway mac based L2L3 seggragation
3 Suite Setup       Start Suite
4 Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
7 Library           Collections
8 Library           RequestsLibrary
9 Library           SSHLibrary
10 Library           String
11 Resource          ../../libraries/BgpOperations.robot
12 Resource          ../../libraries/DevstackUtils.robot
13 Resource          ../../libraries/KarafKeywords.robot
14 Resource          ../../libraries/OVSDB.robot
15 Resource          ../../libraries/OpenStackOperations.robot
16 Resource          ../../libraries/SetupUtils.robot
17 Resource          ../../libraries/Utils.robot
18 Resource          ../../libraries/VpnOperations.robot
19 Resource          ../../variables/netvirt/Variables.robot
20 Resource          ../../variables/Variables.robot
21
22 *** Variables ***
23 ${REQ_NUM_NET}    2
24 ${REQ_NUM_SUBNET}    2
25 ${REQ_NUM_OF_PORTS}    4
26 ${REQ_NUM_OF_VMS_PER_DPN}    2
27 ${NUM_OF_PORTS_PER_HOST}    2
28 @{REQ_NETWORKS}    l2l3_gw_mac_arp_net1    l2l3_gw_mac_arp_net2
29 @{VM_NAMES}       l2l3_gw_mac_arp_vm1    l2l3_gw_mac_arp_vm2    l2l3_gw_mac_arp_vm3    l2l3_gw_mac_arp_vm4
30 @{NET_1_VMS}      l2l3_gw_mac_arp_vm1    l2l3_gw_mac_arp_vm2
31 @{NET_2_VMS}      l2l3_gw_mac_arp_vm3    l2l3_gw_mac_arp_vm4
32 @{PORT_LIST}      l2l3_gw_mac_arp_port1    l2l3_gw_mac_arp_port2    l2l3_gw_mac_arp_port3    l2l3_gw_mac_arp_port4
33 @{REQ_SUBNETS}    l2l3_gw_mac_arp_subnet1    l2l3_gw_mac_arp_subnet2
34 @{REQ_SUBNET_CIDR}    10.1.0.0/16    10.2.0.0/16
35 ${REQ_ROUTER}     l2l3_gw_mac_arp_rtr1
36 @{DEFAULT_GATEWAY_IPS}    10.1.0.1    10.2.0.1
37 ${VPN_INSTANCE_ID}    4ae8cd92-48ca-49b5-94e1-b2921a261112
38 ${VPN_NAME}       l2l3_gw_mac_arp_vpn1
39 ${VPN_REST}       ${CONFIG_API}/odl-l3vpn:vpn-instance-to-vpn-id/
40 ${L3VPN_RD}       ["100:31"]
41 ${SECURITY_GROUP}    l2l3_gw_mac_arp_sg
42 ${TABLE_NO_0}     table=0
43 ${TABLE_NO_220}    table=220
44 ${DUMP_FLOWS}     sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
45 ${GROUP_FLOWS}    sudo ovs-ofctl -O OpenFlow13 dump-groups br-int
46 ${ARP_REQUEST_OPERATIONAL_CODE}    1
47 ${ARP_RESPONSE_OPERATIONAL_CODE}    2
48
49 *** Test Cases ***
50 Verify that table Miss entry for GWMAC table 19 points to table 17 dispatcher table
51     [Documentation]    To Verify there should be an entry for table=17,in the table=19 DUMP_FLOWS
52     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${DUMP_FLOWS}|grep table=${GWMAC_TABLE}
53     BuiltIn.Should Contain    ${flow_output}    priority=0    actions=resubmit(,17)
54
55 Verify the pipeline flow from dispatcher table 17 (L3VPN) to table 19
56     [Documentation]    To Verify the end to end pipeline flow from table=17 to table=19 DUMP_FLOWS
57     ${subport_id_1} =    OpenStackOperations.Get Sub Port Id    ${PORT_LIST[0]}
58     ${subport_id_2} =    OpenStackOperations.Get Sub Port Id    ${PORT_LIST[1]}
59     ${port_num_1} =    OVSDB.Get Port Number    ${subport_id_1}    ${OS_COMPUTE_1_IP}
60     ${port_num_2} =    OVSDB.Get Port Number    ${subport_id_2}    ${OS_COMPUTE_1_IP}
61     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${DUMP_FLOWS}|grep ${TABLE_NO_0}
62     BuiltIn.Should Contain    ${flow_output}    in_port=${port_num_1}    goto_table:${DISPATCHER_TABLE}
63     ${metadata} =    OVSDB.Get Port Metadata    ${OS_COMPUTE_1_IP}    ${port_num_1}
64     ${RD} =    String.Get Regexp Matches    ${L3VPN_RD}    ([0-9]+:[0-9]+)
65     ${VRF_ID} =    Collections.Get From List    ${RD}    0
66     ${vpn_id} =    VpnOperations.VPN Get L3VPN ID    ${VRF_ID}
67     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${DUMP_FLOWS}|grep table=${DISPATCHER_TABLE} | grep ${vpn_id}
68     BuiltIn.Should Contain    ${flow_output}    ${vpn_id}    goto_table:${GWMAC_TABLE}
69     ${gw_mac_addr} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[0]}
70     Verify Flows Are Present For ARP    ${ARP_REQUEST_OPERATIONAL_CODE}    | grep ${metadata}
71     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${DUMP_FLOWS}|grep table=${ARP_RESPONSE_TABLE}
72     BuiltIn.Should Contain    ${flow_output}    set_field:${gw_mac_addr}    resubmit(,220)
73     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${DUMP_FLOWS}|grep ${TABLE_NO_220}
74     BuiltIn.Should Contain    ${flow_output}    output:${port_num_2}
75
76 Verify that ARP requests and ARP response received on GWMAC table are punted to controller for learning ,resubmitted to table 17,sent to ARP responder
77     [Documentation]    To verify the ARP Request and ARP response entry should be there after the dump_groups and dispatcher table should point to ARP responder
78     Verify Flows Are Present For ARP    ${ARP_REQUEST_OPERATIONAL_CODE}
79     Verify Flows Are Present For ARP    ${ARP_RESPONSE_OPERATIONAL_CODE}
80
81 Verify that table miss entry for table 17 should not point to table 81 arp table
82     [Documentation]    To Verify there should not be an entry for the arp_responder_table in table=17
83     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${DUMP_FLOWS} | grep table=${DISPATCHER_TABLE} |grep priority=0
84     BuiltIn.Should Not Contain    ${flow_output}    goto_table:${ARP_RESPONSE_TABLE}
85
86 *** Keywords ***
87 Start Suite
88     [Documentation]    Test Suite for Gateway mac based L2L3 seggragation
89     VpnOperations.Basic Suite Setup
90     Create Setup
91
92 Create Neutron Networks
93     [Arguments]    ${NUM_OF_NETWORK}
94     [Documentation]    Create required number of networks
95     : FOR    ${NET}    IN    @{REQ_NETWORKS}
96     \    OpenStackOperations.Create Network    ${NET}
97     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${NETWORK_URL}    ${REQ_NETWORKS}
98
99 Create Neutron Subnets
100     [Arguments]    ${NUM_OF_NETWORK}
101     [Documentation]    Create required number of subnets for previously created networks
102     : FOR    ${index}    IN RANGE    0    ${NUM_OF_NETWORK}
103     \    OpenStackOperations.Create SubNet    ${REQ_NETWORKS[${index}]}    ${REQ_SUBNETS[${index}]}    ${REQ_SUBNET_CIDR[${index}]}
104     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${SUBNETWORK_URL}    ${REQ_SUBNETS}
105
106 Create Neutron Ports
107     [Documentation]    Create required number of ports under previously created subnets
108     : FOR    ${index}    IN RANGE    0    ${NUM_OF_PORTS_PER_HOST}
109     \    OpenStackOperations.Create Port    @{REQ_NETWORKS}[${index}]    @{PORT_LIST}[${index}]    sg=${SECURITY_GROUP}
110     \    OpenStackOperations.Create Port    @{REQ_NETWORKS}[${index}]    @{PORT_LIST}[${index + 2}]    sg=${SECURITY_GROUP}
111     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${PORT_URL}    ${PORT_LIST}
112
113 Create Nova VMs
114     [Arguments]    ${NUM_OF_VMS_PER_DPN}
115     [Documentation]    Create Vm instances on compute nodes
116     : FOR    ${index}    IN RANGE    0    ${NUM_OF_VMS_PER_DPN}
117     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    ${PORT_LIST[${index}]}    ${VM_NAMES[${index}]}    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
118     ${start} =    Evaluate    ${index}+1
119     ${NUM_OF_VMS_PER_DPN} =    Evaluate    ${start}+${NUM_OF_VMS_PER_DPN}
120     : FOR    ${index}    IN RANGE    ${start}    ${NUM_OF_VMS_PER_DPN}
121     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    ${PORT_LIST[${index}]}    ${VM_NAMES[${index}]}    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
122     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
123     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
124     BuiltIn.Should Not Contain    @{NET_1_VM_IPS}    None
125     BuiltIn.Should Not Contain    @{NET_2_VM_IPS}    None
126     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
127     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
128
129 Create Setup
130     [Documentation]    Create Two Networks, Two Subnets, Four Ports And Four VMs on each DPN
131     ${output} =    Issue Command On Karaf Console    ${TEP_SHOW}
132     Create Neutron Networks    ${REQ_NUM_NET}
133     Create Neutron Subnets    ${REQ_NUM_SUBNET}
134     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
135     Create Neutron Ports
136     OpenStackOperations.Create Router    ${REQ_ROUTER}
137     Add Interfaces To Routers
138     Create Nova VMs    ${REQ_NUM_OF_VMS_PER_DPN}
139     ${router_id} =    OpenStackOperations.Get Router Id    ${REQ_ROUTER}
140     VpnOperations.VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID}    name=${VPN_NAME}    rd=${L3VPN_RD}    exportrt=${L3VPN_RD}    importrt=${L3VPN_RD}
141     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID}
142     ${resp} =    VpnOperations.VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID}
143
144 Add Interfaces To Routers
145     [Documentation]    Add Multiple Interfaces to Router and Verify
146     : FOR    ${INTERFACE}    IN    @{REQ_SUBNETS}
147     \    OpenStackOperations.Add Router Interface    ${REQ_ROUTER}    ${INTERFACE}
148     ${interface_output} =    OpenStackOperations.Show Router Interface    ${REQ_ROUTER}
149     : FOR    ${INTERFACE}    IN    @{REQ_SUBNETS}
150     \    ${subnet_id} =    OpenStackOperations.Get Subnet Id    ${INTERFACE}
151     \    BuiltIn.Should Contain    ${interface_output}    ${subnet_id}
152
153 Verify Flows Are Present For ARP
154     [Arguments]    ${arp_op_code}    ${additional_args}=${EMPTY}
155     [Documentation]    Verify Flows Are Present For ARP entry
156     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${DUMP_FLOWS}|grep table=${GWMAC_TABLE}
157     BuiltIn.Should Contain    ${flow_output}    arp,arp_op=${arp_op_code} actions=resubmit(,17)
158     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${DUMP_FLOWS}|grep table=${DISPATCHER_TABLE} ${additional_args}
159     BuiltIn.Should Contain    ${flow_output}    goto_table:${ARP_CHECK_TABLE}
160     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${DUMP_FLOWS}|grep table=${ARP_CHECK_TABLE}
161     @{group_id} =    String.Get Regexp Matches    ${flow_output}    group:(\\d+)    1
162     BuiltIn.Should Contain    ${flow_output}    arp,arp_op=1 actions=group:${group_id[0]}
163     ${flow_output} =    Utils.Run Command On Remote System    ${OS_COMPUTE_1_IP}    ${GROUP_FLOWS}|grep group_id=${group_id[0]}
164     BuiltIn.Should Contain    ${flow_output}    bucket=actions=resubmit(,81)