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 Verify Test Preconditions
18 Library RequestsLibrary
20 Variables ${CURDIR}/../../../variables/Variables.py
21 Resource ${CURDIR}/../../../libraries/Utils.robot
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/KarafKeywords.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 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
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
43 ${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/
44 ${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
45 ${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
49 [Documentation] Configures bgp application peer
50 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
51 &{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}
52 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
54 Reconfigure_ODL_To_Accept_Connection
55 [Documentation] Configures BGP peer module with initiate-connection set to false.
56 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
57 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
58 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE}
59 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
62 [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.
63 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
64 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start Bgp Peer
66 Odl_To_Play_route_es_arb
67 [Template] Odl_To_Play_Template
70 Play_To_Odl_route_es_arb
71 [Template] Play_To_Odl_Template
74 Odl_To_Play_route_es_as
75 [Template] Odl_To_Play_Template
78 Play_To_Odl_route_es_as
79 [Template] Play_To_Odl_Template
82 Odl_To_Play_route_es_lacp
83 [Template] Odl_To_Play_Template
86 Play_To_Odl_route_es_lacp
87 [Template] Play_To_Odl_Template
90 Odl_To_Play_route_es_lan
91 [Template] Odl_To_Play_Template
94 Play_To_Odl_route_es_lan
95 [Template] Play_To_Odl_Template
98 Odl_To_Play_route_es_mac
99 [Template] Odl_To_Play_Template
102 Play_To_Odl_route_es_mac
103 [Template] Play_To_Odl_Template
106 Odl_To_Play_route_es_rou
107 [Template] Odl_To_Play_Template
110 Play_To_Odl_route_es_rou
111 [Template] Play_To_Odl_Template
114 Odl_To_Play_route_eth_arb
115 [Template] Odl_To_Play_Template
118 Play_To_Odl_route_eth_arb
119 [Template] Play_To_Odl_Template
122 Odl_To_Play_route_eth_as
123 [Template] Odl_To_Play_Template
126 Play_To_Odl_route_eth_as
127 [Template] Play_To_Odl_Template
130 Odl_To_Play_route_eth_lacp
131 [Template] Odl_To_Play_Template
134 Play_To_Odl_route_eth_lacp
135 [Template] Play_To_Odl_Template
138 Odl_To_Play_route_eth_lacp_extdef
139 [Template] Odl_To_Play_Template
140 route_eth_lacp_extdef
142 Play_To_Odl_route_eth_lacp_extdef
143 [Template] Play_To_Odl_Template
144 route_eth_lacp_extdef
146 Odl_To_Play_route_eth_lacp_extesilab
147 [Template] Odl_To_Play_Template
148 route_eth_lacp_extesilab
150 Play_To_Odl_route_eth_lacp_extesilab
151 [Template] Play_To_Odl_Template
152 route_eth_lacp_extesilab
154 Odl_To_Play_route_eth_lacp_extesr
155 [Template] Odl_To_Play_Template
156 route_eth_lacp_extesr
158 Play_To_Odl_route_eth_lacp_extesr
159 [Template] Play_To_Odl_Template
160 route_eth_lacp_extesr
162 Odl_To_Play_route_eth_lacp_extl2
163 [Template] Odl_To_Play_Template
166 Play_To_Odl_route_eth_lacp_extl2
167 [Template] Play_To_Odl_Template
170 Odl_To_Play_route_eth_lacp_extmac
171 [Template] Odl_To_Play_Template
172 route_eth_lacp_extmac
174 Play_To_Odl_route_eth_lacp_extmac
175 [Template] Play_To_Odl_Template
176 route_eth_lacp_extmac
178 Odl_To_Play_route_eth_lan
179 [Template] Odl_To_Play_Template
182 Play_To_Odl_route_eth_lan
183 [Template] Play_To_Odl_Template
186 Odl_To_Play_route_eth_mac
187 [Template] Odl_To_Play_Template
190 Play_To_Odl_route_eth_mac
191 [Template] Play_To_Odl_Template
194 Odl_To_Play_route_eth_rou
195 [Template] Odl_To_Play_Template
198 Play_To_Odl_route_eth_rou
199 [Template] Play_To_Odl_Template
202 Odl_To_Play_route_inc_arb
203 [Template] Odl_To_Play_Template
206 Play_To_Odl_route_inc_arb
207 [Template] Play_To_Odl_Template
210 Odl_To_Play_route_inc_as
211 [Template] Odl_To_Play_Template
214 Play_To_Odl_route_inc_as
215 [Template] Play_To_Odl_Template
218 Odl_To_Play_route_inc_lacp
219 [Template] Odl_To_Play_Template
222 Play_To_Odl_route_inc_lacp
223 [Template] Play_To_Odl_Template
226 Odl_To_Play_route_inc_lan
227 [Template] Odl_To_Play_Template
230 Play_To_Odl_route_inc_lan
231 [Template] Play_To_Odl_Template
234 Odl_To_Play_route_inc_mac
235 [Template] Odl_To_Play_Template
238 Play_To_Odl_route_inc_mac
239 [Template] Play_To_Odl_Template
242 Odl_To_Play_route_inc_rou
243 [Template] Odl_To_Play_Template
246 Play_To_Odl_route_inc_rou
247 [Template] Play_To_Odl_Template
250 Odl_To_Play_route_mac_arb
251 [Template] Odl_To_Play_Template
254 Play_To_Odl_route_mac_arb
255 [Template] Play_To_Odl_Template
258 Odl_To_Play_route_mac_as
259 [Template] Odl_To_Play_Template
262 Play_To_Odl_route_mac_as
263 [Template] Play_To_Odl_Template
266 Odl_To_Play_route_mac_lacp
267 [Template] Odl_To_Play_Template
270 Play_To_Odl_route_mac_lacp
271 [Template] Play_To_Odl_Template
274 Odl_To_Play_route_mac_lan
275 [Template] Odl_To_Play_Template
278 Play_To_Odl_route_mac_lan
279 [Template] Play_To_Odl_Template
282 Odl_To_Play_route_mac_mac
283 [Template] Odl_To_Play_Template
286 Play_To_Odl_route_mac_mac
287 [Template] Play_To_Odl_Template
290 Odl_To_Play_route_mac_rou
291 [Template] Odl_To_Play_Template
294 Play_To_Odl_route_mac_rou
295 [Template] Play_To_Odl_Template
298 Kill_Talking_BGP_Speaker
299 [Documentation] Abort the Python speaker
300 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
301 BGPSpeaker.Kill_BGP_Speaker
303 Delete_Bgp_Peer_Configuration
304 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
305 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
306 &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME}
307 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
310 [Documentation] Revert the BGP configuration to the original state: without application peer
311 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
312 &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME}
313 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
317 [Documentation] Suite setup keyword
318 SetupUtils.Setup_Utils_For_Setup_And_Teardown
319 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
320 Builtin.Set Suite Variable ${mininet_conn_id}
321 Utils.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
322 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
323 SSHLibrary.Put File ${PLAY_SCRIPT} .
324 SSHKeywords.Assure_Library_Ipaddr target_dir=.
327 [Documentation] Suite teardown keyword
328 SSHLibrary.Close_All_Connections
329 RequestsLibrary.Delete_All_Sessions
332 [Documentation] Starts bgp peer and verifies that the peer runs.
333 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
334 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
337 [Arguments] ${totest}
338 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
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 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
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} ${LOC_RIB_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_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} ${LOC_RIB_URL} headers=${HEADERS}
418 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content}