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
9 Suite Setup Start_Suite
10 Suite Teardown Stop_Suite
11 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
12 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8001 WITH NAME BgpRpcClient1
13 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8002 WITH NAME BgpRpcClient2
14 Library OperatingSystem
15 Library RequestsLibrary
18 Resource ../../../libraries/BGPcliKeywords.robot
19 Resource ../../../libraries/BgpOperations.robot
20 Resource ../../../libraries/BGPSpeaker.robot
21 Resource ../../../libraries/SetupUtils.robot
22 Resource ../../../libraries/SSHKeywords.robot
23 Resource ../../../libraries/TemplatedRequests.robot
24 Resource ../../../variables/Variables.robot
28 ${RIB_NAME} example-bgp-rib
29 ${CONFIG_SESSION} config-session
30 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
31 ${GR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional/graceful_restart
38 ${FIRST_PREFIX} 8.1.0.0
39 ${SECOND_PREFIX} 8.2.0.0
44 Verify_Empty_Rib_After_Graceful_Restart_Timer_Expired
45 [Documentation] Prerequistes: One peer with one route running.
46 ... Verify peer route is present in odl's loc-rib.
47 ... Kill bgp speaker. After graceful-restart restart-time runs out, route must not be
48 ... present in odl's loc-rib.
50 Verify_Routes dir=ipv4_1
51 Kill_Talking_BGP_Speakers log_name=gr_tc0.out
52 Verify_Routes retry=10x
53 [Teardown] Teardown_TC gr_tc0.out
55 Verify_Route_Was_Kept_After_Peer_Restart
56 [Documentation] Prerequistes: One peer with one route was just killed.
57 ... Restart killed peer with the same route.
58 ... Verify that route is still present in loc-rib.
59 ... Verify odl advertised end-of-rib message with appropriate flags.
61 Start_Bgp_Peer grace=3 log_name=gr_tc1.out
62 Verify_Routes dir=ipv4_1
63 Verify_Hex_Message tc1
64 [Teardown] Teardown_TC gr_tc1.out
66 Verify_Change_In_Amount_Of_Routes_After_Peer_Restart
67 [Documentation] Prerequistes: One peer with two routes was just killed.
68 ... Restart killed peer with just one route. Verify only one route is present in loc-rib.
70 Start_Bgp_Peer grace=2 log_name=gr_tc2.out
71 Verify_Routes dir=ipv4_1
72 [Teardown] Teardown_TC gr_tc2.out
74 Verify_Odl_Advertisment_Of_New_Route_After_Peer_Restart
75 [Documentation] Prerequistes: One peer with one route, was just killed. Second is still running with one route.
76 ... Restart killed peer with two routes. Verify that two routes from restarted peer and one route
77 ... from second peer is in loc-rib. Verify odl advertised update message to second peer with new route
78 ... and appropriate end-of-rib message.
80 Start_Bgp_Peer amount=2 grace=2
81 Verify_Hex_Message tc3
82 Verify_Routes dir=ipv4_2_1
83 [Teardown] Teardown_TC gr_tc3.out
85 Verify_Odl_Kept_Route_After_Odl_Restart
86 [Documentation] Prerequistes: One peer with one route running.
87 ... Graceful-restart odl. Close tcp connection from peer side and reopen it.
88 ... Send end-of-rib with all 0 flags, and expect the route still in loc-rib.
89 ... Verify end-of-rib message from odl with all flags set to 1.
92 Kill_Talking_BGP_Speakers
93 Start_Bgp_Peer grace=0 log_name=gr_tc4.out
94 Verify_Hex_Message tc4
95 Verify_Routes dir=ipv4_1
96 [Teardown] Teardown_TC gr_tc4.out
98 Verify_Odl_Accepted_Routes_After_Odl_Restart
99 [Documentation] Prerequistes: One peer with one route running.
100 ... Graceful-restart odl. Close tcp connection from peer side and reopen it.
101 ... Start bgp peer with two routes, and send end-of-rib message with ipv4 flag
102 ... set to 1. Verify loc-rib and end-of-rib message from odl.
104 Post_Graceful_Restart
105 Kill_Talking_BGP_Speakers
106 Start_Bgp_Peer amount=2 grace=2 log_name=gr_tc5.out
107 Verify_Hex_Message tc5
108 Verify_Routes dir=ipv4_2
109 [Teardown] Teardown_TC gr_tc5.out
111 Verify_No_Ipv6_Route_Immediately_After_Peer_Was_Killed
112 [Documentation] Prerequistes: One peer with one ipv4 route and one ipv6 route running.
113 ... Kill the speaker. And Verify that there is ipv4 route still present, but ipv6 rib should be empty
114 ... because it had no graceful-restart ability configured.
116 Kill_Talking_BGP_Speakers
117 Verify_Routes dir=ipv4_1
118 Verify_Routes dir=empty_ipv6_route interval=1s
119 [Teardown] Teardown_TC gr_tc6.out
123 [Documentation] Initialize SetupUtils. Suite setup keyword.
124 ... Copies play.py script for peer simulation onto ODL VM.
125 ... Configures peers on odl with graceful-restart enabled.
126 SetupUtils.Setup_Utils_For_Setup_And_Teardown
127 SSHLibrary.Open Connection ${ODL_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
128 SSHKeywords.Flexible_Controller_Login
129 SSHLibrary.Put_File ${PLAY_SCRIPT} .
130 SSHKeywords.Assure_Library_Ipaddr target_dir=.
131 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
135 [Documentation] Delete peer configuration, close all remaining ssh and http sessions.
136 Delete_Bgp_Peers_Configuration
137 SSHLibrary.Close_All_Connections
138 RequestsLibrary.Delete_All_Sessions
141 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
142 ... Start one bgp peer with one routes.
143 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
144 Start_Bgp_Peer log_name=gr_tc0.out
147 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
148 ... Start one bgp peer with one routes, and verify routes is present in loc-rib.
149 ... Kill bgp speaker (effectively simulating graceful-restart)
150 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
152 Verify_Routes dir=ipv4_1
153 Kill_Talking_BGP_Speakers
156 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
157 ... Start one bgp peer with two routes, and verify routes are present in loc-rib.
158 ... Kill bgp speaker (effectively simulating graceful-restart)
159 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
160 Start_Bgp_Peer amount=2
161 Verify_Routes dir=ipv4_2
162 Kill_Talking_BGP_Speakers
165 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
166 ... Start two bgp peers, each with their default values, and verify their respective routes
167 ... are present in loc-rib, than kill the first bgp speaker (effectively simulating graceful-restart)
168 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
169 Start_Bgp_Peer prefix=${SECOND_PREFIX} myip=${PEER2_IP} port=${PEER2_PORT} as_number=${PEER2_AS} log_name=gr_tc3.out
170 Start_Bgp_Peer multiple=${EMPTY}
171 Verify_Routes dir=ipv4_1_1
172 BGPSpeaker.Kill_BGP_Speaker
175 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
176 ... Start one bgp peer, and verify it's route is present in loc-rib.
177 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
179 Verify_Routes dir=ipv4_1
182 [Documentation] Log Test Case name into karaf log, and make sure it wont fail other TC's.
183 ... Start one bgp peer with one routes, and send ipv6 route without gr configured.
184 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
185 Start_Bgp_Peer log_name=gr_tc6.out ipv6=${SPACE}--ipv6
186 ${announce_hex} = OperatingSystem.Get_File ${GR_FOLDER}${/}ipv6.hex
187 ${announce_hex} = String.Remove_String ${announce_hex} \n
188 Verify_Routes dir=ipv4_1
189 BgpRpcClient1.play_send ${announce_hex}
190 Verify_Routes dir=ipv6_1
193 [Arguments] ${log_name}=play.py.out
194 [Documentation] In case Test Case failed to close Python Speakers, we close them.
195 ... Wait until there are no routes present in loc-rib.
196 Kill_Talking_BGP_Speakers ${log_name}
197 Verify_Routes dir=empty_route retry=10x
198 Verify_Routes dir=empty_ipv6_route interval=1s
201 [Arguments] ${dir}=empty_route ${retry}=5x ${interval}=3s
202 [Documentation] Verify route based on how many routes are present in rib.
203 BuiltIn.Wait_Until_Keyword_Succeeds ${retry} ${interval} TemplatedRequests.Get_As_Json_Templated ${GR_FOLDER}${/}${dir} session=${CONFIG_SESSION} verify=True
206 [Arguments] ${file_dir} ${peer}=${PEER1_IP} ${file_name}=${file_dir}.hex
207 [Documentation] Verify hex message advertised from odl.
208 ${expected} = TemplatedRequests.Resolve_Text_From_Template_File ${GR_FOLDER}${/}${file_dir} ${file_name}
209 ${actual} = BuiltIn.Wait_Until_Keyword_Succeeds 5x 3s Get_Hex_Message peer=${peer}
210 BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${expected} ${actual}
213 [Arguments] ${peer}=${PEER1_IP}
214 [Documentation] Gets open message in case of first peer, and update message in case of second peer.
215 ${hex} = BuiltIn.Run_Keyword_If "${peer}" == "${PEER1_IP}" BgpRpcClient1.play_get what=open
216 ... ELSE BgpRpcClient2.play_get
217 BuiltIn.Should_Not_Be_Equal ${hex} ${EMPTY}
221 [Arguments] ${prefix}=${FIRST_PREFIX} ${amount}=1 ${myip}=${PEER1_IP} ${port}=${PEER1_PORT} ${as_number}=${PEER1_AS} ${grace}=0
222 ... ${log_name}=play.py.out ${multiple}=& ${ipv6}=${EMPTY}
223 [Documentation] Starts bgp peer.
224 ${command} = BuiltIn.Set_Variable python 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}
225 BuiltIn.Log ${command}
226 ${output} = SSHLibrary.Write ${command}
228 Kill_Talking_BGP_Speakers
229 [Arguments] ${log_name}=play.py.out
230 [Documentation] Save play.py log into workspace, attempt to dump speaker logs into robot log.
231 ... Abort all Python speakers.
232 BuiltIn.Run_Keyword_And_Ignore_Error BGPcliKeywords.Store_File_To_Workspace ${log_name} ${log_name}.log
233 BuiltIn.Run_Keyword_And_Ignore_Error BGPSpeaker.Dump_BGP_Speaker_Logs
234 BGPSpeaker.Kill_All_BGP_Speakers
237 [Arguments] ${folder}=${EMPTY}
238 [Documentation] Configure two eBGP peers with graceful-restart enabled
239 &{mapping} BuiltIn.Create_Dictionary IP=${PEER1_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} AS_NUMBER=${PEER1_AS} BGP_RIB=${RIB_NAME}
240 TemplatedRequests.Put_As_Xml_Templated ${GR_FOLDER}${/}${folder}peers mapping=${mapping} session=${CONFIG_SESSION}
241 &{mapping} BuiltIn.Create_Dictionary IP=${PEER2_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} AS_NUMBER=${PEER2_AS} BGP_RIB=${RIB_NAME}
242 TemplatedRequests.Put_As_Xml_Templated ${GR_FOLDER}${/}${folder}peers mapping=${mapping} session=${CONFIG_SESSION}
244 Delete_Bgp_Peers_Configuration
245 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
246 &{mapping} BuiltIn.Create_Dictionary IP=${PEER1_IP} BGP_RIB=${RIB_NAME}
247 TemplatedRequests.Delete_Templated ${GR_FOLDER}${/}peers mapping=${mapping} session=${CONFIG_SESSION}
248 &{mapping} BuiltIn.Create_Dictionary IP=${PEER2_IP} BGP_RIB=${RIB_NAME}
249 TemplatedRequests.Delete_Templated ${GR_FOLDER}${/}peers mapping=${mapping} session=${CONFIG_SESSION}
251 Post_Graceful_Restart
252 [Arguments] ${ip}=${PEER1_IP}
253 [Documentation] Post rpc to odl, effectively restarting it.
254 &{mapping} BuiltIn.Create_Dictionary IP=${ip} BGP_RIB=${RIB_NAME}
255 TemplatedRequests.Post_As_Xml_Templated ${GR_FOLDER}${/}restart mapping=${mapping} session=${CONFIG_SESSION}