2 Documentation Functional test for bgp - graceful-restart
4 ... Copyright (c) 2018 AT&T Intellectual Property. 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 distbmution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
10 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8001 WITH NAME BgpRpcClient1
11 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8002 WITH NAME BgpRpcClient2
12 Library OperatingSystem
13 Library RequestsLibrary
16 Resource ../../../libraries/BGPcliKeywords.robot
17 Resource ../../../libraries/BgpOperations.robot
18 Resource ../../../libraries/BGPSpeaker.robot
19 Resource ../../../libraries/SetupUtils.robot
20 Resource ../../../libraries/SSHKeywords.robot
21 Resource ../../../libraries/TemplatedRequests.robot
22 Resource ../../../variables/Variables.robot
24 Suite Setup Start_Suite
25 Suite Teardown Stop_Suite
26 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
31 ${RIB_NAME} example-bgp-rib
32 ${CONFIG_SESSION} config-session
33 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
34 ${GR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional/graceful_restart
41 ${FIRST_PREFIX} 8.1.0.0
42 ${SECOND_PREFIX} 8.2.0.0
48 Verify_Empty_Rib_After_Graceful_Restart_Timer_Expired
49 [Documentation] Prerequistes: One peer with one route running.
50 ... Verify peer route is present in odl's loc-rib.
51 ... Kill bgp speaker. After graceful-restart restart-time runs out, route must not be
52 ... present in odl's loc-rib.
54 Verify_Routes dir=ipv4_1
55 Kill_Talking_BGP_Speakers log_name=gr_tc0.out
56 Verify_Routes retry=10x
57 [Teardown] Teardown_TC gr_tc0.out
59 Verify_Route_Was_Kept_After_Peer_Restart
60 [Documentation] Prerequistes: One peer with one route was just killed.
61 ... Restart killed peer with the same route.
62 ... Verify that route is still present in loc-rib.
63 ... Verify odl advertised end-of-rib message with appropriate flags.
65 Start_Bgp_Peer grace=3 log_name=gr_tc1.out
66 Verify_Routes dir=ipv4_1
67 Verify_Hex_Message tc1
68 [Teardown] Teardown_TC gr_tc1.out
70 Verify_Change_In_Amount_Of_Routes_After_Peer_Restart
71 [Documentation] Prerequistes: One peer with two routes was just killed.
72 ... Restart killed peer with just one route. Verify only one route is present in loc-rib.
74 Start_Bgp_Peer grace=2 log_name=gr_tc2.out
75 Verify_Routes dir=ipv4_1
76 [Teardown] Teardown_TC gr_tc2.out
78 Verify_Odl_Advertisment_Of_New_Route_After_Peer_Restart
79 [Documentation] Prerequistes: One peer with one route, was just killed. Second is still running with one route.
80 ... Restart killed peer with two routes. Verify that two routes from restarted peer and one route
81 ... from second peer is in loc-rib. Verify odl advertised update message to second peer with new route
82 ... and appropriate end-of-rib message.
84 Start_Bgp_Peer amount=2 grace=2
85 Verify_Hex_Message tc3
86 Verify_Routes dir=ipv4_2_1
87 [Teardown] Teardown_TC gr_tc3.out
89 Verify_Odl_Kept_Route_After_Odl_Restart
90 [Documentation] Prerequistes: One peer with one route running.
91 ... Graceful-restart odl. Close tcp connection from peer side and reopen it.
92 ... Send end-of-rib with all 0 flags, and expect the route still in loc-rib.
93 ... Verify end-of-rib message from odl with all flags set to 1.
96 Kill_Talking_BGP_Speakers
97 Start_Bgp_Peer grace=0 log_name=gr_tc4.out
98 Verify_Hex_Message tc4
99 Verify_Routes dir=ipv4_1
100 [Teardown] Teardown_TC gr_tc4.out
102 Verify_Odl_Accepted_Routes_After_Odl_Restart
103 [Documentation] Prerequistes: One peer with one route running.
104 ... Graceful-restart odl. Close tcp connection from peer side and reopen it.
105 ... Start bgp peer with two routes, and send end-of-rib message with ipv4 flag
106 ... set to 1. Verify loc-rib and end-of-rib message from odl.
108 Post_Graceful_Restart
109 Kill_Talking_BGP_Speakers
110 Start_Bgp_Peer amount=2 grace=2 log_name=gr_tc5.out
111 Verify_Hex_Message tc5
112 Verify_Routes dir=ipv4_2
113 [Teardown] Teardown_TC gr_tc5.out
115 Verify_No_Ipv6_Route_Immediately_After_Peer_Was_Killed
116 [Documentation] Prerequistes: One peer with one ipv4 route and one ipv6 route running.
117 ... Kill the speaker. And Verify that there is ipv4 route still present, but ipv6 rib should be empty
118 ... because it had no graceful-restart ability configured.
120 Kill_Talking_BGP_Speakers
121 Verify_Routes dir=ipv4_1
122 Verify_Routes dir=empty_ipv6_route interval=1s
123 [Teardown] Teardown_TC gr_tc6.out
128 [Documentation] Initialize SetupUtils. Suite setup keyword.
129 ... Copies play.py script for peer simulation onto ODL VM.
130 ... Configures peers on odl with graceful-restart enabled.
131 SetupUtils.Setup_Utils_For_Setup_And_Teardown
132 SSHLibrary.Open Connection ${ODL_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
133 SSHKeywords.Flexible_Controller_Login
134 SSHLibrary.Put_File ${PLAY_SCRIPT} .
135 SSHKeywords.Assure_Library_Ipaddr target_dir=.
136 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
140 [Documentation] Delete peer configuration, close all remaining ssh and http sessions.
141 Delete_Bgp_Peers_Configuration
142 SSHLibrary.Close_All_Connections
143 RequestsLibrary.Delete_All_Sessions
146 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
147 ... Start one bgp peer with one routes.
148 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
149 Start_Bgp_Peer log_name=gr_tc0.out
152 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
153 ... Start one bgp peer with one routes, and verify routes is present in loc-rib.
154 ... Kill bgp speaker (effectively simulating graceful-restart)
155 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
157 Verify_Routes dir=ipv4_1
158 Kill_Talking_BGP_Speakers
161 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
162 ... Start one bgp peer with two routes, and verify routes are present in loc-rib.
163 ... Kill bgp speaker (effectively simulating graceful-restart)
164 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
165 Start_Bgp_Peer amount=2
166 Verify_Routes dir=ipv4_2
167 Kill_Talking_BGP_Speakers
170 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
171 ... Start two bgp peers, each with their default values, and verify their respective routes
172 ... are present in loc-rib, than kill the first bgp speaker (effectively simulating graceful-restart)
173 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
175 ... prefix=${SECOND_PREFIX}
177 ... port=${PEER2_PORT}
178 ... as_number=${PEER2_AS}
179 ... log_name=gr_tc3.out
180 Start_Bgp_Peer multiple=${EMPTY}
181 Verify_Routes dir=ipv4_1_1
182 BGPSpeaker.Kill_BGP_Speaker
185 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
186 ... Start one bgp peer, and verify it's route is present in loc-rib.
187 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
189 Verify_Routes dir=ipv4_1
192 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
193 ... Start one bgp peer with one routes, and send ipv6 route without gr configured.
194 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
195 Start_Bgp_Peer log_name=gr_tc6.out ipv6=${SPACE}--ipv6
196 ${announce_hex} = OperatingSystem.Get_File ${GR_FOLDER}${/}ipv6.hex
197 ${announce_hex} = String.Remove_String ${announce_hex} \n
198 Verify_Routes dir=ipv4_1
199 BgpRpcClient1.play_send ${announce_hex}
200 Verify_Routes dir=ipv6_1
203 [Documentation] In case Test Case failed to close Python Speakers, we close them.
204 ... Wait until there are no routes present in loc-rib.
205 [Arguments] ${log_name}=play.py.out
206 Kill_Talking_BGP_Speakers ${log_name}
207 Verify_Routes dir=empty_route retry=10x
208 Verify_Routes dir=empty_ipv6_route interval=1s
211 [Documentation] Verify route based on how many routes are present in rib.
212 [Arguments] ${dir}=empty_route ${retry}=5x ${interval}=3s
213 BuiltIn.Wait_Until_Keyword_Succeeds
216 ... TemplatedRequests.Get_As_Json_Templated
217 ... ${GR_FOLDER}${/}${dir}
218 ... session=${CONFIG_SESSION}
222 [Documentation] Verify hex message advertised from odl.
223 [Arguments] ${file_dir} ${peer}=${PEER1_IP} ${file_name}=${file_dir}.hex
224 ${expected} = TemplatedRequests.Resolve_Text_From_Template_File ${GR_FOLDER}${/}${file_dir} ${file_name}
225 ${actual} = BuiltIn.Wait_Until_Keyword_Succeeds 5x 3s Get_Hex_Message peer=${peer}
226 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${expected} ${actual}
229 [Documentation] Gets open message in case of first peer, and update message in case of second peer.
230 [Arguments] ${peer}=${PEER1_IP}
231 IF "${peer}" == "${PEER1_IP}"
232 ${hex} = BgpRpcClient1.play_get what=open
234 ${hex} = BgpRpcClient2.play_get
236 BuiltIn.Should_Not_Be_Equal ${hex} ${EMPTY}
240 [Documentation] Starts bgp peer.
241 [Arguments] ${prefix}=${FIRST_PREFIX} ${amount}=1 ${myip}=${PEER1_IP} ${port}=${PEER1_PORT} ${as_number}=${PEER1_AS} ${grace}=0
242 ... ${log_name}=play.py.out ${multiple}=& ${ipv6}=${EMPTY}
243 ${command} = BuiltIn.Set_Variable
244 ... python3 play.py${ipv6} --firstprefix ${prefix} --prefixlen ${PREFIX_LEN} --amount ${amount} --myip ${myip} --myport ${BGP_TOOL_PORT} --peerip ${ODL_SYSTEM_IP} --peerport ${ODL_BGP_PORT} --port ${port} --usepeerip --nexthop ${NEXT_HOP} --asnumber ${as_number} --debug --grace ${grace} --wfr 1 &> ${log_name} ${multiple}
245 BuiltIn.Log ${command}
246 ${output} = SSHLibrary.Write ${command}
248 Kill_Talking_BGP_Speakers
249 [Documentation] Save play.py log into workspace, attempt to dump speaker logs into robot log.
250 ... Abort all Python speakers.
251 [Arguments] ${log_name}=play.py.out
252 BuiltIn.Run_Keyword_And_Ignore_Error BGPcliKeywords.Store_File_To_Workspace ${log_name} ${log_name}.log
253 BuiltIn.Run_Keyword_And_Ignore_Error BGPSpeaker.Dump_BGP_Speaker_Logs
254 BGPSpeaker.Kill_All_BGP_Speakers
257 [Documentation] Configure two eBGP peers with graceful-restart enabled
258 [Arguments] ${folder}=${EMPTY}
259 &{mapping} = BuiltIn.Create_Dictionary
261 ... HOLDTIME=${HOLDTIME}
262 ... PEER_PORT=${BGP_TOOL_PORT}
263 ... AS_NUMBER=${PEER1_AS}
264 ... BGP_RIB=${RIB_NAME}
265 TemplatedRequests.Put_As_Xml_Templated
266 ... ${GR_FOLDER}${/}${folder}peers
267 ... mapping=${mapping}
268 ... session=${CONFIG_SESSION}
269 &{mapping} = BuiltIn.Create_Dictionary
271 ... HOLDTIME=${HOLDTIME}
272 ... PEER_PORT=${BGP_TOOL_PORT}
273 ... AS_NUMBER=${PEER2_AS}
274 ... BGP_RIB=${RIB_NAME}
275 TemplatedRequests.Put_As_Xml_Templated
276 ... ${GR_FOLDER}${/}${folder}peers
277 ... mapping=${mapping}
278 ... session=${CONFIG_SESSION}
280 Delete_Bgp_Peers_Configuration
281 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
282 &{mapping} = BuiltIn.Create_Dictionary IP=${PEER1_IP} BGP_RIB=${RIB_NAME}
283 TemplatedRequests.Delete_Templated ${GR_FOLDER}${/}peers mapping=${mapping} session=${CONFIG_SESSION}
284 &{mapping} = BuiltIn.Create_Dictionary IP=${PEER2_IP} BGP_RIB=${RIB_NAME}
285 TemplatedRequests.Delete_Templated ${GR_FOLDER}${/}peers mapping=${mapping} session=${CONFIG_SESSION}
287 Post_Graceful_Restart
288 [Documentation] Post rpc to odl, effectively restarting it.
289 [Arguments] ${ip}=${PEER1_IP}
290 &{mapping} = BuiltIn.Create_Dictionary IP=${ip} BGP_RIB=${RIB_NAME}
291 TemplatedRequests.Post_As_Xml_Templated
292 ... ${GR_FOLDER}${/}restart
293 ... mapping=${mapping}
294 ... session=${CONFIG_SESSION}