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/BGPSpeaker.robot
26 Resource ../../../libraries/CompareStream.robot
27 Resource ../../../libraries/SetupUtils.robot
28 Resource ../../../libraries/SSHKeywords.robot
29 Resource ../../../libraries/TemplatedRequests.robot
30 Resource ../../../variables/Variables.robot
34 ${RIB_NAME} example-bgp-rib
35 ${BGP_DIR} ${CURDIR}/../../../variables/bgpfunctional
36 ${DEFAUTL_RPC_CFG} exa.cfg
37 ${CONFIG_SESSION} config-session
38 ${EVPN_DIR} ${CURDIR}/../../../variables/bgpfunctional/l2vpn_evpn
39 ${BGP_TOOL_LOG_LEVEL} debug
40 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
41 ${SS} ${SPACE}${SPACE}${SPACE}${SPACE}
42 ${PATH_ID_JSON} ${SS}${SS}"path-id": 0,${\n}
43 ${PATH_ID_XML} ${SS}<path-id>0</path-id>${\n}
47 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
48 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
50 &{mapping} BuiltIn.Create_Dictionary BGP_RIB_OPENCONFIG=${RIB_NAME} IP=${ODL_SYSTEM_IP}
51 TemplatedRequests.Put_As_Xml_Templated ${BGP_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
53 Reconfigure_ODL_To_Accept_Connection
54 [Documentation] Configures BGP peer module with initiate-connection set to false.
55 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
57 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} INITIATE=false BGP_RIB_OPENCONFIG=${RIB_NAME}
59 TemplatedRequests.Put_As_Xml_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
62 [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.
63 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
65 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start Bgp Peer
67 Odl_To_Play_route_es_arb
70 Play_To_Odl_route_es_arb
71 [Template] Play_To_Odl_Template
74 Odl_To_Play_route_es_as
77 Play_To_Odl_route_es_as
78 [Template] Play_To_Odl_Template
81 Odl_To_Play_route_es_lacp
84 Play_To_Odl_route_es_lacp
85 [Template] Play_To_Odl_Template
88 Odl_To_Play_route_es_lan
91 Play_To_Odl_route_es_lan
92 [Template] Play_To_Odl_Template
95 Odl_To_Play_route_es_mac
98 Play_To_Odl_route_es_mac
99 [Template] Play_To_Odl_Template
102 Odl_To_Play_route_es_rou
105 Play_To_Odl_route_es_rou
106 [Template] Play_To_Odl_Template
109 Odl_To_Play_route_eth_arb
112 Play_To_Odl_route_eth_arb
113 [Template] Play_To_Odl_Template
116 Odl_To_Play_route_eth_as
119 Play_To_Odl_route_eth_as
120 [Template] Play_To_Odl_Template
123 Odl_To_Play_route_eth_lacp
126 Play_To_Odl_route_eth_lacp
127 [Template] Play_To_Odl_Template
130 Odl_To_Play_route_eth_lacp_extdef
131 route_eth_lacp_extdef
133 Play_To_Odl_route_eth_lacp_extdef
134 [Template] Play_To_Odl_Template
135 route_eth_lacp_extdef
137 Odl_To_Play_route_eth_lacp_extesilab
138 route_eth_lacp_extesilab
140 Play_To_Odl_route_eth_lacp_extesilab
141 [Template] Play_To_Odl_Template
142 route_eth_lacp_extesilab
144 Odl_To_Play_route_eth_lacp_extesr
145 route_eth_lacp_extesr
147 Play_To_Odl_route_eth_lacp_extesr
148 [Template] Play_To_Odl_Template
149 route_eth_lacp_extesr
151 Odl_To_Play_route_eth_lacp_extl2
154 Play_To_Odl_route_eth_lacp_extl2
155 [Template] Play_To_Odl_Template
158 Odl_To_Play_route_eth_lacp_extmac
159 route_eth_lacp_extmac
161 Play_To_Odl_route_eth_lacp_extmac
162 [Template] Play_To_Odl_Template
163 route_eth_lacp_extmac
165 Odl_To_Play_route_eth_lan
168 Play_To_Odl_route_eth_lan
169 [Template] Play_To_Odl_Template
172 Odl_To_Play_route_eth_mac
175 Play_To_Odl_route_eth_mac
176 [Template] Play_To_Odl_Template
179 Odl_To_Play_route_eth_rou
182 Play_To_Odl_route_eth_rou
183 [Template] Play_To_Odl_Template
186 Odl_To_Play_route_inc_arb
189 Play_To_Odl_route_inc_arb
190 [Template] Play_To_Odl_Template
193 Odl_To_Play_route_inc_as
196 Play_To_Odl_route_inc_as
197 [Template] Play_To_Odl_Template
200 Odl_To_Play_route_inc_lacp
203 Play_To_Odl_route_inc_lacp
204 [Template] Play_To_Odl_Template
207 Odl_To_Play_route_inc_lan
210 Play_To_Odl_route_inc_lan
211 [Template] Play_To_Odl_Template
214 Odl_To_Play_route_inc_mac
217 Play_To_Odl_route_inc_mac
218 [Template] Play_To_Odl_Template
221 Odl_To_Play_route_inc_rou
224 Play_To_Odl_route_inc_rou
225 [Template] Play_To_Odl_Template
228 Odl_To_Play_route_mac_arb
231 Play_To_Odl_route_mac_arb
232 [Template] Play_To_Odl_Template
235 Odl_To_Play_route_mac_as
238 Play_To_Odl_route_mac_as
239 [Template] Play_To_Odl_Template
242 Odl_To_Play_route_mac_lacp
245 Play_To_Odl_route_mac_lacp
246 [Template] Play_To_Odl_Template
249 Odl_To_Play_route_mac_lan
252 Play_To_Odl_route_mac_lan
253 [Template] Play_To_Odl_Template
256 Odl_To_Play_route_mac_mac
259 Play_To_Odl_route_mac_mac
260 [Template] Play_To_Odl_Template
263 Odl_To_Play_route_mac_rou
266 Play_To_Odl_route_mac_rou
267 [Template] Play_To_Odl_Template
270 Odl_To_Play_pmsi_rsvp_te_p2mp_lsp
272 CompareStream.Run_Keyword_If_At_Least_Fluorine Odl_To_Play_Template pmsi_rsvp_te_p2mp_lsp
274 Play_To_Odl_pmsi_rsvp_te_p2mp_lsp
276 CompareStream.Run_Keyword_If_At_Least_Fluorine Play_To_Odl_Template pmsi_rsvp_te_p2mp_lsp
278 Odl_To_Play_pmsi_mldp_p2mp_lsp
281 Play_To_Odl_pmsi_mldp_p2mp_lsp
282 [Template] Play_To_Odl_Template
285 Odl_To_Play_pmsi_pim_ssm_tree
288 Play_To_Odl_pmsi_pim_ssm_tree
289 [Template] Play_To_Odl_Template
292 Odl_To_Play_pmsi_pim_sm_tree
295 Play_To_Odl_pmsi_pim_sm_tree
296 [Template] Play_To_Odl_Template
299 Odl_To_Play_pmsi_bidir_pim_tree
302 Play_To_Odl_pmsi_bidir_pim_tree
303 [Template] Play_To_Odl_Template
306 Odl_To_Play_pmsi_ingress_replication
307 pmsi_ingress_replication
309 Play_To_Odl_pmsi_ingress_replication
310 [Template] Play_To_Odl_Template
311 pmsi_ingress_replication
313 Odl_To_Play_pmsi_mldp_mp2mp_lsp
316 Play_To_Odl_pmsi_mldp_mp2mp_lsp
317 [Template] Play_To_Odl_Template
320 Kill_Talking_BGP_Speaker
321 [Documentation] Abort the Python speaker
322 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
324 BGPSpeaker.Kill_BGP_Speaker
325 BGPcliKeywords.Store_File_To_Workspace play.py.out evpn_play.log
327 Delete_Bgp_Peer_Configuration
328 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
329 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
331 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
332 TemplatedRequests.Delete_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
335 [Documentation] Revert the BGP configuration to the original state: without application peer
336 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
338 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
339 TemplatedRequests.Delete_Templated ${BGP_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
343 [Documentation] Initialize SetupUtils. Suite setup keyword.
344 SetupUtils.Setup_Utils_For_Setup_And_Teardown
345 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
346 Builtin.Set Suite Variable ${mininet_conn_id}
347 SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
348 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
349 SSHLibrary.Put File ${PLAY_SCRIPT} .
350 SSHKeywords.Assure_Library_Ipaddr target_dir=.
351 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/
352 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
353 ${EMPTY_ROUTES} = OperatingSystem.Get_File ${EVPN_DIR}/empty_routes/empty_routes.json
354 BuiltIn.Set_Suite_Variable ${EMPTY_ROUTES}
357 [Documentation] Suite teardown keyword
358 SSHLibrary.Close_All_Connections
359 RequestsLibrary.Delete_All_Sessions
362 [Documentation] Starts bgp peer and verifies that the peer runs.
363 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
364 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
367 [Arguments] ${totest}
368 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
369 ${data_json} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.json
370 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
371 ${announce_hex} = String.Remove_String ${announce_hex} \n
372 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
373 ${withdraw_hex} = String.Remove_String ${withdraw_hex} \n
374 ${data_path_xml} CompareStream.Run_Keyword_If_Less_Than_Fluorine String.Replace_String ${data_xml} ${PATH_ID_XML} ${EMPTY}
375 ${post_data_xml} CompareStream.Set_Variable_If_At_Least_Fluorine ${data_xml} ${data_path_xml}
376 BuiltIn.Log ${post_data_xml}
377 BuiltIn.Log ${data_json}
378 BuiltIn.Log ${announce_hex}
379 BuiltIn.Log ${withdraw_hex}
380 BgpRpcClient.play_clean
381 ${resp} = RequestsLibrary.Post_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} data=${post_data_xml} headers=${HEADERS_XML}
382 BuiltIn.Log ${resp.content}
383 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 204
384 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS_XML}
385 BuiltIn.Log ${resp.content}
386 ${aupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
387 BuiltIn.Log ${aupdate}
388 BuiltIn.Should_Be_Equal_As_Strings ${aupdate} ${announce_hex}
389 BgpRpcClient.play_clean
390 Remove_Configured_Routes
391 ${wupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
392 BuiltIn.Log ${wupdate}
393 BuiltIn.Should Be Equal As Strings ${wupdate} ${withdraw_hex}
394 [Teardown] Remove_Configured_Routes
397 [Arguments] ${totest}
398 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
399 ${data_json} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.json
400 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
401 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
402 ${data_path_json} CompareStream.Run_Keyword_If_Less_Than_Fluorine String.Replace_String ${data_json} ${PATH_ID_JSON} ${EMPTY}
403 ${data_json_exp} CompareStream.Set_Variable_If_At_Least_Fluorine ${data_json} ${data_path_json}
404 BuiltIn.Log ${data_xml}
405 BuiltIn.Log ${data_json_exp}
406 BuiltIn.Log ${announce_hex}
407 BuiltIn.Log ${withdraw_hex}
408 BgpRpcClient.play_clean
409 BgpRpcClient.play_send ${announce_hex}
410 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presence ${data_json_exp}
411 BgpRpcClient.play_send ${withdraw_hex}
412 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presence ${EMPTY_ROUTES}
413 [Teardown] Withdraw_Route_And_Verify ${withdraw_hex}
415 Verify_Test_Preconditions
416 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
417 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 404
418 Loc_Rib_Presence ${EMPTY_ROUTES}
420 Remove_Configured_Routes
421 [Documentation] Removes the route if present. First GET is for debug purposes.
422 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
424 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS}
426 BuiltIn.Return_From_Keyword_If "${rsp.status_code}" == "404"
427 ${resp} = RequestsLibrary.Delete_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
428 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 200
430 Withdraw_Route_And_Verify
431 [Arguments] ${withdraw_hex}
432 [Documentation] Sends withdraw update message from exabgp and verifies route removal from odl's rib
433 BgpRpcClient.play_send ${withdraw_hex}
434 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Loc_Rib_Presence ${EMPTY_ROUTES}
437 [Documentation] Gets received data from odl's peer
438 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS_XML}
439 BuiltIn.Log ${resp.content}
440 ${update} = BgpRpcClient.play_get
441 BuiltIn.Should_Not_Be_Equal ${update} ${Empty}
445 [Arguments] ${exp_content}
446 [Documentation] Verifies if loc-rib contains expected data
447 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
448 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content}