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/norm_json.py
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/KarafKeywords.robot
29 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
33 ${DEVICE_NAME} controller-config
34 ${BGP_PEER_NAME} example-bgp-peer
35 ${RIB_INSTANCE} example-bgp-rib
36 ${APP_PEER_NAME} example-bgp-peer-app
37 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
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 ${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/
45 ${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
46 ${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
50 [Documentation] Configures bgp application peer
51 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
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}
53 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
55 Reconfigure_ODL_To_Accept_Connection
56 [Documentation] Configures BGP peer module with initiate-connection set to false.
57 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
58 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
59 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE}
60 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
63 [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.
64 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
65 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start Bgp Peer
67 Odl_To_Play_route_es_arb
68 [Template] Odl_To_Play_Template
71 Play_To_Odl_route_es_arb
72 [Template] Play_To_Odl_Template
75 Odl_To_Play_route_es_as
76 [Template] Odl_To_Play_Template
79 Play_To_Odl_route_es_as
80 [Template] Play_To_Odl_Template
83 Odl_To_Play_route_es_lacp
84 [Template] Odl_To_Play_Template
87 Play_To_Odl_route_es_lacp
88 [Template] Play_To_Odl_Template
91 Odl_To_Play_route_es_lan
92 [Template] Odl_To_Play_Template
95 Play_To_Odl_route_es_lan
96 [Template] Play_To_Odl_Template
99 Odl_To_Play_route_es_mac
100 [Template] Odl_To_Play_Template
103 Play_To_Odl_route_es_mac
104 [Template] Play_To_Odl_Template
107 Odl_To_Play_route_es_rou
108 [Template] Odl_To_Play_Template
111 Play_To_Odl_route_es_rou
112 [Template] Play_To_Odl_Template
115 Odl_To_Play_route_eth_arb
116 [Template] Odl_To_Play_Template
119 Play_To_Odl_route_eth_arb
120 [Template] Play_To_Odl_Template
123 Odl_To_Play_route_eth_as
124 [Template] Odl_To_Play_Template
127 Play_To_Odl_route_eth_as
128 [Template] Play_To_Odl_Template
131 Odl_To_Play_route_eth_lacp
132 [Template] Odl_To_Play_Template
135 Play_To_Odl_route_eth_lacp
136 [Template] Play_To_Odl_Template
139 Odl_To_Play_route_eth_lacp_extdef
140 [Template] Odl_To_Play_Template
141 route_eth_lacp_extdef
143 Play_To_Odl_route_eth_lacp_extdef
144 [Template] Play_To_Odl_Template
145 route_eth_lacp_extdef
147 Odl_To_Play_route_eth_lacp_extesilab
148 [Template] Odl_To_Play_Template
149 route_eth_lacp_extesilab
151 Play_To_Odl_route_eth_lacp_extesilab
152 [Template] Play_To_Odl_Template
153 route_eth_lacp_extesilab
155 Odl_To_Play_route_eth_lacp_extesr
156 [Template] Odl_To_Play_Template
157 route_eth_lacp_extesr
159 Play_To_Odl_route_eth_lacp_extesr
160 [Template] Play_To_Odl_Template
161 route_eth_lacp_extesr
163 Odl_To_Play_route_eth_lacp_extl2
164 [Template] Odl_To_Play_Template
167 Play_To_Odl_route_eth_lacp_extl2
168 [Template] Play_To_Odl_Template
171 Odl_To_Play_route_eth_lacp_extmac
172 [Template] Odl_To_Play_Template
173 route_eth_lacp_extmac
175 Play_To_Odl_route_eth_lacp_extmac
176 [Template] Play_To_Odl_Template
177 route_eth_lacp_extmac
179 Odl_To_Play_route_eth_lan
180 [Template] Odl_To_Play_Template
183 Play_To_Odl_route_eth_lan
184 [Template] Play_To_Odl_Template
187 Odl_To_Play_route_eth_mac
188 [Template] Odl_To_Play_Template
191 Play_To_Odl_route_eth_mac
192 [Template] Play_To_Odl_Template
195 Odl_To_Play_route_eth_rou
196 [Template] Odl_To_Play_Template
199 Play_To_Odl_route_eth_rou
200 [Template] Play_To_Odl_Template
203 Odl_To_Play_route_inc_arb
204 [Template] Odl_To_Play_Template
207 Play_To_Odl_route_inc_arb
208 [Template] Play_To_Odl_Template
211 Odl_To_Play_route_inc_as
212 [Template] Odl_To_Play_Template
215 Play_To_Odl_route_inc_as
216 [Template] Play_To_Odl_Template
219 Odl_To_Play_route_inc_lacp
220 [Template] Odl_To_Play_Template
223 Play_To_Odl_route_inc_lacp
224 [Template] Play_To_Odl_Template
227 Odl_To_Play_route_inc_lan
228 [Template] Odl_To_Play_Template
231 Play_To_Odl_route_inc_lan
232 [Template] Play_To_Odl_Template
235 Odl_To_Play_route_inc_mac
236 [Template] Odl_To_Play_Template
239 Play_To_Odl_route_inc_mac
240 [Template] Play_To_Odl_Template
243 Odl_To_Play_route_inc_rou
244 [Template] Odl_To_Play_Template
247 Play_To_Odl_route_inc_rou
248 [Template] Play_To_Odl_Template
251 Odl_To_Play_route_mac_arb
252 [Template] Odl_To_Play_Template
255 Play_To_Odl_route_mac_arb
256 [Template] Play_To_Odl_Template
259 Odl_To_Play_route_mac_as
260 [Template] Odl_To_Play_Template
263 Play_To_Odl_route_mac_as
264 [Template] Play_To_Odl_Template
267 Odl_To_Play_route_mac_lacp
268 [Template] Odl_To_Play_Template
271 Play_To_Odl_route_mac_lacp
272 [Template] Play_To_Odl_Template
275 Odl_To_Play_route_mac_lan
276 [Template] Odl_To_Play_Template
279 Play_To_Odl_route_mac_lan
280 [Template] Play_To_Odl_Template
283 Odl_To_Play_route_mac_mac
284 [Template] Odl_To_Play_Template
287 Play_To_Odl_route_mac_mac
288 [Template] Play_To_Odl_Template
291 Odl_To_Play_route_mac_rou
292 [Template] Odl_To_Play_Template
295 Play_To_Odl_route_mac_rou
296 [Template] Play_To_Odl_Template
299 Kill_Talking_BGP_Speaker
300 [Documentation] Abort the Python speaker
301 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
302 BGPSpeaker.Kill_BGP_Speaker
304 Delete_Bgp_Peer_Configuration
305 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
306 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
307 &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME}
308 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
311 [Documentation] Revert the BGP configuration to the original state: without application peer
312 [Setup] KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
313 &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME}
314 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
318 [Documentation] Suite setup keyword
319 SetupUtils.Setup_Utils_For_Setup_And_Teardown
320 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
321 Builtin.Set Suite Variable ${mininet_conn_id}
322 Utils.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
323 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
324 SSHLibrary.Put File ${PLAY_SCRIPT} .
325 SSHKeywords.Assure_Library_Ipaddr target_dir=.
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 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
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 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
366 ${data_xml}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.xml
367 ${data_json}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/${totest}.json
368 ${announce_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/announce_${totest}.hex
369 ${withdraw_hex}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/withdraw_${totest}.hex
370 ${empty_routes}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/empty_routes.json
371 BuiltIn.Set_Suite_Variable ${withdraw_hex}
372 BuiltIn.Set_Suite_Variable ${empty_routes}
373 BuiltIn.Log ${data_xml}
374 BuiltIn.Log ${data_json}
375 BuiltIn.Log ${announce_hex}
376 BuiltIn.Log ${withdraw_hex}
377 BuiltIn.Log ${empty_routes}
378 BgpRpcClient.play_clean
379 BgpRpcClient.play_send ${announce_hex}
380 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presnece ${data_json}
381 BgpRpcClient.play_send ${withdraw_hex}
382 BuiltIn.Wait_Until_Keyword_Succeeds 4x 2s Loc_Rib_Presnece ${empty_routes}
383 [Teardown] Withdraw_Route_And_Verify ${withdraw_hex}
385 Verify_Test_Preconditions
386 ${resp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${EVPN_CONF_URL}
387 BuiltIn.Should_Be_Equal_As_Numbers ${resp.status_code} 404
388 ${empty_routes}= OperatingSystem.Get_File ${EVPN_VARIABLES_DIR}/empty_routes.json
389 Loc_Rib_Presnece ${empty_routes}
391 Remove_Configured_Routes
392 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${LOC_RIB_URL} headers=${HEADERS}
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}
416 ${keys_with_bits}= BuiltIn.Create_List op
417 ${received_json}= norm_json.Normalize_Json_Text ${rsp.content} keys_with_bits=${keys_with_bits}
418 BuiltIn.Log ${received_json}
419 ${expected_json}= norm_json.Normalize_Json_Text ${exp_content} keys_with_bits=${keys_with_bits}
420 BuiltIn.Log ${expected_json}
421 BuiltIn.Should_Be_Equal ${received_json} ${expected_json}