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 (Bug 4714),
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 ... Bug 4714 - No routes from loc-rib are advertised to newly connected peer
50 Suite Setup Setup_Everything
51 Suite Teardown Teardown_Everything
52 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
53 Test Teardown FailFast.Start_Failing_Fast_If_This_Failed
54 Library OperatingSystem
55 Library SSHLibrary timeout=10s
56 Library RequestsLibrary
57 Resource ../../../libraries/BGPcliKeywords.robot
58 Resource ../../../libraries/FailFast.robot
59 Resource ../../../libraries/KillPythonTool.robot
60 Resource ../../../libraries/TemplatedRequests.robot
61 Resource ../../../libraries/SetupUtils.robot
62 Resource ../../../libraries/SSHKeywords.robot
63 Resource ../../../libraries/WaitForFailure.robot
64 Resource ../../../variables/Variables.robot
67 ${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpuser/
68 ${TOOLS_SYSTEM_PROMPT} ${DEFAULT_LINUX_PROMPT}
70 ${BGP_PEER_LOG_LEVEL} debug
71 ${BGP_APP_PEER_LOG_LEVEL} debug
73 ${ODL_BGP_LOG_LEVEL} DEFAULT
74 ${BGP_PEER_COMMAND} python 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} python 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}
78 ${BGP_APP_PEER_PUT_COMMAND} python 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}
79 ${BGP_APP_PEER_DELETE_COMMAND} python 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}
80 ${BGP_APP_PEER_DELETE_ALL_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command delete-all --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
81 ${BGP_APP_PEER_GET_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command get --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
82 ${BGP_APP_PEER_OPTIONS} &>/dev/null
83 ${BGP_APP_PEER_TIMEOUT} 30s
84 ${BGP_PEER_APP_NAME} example-bgp-peer-app
85 ${CONFIG_SESSION} session
86 ${RIB_INSTANCE} example-bgp-rib
87 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
88 ${DEVICE_NAME} controller-config
89 ${BGP_PEER_NAME} example-bgp-peer
90 ${RIB_INSTANCE} example-bgp-rib
91 ${SCRIPT_URI_OPT} --uri config/bgp-rib:application-rib/${ODL_SYSTEM_IP}/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/
94 Reconfigure_ODL_To_Accept_BGP_Peer_Connection
95 [Documentation] Configure BGP peer module with initiate-connection set to false.
97 &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
98 ... INITIATE=false BGP_RIB=${RIB_INSTANCE} PASSIVE_MODE=true BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} RIB_INSTANCE_NAME=${RIB_INSTANCE}
99 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}${/}bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
101 Reconfigure_ODL_To_Accept_BGP_Application_Peer
102 [Documentation] Configure BGP application peer module.
104 &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_APP_NAME} RIB_INSTANCE_NAME=${RIB_INSTANCE} IP=${BGP_APP_PEER_ID} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
105 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer mapping=${mapping} session=${CONFIG_SESSION}
107 Check_For_Empty_Example-IPv4-Topology
108 [Documentation] Sanity check example-ipv4-topology is up but empty.
110 Wait_For_Topology_To_Change_To empty_topology timeout=180s
112 TC1_BGP_Application_Peer_Post_3_Initial_Routes
113 [Documentation] Start BGP application peer tool and give it ${BGP_APP_PEER_TIMEOUT}
115 Switch_To_BGP_Application_Peer_Console
116 Start_Console_Tool ${BGP_APP_PEER_POST_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
117 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
118 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_initial_post_tc1.log
120 TC1_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
121 [Documentation] See new routes in example-ipv4-topology as a proof that synchronization was correct.
123 Wait_For_Topology_To_Change_To filled_topology
126 [Documentation] Start BGP peer tool
128 Switch_To_BGP_Peer_Console
129 Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
130 Read_And_Fail_If_Prompt_Is_Seen
132 TC1_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
133 [Documentation] Check incomming updates for new routes
135 Switch_To_BGP_Peer_Console
136 BuiltIn.Wait_Until_Keyword_Succeeds 60s 1s Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
137 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.0/28 1
138 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.16/28 1
139 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.32/28 1
140 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 0
141 [Teardown] Report_Failure_Due_To_Bug 4714
143 TC1_BGP_Application_Peer_Delete_3_Initial_Routes
144 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
146 Switch_To_BGP_Application_Peer_Console
147 Start_Console_Tool ${BGP_APP_PEER_DELETE_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
148 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
149 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_delete_tc1.log
151 TC1_Check_Example-IPv4-Topology_Is_Empty
152 [Documentation] See new routes are deleted.
154 Wait_For_Topology_To_Change_To empty_topology
156 TC1_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
157 [Documentation] Check incomming updates for new routes
159 Switch_To_BGP_Peer_Console
160 BuiltIn.Wait_Until_Keyword_Succeeds 60s 1s Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 3
161 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.0/28 1
162 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.16/28 1
163 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.32/28 1
164 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
165 [Teardown] Report_Failure_Due_To_Bug 4714
168 [Documentation] Stop BGP peer tool
170 Switch_To_BGP_Peer_Console
172 Store_File_To_Workspace bgp_peer.log bgp_peer_tc1.log
174 TC2_Reconnect_BGP_Peer
175 [Documentation] Start BGP peer tool
177 Switch_To_BGP_Peer_Console
178 Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
179 Read_And_Fail_If_Prompt_Is_Seen
180 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 0
181 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 0
183 TC2_BGP_Application_Peer_Put_3_Routes
184 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
186 Switch_To_BGP_Application_Peer_Console
187 Start_Console_Tool ${BGP_APP_PEER_PUT_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
188 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
189 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_put_tc2.log
191 TC2_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
192 [Documentation] See new routes in example-ipv4-topology as a proof that synchronization was correct.
194 Wait_For_Topology_To_Change_To filled_topology
196 TC2_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
197 [Documentation] Check incomming updates for new routes
199 Switch_To_BGP_Peer_Console
200 BuiltIn.Wait_Until_Keyword_Succeeds 60s 1s Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
201 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.0/28 1
202 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.16/28 1
203 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.32/28 1
204 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 0
206 TC2_BGP_Application_Peer_Delete_All_Routes
207 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
209 Switch_To_BGP_Application_Peer_Console
210 Start_Console_Tool ${BGP_APP_PEER_DELETE_ALL_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
211 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
212 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_delete_all_tc2.log
214 TC2_Check_Example-IPv4-Topology_Is_Empty
215 [Documentation] See new routes are deleted.
217 Wait_For_Topology_To_Change_To empty_topology
219 TC2_BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
220 [Documentation] Check incomming updates for new routes
222 Switch_To_BGP_Peer_Console
223 BuiltIn.Wait_Until_Keyword_Succeeds 60s 1s Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 3
224 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.0/28 1
225 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.16/28 1
226 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.32/28 1
227 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
230 [Documentation] Stop BGP peer tool
232 Switch_To_BGP_Peer_Console
234 Store_File_To_Workspace bgp_peer.log bgp_peer_tc2.log
236 TC3_BGP_Application_Peer_Put_3_Routes
237 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
239 Switch_To_BGP_Application_Peer_Console
240 Start_Console_Tool ${BGP_APP_PEER_PUT_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
241 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
242 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_put_tc3.log
244 TC3_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
245 [Documentation] See new routes in example-ipv4-topology as a proof that synchronization was correct.
247 Wait_For_Topology_To_Change_To filled_topology
249 TC3_Reconnect_BGP_Peer_And_Check_Incomming_Updates_For_3_Introduced_Prefixes
250 [Documentation] Start BGP peer tool
252 Switch_To_BGP_Peer_Console
253 Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
254 Read_And_Fail_If_Prompt_Is_Seen
255 BuiltIn.Wait_Until_Keyword_Succeeds 60s 1s Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
256 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
257 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.0/28 1
258 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.16/28 1
259 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 8.0.1.32/28 1
260 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 0
262 TC3_BGP_Application_Peer_Delete_All_Routes
263 [Documentation] Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
265 Switch_To_BGP_Application_Peer_Console
266 Start_Console_Tool ${BGP_APP_PEER_DELETE_ALL_COMMAND} ${SCRIPT_URI_OPT} ${BGP_APP_PEER_OPTIONS}
267 Wait_Until_Console_Tool_Finish ${BGP_APP_PEER_TIMEOUT}
268 Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_delete_all_tc3.log
270 TC3_Check_Example-IPv4-Topology_Is_Empty
271 [Documentation] See new routes are deleted.
273 Wait_For_Topology_To_Change_To empty_topology
275 TC3_BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
276 [Documentation] Check incomming updates for new routes
278 Switch_To_BGP_Peer_Console
279 BuiltIn.Wait_Until_Keyword_Succeeds 60s 1s Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 3
280 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.0/28 1
281 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.16/28 1
282 Check_File_For_Word_Count bgp_peer.log withdrawn_prefix_received: 8.0.1.32/28 1
283 Check_File_For_Word_Count bgp_peer.log nlri_prefix_received: 3
286 [Documentation] Stop BGP peer tool
288 Switch_To_BGP_Peer_Console
290 Store_File_To_Workspace bgp_peer.log bgp_peer_tc3.log
292 Delete_Bgp_Peer_Configuration
293 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
295 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
296 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}${/}bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
298 Delete_Bgp_Application_Peer_Configuration
299 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
301 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_APP_NAME} IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
302 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer mapping=${mapping} session=${CONFIG_SESSION}
306 [Documentation] Initialize SetupUtils. SSH-login to mininet machine, create HTTP session,
307 ... put Python tool to mininet machine, setup imported resources.
308 SetupUtils.Setup_Utils_For_Setup_And_Teardown
309 SSHLibrary.Set_Default_Configuration prompt=${TOOLS_SYSTEM_PROMPT}
310 Open_BGP_Peer_Console
311 SSHKeywords.Require_Python
312 SSHKeywords.Assure_Library_Ipaddr target_dir=.
313 SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/play.py
314 Open_BGP_Aplication_Peer_Console
315 SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/bgp_app_peer.py
316 SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/ipv4-routes-template.xml*
317 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
318 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${ODL_LOG_LEVEL}
319 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.bgpcep
320 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.protocol
323 [Documentation] Make sure Python tool was killed.
324 ... Tear down imported Resources.
325 KillPythonTool.Search_And_Kill_Remote_Python 'play\.py'
326 KillPythonTool.Search_And_Kill_Remote_Python 'bgp_app_peer\.py'
327 RequestsLibrary.Delete_All_Sessions
328 SSHLibrary.Close_All_Connections
330 Open_BGP_Peer_Console
331 [Documentation] Create a session for BGP peer.
332 SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=bgp_peer_console
333 SSHKeywords.Flexible_Mininet_Login
335 Open_BGP_Aplication_Peer_Console
336 [Documentation] Create a session for BGP peer.
337 SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=bgp_app_peer_console
338 SSHKeywords.Flexible_Mininet_Login
340 Switch_To_BGP_Peer_Console
341 SSHLibrary.Switch Connection bgp_peer_console
343 Switch_To_BGP_Application_Peer_Console
344 SSHLibrary.Switch Connection bgp_app_peer_console
346 Wait_For_Topology_To_Change_To
347 [Arguments] ${folder_name} ${timeout}=10s ${refresh}=1s
348 [Documentation] Wait until Compare_Topology matches expected result.
349 BuiltIn.Wait_Until_Keyword_Succeeds ${timeout} ${refresh} Compare_Topology ${folder_name}
351 Verify_That_Topology_Does_Not_Change_From
352 [Arguments] ${folder_name} ${timeout}=10s ${refresh}=1s
353 [Documentation] Verify that Compare_Topology keeps passing, it will hold its last result.
354 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout ${timeout} ${refresh} Compare_Topology ${folder_name}
357 [Arguments] ${folder_name}
358 [Documentation] Get current example-ipv4-topology as json, and compare it to expected result.
359 TemplatedRequests.Get_As_Json_Templated ${BGP_VARIABLES_FOLDER}${/}${folder_name} session=${CONFIG_SESSION} verify=True