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