Update Robot Framework format - step 11
[integration/test.git] / csit / suites / netvirt / l2l3_gatewaymac_arp.robot
1 *** Settings ***
2 Documentation       Test Suite for Gateway mac based L2L3 seggragation
3
4 Library             Collections
5 Library             RequestsLibrary
6 Library             SSHLibrary
7 Library             String
8 Resource            ../../libraries/BgpOperations.robot
9 Resource            ../../libraries/DevstackUtils.robot
10 Resource            ../../libraries/KarafKeywords.robot
11 Resource            ../../libraries/OVSDB.robot
12 Resource            ../../libraries/OpenStackOperations.robot
13 Resource            ../../libraries/OvsManager.robot
14 Resource            ../../libraries/SetupUtils.robot
15 Resource            ../../libraries/Utils.robot
16 Resource            ../../libraries/VpnOperations.robot
17 Resource            ../../variables/netvirt/Variables.robot
18 Resource            ../../variables/Variables.robot
19
20 Suite Setup         Suite Setup
21 Suite Teardown      OpenStackOperations.OpenStack Suite Teardown
22 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
23 Test Teardown       OpenStackOperations.Get Test Teardown Debugs
24
25
26 *** Variables ***
27 ${REQ_NUM_NET}                      2
28 ${REQ_NUM_SUBNET}                   2
29 ${REQ_NUM_OF_PORTS}                 4
30 ${REQ_NUM_OF_VMS_PER_DPN}           2
31 ${NUM_OF_PORTS_PER_HOST}            2
32 ${NEXTHOP}                          0.0.0.0
33 @{REQ_NETWORKS}                     l2l3_gw_mac_arp_net1    l2l3_gw_mac_arp_net2
34 @{VM_NAMES}
35 ...                                 l2l3_gw_mac_arp_vm1
36 ...                                 l2l3_gw_mac_arp_vm2
37 ...                                 l2l3_gw_mac_arp_vm3
38 ...                                 l2l3_gw_mac_arp_vm4
39 @{NET_1_VMS}                        l2l3_gw_mac_arp_vm1    l2l3_gw_mac_arp_vm2
40 @{NET_2_VMS}                        l2l3_gw_mac_arp_vm3    l2l3_gw_mac_arp_vm4
41 @{PORT_LIST}
42 ...                                 l2l3_gw_mac_arp_port1
43 ...                                 l2l3_gw_mac_arp_port2
44 ...                                 l2l3_gw_mac_arp_port3
45 ...                                 l2l3_gw_mac_arp_port4
46 @{REQ_SUBNETS}                      l2l3_gw_mac_arp_subnet1    l2l3_gw_mac_arp_subnet2
47 @{REQ_SUBNET_CIDR}                  10.1.0.0/16    10.2.0.0/16
48 ${REQ_ROUTER}                       l2l3_gw_mac_arp_rtr1
49 @{DEFAULT_GATEWAY_IPS}              10.1.0.1    10.2.0.1
50 ${VPN_INSTANCE_ID}                  4ae8cd92-48ca-49b5-94e1-b2921a261112
51 ${VPN_NAME}                         l2l3_gw_mac_arp_vpn1
52 ${VPN_REST}                         ${CONFIG_API}/odl-l3vpn:vpn-instance-to-vpn-id/
53 ${VRF_ID}                           100:31
54 ${L3VPN_RD}                         ["${VRF_ID}"]
55 ${SECURITY_GROUP}                   l2l3_gw_mac_arp_sg
56 ${TABLE_NO_0}                       0
57 ${TABLE_NO_220}                     220
58 ${DUMP_FLOWS}                       sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
59 ${GROUP_FLOWS}                      sudo ovs-ofctl -O OpenFlow13 dump-groups ${INTEGRATION_BRIDGE}
60 ${ARP_REQUEST_OPERATIONAL_CODE}     1
61 ${ARP_RESPONSE_OPERATIONAL_CODE}    2
62 ${RESUBMIT_VALUE}                   actions=resubmit\(,${DISPATCHER_TABLE}\)
63 ${PING_COUNT_VALUE}                 0
64
65
66 *** Test Cases ***
67 Verify that table Miss entry for GWMAC table 19 points to table 17 dispatcher table
68     [Documentation]    To Verify there should be an entry for table=17,in the table=19 DUMP_FLOWS
69     OVSDB.Verify Dump Flows For Specific Table
70     ...    ${OS_CMP1_IP}
71     ...    ${GWMAC_TABLE}
72     ...    True
73     ...    ${EMPTY}
74     ...    priority=0
75     ...    actions=resubmit(,17)
76
77 Verify the pipeline flow from dispatcher table 17 (L3VPN) to table 19
78     [Documentation]    To Verify the end to end pipeline flow from table=17 to table=19 DUMP_FLOWS
79     ${subport_id_1} =    OpenStackOperations.Get Sub Port Id    ${PORT_LIST[0]}
80     ${subport_id_2} =    OpenStackOperations.Get Sub Port Id    ${PORT_LIST[1]}
81     ${port_num_1} =    OVSDB.Get Port Number    ${subport_id_1}    ${OS_CMP1_IP}
82     ${port_num_2} =    OVSDB.Get Port Number    ${subport_id_2}    ${OS_CMP1_IP}
83     OVSDB.Verify Dump Flows For Specific Table
84     ...    ${OS_CMP1_IP}
85     ...    ${TABLE_NO_0}
86     ...    True
87     ...    ${EMPTY}
88     ...    in_port=${port_num_1}
89     ...    goto_table:${DISPATCHER_TABLE}
90     ${metadata} =    OVSDB.Get Port Metadata    ${OS_CMP1_IP}    ${port_num_1}
91     ${vpn_id} =    VpnOperations.VPN Get L3VPN ID    ${VRF_ID}
92     OVSDB.Verify Dump Flows For Specific Table
93     ...    ${OS_CMP1_IP}
94     ...    ${DISPATCHER_TABLE}
95     ...    True
96     ...    |grep ${vpn_id}
97     ...    ${vpn_id}
98     ...    goto_table:${GWMAC_TABLE}
99     ${gw_mac_addr} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[0]}
100     Verify Flows Are Present For ARP    ${ARP_REQUEST_OPERATIONAL_CODE}    |grep ${metadata}
101     OVSDB.Verify Dump Flows For Specific Table
102     ...    ${OS_CMP1_IP}
103     ...    ${ARP_RESPONSE_TABLE}
104     ...    True
105     ...    ${EMPTY}
106     ...    set_field:${gw_mac_addr}
107     ...    resubmit(,220)
108     OVSDB.Verify Dump Flows For Specific Table
109     ...    ${OS_CMP1_IP}
110     ...    ${TABLE_NO_220}
111     ...    True
112     ...    ${EMPTY}
113     ...    output:${port_num_2}
114
115 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
116     [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
117     Verify Flows Are Present For ARP    ${ARP_REQUEST_OPERATIONAL_CODE}
118     Verify Flows Are Present For ARP    ${ARP_RESPONSE_OPERATIONAL_CODE}
119
120 Verify that table miss entry for table 17 should not point to table 81 arp table
121     [Documentation]    To Verify there should not be an entry for the arp_responder_table in table=17
122     OVSDB.Verify Dump Flows For Specific Table
123     ...    ${OS_CMP1_IP}
124     ...    ${DISPATCHER_TABLE}
125     ...    False
126     ...    |grep priority=0
127     ...    goto_table:${ARP_RESPONSE_TABLE}
128
129 Verify that Multiple GWMAC entries in GWMAC table points to FIB table 21 (L3VPN pipeline)
130     [Documentation]    To Verify the one or more default gateway mac enteries on the table=19 flows that points to FIB table 21
131     ${gw_mac_addr_1} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[0]}
132     ${gw_mac_addr_2} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[1]}
133     OVSDB.Verify Dump Flows For Specific Table
134     ...    ${OS_CMP1_IP}
135     ...    ${GWMAC_TABLE}
136     ...    True
137     ...    ${EMPTY}
138     ...    dl_dst=${gw_mac_addr_1}
139     ...    actions=goto_table:${L3_TABLE}
140     ${pkt_count_before_ping} =    OvsManager.Get Packet Count From Table
141     ...    ${OS_CMP1_IP}
142     ...    ${INTEGRATION_BRIDGE}
143     ...    table=${GWMAC_TABLE} | grep dl_dst=${gw_mac_addr_1}
144     ${output} =    OpenStackOperations.Execute Command on VM Instance
145     ...    ${REQ_NETWORKS}[0]
146     ...    ${NET_1_VM_IPS}[0]
147     ...    ping -c 8 ${NET_2_VM_IPS}[1]
148     BuiltIn.Should Contain    ${output}    64 bytes
149     ${pkt_count_after_ping} =    OvsManager.Get Packet Count From Table
150     ...    ${OS_CMP1_IP}
151     ...    ${INTEGRATION_BRIDGE}
152     ...    table=${GWMAC_TABLE} | grep dl_dst=${gw_mac_addr_1}
153     ${pkt_diff} =    Evaluate    int(${pkt_count_after_ping})-int(${pkt_count_before_ping})
154     BuiltIn.Should Be True    ${pkt_diff} > ${PING_COUNT_VALUE}
155     ${pkt_count_before_ping} =    OvsManager.Get Packet Count From Table
156     ...    ${OS_CMP2_IP}
157     ...    ${INTEGRATION_BRIDGE}
158     ...    table=${GWMAC_TABLE} | grep dl_dst=${gw_mac_addr_1}
159     ${output} =    OpenStackOperations.Execute Command on VM Instance
160     ...    ${REQ_NETWORKS}[0]
161     ...    ${NET_2_VM_IPS}[0]
162     ...    ping -c 8 ${NET_1_VM_IPS}[1]
163     BuiltIn.Should Contain    ${output}    64 bytes
164     ${pkt_count_after_ping} =    OvsManager.Get Packet Count From Table
165     ...    ${OS_CMP2_IP}
166     ...    ${INTEGRATION_BRIDGE}
167     ...    table=${GWMAC_TABLE} | grep dl_dst=${gw_mac_addr_1}
168     ${pkt_diff} =    Evaluate    int(${pkt_count_after_ping})-int(${pkt_count_before_ping})
169     BuiltIn.Should Be True    ${pkt_diff} > ${PING_COUNT_VALUE}
170
171 Verify table miss entry of ARP responder table points to drop actions
172     [Documentation]    To Verify the default flow entry of table=81 drops when openflow controller connected to compute node
173     OVSDB.Verify Dump Flows For Specific Table
174     ...    ${OS_CMP1_IP}
175     ...    ${ARP_RESPONSE_TABLE}
176     ...    True
177     ...    |grep priority=0
178     ...    actions=drop
179
180 Verify ARP eth_type entries and actions for ARP request and ARP response are populated on GWMAC table
181     [Documentation]    To Verify the entry of ARP request(arp=1) and ARP response(arp=2) in table=19
182     OVSDB.Verify Dump Flows For Specific Table
183     ...    ${OS_CMP1_IP}
184     ...    ${GWMAC_TABLE}
185     ...    True
186     ...    ${EMPTY}
187     ...    arp_op=${ARP_REQUEST_OPERATIONAL_CODE}
188     ...    ${RESUBMIT_VALUE}
189
190 Verify GWMAC entires are populated with Neutron Router MAC address per network in GWMAC table
191     [Documentation]    To Verify gateway mac entires are populated with neutron router mac address for network with vpn dissociation from router
192     VpnOperations.Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID}
193     ${gw_mac_addr} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[1]}
194     BuiltIn.Wait Until Keyword Succeeds
195     ...    60s
196     ...    15s
197     ...    OVSDB.Verify Dump Flows For Specific Table
198     ...    ${OS_CMP1_IP}
199     ...    ${GWMAC_TABLE}
200     ...    True
201     ...    ${EMPTY}
202     ...    dl_dst=${gw_mac_addr}
203     ...    actions=goto_table:${L3_TABLE}
204     ${output} =    VpnOperations.Get Fib Entries    session
205     BuiltIn.Should Match Regexp    ${output}    .*${DEFAULT_GATEWAY_IPS}[1]/32.*${NEXTHOP}
206
207 Verify GWMAC entires are populated with port MAC address for network with vpn association to router in GWMAC table
208     [Documentation]    To Verify gateway mac entires are populated with port MAC address for network with vpn association to router
209     VpnOperations.Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID}
210     ${gw_mac_addr} =    OpenStackOperations.Get Port Mac Address From Ip    ${DEFAULT_GATEWAY_IPS[1]}
211     BuiltIn.Wait Until Keyword Succeeds
212     ...    60s
213     ...    15s
214     ...    OVSDB.Verify Dump Flows For Specific Table
215     ...    ${OS_CMP1_IP}
216     ...    ${GWMAC_TABLE}
217     ...    True
218     ...    ${EMPTY}
219     ...    dl_dst=${gw_mac_addr}
220     ...    actions=goto_table:${L3_TABLE}
221     ${output} =    VpnOperations.Get Fib Entries    session
222     BuiltIn.Should Match Regexp    ${output}    .*${VRF_ID}.*${REQ_SUBNET_CIDR[0]}
223     BuiltIn.Should Match Regexp    ${output}    .*${VRF_ID}.*${REQ_SUBNET_CIDR[1]}
224
225
226 *** Keywords ***
227 Suite Setup
228     [Documentation]    Test Suite for Gateway mac based L2L3 seggragation
229     VpnOperations.Basic Suite Setup
230     Create Setup
231     OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}
232     OpenStackOperations.Get Suite Debugs
233
234 Create Neutron Networks
235     [Documentation]    Create required number of networks
236     [Arguments]    ${NUM_OF_NETWORK}
237     FOR    ${NET}    IN    @{REQ_NETWORKS}
238         OpenStackOperations.Create Network    ${NET}
239     END
240     BuiltIn.Wait Until Keyword Succeeds
241     ...    3s
242     ...    1s
243     ...    Utils.Check For Elements At URI
244     ...    ${NETWORK_URL}
245     ...    ${REQ_NETWORKS}
246
247 Create Neutron Subnets
248     [Documentation]    Create required number of subnets for previously created networks
249     [Arguments]    ${NUM_OF_NETWORK}
250     FOR    ${index}    IN RANGE    0    ${NUM_OF_NETWORK}
251         OpenStackOperations.Create SubNet
252         ...    ${REQ_NETWORKS[${index}]}
253         ...    ${REQ_SUBNETS[${index}]}
254         ...    ${REQ_SUBNET_CIDR[${index}]}
255     END
256     BuiltIn.Wait Until Keyword Succeeds
257     ...    3s
258     ...    1s
259     ...    Utils.Check For Elements At URI
260     ...    ${SUBNETWORK_URL}
261     ...    ${REQ_SUBNETS}
262
263 Create Neutron Ports
264     [Documentation]    Create required number of ports under previously created subnets
265     FOR    ${index}    IN RANGE    0    ${NUM_OF_PORTS_PER_HOST}
266         OpenStackOperations.Create Port    ${REQ_NETWORKS}[${index}]    ${PORT_LIST}[${index}]    sg=${SECURITY_GROUP}
267         OpenStackOperations.Create Port
268         ...    ${REQ_NETWORKS}[${index}]
269         ...    ${PORT_LIST}[${index + 2}]
270         ...    sg=${SECURITY_GROUP}
271     END
272     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${PORT_URL}    ${PORT_LIST}
273
274 Create Nova VMs
275     [Documentation]    Create Vm instances on compute nodes
276     [Arguments]    ${NUM_OF_VMS_PER_DPN}
277     FOR    ${index}    IN RANGE    0    ${NUM_OF_VMS_PER_DPN}
278         OpenStackOperations.Create Vm Instance With Port On Compute Node
279         ...    ${PORT_LIST[${index}]}
280         ...    ${VM_NAMES[${index}]}
281         ...    ${OS_CMP1_HOSTNAME}
282         ...    sg=${SECURITY_GROUP}
283     END
284     ${start} =    Evaluate    ${index}+1
285     ${NUM_OF_VMS_PER_DPN} =    Evaluate    ${start}+${NUM_OF_VMS_PER_DPN}
286     FOR    ${index}    IN RANGE    ${start}    ${NUM_OF_VMS_PER_DPN}
287         OpenStackOperations.Create Vm Instance With Port On Compute Node
288         ...    ${PORT_LIST[${index}]}
289         ...    ${VM_NAMES[${index}]}
290         ...    ${OS_CMP2_HOSTNAME}
291         ...    sg=${SECURITY_GROUP}
292     END
293     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
294     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
295     BuiltIn.Set Suite Variable    @{NET_1_VM_IPS}
296     BuiltIn.Set Suite Variable    @{NET_2_VM_IPS}
297     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
298     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
299     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
300     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
301
302 Create Setup
303     [Documentation]    Create Two Networks, Two Subnets, Four Ports And Four VMs on each DPN
304     ${output} =    Issue Command On Karaf Console    ${TEP_SHOW}
305     Create Neutron Networks    ${REQ_NUM_NET}
306     Create Neutron Subnets    ${REQ_NUM_SUBNET}
307     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
308     Create Neutron Ports
309     OpenStackOperations.Create Router    ${REQ_ROUTER}
310     Add Interfaces To Routers
311     Create Nova VMs    ${REQ_NUM_OF_VMS_PER_DPN}
312     ${router_id} =    OpenStackOperations.Get Router Id    ${REQ_ROUTER}
313     Builtin.Set Suite Variable    ${router_id}
314     VpnOperations.VPN Create L3VPN
315     ...    vpnid=${VPN_INSTANCE_ID}
316     ...    name=${VPN_NAME}
317     ...    rd=${L3VPN_RD}
318     ...    exportrt=${L3VPN_RD}
319     ...    importrt=${L3VPN_RD}
320     VpnOperations.Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID}
321     ${resp} =    VpnOperations.VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID}
322
323 Add Interfaces To Routers
324     [Documentation]    Add Multiple Interfaces to Router and Verify
325     FOR    ${INTERFACE}    IN    @{REQ_SUBNETS}
326         OpenStackOperations.Add Router Interface    ${REQ_ROUTER}    ${INTERFACE}
327     END
328     ${interface_output} =    OpenStackOperations.Show Router Interface    ${REQ_ROUTER}
329     FOR    ${INTERFACE}    IN    @{REQ_SUBNETS}
330         ${subnet_id} =    OpenStackOperations.Get Subnet Id    ${INTERFACE}
331         BuiltIn.Should Contain    ${interface_output}    ${subnet_id}
332     END
333
334 Verify Flows Are Present For ARP
335     [Documentation]    Verify Flows Are Present For ARP entry
336     [Arguments]    ${arp_op_code}    ${additional_args}=${EMPTY}
337     ${flow_output} =    Utils.Run Command On Remote System
338     ...    ${OS_CMP1_IP}
339     ...    ${DUMP_FLOWS} | grep table=${GWMAC_TABLE}
340     BuiltIn.Should Contain    ${flow_output}    arp,arp_op=${arp_op_code} ${RESUBMIT_VALUE}
341     ${flow_output} =    Utils.Run Command On Remote System
342     ...    ${OS_CMP1_IP}
343     ...    ${DUMP_FLOWS} | grep table=${DISPATCHER_TABLE} ${additional_args}
344     BuiltIn.Should Contain    ${flow_output}    goto_table:${ARP_CHECK_TABLE}
345     ${flow_output} =    Utils.Run Command On Remote System
346     ...    ${OS_CMP1_IP}
347     ...    ${DUMP_FLOWS} | grep table=${ARP_CHECK_TABLE}
348     @{group_id} =    String.Get Regexp Matches    ${flow_output}    group:(\\d+)    1
349     BuiltIn.Should Contain    ${flow_output}    arp,arp_op=1 actions=group:${group_id[0]}
350     ${flow_output} =    Utils.Run Command On Remote System
351     ...    ${OS_CMP1_IP}
352     ...    ${GROUP_FLOWS} | grep group_id=${group_id[0]}
353     BuiltIn.Should Contain    ${flow_output}    bucket=actions=resubmit(,81)