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/SetupUtils.robot
23 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
24 Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
25 Resource ${CURDIR}/../../../libraries/BGPcliKeywords.robot
26 Resource ${CURDIR}/../../../libraries/BGPSpeaker.robot
27 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
31 ${DEVICE_NAME} controller-config
32 ${BGP_PEER_NAME} example-bgp-peer
33 ${RIB_INSTANCE} example-bgp-rib
34 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
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
45 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
46 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
47 &{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}
48 ... IP=${ODL_SYSTEM_IP}
49 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
51 Reconfigure_ODL_To_Accept_Connection
52 [Documentation] Configures BGP peer module with initiate-connection set to false.
53 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
54 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
55 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} PASSIVE_MODE=true
56 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
59 [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.
60 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
61 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start Bgp Peer
63 Odl_To_Play_route_es_arb
64 [Template] Odl_To_Play_Template
67 Play_To_Odl_route_es_arb
68 [Template] Play_To_Odl_Template
71 Odl_To_Play_route_es_as
72 [Template] Odl_To_Play_Template
75 Play_To_Odl_route_es_as
76 [Template] Play_To_Odl_Template
79 Odl_To_Play_route_es_lacp
80 [Template] Odl_To_Play_Template
83 Play_To_Odl_route_es_lacp
84 [Template] Play_To_Odl_Template
87 Odl_To_Play_route_es_lan
88 [Template] Odl_To_Play_Template
91 Play_To_Odl_route_es_lan
92 [Template] Play_To_Odl_Template
95 Odl_To_Play_route_es_mac
96 [Template] Odl_To_Play_Template
99 Play_To_Odl_route_es_mac
100 [Template] Play_To_Odl_Template
103 Odl_To_Play_route_es_rou
104 [Template] Odl_To_Play_Template
107 Play_To_Odl_route_es_rou
108 [Template] Play_To_Odl_Template
111 Odl_To_Play_route_eth_arb
112 [Template] Odl_To_Play_Template
115 Play_To_Odl_route_eth_arb
116 [Template] Play_To_Odl_Template
119 Odl_To_Play_route_eth_as
120 [Template] Odl_To_Play_Template
123 Play_To_Odl_route_eth_as
124 [Template] Play_To_Odl_Template
127 Odl_To_Play_route_eth_lacp
128 [Template] Odl_To_Play_Template
131 Play_To_Odl_route_eth_lacp
132 [Template] Play_To_Odl_Template
135 Odl_To_Play_route_eth_lacp_extdef
136 [Template] Odl_To_Play_Template
137 route_eth_lacp_extdef
139 Play_To_Odl_route_eth_lacp_extdef
140 [Template] Play_To_Odl_Template
141 route_eth_lacp_extdef
143 Odl_To_Play_route_eth_lacp_extesilab
144 [Template] Odl_To_Play_Template
145 route_eth_lacp_extesilab
147 Play_To_Odl_route_eth_lacp_extesilab
148 [Template] Play_To_Odl_Template
149 route_eth_lacp_extesilab
151 Odl_To_Play_route_eth_lacp_extesr
152 [Template] Odl_To_Play_Template
153 route_eth_lacp_extesr
155 Play_To_Odl_route_eth_lacp_extesr
156 [Template] Play_To_Odl_Template
157 route_eth_lacp_extesr
159 Odl_To_Play_route_eth_lacp_extl2
160 [Template] Odl_To_Play_Template
163 Play_To_Odl_route_eth_lacp_extl2
164 [Template] Play_To_Odl_Template
167 Odl_To_Play_route_eth_lacp_extmac
168 [Template] Odl_To_Play_Template
169 route_eth_lacp_extmac
171 Play_To_Odl_route_eth_lacp_extmac
172 [Template] Play_To_Odl_Template
173 route_eth_lacp_extmac
175 Odl_To_Play_route_eth_lan
176 [Template] Odl_To_Play_Template
179 Play_To_Odl_route_eth_lan
180 [Template] Play_To_Odl_Template
183 Odl_To_Play_route_eth_mac
184 [Template] Odl_To_Play_Template
187 Play_To_Odl_route_eth_mac
188 [Template] Play_To_Odl_Template
191 Odl_To_Play_route_eth_rou
192 [Template] Odl_To_Play_Template
195 Play_To_Odl_route_eth_rou
196 [Template] Play_To_Odl_Template
199 Odl_To_Play_route_inc_arb
200 [Template] Odl_To_Play_Template
203 Play_To_Odl_route_inc_arb
204 [Template] Play_To_Odl_Template
207 Odl_To_Play_route_inc_as
208 [Template] Odl_To_Play_Template
211 Play_To_Odl_route_inc_as
212 [Template] Play_To_Odl_Template
215 Odl_To_Play_route_inc_lacp
216 [Template] Odl_To_Play_Template
219 Play_To_Odl_route_inc_lacp
220 [Template] Play_To_Odl_Template
223 Odl_To_Play_route_inc_lan
224 [Template] Odl_To_Play_Template
227 Play_To_Odl_route_inc_lan
228 [Template] Play_To_Odl_Template
231 Odl_To_Play_route_inc_mac
232 [Template] Odl_To_Play_Template
235 Play_To_Odl_route_inc_mac
236 [Template] Play_To_Odl_Template
239 Odl_To_Play_route_inc_rou
240 [Template] Odl_To_Play_Template
243 Play_To_Odl_route_inc_rou
244 [Template] Play_To_Odl_Template
247 Odl_To_Play_route_mac_arb
248 [Template] Odl_To_Play_Template
251 Play_To_Odl_route_mac_arb
252 [Template] Play_To_Odl_Template
255 Odl_To_Play_route_mac_as
256 [Template] Odl_To_Play_Template
259 Play_To_Odl_route_mac_as
260 [Template] Play_To_Odl_Template
263 Odl_To_Play_route_mac_lacp
264 [Template] Odl_To_Play_Template
267 Play_To_Odl_route_mac_lacp
268 [Template] Play_To_Odl_Template
271 Odl_To_Play_route_mac_lan
272 [Template] Odl_To_Play_Template
275 Play_To_Odl_route_mac_lan
276 [Template] Play_To_Odl_Template
279 Odl_To_Play_route_mac_mac
280 [Template] Odl_To_Play_Template
283 Play_To_Odl_route_mac_mac
284 [Template] Play_To_Odl_Template
287 Odl_To_Play_route_mac_rou
288 [Template] Odl_To_Play_Template
291 Play_To_Odl_route_mac_rou
292 [Template] Play_To_Odl_Template
295 Kill_Talking_BGP_Speaker
296 [Documentation] Abort the Python speaker
297 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
298 BGPSpeaker.Kill_BGP_Speaker
300 Delete_Bgp_Peer_Configuration
301 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
302 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
303 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
304 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
307 [Documentation] Revert the BGP configuration to the original state: without application peer
308 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
309 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME} IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
310 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
314 [Documentation] Initialize SetupUtils. Suite setup keyword.
315 SetupUtils.Setup_Utils_For_Setup_And_Teardown
316 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
317 Builtin.Set Suite Variable ${mininet_conn_id}
318 SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
319 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
320 SSHLibrary.Put File ${PLAY_SCRIPT} .
321 SSHKeywords.Assure_Library_Ipaddr target_dir=.
322 ${app_rib}= Set Variable ${ODL_SYSTEM_IP}
323 ${bgp_rib}= Set Variable example-bgp-rib
324 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/
325 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
328 [Documentation] Suite teardown keyword
329 SSHLibrary.Close_All_Connections
330 RequestsLibrary.Delete_All_Sessions
333 [Documentation] Starts bgp peer and verifies that the peer runs.
334 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
335 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
338 [Arguments] ${totest}
339 ${data_xml}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.xml
340 ${data_json}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.json
341 ${announce_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/announce_${totest}.hex
342 ${withdraw_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/withdraw_${totest}.hex
343 BuiltIn.Log ${data_xml}
344 BuiltIn.Log ${data_json}
345 BuiltIn.Log ${announce_hex}
346 BuiltIn.Log ${withdraw_hex}
347 BgpRpcClient.play_clean
348 ${resp}= RequestsLibrary.Post_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} data=${data_xml} headers=${HEADERS_XML}
349 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 204
350 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS_XML}
351 BuiltIn.Log ${resp.content}
352 ${aupdate}= BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
353 BuiltIn.Log ${aupdate}
354 BuiltIn.Should_Be_Equal_As_Strings ${aupdate} ${announce_hex}
355 BgpRpcClient.play_clean
356 Remove_Configured_Routes
357 ${wupdate}= BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Get_Update_Content
358 BuiltIn.Log ${wupdate}
359 BuiltIn.Should Be Equal As Strings ${wupdate} ${withdraw_hex}
360 [Teardown] Remove_Configured_Routes
363 [Arguments] ${totest}
364 ${data_xml}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.xml
365 ${data_json}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.json
366 ${announce_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/announce_${totest}.hex
367 ${withdraw_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/withdraw_${totest}.hex
368 ${empty_routes}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/empty_routes.json
369 BuiltIn.Set_Suite_Variable ${withdraw_hex}
370 BuiltIn.Set_Suite_Variable ${empty_routes}
371 BuiltIn.Log ${data_xml}
372 BuiltIn.Log ${data_json}
373 BuiltIn.Log ${announce_hex}
374 BuiltIn.Log ${withdraw_hex}
375 BuiltIn.Log ${empty_routes}
376 BgpRpcClient.play_clean
377 BgpRpcClient.play_send ${announce_hex}
378 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presnece ${data_json}
379 BgpRpcClient.play_send ${withdraw_hex}
380 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presnece ${empty_routes}
381 [Teardown] Withdraw_Route_And_Verify ${withdraw_hex}
383 Verify_Test_Preconditions
384 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
385 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 404
386 ${empty_routes}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/empty_routes.json
387 Loc_Rib_Presnece ${empty_routes}
389 Remove_Configured_Routes
390 [Documentation] Removes the route if present. First GET is for debug purposes.
391 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB_OPER_URL} headers=${HEADERS}
393 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL} headers=${HEADERS}
395 BuiltIn.Return_From_Keyword_If "${rsp.status_code}"=="404"
396 ${resp}= RequestsLibrary.Delete_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
397 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 200
399 Withdraw_Route_And_Verify
400 [Arguments] ${withdraw_hex}
401 [Documentation] Sends withdraw update message from exabgp and verifies route removal from odl's rib
402 BgpRpcClient.play_send ${withdraw_hex}
403 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Loc Rib Presnece ${empty_routes}
406 [Documentation] Gets received data from odl's peer
407 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB_OPER_URL} headers=${HEADERS_XML}
408 BuiltIn.Log ${resp.content}
409 ${update}= BgpRpcClient.play_get
410 BuiltIn.Should_Not_Be_Equal ${update} ${Empty}
414 [Arguments] ${exp_content}
415 [Documentation] Verifies if loc-rib contains expected data
416 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_LOC_RIB_OPER_URL} headers=${HEADERS}
417 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content}