2 Documentation Functional test for bgp - evpn
4 ... Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
10 ... This suite tests advertising and receiveing routes with evpn content.
11 ... It uses play.py and odl as bgp peers. Routes advertized from odl
12 ... are configured via application peer. Routes advertised from play.py are
13 ... stored in *.hex files. These files are used also as expected data which
14 ... is recevied from odl.
15 Suite Setup Start_Suite
16 Suite Teardown Stop_Suite
17 Test Setup Run Keywords SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
18 ... AND Verify Test Preconditions
19 Test Template Odl_To_Play_Template
20 Library RequestsLibrary
23 Library ../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
24 Resource ../../../libraries/BGPcliKeywords.robot
25 Resource ../../../libraries/BgpOperations.robot
26 Resource ../../../libraries/BGPSpeaker.robot
27 Resource ../../../libraries/CompareStream.robot
28 Resource ../../../libraries/SetupUtils.robot
29 Resource ../../../libraries/SSHKeywords.robot
30 Resource ../../../libraries/TemplatedRequests.robot
31 Resource ../../../variables/Variables.robot
35 ${RIB_NAME} example-bgp-rib
36 ${BGP_DIR} ${CURDIR}/../../../variables/bgpfunctional
37 ${DEFAUTL_RPC_CFG} exa.cfg
38 ${CONFIG_SESSION} config-session
39 ${EVPN_DIR} ${CURDIR}/../../../variables/bgpfunctional/l2vpn_evpn
40 ${BGP_TOOL_LOG_LEVEL} debug
41 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
42 ${SS} ${SPACE}${SPACE}${SPACE}${SPACE}
43 ${PATH_ID_JSON} ${SS}${SS}"path-id": 0,${\n}
44 ${PATH_ID_XML} ${SS}<path-id>0</path-id>${\n}
48 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
49 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
51 &{mapping} BuiltIn.Create_Dictionary BGP_RIB_OPENCONFIG=${RIB_NAME} IP=${ODL_SYSTEM_IP}
52 TemplatedRequests.Put_As_Xml_Templated ${BGP_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
54 Reconfigure_ODL_To_Accept_Connection
55 [Documentation] Configures BGP peer module with initiate-connection set to false.
56 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
58 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} INITIATE=false BGP_RIB_OPENCONFIG=${RIB_NAME}
60 TemplatedRequests.Put_As_Xml_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
63 [Documentation] Start Python speaker to connect to ODL. We need to do WUKS until odl really starts to accept incomming bgp connection. The failure happens if the incomming connection comes too quickly after configuring the peer in the previous test case.
64 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
66 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start Bgp Peer
68 Odl_To_Play_route_es_arb
71 Play_To_Odl_route_es_arb
72 [Template] Play_To_Odl_Template
75 Odl_To_Play_route_es_as
78 Play_To_Odl_route_es_as
79 [Template] Play_To_Odl_Template
82 Odl_To_Play_route_es_lacp
85 Play_To_Odl_route_es_lacp
86 [Template] Play_To_Odl_Template
89 Odl_To_Play_route_es_lan
92 Play_To_Odl_route_es_lan
93 [Template] Play_To_Odl_Template
96 Odl_To_Play_route_es_mac
99 Play_To_Odl_route_es_mac
100 [Template] Play_To_Odl_Template
103 Odl_To_Play_route_es_rou
106 Play_To_Odl_route_es_rou
107 [Template] Play_To_Odl_Template
110 Odl_To_Play_route_eth_arb
113 Play_To_Odl_route_eth_arb
114 [Template] Play_To_Odl_Template
117 Odl_To_Play_route_eth_as
120 Play_To_Odl_route_eth_as
121 [Template] Play_To_Odl_Template
124 Odl_To_Play_route_eth_lacp
127 Play_To_Odl_route_eth_lacp
128 [Template] Play_To_Odl_Template
131 Odl_To_Play_route_eth_lacp_extdef
132 route_eth_lacp_extdef
134 Play_To_Odl_route_eth_lacp_extdef
135 [Template] Play_To_Odl_Template
136 route_eth_lacp_extdef
138 Odl_To_Play_route_eth_lacp_extesilab
139 route_eth_lacp_extesilab
141 Play_To_Odl_route_eth_lacp_extesilab
142 [Template] Play_To_Odl_Template
143 route_eth_lacp_extesilab
145 Odl_To_Play_route_eth_lacp_extesr
146 route_eth_lacp_extesr
148 Play_To_Odl_route_eth_lacp_extesr
149 [Template] Play_To_Odl_Template
150 route_eth_lacp_extesr
152 Odl_To_Play_route_eth_lacp_extl2
155 Play_To_Odl_route_eth_lacp_extl2
156 [Template] Play_To_Odl_Template
159 Odl_To_Play_route_eth_lacp_extmac
160 route_eth_lacp_extmac
162 Play_To_Odl_route_eth_lacp_extmac
163 [Template] Play_To_Odl_Template
164 route_eth_lacp_extmac
166 Odl_To_Play_route_eth_lan
169 Play_To_Odl_route_eth_lan
170 [Template] Play_To_Odl_Template
173 Odl_To_Play_route_eth_mac
176 Play_To_Odl_route_eth_mac
177 [Template] Play_To_Odl_Template
180 Odl_To_Play_route_eth_rou
183 Play_To_Odl_route_eth_rou
184 [Template] Play_To_Odl_Template
187 Odl_To_Play_route_inc_arb
190 Play_To_Odl_route_inc_arb
191 [Template] Play_To_Odl_Template
194 Odl_To_Play_route_inc_as
197 Play_To_Odl_route_inc_as
198 [Template] Play_To_Odl_Template
201 Odl_To_Play_route_inc_lacp
204 Play_To_Odl_route_inc_lacp
205 [Template] Play_To_Odl_Template
208 Odl_To_Play_route_inc_lan
211 Play_To_Odl_route_inc_lan
212 [Template] Play_To_Odl_Template
215 Odl_To_Play_route_inc_mac
218 Play_To_Odl_route_inc_mac
219 [Template] Play_To_Odl_Template
222 Odl_To_Play_route_inc_rou
225 Play_To_Odl_route_inc_rou
226 [Template] Play_To_Odl_Template
229 Odl_To_Play_route_mac_arb
232 Play_To_Odl_route_mac_arb
233 [Template] Play_To_Odl_Template
236 Odl_To_Play_route_mac_as
239 Play_To_Odl_route_mac_as
240 [Template] Play_To_Odl_Template
243 Odl_To_Play_route_mac_lacp
246 Play_To_Odl_route_mac_lacp
247 [Template] Play_To_Odl_Template
250 Odl_To_Play_route_mac_lan
253 Play_To_Odl_route_mac_lan
254 [Template] Play_To_Odl_Template
257 Odl_To_Play_route_mac_mac
260 Play_To_Odl_route_mac_mac
261 [Template] Play_To_Odl_Template
264 Odl_To_Play_route_mac_rou
267 Play_To_Odl_route_mac_rou
268 [Template] Play_To_Odl_Template
271 Odl_To_Play_pmsi_rsvp_te_p2mp_lsp
273 CompareStream.Run_Keyword_If_At_Least_Fluorine Odl_To_Play_Template pmsi_rsvp_te_p2mp_lsp
275 Play_To_Odl_pmsi_rsvp_te_p2mp_lsp
277 CompareStream.Run_Keyword_If_At_Least_Fluorine Play_To_Odl_Template pmsi_rsvp_te_p2mp_lsp
279 Odl_To_Play_pmsi_mldp_p2mp_lsp
282 Play_To_Odl_pmsi_mldp_p2mp_lsp
283 [Template] Play_To_Odl_Template
286 Odl_To_Play_pmsi_pim_ssm_tree
289 Play_To_Odl_pmsi_pim_ssm_tree
290 [Template] Play_To_Odl_Template
293 Odl_To_Play_pmsi_pim_sm_tree
296 Play_To_Odl_pmsi_pim_sm_tree
297 [Template] Play_To_Odl_Template
300 Odl_To_Play_pmsi_bidir_pim_tree
303 Play_To_Odl_pmsi_bidir_pim_tree
304 [Template] Play_To_Odl_Template
307 Odl_To_Play_pmsi_ingress_replication
308 pmsi_ingress_replication
310 Play_To_Odl_pmsi_ingress_replication
311 [Template] Play_To_Odl_Template
312 pmsi_ingress_replication
314 Odl_To_Play_pmsi_mldp_mp2mp_lsp
317 Play_To_Odl_pmsi_mldp_mp2mp_lsp
318 [Template] Play_To_Odl_Template
321 Kill_Talking_BGP_Speaker
322 [Documentation] Abort the Python speaker
323 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
325 BGPSpeaker.Kill_BGP_Speaker
326 BGPcliKeywords.Store_File_To_Workspace play.py.out evpn_play.log
328 Delete_Bgp_Peer_Configuration
329 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
330 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
332 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
333 TemplatedRequests.Delete_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
336 [Documentation] Revert the BGP configuration to the original state: without application peer
337 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
339 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
340 TemplatedRequests.Delete_Templated ${BGP_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
344 [Documentation] Initialize SetupUtils. Suite setup keyword.
345 SetupUtils.Setup_Utils_For_Setup_And_Teardown
346 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
347 Builtin.Set Suite Variable ${mininet_conn_id}
348 SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
349 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
350 SSHLibrary.Put File ${PLAY_SCRIPT} .
351 SSHKeywords.Assure_Library_Ipaddr target_dir=.
352 BuiltIn.Set_Suite_Variable ${EVPN_CONF_URL} /restconf/config/bgp-rib:application-rib/${ODL_SYSTEM_IP}/tables/odl-bgp-evpn:l2vpn-address-family/odl-bgp-evpn:evpn-subsequent-address-family/odl-bgp-evpn:evpn-routes/
353 BuiltIn.Set_Suite_Variable ${EVPN_LOC_RIB} /restconf/operational/bgp-rib:bgp-rib/rib/${RIB_NAME}/loc-rib/tables/odl-bgp-evpn:l2vpn-address-family/odl-bgp-evpn:evpn-subsequent-address-family/odl-bgp-evpn:evpn-routes
354 ${EMPTY_ROUTES} = OperatingSystem.Get_File ${EVPN_DIR}/empty_routes/empty_routes.json
355 BuiltIn.Set_Suite_Variable ${EMPTY_ROUTES}
358 [Documentation] Suite teardown keyword
359 SSHLibrary.Close_All_Connections
360 RequestsLibrary.Delete_All_Sessions
363 [Documentation] Starts bgp peer and verifies that the peer runs.
364 BGPSpeaker.Start_BGP_Speaker --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_TOOL_LOG_LEVEL} --evpn --wfr 1
365 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
368 [Arguments] ${totest}
369 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
370 ${data_json} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.json
371 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
372 ${announce_hex} = String.Remove_String ${announce_hex} \n
373 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
374 ${withdraw_hex} = String.Remove_String ${withdraw_hex} \n
375 ${data_path_xml} CompareStream.Run_Keyword_If_Less_Than_Fluorine String.Replace_String ${data_xml} ${PATH_ID_XML} ${EMPTY}
376 ${post_data_xml} CompareStream.Set_Variable_If_At_Least_Fluorine ${data_xml} ${data_path_xml}
377 BuiltIn.Log ${post_data_xml}
378 BuiltIn.Log ${data_json}
379 BuiltIn.Log ${announce_hex}
380 BuiltIn.Log ${withdraw_hex}
381 BgpRpcClient.play_clean
382 ${resp} = RequestsLibrary.Post_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} data=${post_data_xml} headers=${HEADERS_XML}
383 BuiltIn.Log ${resp.content}
384 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 204
385 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS_XML}
386 BuiltIn.Log ${resp.content}
387 ${aupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
388 BuiltIn.Log ${aupdate}
389 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${aupdate} ${announce_hex}
390 BgpRpcClient.play_clean
391 Remove_Configured_Routes
392 ${wupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
393 BuiltIn.Log ${wupdate}
394 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${wupdate} ${withdraw_hex}
395 [Teardown] Remove_Configured_Routes
398 [Arguments] ${totest}
399 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
400 ${data_json} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.json
401 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
402 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
403 ${data_path_json} CompareStream.Run_Keyword_If_Less_Than_Fluorine String.Replace_String ${data_json} ${PATH_ID_JSON} ${EMPTY}
404 ${data_json_exp} CompareStream.Set_Variable_If_At_Least_Fluorine ${data_json} ${data_path_json}
405 BuiltIn.Log ${data_xml}
406 BuiltIn.Log ${data_json_exp}
407 BuiltIn.Log ${announce_hex}
408 BuiltIn.Log ${withdraw_hex}
409 BgpRpcClient.play_clean
410 BgpRpcClient.play_send ${announce_hex}
411 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presence ${data_json_exp}
412 BgpRpcClient.play_send ${withdraw_hex}
413 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presence ${EMPTY_ROUTES}
414 [Teardown] Withdraw_Route_And_Verify ${withdraw_hex}
416 Verify_Test_Preconditions
417 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
418 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 404
419 Loc_Rib_Presence ${EMPTY_ROUTES}
421 Remove_Configured_Routes
422 [Documentation] Removes the route if present. First GET is for debug purposes.
423 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
425 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS}
427 BuiltIn.Return_From_Keyword_If "${rsp.status_code}" == "404"
428 ${resp} = RequestsLibrary.Delete_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
429 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 200
431 Withdraw_Route_And_Verify
432 [Arguments] ${withdraw_hex}
433 [Documentation] Sends withdraw update message from exabgp and verifies route removal from odl's rib
434 BgpRpcClient.play_send ${withdraw_hex}
435 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Loc_Rib_Presence ${EMPTY_ROUTES}
438 [Documentation] Gets received data from odl's peer
439 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS_XML}
440 BuiltIn.Log ${resp.content}
441 ${update} = BgpRpcClient.play_get
442 BuiltIn.Should_Not_Be_Equal ${update} ${Empty}
446 [Arguments] ${exp_content}
447 [Documentation] Verifies if loc-rib contains expected data
448 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
449 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content}