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 ${SS} ${SPACE}${SPACE}${SPACE}${SPACE}
46 ${PATH_ID_JSON} ${SS}${SS}"path-id": 0,${\n}
47 ${PATH_ID_XML} ${SS}<path-id>0</path-id>${\n}
48 ${OLD_EVPN_ROUTES_LINE} \n"odl-bgp-evpn:evpn-routes": {},
49 ${NEW_EVPN_ROUTES_LINE} ${EMPTY}
50 ${OLD_AS_PATH} ,\n"as-path": {}
51 ${NEW_AS_PATH} ${EMPTY}
56 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
58 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
59 &{mapping} = BuiltIn.Create_Dictionary BGP_RIB_OPENCONFIG=${RIB_NAME} IP=${ODL_SYSTEM_IP}
60 TemplatedRequests.Put_As_Xml_Templated ${BGP_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
61 Reconfigure_ODL_To_Accept_Connection
62 [Documentation] Configures BGP peer module with initiate-connection set to false.
64 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
65 &{mapping} = BuiltIn.Create_Dictionary
66 ... IP=${TOOLS_SYSTEM_IP}
67 ... HOLDTIME=${HOLDTIME}
68 ... PEER_PORT=${BGP_TOOL_PORT}
70 ... BGP_RIB_OPENCONFIG=${RIB_NAME}
72 TemplatedRequests.Put_As_Xml_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
74 [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.
76 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
77 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start Bgp Peer
78 Odl_To_Play_route_es_arb
80 Play_To_Odl_route_es_arb
81 [Template] Play_To_Odl_Template
83 Odl_To_Play_route_es_as
85 Play_To_Odl_route_es_as
86 [Template] Play_To_Odl_Template
88 Odl_To_Play_route_es_lacp
90 Play_To_Odl_route_es_lacp
91 [Template] Play_To_Odl_Template
93 Odl_To_Play_route_es_lan
95 Play_To_Odl_route_es_lan
96 [Template] Play_To_Odl_Template
98 Odl_To_Play_route_es_mac
100 Play_To_Odl_route_es_mac
101 [Template] Play_To_Odl_Template
103 Odl_To_Play_route_es_rou
105 Play_To_Odl_route_es_rou
106 [Template] Play_To_Odl_Template
108 Odl_To_Play_route_eth_arb
110 Play_To_Odl_route_eth_arb
111 [Template] Play_To_Odl_Template
113 Odl_To_Play_route_eth_as
115 Play_To_Odl_route_eth_as
116 [Template] Play_To_Odl_Template
118 Odl_To_Play_route_eth_lacp
120 Play_To_Odl_route_eth_lacp
121 [Template] Play_To_Odl_Template
123 Odl_To_Play_route_eth_lacp_extdef
124 route_eth_lacp_extdef
125 Play_To_Odl_route_eth_lacp_extdef
126 [Template] Play_To_Odl_Template
127 route_eth_lacp_extdef
128 Odl_To_Play_route_eth_lacp_extesilab
129 route_eth_lacp_extesilab
130 Play_To_Odl_route_eth_lacp_extesilab
131 [Template] Play_To_Odl_Template
132 route_eth_lacp_extesilab
133 Odl_To_Play_route_eth_lacp_extesr
134 route_eth_lacp_extesr
135 Play_To_Odl_route_eth_lacp_extesr
136 [Template] Play_To_Odl_Template
137 route_eth_lacp_extesr
138 Odl_To_Play_route_eth_lacp_extl2
140 Play_To_Odl_route_eth_lacp_extl2
141 [Template] Play_To_Odl_Template
143 Odl_To_Play_route_eth_lacp_extmac
144 route_eth_lacp_extmac
145 Play_To_Odl_route_eth_lacp_extmac
146 [Template] Play_To_Odl_Template
147 route_eth_lacp_extmac
148 Odl_To_Play_route_eth_lan
150 Play_To_Odl_route_eth_lan
151 [Template] Play_To_Odl_Template
153 Odl_To_Play_route_eth_mac
155 Play_To_Odl_route_eth_mac
156 [Template] Play_To_Odl_Template
158 Odl_To_Play_route_eth_rou
160 Play_To_Odl_route_eth_rou
161 [Template] Play_To_Odl_Template
163 Odl_To_Play_route_inc_arb
165 Play_To_Odl_route_inc_arb
166 [Template] Play_To_Odl_Template
168 Odl_To_Play_route_inc_as
170 Play_To_Odl_route_inc_as
171 [Template] Play_To_Odl_Template
173 Odl_To_Play_route_inc_lacp
175 Play_To_Odl_route_inc_lacp
176 [Template] Play_To_Odl_Template
178 Odl_To_Play_route_inc_lan
180 Play_To_Odl_route_inc_lan
181 [Template] Play_To_Odl_Template
183 Odl_To_Play_route_inc_mac
185 Play_To_Odl_route_inc_mac
186 [Template] Play_To_Odl_Template
188 Odl_To_Play_route_inc_rou
190 Play_To_Odl_route_inc_rou
191 [Template] Play_To_Odl_Template
193 Odl_To_Play_route_mac_arb
195 Play_To_Odl_route_mac_arb
196 [Template] Play_To_Odl_Template
198 Odl_To_Play_route_mac_as
200 Play_To_Odl_route_mac_as
201 [Template] Play_To_Odl_Template
203 Odl_To_Play_route_mac_lacp
205 Play_To_Odl_route_mac_lacp
206 [Template] Play_To_Odl_Template
208 Odl_To_Play_route_mac_lan
210 Play_To_Odl_route_mac_lan
211 [Template] Play_To_Odl_Template
213 Odl_To_Play_route_mac_mac
215 Play_To_Odl_route_mac_mac
216 [Template] Play_To_Odl_Template
218 Odl_To_Play_route_mac_rou
220 Play_To_Odl_route_mac_rou
221 [Template] Play_To_Odl_Template
223 Odl_To_Play_pmsi_rsvp_te_p2mp_lsp
225 CompareStream.Run_Keyword_If_At_Least_Fluorine Odl_To_Play_Template pmsi_rsvp_te_p2mp_lsp
226 Play_To_Odl_pmsi_rsvp_te_p2mp_lsp
228 CompareStream.Run_Keyword_If_At_Least_Fluorine Play_To_Odl_Template pmsi_rsvp_te_p2mp_lsp
229 Odl_To_Play_pmsi_mldp_p2mp_lsp
231 Play_To_Odl_pmsi_mldp_p2mp_lsp
232 [Template] Play_To_Odl_Template
234 Odl_To_Play_pmsi_pim_ssm_tree
236 Play_To_Odl_pmsi_pim_ssm_tree
237 [Template] Play_To_Odl_Template
239 Odl_To_Play_pmsi_pim_sm_tree
241 Play_To_Odl_pmsi_pim_sm_tree
242 [Template] Play_To_Odl_Template
244 Odl_To_Play_pmsi_bidir_pim_tree
246 Play_To_Odl_pmsi_bidir_pim_tree
247 [Template] Play_To_Odl_Template
249 Odl_To_Play_pmsi_ingress_replication
250 pmsi_ingress_replication
251 Play_To_Odl_pmsi_ingress_replication
252 [Template] Play_To_Odl_Template
253 pmsi_ingress_replication
254 Odl_To_Play_pmsi_mldp_mp2mp_lsp
256 Play_To_Odl_pmsi_mldp_mp2mp_lsp
257 [Template] Play_To_Odl_Template
259 Kill_Talking_BGP_Speaker
260 [Documentation] Abort the Python speaker
262 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
263 BGPSpeaker.Kill_BGP_Speaker
264 BGPcliKeywords.Store_File_To_Workspace play.py.out evpn_play.log
265 Delete_Bgp_Peer_Configuration
266 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
268 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
269 &{mapping} = BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
270 TemplatedRequests.Delete_Templated ${BGP_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
272 [Documentation] Revert the BGP configuration to the original state: without application peer
274 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
275 &{mapping} = BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_NAME}
276 TemplatedRequests.Delete_Templated ${BGP_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
281 [Documentation] Initialize SetupUtils. Suite setup keyword.
282 SetupUtils.Setup_Utils_For_Setup_And_Teardown
283 ${mininet_conn_id} = SSHLibrary.Open Connection
284 ... ${TOOLS_SYSTEM_IP}
285 ... prompt=${DEFAULT_LINUX_PROMPT}
287 Builtin.Set Suite Variable ${mininet_conn_id}
288 SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
289 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
290 SSHLibrary.Put File ${PLAY_SCRIPT} .
291 SSHKeywords.Assure_Library_Ipaddr target_dir=.
292 BuiltIn.Set_Suite_Variable
294 ... /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
295 BuiltIn.Set_Suite_Variable
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/odl-bgp-evpn:evpn-routes?content=nonconfig
298 BuiltIn.Set_Suite_Variable
299 ... ${EVPN_FAMILY_LOC_RIB}
300 ... /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
301 ${evpn_routes_line} = CompareStream.Set_Variable_If_At_Least_Neon
302 ... ${NEW_EVPN_ROUTES_LINE}
303 ... ${OLD_EVPN_ROUTES_LINE}
304 &{mapping} = BuiltIn.Create_Dictionary EVPN_ROUTES=${evpn_routes_line}
305 ${EMPTY_ROUTES} = TemplatedRequests.Resolve_Text_From_Template_File
306 ... ${EVPN_DIR}/empty_routes
307 ... empty_routes.json
309 BuiltIn.Set_Suite_Variable ${EMPTY_ROUTES}
312 [Documentation] Suite teardown keyword
313 SSHLibrary.Close_All_Connections
314 RequestsLibrary.Delete_All_Sessions
317 [Documentation] Starts bgp peer and verifies that the peer runs.
318 BGPSpeaker.Start_BGP_Speaker
319 ... --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
320 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
323 [Arguments] ${totest}
324 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
325 ${data_json} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.json
326 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
327 ${announce_hex} = String.Remove_String ${announce_hex} \n
328 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
329 ${withdraw_hex} = String.Remove_String ${withdraw_hex} \n
330 ${data_path_xml} = CompareStream.Run_Keyword_If_Less_Than_Fluorine
331 ... String.Replace_String
335 ${post_data_xml} = CompareStream.Set_Variable_If_At_Least_Fluorine ${data_xml} ${data_path_xml}
336 BuiltIn.Log ${post_data_xml}
337 BuiltIn.Log ${data_json}
338 BuiltIn.Log ${announce_hex}
339 BuiltIn.Log ${withdraw_hex}
340 BgpRpcClient.play_clean
341 ${resp} = RequestsLibrary.Post_Request
342 ... ${CONFIG_SESSION}
344 ... data=${post_data_xml}
345 ... headers=${HEADERS_XML}
346 BuiltIn.Log ${resp.content}
347 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 201
348 ${resp} = RequestsLibrary.Get_Request
349 ... ${CONFIG_SESSION}
350 ... ${EVPN_CONF_URL}?content=config
351 ... headers=${HEADERS_XML}
352 BuiltIn.Log ${resp.content}
353 ${aupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
354 BuiltIn.Log ${aupdate}
355 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${aupdate} ${announce_hex}
356 BgpRpcClient.play_clean
357 Remove_Configured_Routes
358 ${wupdate} = BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
359 BuiltIn.Log ${wupdate}
360 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${wupdate} ${withdraw_hex}
361 [Teardown] Remove_Configured_Routes
364 [Arguments] ${totest}
365 ${data_xml} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/${totest}.xml
366 ${AS_PATH} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH}
367 &{mapping} = BuiltIn.Create_Dictionary AS_PATH=${AS_PATH}
368 ${data_json} = TemplatedRequests.Resolve_Text_From_Template_File
369 ... ${EVPN_DIR}/${totest}
372 ${announce_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/announce_${totest}.hex
373 ${withdraw_hex} = OperatingSystem.Get_File ${EVPN_DIR}/${totest}/withdraw_${totest}.hex
374 ${data_path_json} = CompareStream.Run_Keyword_If_Less_Than_Fluorine
375 ... String.Replace_String
379 ${data_json_exp} = CompareStream.Set_Variable_If_At_Least_Fluorine ${data_json} ${data_path_json}
380 BuiltIn.Log ${data_xml}
381 BuiltIn.Log ${data_json_exp}
382 BuiltIn.Log ${announce_hex}
383 BuiltIn.Log ${withdraw_hex}
384 BgpRpcClient.play_clean
385 BgpRpcClient.play_send ${announce_hex}
386 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presence ${data_json_exp}
387 BgpRpcClient.play_send ${withdraw_hex}
388 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Verify_Test_Preconditions
389 [Teardown] Withdraw_Route_And_Verify ${withdraw_hex}
391 Verify_Test_Preconditions
392 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}?content=config
393 BuiltIn.Should_Contain ${DELETED_STATUS_CODES} ${resp.status_code}
394 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_FAMILY_LOC_RIB} headers=${HEADERS}
395 TemplatedRequests.Normalize_Jsons_And_Compare ${EMPTY_ROUTES} ${rsp.content}
397 Remove_Configured_Routes
398 [Documentation] Removes the route if present. First GET is for debug purposes.
399 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
401 ${rsp} = RequestsLibrary.Get_Request
402 ... ${CONFIG_SESSION}
403 ... ${EVPN_CONF_URL}?content=config
404 ... headers=${HEADERS}
406 IF ${rsp.status_code} in ${DELETED_STATUS_CODES} RETURN
407 ${resp} = RequestsLibrary.Delete_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
408 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 204
410 Withdraw_Route_And_Verify
411 [Documentation] Sends withdraw update message from exabgp and verifies route removal from odl's rib
412 [Arguments] ${withdraw_hex}
413 BgpRpcClient.play_send ${withdraw_hex}
414 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Verify_Test_Preconditions
417 [Documentation] Gets received data from odl's peer
418 ${resp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS_XML}
419 BuiltIn.Log ${resp.content}
420 ${update} = BgpRpcClient.play_get
421 BuiltIn.Should_Not_Be_Equal ${update} ${Empty}
425 [Documentation] Verifies if loc-rib contains expected data
426 [Arguments] ${exp_content}
427 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB} headers=${HEADERS}
428 BuiltIn.Log_Many ${exp_content} ${rsp.content}
429 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content}