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.
16 Library RequestsLibrary
19 Library ../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
20 Resource ../../../libraries/BGPcliKeywords.robot
21 Resource ../../../libraries/BgpOperations.robot
22 Resource ../../../libraries/BGPSpeaker.robot
23 Resource ../../../libraries/CompareStream.robot
24 Resource ../../../libraries/SetupUtils.robot
25 Resource ../../../libraries/SSHKeywords.robot
26 Resource ../../../libraries/TemplatedRequests.robot
27 Resource ../../../variables/Variables.robot
29 Suite Setup Start_Suite
30 Suite Teardown Stop_Suite
31 Test Setup Run Keywords SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
32 ... AND Verify_Test_Preconditions
33 Test Template Odl_To_Play_Template
38 ${RIB_NAME} example-bgp-rib
39 ${BGP_DIR} ${CURDIR}/../../../variables/bgpfunctional
40 ${DEFAUTL_RPC_CFG} exa.cfg
41 ${CONFIG_SESSION} config-session
42 ${EVPN_DIR} ${CURDIR}/../../../variables/bgpfunctional/l2vpn_evpn
43 ${BGP_TOOL_LOG_LEVEL} debug
44 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
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}
53 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
55 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
56 &{mapping} = BuiltIn.Create_Dictionary BGP_RIB_OPENCONFIG=${RIB_NAME} IP=${ODL_SYSTEM_IP}
57 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.
61 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
62 &{mapping} = BuiltIn.Create_Dictionary
63 ... IP=${TOOLS_SYSTEM_IP}
64 ... HOLDTIME=${HOLDTIME}
65 ... PEER_PORT=${BGP_TOOL_PORT}
67 ... BGP_RIB_OPENCONFIG=${RIB_NAME}
69 TemplatedRequests.Put_As_Xml_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
71 [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.
73 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
74 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start Bgp Peer
75 Odl_To_Play_route_es_arb
77 Play_To_Odl_route_es_arb
78 [Template] Play_To_Odl_Template
80 Odl_To_Play_route_es_as
82 Play_To_Odl_route_es_as
83 [Template] Play_To_Odl_Template
85 Odl_To_Play_route_es_lacp
87 Play_To_Odl_route_es_lacp
88 [Template] Play_To_Odl_Template
90 Odl_To_Play_route_es_lan
92 Play_To_Odl_route_es_lan
93 [Template] Play_To_Odl_Template
95 Odl_To_Play_route_es_mac
97 Play_To_Odl_route_es_mac
98 [Template] Play_To_Odl_Template
100 Odl_To_Play_route_es_rou
102 Play_To_Odl_route_es_rou
103 [Template] Play_To_Odl_Template
105 Odl_To_Play_route_eth_arb
107 Play_To_Odl_route_eth_arb
108 [Template] Play_To_Odl_Template
110 Odl_To_Play_route_eth_as
112 Play_To_Odl_route_eth_as
113 [Template] Play_To_Odl_Template
115 Odl_To_Play_route_eth_lacp
117 Play_To_Odl_route_eth_lacp
118 [Template] Play_To_Odl_Template
120 Odl_To_Play_route_eth_lacp_extdef
121 route_eth_lacp_extdef
122 Play_To_Odl_route_eth_lacp_extdef
123 [Template] Play_To_Odl_Template
124 route_eth_lacp_extdef
125 Odl_To_Play_route_eth_lacp_extesilab
126 route_eth_lacp_extesilab
127 Play_To_Odl_route_eth_lacp_extesilab
128 [Template] Play_To_Odl_Template
129 route_eth_lacp_extesilab
130 Odl_To_Play_route_eth_lacp_extesr
131 route_eth_lacp_extesr
132 Play_To_Odl_route_eth_lacp_extesr
133 [Template] Play_To_Odl_Template
134 route_eth_lacp_extesr
135 Odl_To_Play_route_eth_lacp_extl2
137 Play_To_Odl_route_eth_lacp_extl2
138 [Template] Play_To_Odl_Template
140 Odl_To_Play_route_eth_lacp_extmac
141 route_eth_lacp_extmac
142 Play_To_Odl_route_eth_lacp_extmac
143 [Template] Play_To_Odl_Template
144 route_eth_lacp_extmac
145 Odl_To_Play_route_eth_lan
147 Play_To_Odl_route_eth_lan
148 [Template] Play_To_Odl_Template
150 Odl_To_Play_route_eth_mac
152 Play_To_Odl_route_eth_mac
153 [Template] Play_To_Odl_Template
155 Odl_To_Play_route_eth_rou
157 Play_To_Odl_route_eth_rou
158 [Template] Play_To_Odl_Template
160 Odl_To_Play_route_inc_arb
162 Play_To_Odl_route_inc_arb
163 [Template] Play_To_Odl_Template
165 Odl_To_Play_route_inc_as
167 Play_To_Odl_route_inc_as
168 [Template] Play_To_Odl_Template
170 Odl_To_Play_route_inc_lacp
172 Play_To_Odl_route_inc_lacp
173 [Template] Play_To_Odl_Template
175 Odl_To_Play_route_inc_lan
177 Play_To_Odl_route_inc_lan
178 [Template] Play_To_Odl_Template
180 Odl_To_Play_route_inc_mac
182 Play_To_Odl_route_inc_mac
183 [Template] Play_To_Odl_Template
185 Odl_To_Play_route_inc_rou
187 Play_To_Odl_route_inc_rou
188 [Template] Play_To_Odl_Template
190 Odl_To_Play_route_mac_arb
192 Play_To_Odl_route_mac_arb
193 [Template] Play_To_Odl_Template
195 Odl_To_Play_route_mac_as
197 Play_To_Odl_route_mac_as
198 [Template] Play_To_Odl_Template
200 Odl_To_Play_route_mac_lacp
202 Play_To_Odl_route_mac_lacp
203 [Template] Play_To_Odl_Template
205 Odl_To_Play_route_mac_lan
207 Play_To_Odl_route_mac_lan
208 [Template] Play_To_Odl_Template
210 Odl_To_Play_route_mac_mac
212 Play_To_Odl_route_mac_mac
213 [Template] Play_To_Odl_Template
215 Odl_To_Play_route_mac_rou
217 Play_To_Odl_route_mac_rou
218 [Template] Play_To_Odl_Template
220 Odl_To_Play_pmsi_rsvp_te_p2mp_lsp
222 Odl_To_Play_Template pmsi_rsvp_te_p2mp_lsp
223 Play_To_Odl_pmsi_rsvp_te_p2mp_lsp
225 Play_To_Odl_Template pmsi_rsvp_te_p2mp_lsp
226 Odl_To_Play_pmsi_mldp_p2mp_lsp
228 Play_To_Odl_pmsi_mldp_p2mp_lsp
229 [Template] Play_To_Odl_Template
231 Odl_To_Play_pmsi_pim_ssm_tree
233 Play_To_Odl_pmsi_pim_ssm_tree
234 [Template] Play_To_Odl_Template
236 Odl_To_Play_pmsi_pim_sm_tree
238 Play_To_Odl_pmsi_pim_sm_tree
239 [Template] Play_To_Odl_Template
241 Odl_To_Play_pmsi_bidir_pim_tree
243 Play_To_Odl_pmsi_bidir_pim_tree
244 [Template] Play_To_Odl_Template
246 Odl_To_Play_pmsi_ingress_replication
247 pmsi_ingress_replication
248 Play_To_Odl_pmsi_ingress_replication
249 [Template] Play_To_Odl_Template
250 pmsi_ingress_replication
251 Odl_To_Play_pmsi_mldp_mp2mp_lsp
253 Play_To_Odl_pmsi_mldp_mp2mp_lsp
254 [Template] Play_To_Odl_Template
256 Kill_Talking_BGP_Speaker
257 [Documentation] Abort the Python speaker
259 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
260 BGPSpeaker.Kill_BGP_Speaker
261 BGPcliKeywords.Store_File_To_Workspace play.py.out evpn_play.log
262 Delete_Bgp_Peer_Configuration
263 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
265 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
266 &{mapping} = BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
267 TemplatedRequests.Delete_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
269 [Documentation] Revert the BGP configuration to the original state: without application peer
271 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
272 &{mapping} = BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
273 TemplatedRequests.Delete_Templated ${BGP_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
278 [Documentation] Initialize SetupUtils. Suite setup keyword.
279 SetupUtils.Setup_Utils_For_Setup_And_Teardown
280 ${mininet_conn_id} = SSHLibrary.Open Connection
281 ... ${TOOLS_SYSTEM_IP}
282 ... prompt=${DEFAULT_LINUX_PROMPT}
284 Builtin.Set Suite Variable ${mininet_conn_id}
285 SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
286 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
287 SSHLibrary.Put File ${PLAY_SCRIPT} .
288 SSHKeywords.Assure_Library_Ipaddr target_dir=.
289 BuiltIn.Set_Suite_Variable
291 ... /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
292 BuiltIn.Set_Suite_Variable
294 ... /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
295 BuiltIn.Set_Suite_Variable
296 ... ${EVPN_FAMILY_LOC_RIB}
297 ... /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
298 ${evpn_routes_line} = CompareStream.Set_Variable_If_At_Least_Neon
299 ... ${NEW_EVPN_ROUTES_LINE}
300 ... ${OLD_EVPN_ROUTES_LINE}
301 &{mapping} = BuiltIn.Create_Dictionary EVPN_ROUTES=${evpn_routes_line}
302 ${EMPTY_ROUTES} = TemplatedRequests.Resolve_Text_From_Template_File
303 ... ${EVPN_DIR}/empty_routes
304 ... empty_routes.json
306 BuiltIn.Set_Suite_Variable ${EMPTY_ROUTES}
309 [Documentation] Suite teardown keyword
310 SSHLibrary.Close_All_Connections
311 RequestsLibrary.Delete_All_Sessions
314 [Documentation] Starts bgp peer and verifies that the peer runs.
315 BGPSpeaker.Start_BGP_Speaker
316 ... --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
317 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
320 [Arguments] ${totest}
321 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
322 ${data_json} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.json
323 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
324 ${announce_hex} = String.Remove_String ${announce_hex} \n
325 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
326 ${withdraw_hex} = String.Remove_String ${withdraw_hex} \n
327 BuiltIn.Log ${data_xml}
328 BuiltIn.Log ${data_json}
329 BuiltIn.Log ${announce_hex}
330 BuiltIn.Log ${withdraw_hex}
331 BgpRpcClient.play_clean
332 ${resp} = RequestsLibrary.Post_Request
333 ... ${CONFIG_SESSION}
336 ... headers=${HEADERS_XML}
337 BuiltIn.Log ${resp.content}
338 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 201
339 ${resp} = RequestsLibrary.Get_Request
340 ... ${CONFIG_SESSION}
341 ... ${EVPN_CONF_URL}?content=config
342 ... headers=${HEADERS_XML}
343 BuiltIn.Log ${resp.content}
344 ${aupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
345 BuiltIn.Log ${aupdate}
346 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${aupdate} ${announce_hex}
347 BgpRpcClient.play_clean
348 Remove_Configured_Routes
349 ${wupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
350 BuiltIn.Log ${wupdate}
351 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${wupdate} ${withdraw_hex}
352 [Teardown] Remove_Configured_Routes
355 [Arguments] ${totest}
356 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
357 ${AS_PATH} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH}
358 &{mapping} = BuiltIn.Create_Dictionary AS_PATH=${AS_PATH}
359 ${data_json} = TemplatedRequests.Resolve_Text_From_Template_File
360 ... ${EVPN_DIR}/${totest}
363 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
364 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
365 BuiltIn.Log ${data_xml}
366 BuiltIn.Log ${data_json}
367 BuiltIn.Log ${announce_hex}
368 BuiltIn.Log ${withdraw_hex}
369 BgpRpcClient.play_clean
370 BgpRpcClient.play_send ${announce_hex}
371 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presence ${data_json}
372 BgpRpcClient.play_send ${withdraw_hex}
373 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Verify_Test_Preconditions
374 [Teardown] Withdraw_Route_And_Verify ${withdraw_hex}
376 Verify_Test_Preconditions
377 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}?content=config
378 BuiltIn.Should_Contain ${DELETED_STATUS_CODES} ${resp.status_code}
379 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_FAMILY_LOC_RIB} headers=${HEADERS}
380 TemplatedRequests.Normalize_Jsons_And_Compare ${EMPTY_ROUTES} ${rsp.content}
382 Remove_Configured_Routes
383 [Documentation] Removes the route if present. First GET is for debug purposes.
384 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
386 ${rsp} = RequestsLibrary.Get_Request
387 ... ${CONFIG_SESSION}
388 ... ${EVPN_CONF_URL}?content=config
389 ... headers=${HEADERS}
391 IF ${rsp.status_code} in ${DELETED_STATUS_CODES} RETURN
392 ${resp} = RequestsLibrary.Delete_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
393 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 204
395 Withdraw_Route_And_Verify
396 [Documentation] Sends withdraw update message from exabgp and verifies route removal from odl's rib
397 [Arguments] ${withdraw_hex}
398 BgpRpcClient.play_send ${withdraw_hex}
399 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Verify_Test_Preconditions
402 [Documentation] Gets received data from odl's peer
403 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS_XML}
404 BuiltIn.Log ${resp.content}
405 ${update} = BgpRpcClient.play_get
406 BuiltIn.Should_Not_Be_Equal ${update} ${Empty}
410 [Documentation] Verifies if loc-rib contains expected data
411 [Arguments] ${exp_content}
412 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
413 BuiltIn.Log_Many ${exp_content} ${rsp.content}
414 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content}