2 Documentation Functional test for bgp - route-target-constrain safi
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 ... This suite tests advertising rt-constrain routes to odl. For advertising from peer,
11 ... play.py is used, sending hex messages to odl.
12 ... There are 3 peers: ebgp and two ibgps. First peer sends l3vpn route with specific RT to odl, second peer
13 ... sends RT route and third peer only establishes connection. Then it is checked that odl advertizes l3vpn route
14 ... to second peer. Third peer sends wildcard RT route and it is checked that odl doesn't advertize l3vpn route
15 ... to it. Then second peer removes RT and it is checked that second peer withdrew RT route and that odl withdrew
16 ... l3vpn route from it.
18 Library RequestsLibrary
21 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8002 WITH NAME BgpRpcClient2
22 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8003 WITH NAME BgpRpcClient3
23 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8004 WITH NAME BgpRpcClient4
24 Resource ../../../libraries/BGPcliKeywords.robot
25 Resource ../../../libraries/BgpOperations.robot
26 Resource ../../../libraries/BGPSpeaker.robot
27 Resource ../../../libraries/SetupUtils.robot
28 Resource ../../../libraries/SSHKeywords.robot
29 Resource ../../../libraries/TemplatedRequests.robot
30 Resource ../../../libraries/TemplatedRequests.robot
31 Resource ../../../variables/Variables.robot
33 Suite Setup Start_Suite
34 Suite Teardown Stop_Suite
35 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
40 ${CONFIG_SESSION} config-session
41 ${RT_CONSTRAIN_DIR} ${CURDIR}/../../../variables/bgpfunctional/rt_constrain
42 ${EBGP_DIR} ${CURDIR}/../../../variables/bgpfunctional/ebgp_peer
43 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
44 ${RIB_NAME} example-bgp-rib
48 ${OLD_AS_PATH} \n"as-path": {},
49 ${NEW_AS_PATH} ${EMPTY}
50 @{BGP_PEER_TYPES} external internal internal
51 @{BGP_PEER_AS_NUMBERS} 65000 64496 64496
52 @{ODL_IP_INDICES_ALL} 2 3 4
53 @{L3VPN_RT_CHECK} false true false
54 &{RT_CONSTRAIN_APP_PEER} IP=${ODL_SYSTEM_IP} BGP_RIB=${RIB_NAME}
55 &{ADJ_RIB_OUT} PATH=peer\=bgp:%2F%2F${ODL_3_IP}/adj-rib-out BGP_RIB=${RIB_NAME}
59 Reconfigure_ODL_To_Accept_Connection
60 [Documentation] Configures BGP peer module with initiate-connection set to false.
61 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
62 FOR ${i} ${type} IN ZIP ${ODL_IP_INDICES_ALL} ${BGP_PEER_TYPES}
63 &{ODL_CONFIG} = BuiltIn.Create_Dictionary
66 ... HOLDTIME=${HOLDTIME}
67 ... PEER_PORT=${BGP_TOOL_PORT}
69 ... BGP_RIB=${RIB_NAME}
71 TemplatedRequests.Put_As_Xml_Templated ${EBGP_DIR} mapping=${ODL_CONFIG} session=${CONFIG_SESSION}
75 [Documentation] Start Python speaker to connect to ODL. We give each speaker time until odl really starts to accept incoming
76 ... bgp connection. The failure happens if the incoming connection comes too quickly after configuring the peer.
78 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
79 FOR ${i} ${as_number} IN ZIP ${ODL_IP_INDICES_ALL} ${BGP_PEER_AS_NUMBERS}
80 BuiltIn.Log_Many IP: ${ODL_${i}_IP} as_number: ${as_number}
81 Start_Bgp_Peer ${ODL_${i}_IP} ${as_number} 800${i} play.py.090.${i}
84 Play_To_Odl_ext_l3vpn_rt_arg
85 [Documentation] This TC sends route-target route containing route-target argument from node 1 to odl
86 ... so odl can identify this peer as appropriate for advertizement when it recieves such route.
87 Play_To_Odl_Non_Removal_BgpRpcClient2 ext_l3vpn_rt_arg ${RT_CONSTRAIN_DIR}
88 &{effective_rib_in} = BuiltIn.Create_Dictionary
89 ... PATH=peer\=bgp:%2F%2F${ODL_2_IP}/effective-rib-in
90 ... BGP_RIB=${RIB_NAME}
91 ... AS_PATH=${AS_PATH}
92 BuiltIn.Wait_Until_Keyword_Succeeds
95 ... TemplatedRequests.Get_As_Json_Templated
96 ... ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/rib
97 ... mapping=${effective_rib_in}
98 ... session=${CONFIG_SESSION}
101 Play_To_Odl_rt_constrain_type_0
102 [Documentation] Sends RT route from node 2 to odl and then checks that odl advertizes l3vpn route from previous TC.
103 Play_To_Odl_Non_Removal_BgpRpcClient3 rt_constrain_type_0 ${RT_CONSTRAIN_DIR}
104 &{loc_rib} = BuiltIn.Create_Dictionary PATH=loc-rib BGP_RIB=${RIB_NAME} AS_PATH=${AS_PATH}
105 BuiltIn.Wait_Until_Keyword_Succeeds
108 ... TemplatedRequests.Get_As_Json_Templated
109 ... ${RT_CONSTRAIN_DIR}/rt_constrain_type_0/rib
110 ... mapping=${loc_rib}
111 ... session=${CONFIG_SESSION}
114 Check_Presence_Of_l3vpn_Route_In_Node_2_Effective_Rib_In_Table
115 [Documentation] Checks l3vpn route is present in node 2 effective-rib-in table.
116 BuiltIn.Wait_Until_Keyword_Succeeds
119 ... TemplatedRequests.Get_As_Json_Templated
120 ... ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/rib
121 ... mapping=${ADJ_RIB_OUT}
122 ... session=${CONFIG_SESSION}
125 Check_l3vpn_Route_Advertisement_On_Each_Node
126 [Documentation] Checks that each node received or did not receive update message containing given hex message.
127 ${announce} = OperatingSystem.Get_File ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/announce_ext_l3vpn_rt_arg.hex
128 ${announce_hex} = String.Remove_String ${announce} \n
129 Check_For_L3VPN_Odl_Avertisement ${announce_hex}
131 Play_To_Odl_rt_constrain_type_1
132 [Documentation] Sends RT route from node 3 to odl and then checks that odl does not advertize l3vpn route from previous TC,
133 ... that is that update message is empty.
134 Play_To_Odl_Non_Removal_BgpRpcClient4 rt_constrain_type_1 ${RT_CONSTRAIN_DIR}
135 &{effective_rib_in} = BuiltIn.Create_Dictionary
136 ... PATH=peer\=bgp:%2F%2F${ODL_4_IP}/effective-rib-in
137 ... BGP_RIB=${RIB_NAME}
138 ... AS_PATH=${AS_PATH}
139 BuiltIn.Wait_Until_Keyword_Succeeds
142 ... TemplatedRequests.Get_As_Json_Templated
143 ... ${RT_CONSTRAIN_DIR}/rt_constrain_type_1/rib
144 ... mapping=${effective_rib_in}
145 ... session=${CONFIG_SESSION}
147 ${update} = BgpRpcClient4.play_get
148 Comment From neon onwards there is extra BGP End-Of-RIB message
149 CompareStream.Run_Keyword_If_At_Most_Fluorine BuiltIn.Should_Be_Equal ${update} ${Empty}
151 Play_To_Odl_remove_rt
152 [Documentation] Removes RT from odl and then checks that second node withdrew l3vpn route and third node did not receive any message.
153 BgpRpcClient3.play_clean
154 Play_To_Odl_Routes_Removal_Template_BgpRpcClient3 rt_constrain_type_0 ${RT_CONSTRAIN_DIR}
155 Comment From neon onwards there is extra BGP End-Of-RIB message
156 CompareStream.Run_Keyword_If_At_Most_Fluorine
157 ... BuiltIn.Wait_Until_Keyword_Succeeds
160 ... Verify_Empty_Reported_Data
161 ${update} = BgpRpcClient4.play_get
162 Comment From neon onwards there is extra BGP End-Of-RIB message
163 CompareStream.Run_Keyword_If_At_Most_Fluorine BuiltIn.Should_Be_Equal ${update} ${Empty}
165 Play_To_Odl_remove_routes
166 [Documentation] Removes rt arguments from odl.
167 Play_To_Odl_Routes_Removal_Template_BgpRpcClient2 ext_l3vpn_rt_arg ${RT_CONSTRAIN_DIR}
168 Play_To_Odl_Routes_Removal_Template_BgpRpcClient4 rt_constrain_type_1 ${RT_CONSTRAIN_DIR}
170 Kill_Talking_BGP_Speakers
171 [Documentation] Abort all Python speakers.
172 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
173 BGPcliKeywords.Store_File_To_Workspace play.py.090.2 090_rt_constrain_play_1.log
174 BGPcliKeywords.Store_File_To_Workspace play.py.090.3 090_rt_constrain_play_2.log
175 BGPcliKeywords.Store_File_To_Workspace play.py.090.4 090_rt_constrain_play_3.log
176 BGPSpeaker.Kill_All_BGP_Speakers
178 Delete_Bgp_Peers_Configuration
179 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
180 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
181 FOR ${i} ${type} IN ZIP ${ODL_IP_INDICES_ALL} ${BGP_PEER_TYPES}
182 &{ODL_CONFIG} = BuiltIn.Create_Dictionary
183 ... IP=${ODL_${i}_IP}
185 ... HOLDTIME=${HOLDTIME}
186 ... PEER_PORT=${BGP_TOOL_PORT}
188 ... BGP_RIB=${RIB_NAME}
189 ... PASSIVE_MODE=true
190 TemplatedRequests.Delete_Templated ${EBGP_DIR} mapping=${ODL_CONFIG} session=${CONFIG_SESSION}
196 [Documentation] Initialize SetupUtils. Suite setup keyword.
197 SetupUtils.Setup_Utils_For_Setup_And_Teardown
198 ${conn_id} = SSHLibrary.Open Connection ${ODL_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
199 Builtin.Set_Suite_Variable ${conn_id}
200 SSHKeywords.Flexible_Controller_Login
201 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
202 SSHLibrary.Put_File ${PLAY_SCRIPT} .
203 SSHKeywords.Assure_Library_Ipaddr target_dir=.
204 ${AS_PATH} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH}
205 BuiltIn.Set_Suite_Variable ${AS_PATH}
208 [Documentation] Suite teardown keyword
209 SSHLibrary.Close_All_Connections
210 RequestsLibrary.Delete_All_Sessions
213 [Documentation] Starts bgp peer.
214 [Arguments] ${ip} ${as_number} ${port} ${filename}
215 ${command} = BuiltIn.Set_Variable
216 ... python3 play.py --amount 0 --myip=${ip} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --asnumber=${as_number} --peerport=${ODL_BGP_PORT} --port=${port} --usepeerip --debug --allf --wfr 1 &> ${filename} &
217 BuiltIn.Log ${command}
218 ${output} = SSHLibrary.Write ${command}
220 Play_To_Odl_Non_Removal_BgpRpcClient2
221 [Documentation] Read contents of file ${dir}/${totest}/announce_${totest}.hex and send it to odl.
222 [Arguments] ${totest} ${dir} ${ipv}=ipv4
223 ${announce_hex} = OperatingSystem.Get_File ${dir}/${totest}/announce_${totest}.hex
224 BgpRpcClient2.play_send ${announce_hex}
226 Play_To_Odl_Non_Removal_BgpRpcClient3
227 [Documentation] Read contents of file ${dir}/${totest}/announce_${totest}.hex and send it to odl.
228 [Arguments] ${totest} ${dir} ${ipv}=ipv4
229 ${announce_hex} = OperatingSystem.Get_File ${dir}/${totest}/announce_${totest}.hex
230 BgpRpcClient3.play_send ${announce_hex}
232 Play_To_Odl_Non_Removal_BgpRpcClient4
233 [Documentation] Read contents of file ${dir}/${totest}/announce_${totest}.hex and send it to odl.
234 [Arguments] ${totest} ${dir} ${ipv}=ipv4
235 ${announce_hex} = OperatingSystem.Get_File ${dir}/${totest}/announce_${totest}.hex
236 BgpRpcClient4.play_send ${announce_hex}
238 Play_To_Odl_Routes_Removal_Template_BgpRpcClient2
239 [Documentation] Read contents of file ${dir}/${totest}/withdraw_${totest}.hex and send it to odl to remove rt argument from odl.
240 [Arguments] ${totest} ${dir} ${ipv}=ipv4
241 ${withdraw_hex} = OperatingSystem.Get_File ${dir}/${totest}/withdraw_${totest}.hex
242 BgpRpcClient2.play_clean
243 BgpRpcClient2.play_send ${withdraw_hex}
245 Play_To_Odl_Routes_Removal_Template_BgpRpcClient3
246 [Documentation] Read contents of file ${dir}/${totest}/withdraw_${totest}.hex and send it to odl to remove rt argument from odl.
247 [Arguments] ${totest} ${dir} ${ipv}=ipv4
248 ${withdraw_hex} = OperatingSystem.Get_File ${dir}/${totest}/withdraw_${totest}.hex
249 BgpRpcClient3.play_clean
250 BgpRpcClient3.play_send ${withdraw_hex}
252 Play_To_Odl_Routes_Removal_Template_BgpRpcClient4
253 [Documentation] Read contents of file ${dir}/${totest}/withdraw_${totest}.hex and send it to odl to remove rt argument from odl.
254 [Arguments] ${totest} ${dir} ${ipv}=ipv4
255 ${withdraw_hex} = OperatingSystem.Get_File ${dir}/${totest}/withdraw_${totest}.hex
256 BgpRpcClient4.play_clean
257 BgpRpcClient4.play_send ${withdraw_hex}
259 Get_Update_Message_And_Compare_With_Hex_BgpRpcClient2
260 [Documentation] Returns hex update message and compares it to hex.
261 [Arguments] ${hex} ${option}
262 ${update} = BgpRpcClient2.play_get
263 IF "${option}" == "true"
264 BuiltIn.Should_Be_Equal_As_Strings ${update} ${hex}
266 IF "${option}" == "false"
267 BuiltIn.Should_Not_Be_Equal_As_Strings ${update} ${hex}
270 Get_Update_Message_And_Compare_With_Hex_BgpRpcClient3
271 [Documentation] Returns hex update message and compares it to hex.
272 [Arguments] ${hex} ${option}
273 ${update} = BgpRpcClient3.play_get
274 IF "${option}" == "true"
275 BuiltIn.Should_Be_Equal_As_Strings ${update} ${hex}
277 IF "${option}" == "false"
278 BuiltIn.Should_Not_Be_Equal_As_Strings ${update} ${hex}
281 Get_Update_Message_And_Compare_With_Hex_BgpRpcClient4
282 [Documentation] Returns hex update message and compares it to hex.
283 [Arguments] ${hex} ${option}
284 ${update} = BgpRpcClient4.play_get
285 IF "${option}" == "true"
286 BuiltIn.Should_Be_Equal_As_Strings ${update} ${hex}
288 IF "${option}" == "false"
289 BuiltIn.Should_Not_Be_Equal_As_Strings ${update} ${hex}
292 Check_For_L3VPN_Odl_Avertisement
293 [Documentation] Checks that each node received or did not receive update message containing given hex message.
294 [Arguments] ${announce_hex}
295 FOR ${i} ${option} IN ZIP ${ODL_IP_INDICES_ALL} ${L3VPN_RT_CHECK}
296 ${keyword_name} = BuiltIn.Set_Variable Get_Update_Message_And_Compare_With_Hex_BgpRpcClient${i}
297 BuiltIn.Run_Keyword ${keyword_name} ${announce_hex} ${option}
301 [Documentation] Verifies expected response
302 [Arguments] ${url} ${exprspfile}
303 ${expresponse} = OperatingSystem.Get File ${exprspfile}
304 BuiltIn.Log expected_response: ${expresponse}
305 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${url}
306 BuiltIn.Log actual_response: ${rsp}
307 BuiltIn.Log actual_response_content: ${rsp.content}
308 TemplatedRequests.Normalize_Jsons_And_Compare ${expresponse} ${rsp.content}
310 Verify_Empty_Reported_Data
311 [Documentation] Verify empty data response
312 TemplatedRequests.Get_As_Json_Templated
313 ... ${RT_CONSTRAIN_DIR}${/}empty_l3vpn
314 ... session=${CONFIG_SESSION}
315 ... mapping=${ADJ_RIB_OUT}
318 Verify_Empty_Data_Neon
319 [Documentation] Verify empty data on neon
320 TemplatedRequests.Get_As_Json_Templated
321 ... ${RT_CONSTRAIN_DIR}${/}empty_route
322 ... session=${CONFIG_SESSION}
323 ... mapping=${ADJ_RIB_OUT}