2 Documentation Basic tests for BGP application peer.
4 ... Copyright (c) 2015 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 ... Test suite performs basic BGP functional test cases for
11 ... BGP application peer operations and checks for IP4 topology updates
12 ... and updates towards BGP peer as follows:
14 ... Test case 1: Initial BGP peer connection with pre-filled topology,
15 ... POST and simple DELETE requests used.
16 ... BGP_Application_Peer_Post_3_Initial_Routes,
17 ... Check_Example-IPv4-Topology_Is_Filled_With_3_Routes,
19 ... BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes,
20 ... BGP_Application_Peer_Delete_3_Initial_Routes,
21 ... Check_Example-IPv4-Topology_Is_Empty,
22 ... Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes,
25 ... Test case 2: PUT and DELETE all routes requests while BGP peer is connected.
26 ... Reconnect_BGP_Peer,
27 ... BGP_Application_Peer_Put_3_Routes,
28 ... Check_Example-IPv4-Topology_Is_Filled_With_3_Routes,
29 ... BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes,
30 ... BGP_Application_Peer_Delete_All_Routes,
31 ... Check_Example-IPv4-Topology_Is_Empty,
32 ... BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes,
35 ... Test case 3: Repeated BGP peer re-connection with pre-filled topology.
36 ... BGP_Application_Peer_Put_3_Routes,
37 ... Check_Example-IPv4-Topology_Is_Filled_With_3_Routes,
38 ... Reconnect_BGP_Peer_And_Check_Incomming_Updates_For_3_Introduced_Prefixes,
39 ... BGP_Application_Peer_Delete_All_Routes,
40 ... Check_Example-IPv4-Topology_Is_Empty,
41 ... BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes,
44 ... Brief description how to configure BGP application peer and
45 ... how to use restconf application peer interface:
46 ... https://wiki.opendaylight.org/view/BGP_LS_PCEP:User_Guide#BGP_Application_Peer
47 ... https://wiki.opendaylight.org/view/BGP_LS_PCEP:Programmer_Guide#BGP
49 Library OperatingSystem
50 Library SSHLibrary timeout=10s
51 Library RequestsLibrary
52 Resource ../../../libraries/BGPcliKeywords.robot
53 Resource ../../../libraries/FailFast.robot
54 Resource ../../../libraries/KillPythonTool.robot
55 Resource ../../../libraries/TemplatedRequests.robot
56 Resource ../../../libraries/SetupUtils.robot
57 Resource ../../../libraries/SSHKeywords.robot
58 Resource ../../../libraries/WaitForFailure.robot
59 Resource ../../../variables/Variables.robot
61 Suite Setup Setup_Everything
62 Suite Teardown Teardown_Everything
63 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
64 Test Teardown FailFast.Start_Failing_Fast_If_This_Failed
68 ${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpuser/
69 ${TOOLS_SYSTEM_PROMPT} ${DEFAULT_LINUX_PROMPT}
71 ${BGP_PEER_LOG_LEVEL} debug
72 ${BGP_APP_PEER_LOG_LEVEL} debug
74 ... python3 play.py --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_PEER_LOG_LEVEL}
75 ${BGP_PEER_OPTIONS} ${EMPTY}
76 ${BGP_APP_PEER_ID} ${ODL_SYSTEM_IP}
77 ${BGP_APP_PEER_POST_COMMAND}
78 ... python3 bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command post --count 3 --prefix 8.0.1.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
79 ${BGP_APP_PEER_PUT_COMMAND}
80 ... python3 bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command put --count 3 --prefix 8.0.1.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
81 ${BGP_APP_PEER_DELETE_COMMAND}
82 ... python3 bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command delete --count 3 --prefix 8.0.1.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
83 ${BGP_APP_PEER_DELETE_ALL_COMMAND}
84 ... python3 bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command delete-all --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
85 ${BGP_APP_PEER_GET_COMMAND}
86 ... python3 bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command get --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
87 ${BGP_APP_PEER_OPTIONS} &>/dev/null
88 ${BGP_APP_PEER_TIMEOUT} 30s
89 ${BGP_PEER_APP_NAME} example-bgp-peer-app
90 ${CONFIG_SESSION} session
91 ${RIB_INSTANCE} example-bgp-rib
92 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
93 ${DEVICE_NAME} controller-config
94 ${BGP_PEER_NAME} example-bgp-peer
95 ${RIB_INSTANCE} example-bgp-rib
97 ... --uri data/bgp-rib:application-rib=${ODL_SYSTEM_IP}/tables=bgp-types%3Aipv4-address-family,bgp-types%3Aunicast-subsequent-address-family
101 Reconfigure_ODL_To_Accept_BGP_Peer_Connection
102 [Documentation] Configure BGP peer module with initiate-connection set to false.
104 &{mapping} Create Dictionary
105 ... DEVICE_NAME=${DEVICE_NAME}
106 ... BGP_NAME=${BGP_PEER_NAME}
107 ... IP=${TOOLS_SYSTEM_IP}
108 ... HOLDTIME=${HOLDTIME}
109 ... PEER_PORT=${BGP_TOOL_PORT}
111 ... BGP_RIB=${RIB_INSTANCE}
112 ... PASSIVE_MODE=true
113 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
114 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
115 TemplatedRequests.Put_As_Xml_Templated
116 ... ${BGP_VARIABLES_FOLDER}${/}bgp_peer
117 ... mapping=${mapping}
118 ... session=${CONFIG_SESSION}
120 Reconfigure_ODL_To_Accept_BGP_Application_Peer
121 [Documentation] Configure BGP application peer module.
123 &{mapping} Create Dictionary
124 ... DEVICE_NAME=${DEVICE_NAME}
125 ... NAME=${BGP_PEER_APP_NAME}
126 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
127 ... IP=${BGP_APP_PEER_ID}
128 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
129 TemplatedRequests.Put_As_Xml_Templated
130 ... ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer
131 ... mapping=${mapping}
132 ... session=${CONFIG_SESSION}
134 Check_For_Empty_Example-IPv4-Topology
135 [Documentation] Sanity check example-ipv4-topology is up but empty.
137 Wait_For_Topology_To_Change_To empty_topology timeout=180s
139 TC1_BGP_Application_Peer_Post_3_Initial_Routes
140 [Documentation] Start BGP application peer tool and give it ${BGP_APP_PEER_TIMEOUT}
142 Switch_To_BGP_Application_Peer_Console
143 Start_Console_Tool ${BGP_APP_PEER_POST_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
144 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
145 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_initial_post_tc1.log
147 TC1_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
148 [Documentation] See new routes in example-ipv4-topology as a proof that synchronization was correct.
150 Wait_For_Topology_To_Change_To filled_topology
153 [Documentation] Start BGP peer tool
155 Switch_To_BGP_Peer_Console
156 Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
157 Read_And_Fail_If_Prompt_Is_Seen
159 TC1_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
160 [Documentation] Check incomming updates for new routes
162 Switch_To_BGP_Peer_Console
163 BuiltIn.Wait_Until_Keyword_Succeeds
166 ... Check_File_For_Word_Count
168 ... nlri_prefix_received:
170 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.0/28 1
171 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.16/28 1
172 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.32/28 1
173 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 0
175 TC1_BGP_Application_Peer_Delete_3_Initial_Routes
176 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
178 Switch_To_BGP_Application_Peer_Console
179 Start_Console_Tool ${BGP_APP_PEER_DELETE_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
180 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
181 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_delete_tc1.log
183 TC1_Check_Example-IPv4-Topology_Is_Empty
184 [Documentation] See new routes are deleted.
186 Wait_For_Topology_To_Change_To empty_topology
188 TC1_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
189 [Documentation] Check incomming updates for new routes
191 Switch_To_BGP_Peer_Console
192 BuiltIn.Wait_Until_Keyword_Succeeds
195 ... Check_File_For_Word_Count
197 ... withdrawn_prefix_received:
199 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.0/28 1
200 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.16/28 1
201 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.32/28 1
202 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
205 [Documentation] Stop BGP peer tool
207 Switch_To_BGP_Peer_Console
209 Store_File_To_Workspace bgp_peer.log bgp_peer_tc1.log
211 TC2_Reconnect_BGP_Peer
212 [Documentation] Start BGP peer tool
214 Switch_To_BGP_Peer_Console
215 Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
216 Read_And_Fail_If_Prompt_Is_Seen
217 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 0
218 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 0
220 TC2_BGP_Application_Peer_Put_3_Routes
221 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
223 Switch_To_BGP_Application_Peer_Console
224 Start_Console_Tool ${BGP_APP_PEER_PUT_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
225 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
226 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_put_tc2.log
228 TC2_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
229 [Documentation] See new routes in example-ipv4-topology as a proof that synchronization was correct.
231 Wait_For_Topology_To_Change_To filled_topology
233 TC2_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
234 [Documentation] Check incomming updates for new routes
236 Switch_To_BGP_Peer_Console
237 BuiltIn.Wait_Until_Keyword_Succeeds
240 ... Check_File_For_Word_Count
242 ... nlri_prefix_received:
244 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.0/28 1
245 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.16/28 1
246 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.32/28 1
247 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 0
249 TC2_BGP_Application_Peer_Delete_All_Routes
250 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
252 Switch_To_BGP_Application_Peer_Console
253 Start_Console_Tool ${BGP_APP_PEER_DELETE_ALL_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
254 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
255 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_delete_all_tc2.log
257 TC2_Check_Example-IPv4-Topology_Is_Empty
258 [Documentation] See new routes are deleted.
260 Wait_For_Topology_To_Change_To empty_topology
262 TC2_BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
263 [Documentation] Check incomming updates for new routes
265 Switch_To_BGP_Peer_Console
266 BuiltIn.Wait_Until_Keyword_Succeeds
269 ... Check_File_For_Word_Count
271 ... withdrawn_prefix_received:
273 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.0/28 1
274 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.16/28 1
275 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.32/28 1
276 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
279 [Documentation] Stop BGP peer tool
281 Switch_To_BGP_Peer_Console
283 Store_File_To_Workspace bgp_peer.log bgp_peer_tc2.log
285 TC3_BGP_Application_Peer_Put_3_Routes
286 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
288 Switch_To_BGP_Application_Peer_Console
289 Start_Console_Tool ${BGP_APP_PEER_PUT_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
290 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
291 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_put_tc3.log
293 TC3_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
294 [Documentation] See new routes in example-ipv4-topology as a proof that synchronization was correct.
296 Wait_For_Topology_To_Change_To filled_topology
298 TC3_Reconnect_BGP_Peer_And_Check_Incomming_Updates_For_3_Introduced_Prefixes
299 [Documentation] Start BGP peer tool
301 Switch_To_BGP_Peer_Console
302 Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
303 Read_And_Fail_If_Prompt_Is_Seen
304 BuiltIn.Wait_Until_Keyword_Succeeds
307 ... Check_File_For_Word_Count
309 ... nlri_prefix_received:
311 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
312 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.0/28 1
313 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.16/28 1
314 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.32/28 1
315 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 0
317 TC3_BGP_Application_Peer_Delete_All_Routes
318 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
320 Switch_To_BGP_Application_Peer_Console
321 Start_Console_Tool ${BGP_APP_PEER_DELETE_ALL_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
322 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
323 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_delete_all_tc3.log
325 TC3_Check_Example-IPv4-Topology_Is_Empty
326 [Documentation] See new routes are deleted.
328 Wait_For_Topology_To_Change_To empty_topology
330 TC3_BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
331 [Documentation] Check incomming updates for new routes
333 Switch_To_BGP_Peer_Console
334 BuiltIn.Wait_Until_Keyword_Succeeds
337 ... Check_File_For_Word_Count
339 ... withdrawn_prefix_received:
341 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.0/28 1
342 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.16/28 1
343 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.32/28 1
344 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
347 [Documentation] Stop BGP peer tool
349 Switch_To_BGP_Peer_Console
351 Store_File_To_Workspace bgp_peer.log bgp_peer_tc3.log
353 Delete_Bgp_Peer_Configuration
354 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
356 &{mapping} BuiltIn.Create_Dictionary
357 ... DEVICE_NAME=${DEVICE_NAME}
358 ... BGP_NAME=${BGP_PEER_NAME}
359 ... IP=${TOOLS_SYSTEM_IP}
360 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
361 TemplatedRequests.Delete_Templated
362 ... ${BGP_VARIABLES_FOLDER}${/}bgp_peer
363 ... mapping=${mapping}
364 ... session=${CONFIG_SESSION}
366 Delete_Bgp_Application_Peer_Configuration
367 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
369 &{mapping} BuiltIn.Create_Dictionary
370 ... DEVICE_NAME=${DEVICE_NAME}
371 ... NAME=${BGP_PEER_APP_NAME}
372 ... IP=${ODL_SYSTEM_IP}
373 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
374 TemplatedRequests.Delete_Templated
375 ... ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer
376 ... mapping=${mapping}
377 ... session=${CONFIG_SESSION}
382 [Documentation] Initialize SetupUtils. SSH-login to mininet machine, create HTTP session,
383 ... put Python tool to mininet machine, setup imported resources.
384 SetupUtils.Setup_Utils_For_Setup_And_Teardown
385 SSHLibrary.Set_Default_Configuration prompt=${TOOLS_SYSTEM_PROMPT}
386 Open_BGP_Peer_Console
387 SSHKeywords.Require_Python
388 SSHKeywords.Assure_Library_Ipaddr target_dir=.
389 SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/play.py
390 Open_BGP_Aplication_Peer_Console
391 SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/bgp_app_peer.py
392 SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/ipv4-routes-template.xml*
393 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
396 [Documentation] Make sure Python tool was killed.
397 ... Tear down imported Resources.
398 KillPythonTool.Search_And_Kill_Remote_Python 'play\.py'
399 KillPythonTool.Search_And_Kill_Remote_Python 'bgp_app_peer\.py'
400 RequestsLibrary.Delete_All_Sessions
401 SSHLibrary.Close_All_Connections
403 Open_BGP_Peer_Console
404 [Documentation] Create a session for BGP peer.
405 SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=bgp_peer_console
406 SSHKeywords.Flexible_Mininet_Login
408 Open_BGP_Aplication_Peer_Console
409 [Documentation] Create a session for BGP peer.
410 SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=bgp_app_peer_console
411 SSHKeywords.Flexible_Mininet_Login
413 Switch_To_BGP_Peer_Console
414 SSHLibrary.Switch Connection bgp_peer_console
416 Switch_To_BGP_Application_Peer_Console
417 SSHLibrary.Switch Connection bgp_app_peer_console
419 Wait_For_Topology_To_Change_To
420 [Documentation] Wait until Compare_Topology matches expected result.
421 [Arguments] ${folder_name} ${timeout}=10s ${refresh}=1s
422 BuiltIn.Wait_Until_Keyword_Succeeds ${timeout} ${refresh} Compare_Topology ${folder_name}
424 Verify_That_Topology_Does_Not_Change_From
425 [Documentation] Verify that Compare_Topology keeps passing, it will hold its last result.
426 [Arguments] ${folder_name} ${timeout}=10s ${refresh}=1s
427 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout
434 [Documentation] Get current example-ipv4-topology as json, and compare it to expected result.
435 [Arguments] ${folder_name}
436 TemplatedRequests.Get_As_Json_Templated
437 ... ${BGP_VARIABLES_FOLDER}${/}${folder_name}
438 ... session=${CONFIG_SESSION}