Upgrade RF syntax for v3.2 compatibility
[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       Suite Setup
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/OvsManager.robot
17 Resource          ../../libraries/SetupUtils.robot
18 Resource          ../../libraries/Utils.robot
19 Resource          ../../libraries/VpnOperations.robot
20 Resource          ../../variables/netvirt/Variables.robot
21 Resource          ../../variables/Variables.robot
22
23 *** Variables ***
24 ${REQ_NUM_NET}    2
25 ${REQ_NUM_SUBNET}    2
26 ${REQ_NUM_OF_PORTS}    4
27 ${REQ_NUM_OF_VMS_PER_DPN}    2
28 ${NUM_OF_PORTS_PER_HOST}    2
29 ${NEXTHOP}        0.0.0.0
30 @{REQ_NETWORKS}    l2l3_gw_mac_arp_net1    l2l3_gw_mac_arp_net2
31 @{VM_NAMES}       l2l3_gw_mac_arp_vm1    l2l3_gw_mac_arp_vm2    l2l3_gw_mac_arp_vm3    l2l3_gw_mac_arp_vm4
32 @{NET_1_VMS}      l2l3_gw_mac_arp_vm1    l2l3_gw_mac_arp_vm2
33 @{NET_2_VMS}      l2l3_gw_mac_arp_vm3    l2l3_gw_mac_arp_vm4
34 @{PORT_LIST}      l2l3_gw_mac_arp_port1    l2l3_gw_mac_arp_port2    l2l3_gw_mac_arp_port3    l2l3_gw_mac_arp_port4
35 @{REQ_SUBNETS}    l2l3_gw_mac_arp_subnet1    l2l3_gw_mac_arp_subnet2
36 @{REQ_SUBNET_CIDR}    10.1.0.0/16    10.2.0.0/16
37 ${REQ_ROUTER}     l2l3_gw_mac_arp_rtr1
38 @{DEFAULT_GATEWAY_IPS}    10.1.0.1    10.2.0.1
39 ${VPN_INSTANCE_ID}    4ae8cd92-48ca-49b5-94e1-b2921a261112
40 ${VPN_NAME}       l2l3_gw_mac_arp_vpn1
41 ${VPN_REST}       ${CONFIG_API}/odl-l3vpn:vpn-instance-to-vpn-id/
42 ${VRF_ID}         100:31
43 ${L3VPN_RD}       ["${VRF_ID}"]
44 ${SECURITY_GROUP}    l2l3_gw_mac_arp_sg
45 ${TABLE_NO_0}     0
46 ${TABLE_NO_220}    220
47 ${DUMP_FLOWS}     sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
48 ${GROUP_FLOWS}    sudo ovs-ofctl -O OpenFlow13 dump-groups ${INTEGRATION_BRIDGE}
49 ${ARP_REQUEST_OPERATIONAL_CODE}    1
50 ${ARP_RESPONSE_OPERATIONAL_CODE}    2
51 ${RESUBMIT_VALUE}    actions=resubmit\(,${DISPATCHER_TABLE}\)
52 ${PING_COUNT_VALUE}    0
53
54 *** Test Cases ***
55 Verify that table Miss entry for GWMAC table 19 points to table 17 dispatcher table
56     [Documentation]    To Verify there should be an entry for table=17,in the table=19 DUMP_FLOWS
57     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${GWMAC_TABLE}    True    ${EMPTY}    priority=0    actions=resubmit(,17)
58
59 Verify the pipeline flow from dispatcher table 17 (L3VPN) to table 19
60     [Documentation]    To Verify the end to end pipeline flow from table=17 to table=19 DUMP_FLOWS
61     ${subport_id_1} =    OpenStackOperations.Get Sub Port Id    ${PORT_LIST[0]}
62     ${subport_id_2} =    OpenStackOperations.Get Sub Port Id    ${PORT_LIST[1]}
63     ${port_num_1} =    OVSDB.Get Port Number    ${subport_id_1}    ${OS_CMP1_IP}
64     ${port_num_2} =    OVSDB.Get Port Number    ${subport_id_2}    ${OS_CMP1_IP}
65     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${TABLE_NO_0}    True    ${EMPTY}    in_port=${port_num_1}    goto_table:${DISPATCHER_TABLE}
66     ${metadata} =    OVSDB.Get Port Metadata    ${OS_CMP1_IP}    ${port_num_1}
67     ${vpn_id} =    VpnOperations.VPN Get L3VPN ID    ${VRF_ID}
68     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${DISPATCHER_TABLE}    True    |grep ${vpn_id}    ${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     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_RESPONSE_TABLE}    True    ${EMPTY}    set_field:${gw_mac_addr}    resubmit(,220)
72     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${TABLE_NO_220}    True    ${EMPTY}    output:${port_num_2}
73
74 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
75     [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
76     Verify Flows Are Present For ARP    ${ARP_REQUEST_OPERATIONAL_CODE}
77     Verify Flows Are Present For ARP    ${ARP_RESPONSE_OPERATIONAL_CODE}
78
79 Verify that table miss entry for table 17 should not point to table 81 arp table
80     [Documentation]    To Verify there should not be an entry for the arp_responder_table in table=17
81     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${DISPATCHER_TABLE}    False    |grep priority=0    goto_table:${ARP_RESPONSE_TABLE}
82
83 Verify that Multiple GWMAC entries in GWMAC table points to FIB table 21 (L3VPN pipeline)
84     [Documentation]    To Verify the one or more default gateway mac enteries on the table=19 flows that points to FIB table 21
85     ${gw_mac_addr_1} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[0]}
86     ${gw_mac_addr_2} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[1]}
87     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${GWMAC_TABLE}    True    ${EMPTY}    dl_dst=${gw_mac_addr_1}    actions=goto_table:${L3_TABLE}
88     ${pkt_count_before_ping} =    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${GWMAC_TABLE} | grep dl_dst=${gw_mac_addr_1}
89     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{REQ_NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 8 @{NET_2_VM_IPS}[1]
90     BuiltIn.Should Contain    ${output}    64 bytes
91     ${pkt_count_after_ping} =    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${GWMAC_TABLE} | grep dl_dst=${gw_mac_addr_1}
92     ${pkt_diff} =    Evaluate    int(${pkt_count_after_ping})-int(${pkt_count_before_ping})
93     BuiltIn.Should Be True    ${pkt_diff} > ${PING_COUNT_VALUE}
94     ${pkt_count_before_ping} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${GWMAC_TABLE} | grep dl_dst=${gw_mac_addr_1}
95     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{REQ_NETWORKS}[0]    @{NET_2_VM_IPS}[0]    ping -c 8 @{NET_1_VM_IPS}[1]
96     BuiltIn.Should Contain    ${output}    64 bytes
97     ${pkt_count_after_ping} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${GWMAC_TABLE} | grep dl_dst=${gw_mac_addr_1}
98     ${pkt_diff} =    Evaluate    int(${pkt_count_after_ping})-int(${pkt_count_before_ping})
99     BuiltIn.Should Be True    ${pkt_diff} > ${PING_COUNT_VALUE}
100
101 Verify table miss entry of ARP responder table points to drop actions
102     [Documentation]    To Verify the default flow entry of table=81 drops when openflow controller connected to compute node
103     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_RESPONSE_TABLE}    True    |grep priority=0    actions=drop
104
105 Verify ARP eth_type entries and actions for ARP request and ARP response are populated on GWMAC table
106     [Documentation]    To Verify the entry of ARP request(arp=1) and ARP response(arp=2) in table=19
107     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${GWMAC_TABLE}    True    ${EMPTY}    arp_op=${ARP_REQUEST_OPERATIONAL_CODE}    ${RESUBMIT_VALUE}
108
109 Verify GWMAC entires are populated with Neutron Router MAC address per network in GWMAC table
110     [Documentation]    To Verify gateway mac entires are populated with neutron router mac address for network with vpn dissociation from router
111     VpnOperations.Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID}
112     ${gw_mac_addr} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[1]}
113     BuiltIn.Wait Until Keyword Succeeds    60s    15s    OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${GWMAC_TABLE}    True
114     ...    ${EMPTY}    dl_dst=${gw_mac_addr}    actions=goto_table:${L3_TABLE}
115     ${output} =    VpnOperations.Get Fib Entries    session
116     BuiltIn.Should Match Regexp    ${output}    .*@{DEFAULT_GATEWAY_IPS}[1]/32.*${NEXTHOP}
117
118 Verify GWMAC entires are populated with port MAC address for network with vpn association to router in GWMAC table
119     [Documentation]    To Verify gateway mac entires are populated with port MAC address for network with vpn association to router
120     VpnOperations.Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID}
121     ${gw_mac_addr} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[1]}
122     BuiltIn.Wait Until Keyword Succeeds    60s    15s    OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${GWMAC_TABLE}    True
123     ...    ${EMPTY}    dl_dst=${gw_mac_addr}    actions=goto_table:${L3_TABLE}
124     ${output} =    VpnOperations.Get Fib Entries    session
125     BuiltIn.Should Match Regexp    ${output}    .*${VRF_ID}.*${REQ_SUBNET_CIDR[0]}
126     BuiltIn.Should Match Regexp    ${output}    .*${VRF_ID}.*${REQ_SUBNET_CIDR[1]}
127
128 *** Keywords ***
129 Suite Setup
130     [Documentation]    Test Suite for Gateway mac based L2L3 seggragation
131     VpnOperations.Basic Suite Setup
132     Create Setup
133     OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}
134     OpenStackOperations.Get Suite Debugs
135
136 Create Neutron Networks
137     [Arguments]    ${NUM_OF_NETWORK}
138     [Documentation]    Create required number of networks
139     FOR    ${NET}    IN    @{REQ_NETWORKS}
140         OpenStackOperations.Create Network    ${NET}
141     END
142     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${NETWORK_URL}    ${REQ_NETWORKS}
143
144 Create Neutron Subnets
145     [Arguments]    ${NUM_OF_NETWORK}
146     [Documentation]    Create required number of subnets for previously created networks
147     FOR    ${index}    IN RANGE    0    ${NUM_OF_NETWORK}
148         OpenStackOperations.Create SubNet    ${REQ_NETWORKS[${index}]}    ${REQ_SUBNETS[${index}]}    ${REQ_SUBNET_CIDR[${index}]}
149     END
150     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${SUBNETWORK_URL}    ${REQ_SUBNETS}
151
152 Create Neutron Ports
153     [Documentation]    Create required number of ports under previously created subnets
154     FOR    ${index}    IN RANGE    0    ${NUM_OF_PORTS_PER_HOST}
155         OpenStackOperations.Create Port    @{REQ_NETWORKS}[${index}]    @{PORT_LIST}[${index}]    sg=${SECURITY_GROUP}
156         OpenStackOperations.Create Port    @{REQ_NETWORKS}[${index}]    @{PORT_LIST}[${index + 2}]    sg=${SECURITY_GROUP}
157     END
158     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${PORT_URL}    ${PORT_LIST}
159
160 Create Nova VMs
161     [Arguments]    ${NUM_OF_VMS_PER_DPN}
162     [Documentation]    Create Vm instances on compute nodes
163     FOR    ${index}    IN RANGE    0    ${NUM_OF_VMS_PER_DPN}
164         OpenStackOperations.Create Vm Instance With Port On Compute Node    ${PORT_LIST[${index}]}    ${VM_NAMES[${index}]}    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
165     END
166     ${start} =    Evaluate    ${index}+1
167     ${NUM_OF_VMS_PER_DPN} =    Evaluate    ${start}+${NUM_OF_VMS_PER_DPN}
168     FOR    ${index}    IN RANGE    ${start}    ${NUM_OF_VMS_PER_DPN}
169         OpenStackOperations.Create Vm Instance With Port On Compute Node    ${PORT_LIST[${index}]}    ${VM_NAMES[${index}]}    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
170     END
171     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
172     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
173     BuiltIn.Set Suite Variable    @{NET_1_VM_IPS}
174     BuiltIn.Set Suite Variable    @{NET_2_VM_IPS}
175     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
176     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
177     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
178     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
179
180 Create Setup
181     [Documentation]    Create Two Networks, Two Subnets, Four Ports And Four VMs on each DPN
182     ${output} =    Issue Command On Karaf Console    ${TEP_SHOW}
183     Create Neutron Networks    ${REQ_NUM_NET}
184     Create Neutron Subnets    ${REQ_NUM_SUBNET}
185     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
186     Create Neutron Ports
187     OpenStackOperations.Create Router    ${REQ_ROUTER}
188     Add Interfaces To Routers
189     Create Nova VMs    ${REQ_NUM_OF_VMS_PER_DPN}
190     ${router_id} =    OpenStackOperations.Get Router Id    ${REQ_ROUTER}
191     Builtin.Set Suite Variable    ${router_id}
192     VpnOperations.VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID}    name=${VPN_NAME}    rd=${L3VPN_RD}    exportrt=${L3VPN_RD}    importrt=${L3VPN_RD}
193     VpnOperations.Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID}
194     ${resp} =    VpnOperations.VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID}
195
196 Add Interfaces To Routers
197     [Documentation]    Add Multiple Interfaces to Router and Verify
198     FOR    ${INTERFACE}    IN    @{REQ_SUBNETS}
199         OpenStackOperations.Add Router Interface    ${REQ_ROUTER}    ${INTERFACE}
200     END
201     ${interface_output} =    OpenStackOperations.Show Router Interface    ${REQ_ROUTER}
202     FOR    ${INTERFACE}    IN    @{REQ_SUBNETS}
203         ${subnet_id} =    OpenStackOperations.Get Subnet Id    ${INTERFACE}
204         BuiltIn.Should Contain    ${interface_output}    ${subnet_id}
205     END
206
207 Verify Flows Are Present For ARP
208     [Arguments]    ${arp_op_code}    ${additional_args}=${EMPTY}
209     [Documentation]    Verify Flows Are Present For ARP entry
210     ${flow_output} =    Utils.Run Command On Remote System    ${OS_CMP1_IP}    ${DUMP_FLOWS} | grep table=${GWMAC_TABLE}
211     BuiltIn.Should Contain    ${flow_output}    arp,arp_op=${arp_op_code} ${RESUBMIT_VALUE}
212     ${flow_output} =    Utils.Run Command On Remote System    ${OS_CMP1_IP}    ${DUMP_FLOWS} | grep table=${DISPATCHER_TABLE} ${additional_args}
213     BuiltIn.Should Contain    ${flow_output}    goto_table:${ARP_CHECK_TABLE}
214     ${flow_output} =    Utils.Run Command On Remote System    ${OS_CMP1_IP}    ${DUMP_FLOWS} | grep table=${ARP_CHECK_TABLE}
215     @{group_id} =    String.Get Regexp Matches    ${flow_output}    group:(\\d+)    1
216     BuiltIn.Should Contain    ${flow_output}    arp,arp_op=1 actions=group:${group_id[0]}
217     ${flow_output} =    Utils.Run Command On Remote System    ${OS_CMP1_IP}    ${GROUP_FLOWS} | grep group_id=${group_id[0]}
218     BuiltIn.Should Contain    ${flow_output}    bucket=actions=resubmit(,81)