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}
45 ${OLD_EVPN_ROUTES_LINE} \n"odl-bgp-evpn:evpn-routes": {},
46 ${NEW_EVPN_ROUTES_LINE} ${EMPTY}
47 ${OLD_AS_PATH} ,\n"as-path": {}
48 ${NEW_AS_PATH} ${EMPTY}
52 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
53 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
55 &{mapping} BuiltIn.Create_Dictionary BGP_RIB_OPENCONFIG=${RIB_NAME} IP=${ODL_SYSTEM_IP}
56 TemplatedRequests.Put_As_Xml_Templated ${BGP_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
58 Reconfigure_ODL_To_Accept_Connection
59 [Documentation] Configures BGP peer module with initiate-connection set to false.
60 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
62 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} INITIATE=false BGP_RIB_OPENCONFIG=${RIB_NAME}
64 TemplatedRequests.Put_As_Xml_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
67 [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.
68 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
70 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start Bgp Peer
72 Odl_To_Play_route_es_arb
75 Play_To_Odl_route_es_arb
76 [Template] Play_To_Odl_Template
79 Odl_To_Play_route_es_as
82 Play_To_Odl_route_es_as
83 [Template] Play_To_Odl_Template
86 Odl_To_Play_route_es_lacp
89 Play_To_Odl_route_es_lacp
90 [Template] Play_To_Odl_Template
93 Odl_To_Play_route_es_lan
96 Play_To_Odl_route_es_lan
97 [Template] Play_To_Odl_Template
100 Odl_To_Play_route_es_mac
103 Play_To_Odl_route_es_mac
104 [Template] Play_To_Odl_Template
107 Odl_To_Play_route_es_rou
110 Play_To_Odl_route_es_rou
111 [Template] Play_To_Odl_Template
114 Odl_To_Play_route_eth_arb
117 Play_To_Odl_route_eth_arb
118 [Template] Play_To_Odl_Template
121 Odl_To_Play_route_eth_as
124 Play_To_Odl_route_eth_as
125 [Template] Play_To_Odl_Template
128 Odl_To_Play_route_eth_lacp
131 Play_To_Odl_route_eth_lacp
132 [Template] Play_To_Odl_Template
135 Odl_To_Play_route_eth_lacp_extdef
136 route_eth_lacp_extdef
138 Play_To_Odl_route_eth_lacp_extdef
139 [Template] Play_To_Odl_Template
140 route_eth_lacp_extdef
142 Odl_To_Play_route_eth_lacp_extesilab
143 route_eth_lacp_extesilab
145 Play_To_Odl_route_eth_lacp_extesilab
146 [Template] Play_To_Odl_Template
147 route_eth_lacp_extesilab
149 Odl_To_Play_route_eth_lacp_extesr
150 route_eth_lacp_extesr
152 Play_To_Odl_route_eth_lacp_extesr
153 [Template] Play_To_Odl_Template
154 route_eth_lacp_extesr
156 Odl_To_Play_route_eth_lacp_extl2
159 Play_To_Odl_route_eth_lacp_extl2
160 [Template] Play_To_Odl_Template
163 Odl_To_Play_route_eth_lacp_extmac
164 route_eth_lacp_extmac
166 Play_To_Odl_route_eth_lacp_extmac
167 [Template] Play_To_Odl_Template
168 route_eth_lacp_extmac
170 Odl_To_Play_route_eth_lan
173 Play_To_Odl_route_eth_lan
174 [Template] Play_To_Odl_Template
177 Odl_To_Play_route_eth_mac
180 Play_To_Odl_route_eth_mac
181 [Template] Play_To_Odl_Template
184 Odl_To_Play_route_eth_rou
187 Play_To_Odl_route_eth_rou
188 [Template] Play_To_Odl_Template
191 Odl_To_Play_route_inc_arb
194 Play_To_Odl_route_inc_arb
195 [Template] Play_To_Odl_Template
198 Odl_To_Play_route_inc_as
201 Play_To_Odl_route_inc_as
202 [Template] Play_To_Odl_Template
205 Odl_To_Play_route_inc_lacp
208 Play_To_Odl_route_inc_lacp
209 [Template] Play_To_Odl_Template
212 Odl_To_Play_route_inc_lan
215 Play_To_Odl_route_inc_lan
216 [Template] Play_To_Odl_Template
219 Odl_To_Play_route_inc_mac
222 Play_To_Odl_route_inc_mac
223 [Template] Play_To_Odl_Template
226 Odl_To_Play_route_inc_rou
229 Play_To_Odl_route_inc_rou
230 [Template] Play_To_Odl_Template
233 Odl_To_Play_route_mac_arb
236 Play_To_Odl_route_mac_arb
237 [Template] Play_To_Odl_Template
240 Odl_To_Play_route_mac_as
243 Play_To_Odl_route_mac_as
244 [Template] Play_To_Odl_Template
247 Odl_To_Play_route_mac_lacp
250 Play_To_Odl_route_mac_lacp
251 [Template] Play_To_Odl_Template
254 Odl_To_Play_route_mac_lan
257 Play_To_Odl_route_mac_lan
258 [Template] Play_To_Odl_Template
261 Odl_To_Play_route_mac_mac
264 Play_To_Odl_route_mac_mac
265 [Template] Play_To_Odl_Template
268 Odl_To_Play_route_mac_rou
271 Play_To_Odl_route_mac_rou
272 [Template] Play_To_Odl_Template
275 Odl_To_Play_pmsi_rsvp_te_p2mp_lsp
277 CompareStream.Run_Keyword_If_At_Least_Fluorine Odl_To_Play_Template pmsi_rsvp_te_p2mp_lsp
279 Play_To_Odl_pmsi_rsvp_te_p2mp_lsp
281 CompareStream.Run_Keyword_If_At_Least_Fluorine Play_To_Odl_Template pmsi_rsvp_te_p2mp_lsp
283 Odl_To_Play_pmsi_mldp_p2mp_lsp
286 Play_To_Odl_pmsi_mldp_p2mp_lsp
287 [Template] Play_To_Odl_Template
290 Odl_To_Play_pmsi_pim_ssm_tree
293 Play_To_Odl_pmsi_pim_ssm_tree
294 [Template] Play_To_Odl_Template
297 Odl_To_Play_pmsi_pim_sm_tree
300 Play_To_Odl_pmsi_pim_sm_tree
301 [Template] Play_To_Odl_Template
304 Odl_To_Play_pmsi_bidir_pim_tree
307 Play_To_Odl_pmsi_bidir_pim_tree
308 [Template] Play_To_Odl_Template
311 Odl_To_Play_pmsi_ingress_replication
312 pmsi_ingress_replication
314 Play_To_Odl_pmsi_ingress_replication
315 [Template] Play_To_Odl_Template
316 pmsi_ingress_replication
318 Odl_To_Play_pmsi_mldp_mp2mp_lsp
321 Play_To_Odl_pmsi_mldp_mp2mp_lsp
322 [Template] Play_To_Odl_Template
325 Kill_Talking_BGP_Speaker
326 [Documentation] Abort the Python speaker
327 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
329 BGPSpeaker.Kill_BGP_Speaker
330 BGPcliKeywords.Store_File_To_Workspace play.py.out evpn_play.log
332 Delete_Bgp_Peer_Configuration
333 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
334 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
336 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
337 TemplatedRequests.Delete_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
340 [Documentation] Revert the BGP configuration to the original state: without application peer
341 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
343 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
344 TemplatedRequests.Delete_Templated ${BGP_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
348 [Documentation] Initialize SetupUtils. Suite setup keyword.
349 SetupUtils.Setup_Utils_For_Setup_And_Teardown
350 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
351 Builtin.Set Suite Variable ${mininet_conn_id}
352 SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
353 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
354 SSHLibrary.Put File ${PLAY_SCRIPT} .
355 SSHKeywords.Assure_Library_Ipaddr target_dir=.
356 BuiltIn.Set_Suite_Variable ${EVPN_CONF_URL} /rests/data/bgp-rib:application-rib=${ODL_SYSTEM_IP}/tables=odl-bgp-evpn%3Al2vpn-address-family,odl-bgp-evpn%3Aevpn-subsequent-address-family/odl-bgp-evpn:evpn-routes
357 BuiltIn.Set_Suite_Variable ${EVPN_LOC_RIB} /rests/data/bgp-rib:bgp-rib/rib=${RIB_NAME}/loc-rib/tables=odl-bgp-evpn%3Al2vpn-address-family,odl-bgp-evpn%3Aevpn-subsequent-address-family/odl-bgp-evpn:evpn-routes?content=nonconfig
358 BuiltIn.Set_Suite_Variable ${EVPN_FAMILY_LOC_RIB} /rests/data/bgp-rib:bgp-rib/rib=${RIB_NAME}/loc-rib/tables=odl-bgp-evpn%3Al2vpn-address-family,odl-bgp-evpn%3Aevpn-subsequent-address-family?content=nonconfig
359 ${evpn_routes_line} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_EVPN_ROUTES_LINE} ${OLD_EVPN_ROUTES_LINE}
360 &{mapping} BuiltIn.Create_Dictionary EVPN_ROUTES=${evpn_routes_line}
361 ${EMPTY_ROUTES} = TemplatedRequests.Resolve_Text_From_Template_File ${EVPN_DIR}/empty_routes empty_routes.json ${mapping}
362 BuiltIn.Set_Suite_Variable ${EMPTY_ROUTES}
365 [Documentation] Suite teardown keyword
366 SSHLibrary.Close_All_Connections
367 RequestsLibrary.Delete_All_Sessions
370 [Documentation] Starts bgp peer and verifies that the peer runs.
371 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
372 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
375 [Arguments] ${totest}
376 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
377 ${data_json} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.json
378 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
379 ${announce_hex} = String.Remove_String ${announce_hex} \n
380 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
381 ${withdraw_hex} = String.Remove_String ${withdraw_hex} \n
382 ${data_path_xml} CompareStream.Run_Keyword_If_Less_Than_Fluorine String.Replace_String ${data_xml} ${PATH_ID_XML} ${EMPTY}
383 ${post_data_xml} CompareStream.Set_Variable_If_At_Least_Fluorine ${data_xml} ${data_path_xml}
384 BuiltIn.Log ${post_data_xml}
385 BuiltIn.Log ${data_json}
386 BuiltIn.Log ${announce_hex}
387 BuiltIn.Log ${withdraw_hex}
388 BgpRpcClient.play_clean
389 ${resp} = RequestsLibrary.Post_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} data=${post_data_xml} headers=${HEADERS_XML}
390 BuiltIn.Log ${resp.content}
391 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 201
392 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}?content=config headers=${HEADERS_XML}
393 BuiltIn.Log ${resp.content}
394 ${aupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
395 BuiltIn.Log ${aupdate}
396 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${aupdate} ${announce_hex}
397 BgpRpcClient.play_clean
398 Remove_Configured_Routes
399 ${wupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
400 BuiltIn.Log ${wupdate}
401 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${wupdate} ${withdraw_hex}
402 [Teardown] Remove_Configured_Routes
405 [Arguments] ${totest}
406 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
407 ${AS_PATH} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH}
408 &{mapping} BuiltIn.Create_Dictionary AS_PATH=${AS_PATH}
409 ${data_json} = TemplatedRequests.Resolve_Text_From_Template_File ${EVPN_DIR}/${totest} ${totest}.json ${mapping}
410 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
411 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
412 ${data_path_json} CompareStream.Run_Keyword_If_Less_Than_Fluorine String.Replace_String ${data_json} ${PATH_ID_JSON} ${EMPTY}
413 ${data_json_exp} CompareStream.Set_Variable_If_At_Least_Fluorine ${data_json} ${data_path_json}
414 BuiltIn.Log ${data_xml}
415 BuiltIn.Log ${data_json_exp}
416 BuiltIn.Log ${announce_hex}
417 BuiltIn.Log ${withdraw_hex}
418 BgpRpcClient.play_clean
419 BgpRpcClient.play_send ${announce_hex}
420 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presence ${data_json_exp}
421 BgpRpcClient.play_send ${withdraw_hex}
422 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Verify_Test_Preconditions
423 [Teardown] Withdraw_Route_And_Verify ${withdraw_hex}
425 Verify_Test_Preconditions
426 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}?content=config
427 BuiltIn.Should_Contain ${DELETED_STATUS_CODES} ${resp.status_code}
428 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_FAMILY_LOC_RIB} headers=${HEADERS}
429 TemplatedRequests.Normalize_Jsons_And_Compare ${EMPTY_ROUTES} ${rsp.content}
431 Remove_Configured_Routes
432 [Documentation] Removes the route if present. First GET is for debug purposes.
433 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
435 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}?content=config headers=${HEADERS}
437 BuiltIn.Return_From_Keyword_If ${rsp.status_code} in ${DELETED_STATUS_CODES}
438 ${resp} = RequestsLibrary.Delete_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
439 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 204
441 Withdraw_Route_And_Verify
442 [Arguments] ${withdraw_hex}
443 [Documentation] Sends withdraw update message from exabgp and verifies route removal from odl's rib
444 BgpRpcClient.play_send ${withdraw_hex}
445 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Verify_Test_Preconditions
448 [Documentation] Gets received data from odl's peer
449 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS_XML}
450 BuiltIn.Log ${resp.content}
451 ${update} = BgpRpcClient.play_get
452 BuiltIn.Should_Not_Be_Equal ${update} ${Empty}
456 [Arguments] ${exp_content}
457 [Documentation] Verifies if loc-rib contains expected data
458 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
459 BuiltIn.Log_Many ${exp_content} ${rsp.content}
460 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content}