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 Library RequestsLibrary
22 Resource ${CURDIR}/../../../variables/Variables.robot
23 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
24 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
25 Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
26 Resource ${CURDIR}/../../../libraries/BGPcliKeywords.robot
27 Resource ${CURDIR}/../../../libraries/BGPSpeaker.robot
28 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
29 Resource ${CURDIR}/../../../libraries/CompareStream.robot
33 ${DEVICE_NAME} controller-config
34 ${BGP_PEER_NAME} example-bgp-peer
35 ${RIB_INSTANCE} example-bgp-rib
36 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
37 ${APP_PEER_NAME} example-bgp-peer-app
38 ${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
39 ${DEFAUTL_RPC_CFG} exa.cfg
40 ${CONFIG_SESSION} config-session
41 ${EVPN_VARIABLES_DIR} ${CURDIR}/../../../variables/bgpfunctional/l2vpn_evpn
42 ${BGP_TOOL_LOG_LEVEL} debug
43 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
44 ${SS} ${SPACE}${SPACE}${SPACE}${SPACE}
45 ${PATH_ID_JSON} ${SS}${SS}"path-id": 0,${\n}
46 ${PATH_ID_XML} ${SS}<path-id>0</path-id>${\n}
50 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
51 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
52 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME} RIB_INSTANCE_NAME=${RIB_INSTANCE} APP_PEER_ID=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
53 ... IP=${ODL_SYSTEM_IP}
54 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
56 Reconfigure_ODL_To_Accept_Connection
57 [Documentation] Configures BGP peer module with initiate-connection set to false.
58 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
59 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
60 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} PASSIVE_MODE=true
61 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
64 [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.
65 [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
69 [Template] Odl_To_Play_Template
72 Play_To_Odl_route_es_arb
73 [Template] Play_To_Odl_Template
76 Odl_To_Play_route_es_as
77 [Template] Odl_To_Play_Template
80 Play_To_Odl_route_es_as
81 [Template] Play_To_Odl_Template
84 Odl_To_Play_route_es_lacp
85 [Template] Odl_To_Play_Template
88 Play_To_Odl_route_es_lacp
89 [Template] Play_To_Odl_Template
92 Odl_To_Play_route_es_lan
93 [Template] Odl_To_Play_Template
96 Play_To_Odl_route_es_lan
97 [Template] Play_To_Odl_Template
100 Odl_To_Play_route_es_mac
101 [Template] Odl_To_Play_Template
104 Play_To_Odl_route_es_mac
105 [Template] Play_To_Odl_Template
108 Odl_To_Play_route_es_rou
109 [Template] Odl_To_Play_Template
112 Play_To_Odl_route_es_rou
113 [Template] Play_To_Odl_Template
116 Odl_To_Play_route_eth_arb
117 [Template] Odl_To_Play_Template
120 Play_To_Odl_route_eth_arb
121 [Template] Play_To_Odl_Template
124 Odl_To_Play_route_eth_as
125 [Template] Odl_To_Play_Template
128 Play_To_Odl_route_eth_as
129 [Template] Play_To_Odl_Template
132 Odl_To_Play_route_eth_lacp
133 [Template] Odl_To_Play_Template
136 Play_To_Odl_route_eth_lacp
137 [Template] Play_To_Odl_Template
140 Odl_To_Play_route_eth_lacp_extdef
141 [Template] Odl_To_Play_Template
142 route_eth_lacp_extdef
144 Play_To_Odl_route_eth_lacp_extdef
145 [Template] Play_To_Odl_Template
146 route_eth_lacp_extdef
148 Odl_To_Play_route_eth_lacp_extesilab
149 [Template] Odl_To_Play_Template
150 route_eth_lacp_extesilab
152 Play_To_Odl_route_eth_lacp_extesilab
153 [Template] Play_To_Odl_Template
154 route_eth_lacp_extesilab
156 Odl_To_Play_route_eth_lacp_extesr
157 [Template] Odl_To_Play_Template
158 route_eth_lacp_extesr
160 Play_To_Odl_route_eth_lacp_extesr
161 [Template] Play_To_Odl_Template
162 route_eth_lacp_extesr
164 Odl_To_Play_route_eth_lacp_extl2
165 [Template] Odl_To_Play_Template
168 Play_To_Odl_route_eth_lacp_extl2
169 [Template] Play_To_Odl_Template
172 Odl_To_Play_route_eth_lacp_extmac
173 [Template] Odl_To_Play_Template
174 route_eth_lacp_extmac
176 Play_To_Odl_route_eth_lacp_extmac
177 [Template] Play_To_Odl_Template
178 route_eth_lacp_extmac
180 Odl_To_Play_route_eth_lan
181 [Template] Odl_To_Play_Template
184 Play_To_Odl_route_eth_lan
185 [Template] Play_To_Odl_Template
188 Odl_To_Play_route_eth_mac
189 [Template] Odl_To_Play_Template
192 Play_To_Odl_route_eth_mac
193 [Template] Play_To_Odl_Template
196 Odl_To_Play_route_eth_rou
197 [Template] Odl_To_Play_Template
200 Play_To_Odl_route_eth_rou
201 [Template] Play_To_Odl_Template
204 Odl_To_Play_route_inc_arb
205 [Template] Odl_To_Play_Template
208 Play_To_Odl_route_inc_arb
209 [Template] Play_To_Odl_Template
212 Odl_To_Play_route_inc_as
213 [Template] Odl_To_Play_Template
216 Play_To_Odl_route_inc_as
217 [Template] Play_To_Odl_Template
220 Odl_To_Play_route_inc_lacp
221 [Template] Odl_To_Play_Template
224 Play_To_Odl_route_inc_lacp
225 [Template] Play_To_Odl_Template
228 Odl_To_Play_route_inc_lan
229 [Template] Odl_To_Play_Template
232 Play_To_Odl_route_inc_lan
233 [Template] Play_To_Odl_Template
236 Odl_To_Play_route_inc_mac
237 [Template] Odl_To_Play_Template
240 Play_To_Odl_route_inc_mac
241 [Template] Play_To_Odl_Template
244 Odl_To_Play_route_inc_rou
245 [Template] Odl_To_Play_Template
248 Play_To_Odl_route_inc_rou
249 [Template] Play_To_Odl_Template
252 Odl_To_Play_route_mac_arb
253 [Template] Odl_To_Play_Template
256 Play_To_Odl_route_mac_arb
257 [Template] Play_To_Odl_Template
260 Odl_To_Play_route_mac_as
261 [Template] Odl_To_Play_Template
264 Play_To_Odl_route_mac_as
265 [Template] Play_To_Odl_Template
268 Odl_To_Play_route_mac_lacp
269 [Template] Odl_To_Play_Template
272 Play_To_Odl_route_mac_lacp
273 [Template] Play_To_Odl_Template
276 Odl_To_Play_route_mac_lan
277 [Template] Odl_To_Play_Template
280 Play_To_Odl_route_mac_lan
281 [Template] Play_To_Odl_Template
284 Odl_To_Play_route_mac_mac
285 [Template] Odl_To_Play_Template
288 Play_To_Odl_route_mac_mac
289 [Template] Play_To_Odl_Template
292 Odl_To_Play_route_mac_rou
293 [Template] Odl_To_Play_Template
296 Play_To_Odl_route_mac_rou
297 [Template] Play_To_Odl_Template
300 Kill_Talking_BGP_Speaker
301 [Documentation] Abort the Python speaker
302 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
303 BGPSpeaker.Kill_BGP_Speaker
305 Delete_Bgp_Peer_Configuration
306 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
307 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
308 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
309 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
312 [Documentation] Revert the BGP configuration to the original state: without application peer
313 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
314 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME} IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
315 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
319 [Documentation] Initialize SetupUtils. Suite setup keyword.
320 SetupUtils.Setup_Utils_For_Setup_And_Teardown
321 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
322 Builtin.Set Suite Variable ${mininet_conn_id}
323 SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
324 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
325 SSHLibrary.Put File ${PLAY_SCRIPT} .
326 SSHKeywords.Assure_Library_Ipaddr target_dir=.
327 ${app_rib}= Set Variable ${ODL_SYSTEM_IP}
328 ${bgp_rib}= Set Variable example-bgp-rib
329 BuiltIn.Set_Suite_Variable ${EVPN_CONF_URL} /restconf/config/bgp-rib:application-rib/${app_rib}/tables/odl-bgp-evpn:l2vpn-address-family/odl-bgp-evpn:evpn-subsequent-address-family/odl-bgp-evpn:evpn-routes/
330 BuiltIn.Set_Suite_Variable ${EVPN_LOC_RIB_OPER_URL} /restconf/operational/bgp-rib:bgp-rib/rib/${bgp_rib}/loc-rib/tables/odl-bgp-evpn:l2vpn-address-family/odl-bgp-evpn:evpn-subsequent-address-family/odl-bgp-evpn:evpn-routes
333 [Documentation] Suite teardown keyword
334 SSHLibrary.Close_All_Connections
335 RequestsLibrary.Delete_All_Sessions
338 [Documentation] Starts bgp peer and verifies that the peer runs.
339 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
340 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
343 [Arguments] ${totest}
344 ${data_xml}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.xml
345 ${data_json}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.json
346 ${announce_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/announce_${totest}.hex
347 ${withdraw_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/withdraw_${totest}.hex
348 ${data_path_xml} CompareStream.Run_Keyword_If_Less_Than_Fluorine String.Replace_String ${data_xml} ${PATH_ID_XML} ${EMPTY}
349 ${post_data_xml} CompareStream.Set_Variable_If_At_Least_Fluorine ${data_xml} ${data_path_xml}
350 BuiltIn.Log ${post_data_xml}
351 BuiltIn.Log ${data_json}
352 BuiltIn.Log ${announce_hex}
353 BuiltIn.Log ${withdraw_hex}
354 BgpRpcClient.play_clean
355 ${resp}= RequestsLibrary.Post_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} data=${post_data_xml} headers=${HEADERS_XML}
356 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 204
357 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS_XML}
358 BuiltIn.Log ${resp.content}
359 ${aupdate}= BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
360 BuiltIn.Log ${aupdate}
361 BuiltIn.Should_Be_Equal_As_Strings ${aupdate} ${announce_hex}
362 BgpRpcClient.play_clean
363 Remove_Configured_Routes
364 ${wupdate}= BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
365 BuiltIn.Log ${wupdate}
366 BuiltIn.Should Be Equal As Strings ${wupdate} ${withdraw_hex}
367 [Teardown] Remove_Configured_Routes
370 [Arguments] ${totest}
371 ${data_xml}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.xml
372 ${data_json}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.json
373 ${announce_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/announce_${totest}.hex
374 ${withdraw_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/withdraw_${totest}.hex
375 ${empty_routes}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/empty_routes.json
376 ${data_path_json} CompareStream.Run_Keyword_If_Less_Than_Fluorine String.Replace_String ${data_json} ${PATH_ID_JSON} ${EMPTY}
377 ${data_json_exp} CompareStream.Set_Variable_If_At_Least_Fluorine ${data_json} ${data_path_json}
378 BuiltIn.Set_Suite_Variable ${withdraw_hex}
379 BuiltIn.Set_Suite_Variable ${empty_routes}
380 BuiltIn.Log ${data_xml}
381 BuiltIn.Log ${data_json_exp}
382 BuiltIn.Log ${announce_hex}
383 BuiltIn.Log ${withdraw_hex}
384 BuiltIn.Log ${empty_routes}
385 BgpRpcClient.play_clean
386 BgpRpcClient.play_send ${announce_hex}
387 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presnece ${data_json_exp}
388 BgpRpcClient.play_send ${withdraw_hex}
389 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presnece ${empty_routes}
390 [Teardown] Withdraw_Route_And_Verify ${withdraw_hex}
392 Verify_Test_Preconditions
393 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
394 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 404
395 ${empty_routes}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/empty_routes.json
396 Loc_Rib_Presnece ${empty_routes}
398 Remove_Configured_Routes
399 [Documentation] Removes the route if present. First GET is for debug purposes.
400 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB_OPER_URL} headers=${HEADERS}
402 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS}
404 BuiltIn.Return_From_Keyword_If "${rsp.status_code}"=="404"
405 ${resp}= RequestsLibrary.Delete_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
406 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 200
408 Withdraw_Route_And_Verify
409 [Arguments] ${withdraw_hex}
410 [Documentation] Sends withdraw update message from exabgp and verifies route removal from odl's rib
411 BgpRpcClient.play_send ${withdraw_hex}
412 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Loc Rib Presnece ${empty_routes}
415 [Documentation] Gets received data from odl's peer
416 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB_OPER_URL} headers=${HEADERS_XML}
417 BuiltIn.Log ${resp.content}
418 ${update}= BgpRpcClient.play_get
419 BuiltIn.Should_Not_Be_Equal ${update} ${Empty}
423 [Arguments] ${exp_content}
424 [Documentation] Verifies if loc-rib contains expected data
425 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB_OPER_URL} headers=${HEADERS}
426 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content}