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
21 Variables ${CURDIR}/../../../variables/Variables.py
22 Resource ${CURDIR}/../../../libraries/Utils.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
32 ${DEVICE_NAME} controller-config
33 ${BGP_PEER_NAME} example-bgp-peer
34 ${RIB_INSTANCE} example-bgp-rib
35 ${APP_PEER_NAME} example-bgp-peer-app
36 ${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
37 ${DEFAUTL_RPC_CFG} exa.cfg
38 ${CONFIG_SESSION} config-session
39 ${EVPN_VARIABLES_DIR} ${CURDIR}/../../../variables/bgpfunctional/l2vpn_evpn
40 ${BGP_TOOL_LOG_LEVEL} debug
41 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
42 ${EVPN_CONF_URL} /restconf/config/bgp-rib:application-rib/example-app-rib/tables/odl-bgp-evpn:l2vpn-address-family/odl-bgp-evpn:evpn-subsequent-address-family/odl-bgp-evpn:evpn-routes/
43 ${EVPN_RIB_OPER_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/odl-bgp-evpn:l2vpn-address-family/odl-bgp-evpn:evpn-subsequent-address-family/odl-bgp-evpn:evpn-routes
44 ${LOC_RIB_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/odl-bgp-evpn:l2vpn-address-family/odl-bgp-evpn:evpn-subsequent-address-family/odl-bgp-evpn:evpn-routes
48 [Documentation] Configures bgp application peer
49 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
50 &{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}
51 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/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
56 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
57 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE}
58 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
61 [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.
62 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
63 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start Bgp Peer
65 Odl_To_Play_route_es_arb
66 [Template] Odl_To_Play_Template
69 Play_To_Odl_route_es_arb
70 [Template] Play_To_Odl_Template
73 Odl_To_Play_route_es_as
74 [Template] Odl_To_Play_Template
77 Play_To_Odl_route_es_as
78 [Template] Play_To_Odl_Template
81 Odl_To_Play_route_es_lacp
82 [Template] Odl_To_Play_Template
85 Play_To_Odl_route_es_lacp
86 [Template] Play_To_Odl_Template
89 Odl_To_Play_route_es_lan
90 [Template] Odl_To_Play_Template
93 Play_To_Odl_route_es_lan
94 [Template] Play_To_Odl_Template
97 Odl_To_Play_route_es_mac
98 [Template] Odl_To_Play_Template
101 Play_To_Odl_route_es_mac
102 [Template] Play_To_Odl_Template
105 Odl_To_Play_route_es_rou
106 [Template] Odl_To_Play_Template
109 Play_To_Odl_route_es_rou
110 [Template] Play_To_Odl_Template
113 Odl_To_Play_route_eth_arb
114 [Template] Odl_To_Play_Template
117 Play_To_Odl_route_eth_arb
118 [Template] Play_To_Odl_Template
121 Odl_To_Play_route_eth_as
122 [Template] Odl_To_Play_Template
125 Play_To_Odl_route_eth_as
126 [Template] Play_To_Odl_Template
129 Odl_To_Play_route_eth_lacp
130 [Template] Odl_To_Play_Template
133 Play_To_Odl_route_eth_lacp
134 [Template] Play_To_Odl_Template
137 Odl_To_Play_route_eth_lacp_extdef
138 [Template] Odl_To_Play_Template
139 route_eth_lacp_extdef
141 Play_To_Odl_route_eth_lacp_extdef
142 [Template] Play_To_Odl_Template
143 route_eth_lacp_extdef
145 Odl_To_Play_route_eth_lacp_extesilab
146 [Template] Odl_To_Play_Template
147 route_eth_lacp_extesilab
149 Play_To_Odl_route_eth_lacp_extesilab
150 [Template] Play_To_Odl_Template
151 route_eth_lacp_extesilab
153 Odl_To_Play_route_eth_lacp_extesr
154 [Template] Odl_To_Play_Template
155 route_eth_lacp_extesr
157 Play_To_Odl_route_eth_lacp_extesr
158 [Template] Play_To_Odl_Template
159 route_eth_lacp_extesr
161 Odl_To_Play_route_eth_lacp_extl2
162 [Template] Odl_To_Play_Template
165 Play_To_Odl_route_eth_lacp_extl2
166 [Template] Play_To_Odl_Template
169 Odl_To_Play_route_eth_lacp_extmac
170 [Template] Odl_To_Play_Template
171 route_eth_lacp_extmac
173 Play_To_Odl_route_eth_lacp_extmac
174 [Template] Play_To_Odl_Template
175 route_eth_lacp_extmac
177 Odl_To_Play_route_eth_lan
178 [Template] Odl_To_Play_Template
181 Play_To_Odl_route_eth_lan
182 [Template] Play_To_Odl_Template
185 Odl_To_Play_route_eth_mac
186 [Template] Odl_To_Play_Template
189 Play_To_Odl_route_eth_mac
190 [Template] Play_To_Odl_Template
193 Odl_To_Play_route_eth_rou
194 [Template] Odl_To_Play_Template
197 Play_To_Odl_route_eth_rou
198 [Template] Play_To_Odl_Template
201 Odl_To_Play_route_inc_arb
202 [Template] Odl_To_Play_Template
205 Play_To_Odl_route_inc_arb
206 [Template] Play_To_Odl_Template
209 Odl_To_Play_route_inc_as
210 [Template] Odl_To_Play_Template
213 Play_To_Odl_route_inc_as
214 [Template] Play_To_Odl_Template
217 Odl_To_Play_route_inc_lacp
218 [Template] Odl_To_Play_Template
221 Play_To_Odl_route_inc_lacp
222 [Template] Play_To_Odl_Template
225 Odl_To_Play_route_inc_lan
226 [Template] Odl_To_Play_Template
229 Play_To_Odl_route_inc_lan
230 [Template] Play_To_Odl_Template
233 Odl_To_Play_route_inc_mac
234 [Template] Odl_To_Play_Template
237 Play_To_Odl_route_inc_mac
238 [Template] Play_To_Odl_Template
241 Odl_To_Play_route_inc_rou
242 [Template] Odl_To_Play_Template
245 Play_To_Odl_route_inc_rou
246 [Template] Play_To_Odl_Template
249 Odl_To_Play_route_mac_arb
250 [Template] Odl_To_Play_Template
253 Play_To_Odl_route_mac_arb
254 [Template] Play_To_Odl_Template
257 Odl_To_Play_route_mac_as
258 [Template] Odl_To_Play_Template
261 Play_To_Odl_route_mac_as
262 [Template] Play_To_Odl_Template
265 Odl_To_Play_route_mac_lacp
266 [Template] Odl_To_Play_Template
269 Play_To_Odl_route_mac_lacp
270 [Template] Play_To_Odl_Template
273 Odl_To_Play_route_mac_lan
274 [Template] Odl_To_Play_Template
277 Play_To_Odl_route_mac_lan
278 [Template] Play_To_Odl_Template
281 Odl_To_Play_route_mac_mac
282 [Template] Odl_To_Play_Template
285 Play_To_Odl_route_mac_mac
286 [Template] Play_To_Odl_Template
289 Odl_To_Play_route_mac_rou
290 [Template] Odl_To_Play_Template
293 Play_To_Odl_route_mac_rou
294 [Template] Play_To_Odl_Template
297 Kill_Talking_BGP_Speaker
298 [Documentation] Abort the Python speaker
299 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
300 BGPSpeaker.Kill_BGP_Speaker
302 Delete_Bgp_Peer_Configuration
303 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
304 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
305 &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME}
306 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
309 [Documentation] Revert the BGP configuration to the original state: without application peer
310 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
311 &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME}
312 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
316 [Documentation] Initialize SetupUtils. Suite setup keyword.
317 SetupUtils.Setup_Utils_For_Setup_And_Teardown
318 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
319 Builtin.Set Suite Variable ${mininet_conn_id}
320 Utils.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
321 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
322 SSHLibrary.Put File ${PLAY_SCRIPT} .
323 SSHKeywords.Assure_Library_Ipaddr target_dir=.
326 [Documentation] Suite teardown keyword
327 SSHLibrary.Close_All_Connections
328 RequestsLibrary.Delete_All_Sessions
331 [Documentation] Starts bgp peer and verifies that the peer runs.
332 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
333 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
336 [Arguments] ${totest}
337 ${data_xml}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.xml
338 ${data_json}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.json
339 ${announce_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/announce_${totest}.hex
340 ${withdraw_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/withdraw_${totest}.hex
341 BuiltIn.Log ${data_xml}
342 BuiltIn.Log ${data_json}
343 BuiltIn.Log ${announce_hex}
344 BuiltIn.Log ${withdraw_hex}
345 BgpRpcClient.play_clean
346 ${resp}= RequestsLibrary.Post_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} data=${data_xml} headers=${HEADERS_XML}
347 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 204
348 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS_XML}
349 BuiltIn.Log ${resp.content}
350 ${aupdate}= BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
351 BuiltIn.Log ${aupdate}
352 BuiltIn.Should_Be_Equal_As_Strings ${aupdate} ${announce_hex}
353 BgpRpcClient.play_clean
354 Remove_Configured_Routes
355 ${wupdate}= BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
356 BuiltIn.Log ${wupdate}
357 BuiltIn.Should Be Equal As Strings ${wupdate} ${withdraw_hex}
358 [Teardown] Remove_Configured_Routes
361 [Arguments] ${totest}
362 ${data_xml}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.xml
363 ${data_json}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.json
364 ${announce_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/announce_${totest}.hex
365 ${withdraw_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/withdraw_${totest}.hex
366 ${empty_routes}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/empty_routes.json
367 BuiltIn.Set_Suite_Variable ${withdraw_hex}
368 BuiltIn.Set_Suite_Variable ${empty_routes}
369 BuiltIn.Log ${data_xml}
370 BuiltIn.Log ${data_json}
371 BuiltIn.Log ${announce_hex}
372 BuiltIn.Log ${withdraw_hex}
373 BuiltIn.Log ${empty_routes}
374 BgpRpcClient.play_clean
375 BgpRpcClient.play_send ${announce_hex}
376 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presnece ${data_json}
377 BgpRpcClient.play_send ${withdraw_hex}
378 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presnece ${empty_routes}
379 [Teardown] Withdraw_Route_And_Verify ${withdraw_hex}
381 Verify_Test_Preconditions
382 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
383 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 404
384 ${empty_routes}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/empty_routes.json
385 Loc_Rib_Presnece ${empty_routes}
387 Remove_Configured_Routes
388 [Documentation] Removes the route if present. First GET is for debug purposes.
389 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${LOC_RIB_URL} headers=${HEADERS}
391 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS}
393 BuiltIn.Return_From_Keyword_If "${rsp.status_code}"=="404"
394 ${resp}= RequestsLibrary.Delete_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
395 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 200
397 Withdraw_Route_And_Verify
398 [Arguments] ${withdraw_hex}
399 [Documentation] Sends withdraw update message from exabgp and verifies route removal from odl's rib
400 BgpRpcClient.play_send ${withdraw_hex}
401 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Loc Rib Presnece ${empty_routes}
404 [Documentation] Gets received data from odl's peer
405 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_RIB_OPER_URL} headers=${HEADERS_XML}
406 BuiltIn.Log ${resp.content}
407 ${update}= BgpRpcClient.play_get
408 BuiltIn.Should_Not_Be_Equal ${update} ${Empty}
412 [Arguments] ${exp_content}
413 [Documentation] Verifies if loc-rib contains expected data
414 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${LOC_RIB_URL} headers=${HEADERS}
415 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content}