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.
17 Suite Setup Start_Suite
18 Suite Teardown Stop_Suite
19 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
20 Library RequestsLibrary
23 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8002 WITH NAME BgpRpcClient2
24 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8003 WITH NAME BgpRpcClient3
25 Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8004 WITH NAME BgpRpcClient4
26 Resource ../../../libraries/BGPcliKeywords.robot
27 Resource ../../../libraries/BgpOperations.robot
28 Resource ../../../libraries/BGPSpeaker.robot
29 Resource ../../../libraries/SetupUtils.robot
30 Resource ../../../libraries/SSHKeywords.robot
31 Resource ../../../libraries/TemplatedRequests.robot
32 Resource ../../../libraries/TemplatedRequests.robot
33 Resource ../../../variables/Variables.robot
37 ${CONFIG_SESSION} config-session
38 ${RT_CONSTRAIN_DIR} ${CURDIR}/../../../variables/bgpfunctional/rt_constrain
39 ${EBGP_DIR} ${CURDIR}/../../../variables/bgpfunctional/ebgp_peer
40 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
41 ${RIB_NAME} example-bgp-rib
45 ${OLD_AS_PATH} \n"as-path": {},
46 ${NEW_AS_PATH} ${EMPTY}
47 @{BGP_PEER_TYPES} external internal internal
48 @{BGP_PEER_AS_NUMBERS} 65000 64496 64496
49 @{ODL_IP_INDICES_ALL} 2 3 4
50 @{L3VPN_RT_CHECK} false true false
51 &{RT_CONSTRAIN_APP_PEER} IP=${ODL_SYSTEM_IP} BGP_RIB=${RIB_NAME}
52 &{ADJ_RIB_OUT} PATH=peer/bgp:%2F%2F${ODL_3_IP}/adj-rib-out BGP_RIB=${RIB_NAME}
55 Reconfigure_ODL_To_Accept_Connection
56 [Documentation] Configures BGP peer module with initiate-connection set to false.
57 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
58 : FOR ${i} ${type} IN ZIP ${ODL_IP_INDICES_ALL} ${BGP_PEER_TYPES}
59 \ &{ODL_CONFIG}= BuiltIn.Create_Dictionary IP=${ODL_${i}_IP} TYPE=${type} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
60 \ ... INITIATE=false BGP_RIB=${RIB_NAME} PASSIVE_MODE=true
61 \ TemplatedRequests.Put_As_Xml_Templated ${EBGP_DIR} mapping=${ODL_CONFIG} session=${CONFIG_SESSION}
64 [Documentation] Start Python speaker to connect to ODL. We give each speaker time until odl really starts to accept incoming
65 ... bgp connection. The failure happens if the incoming connection comes too quickly after configuring the peer.
67 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
68 : FOR ${i} ${as_number} IN ZIP ${ODL_IP_INDICES_ALL} ${BGP_PEER_AS_NUMBERS}
69 \ BuiltIn.Log_Many IP: ${ODL_${i}_IP} as_number: ${as_number}
70 \ Start_Bgp_Peer ${ODL_${i}_IP} ${as_number} 800${i} play.py.090.${i}
72 Play_To_Odl_ext_l3vpn_rt_arg
73 [Documentation] This TC sends route-target route containing route-target argument from node 1 to odl
74 ... so odl can identify this peer as appropriate for advertizement when it recieves such route.
75 Play_To_Odl_Non_Removal_BgpRpcClient2 ext_l3vpn_rt_arg ${RT_CONSTRAIN_DIR}
76 &{effective_rib_in} BuiltIn.Create_Dictionary PATH=peer/bgp:%2F%2F${ODL_2_IP}/effective-rib-in BGP_RIB=${RIB_NAME} AS_PATH=${AS_PATH}
77 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s TemplatedRequests.Get_As_Json_Templated ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/rib mapping=${effective_rib_in} session=${CONFIG_SESSION}
80 Play_To_Odl_rt_constrain_type_0
81 [Documentation] Sends RT route from node 2 to odl and then checks that odl advertizes l3vpn route from previous TC.
82 Play_To_Odl_Non_Removal_BgpRpcClient3 rt_constrain_type_0 ${RT_CONSTRAIN_DIR}
83 &{loc_rib} BuiltIn.Create_Dictionary PATH=loc-rib BGP_RIB=${RIB_NAME} AS_PATH=${AS_PATH}
84 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s TemplatedRequests.Get_As_Json_Templated ${RT_CONSTRAIN_DIR}/rt_constrain_type_0/rib mapping=${loc_rib} session=${CONFIG_SESSION}
87 Check_Presence_Of_l3vpn_Route_In_Node_2_Effective_Rib_In_Table
88 [Documentation] Checks l3vpn route is present in node 2 effective-rib-in table.
89 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s TemplatedRequests.Get_As_Json_Templated ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/rib mapping=${ADJ_RIB_OUT} session=${CONFIG_SESSION}
92 Check_l3vpn_Route_Advertisement_On_Each_Node
93 [Documentation] Checks that each node received or did not receive update message containing given hex message.
94 ${announce} = OperatingSystem.Get_File ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/announce_ext_l3vpn_rt_arg.hex
95 ${announce_hex} = String.Remove_String ${announce} \n
96 Check_For_L3VPN_Odl_Avertisement ${announce_hex}
98 Play_To_Odl_rt_constrain_type_1
99 [Documentation] Sends RT route from node 3 to odl and then checks that odl does not advertize l3vpn route from previous TC,
100 ... that is that update message is empty.
101 Play_To_Odl_Non_Removal_BgpRpcClient4 rt_constrain_type_1 ${RT_CONSTRAIN_DIR}
102 &{effective_rib_in} = BuiltIn.Create_Dictionary PATH=peer/bgp:%2F%2F${ODL_4_IP}/effective-rib-in BGP_RIB=${RIB_NAME} AS_PATH=${AS_PATH}
103 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s TemplatedRequests.Get_As_Json_Templated ${RT_CONSTRAIN_DIR}/rt_constrain_type_1/rib mapping=${effective_rib_in} session=${CONFIG_SESSION}
105 ${update} = BgpRpcClient4.play_get
106 BuiltIn.Should_Be_Equal ${update} ${Empty}
108 Play_To_Odl_remove_rt
109 [Documentation] Removes RT from odl and then checks that second node withdrew l3vpn route and third node did not receive any message.
110 BgpRpcClient3.play_clean
111 Play_To_Odl_Routes_Removal_Template_BgpRpcClient3 rt_constrain_type_0 ${RT_CONSTRAIN_DIR}
112 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Verify_Empty_Reported_Data
113 ${update} = BgpRpcClient4.play_get
114 BuiltIn.Should_Be_Equal ${update} ${Empty}
116 Play_To_Odl_remove_routes
117 [Documentation] Removes rt arguments from odl.
118 Play_To_Odl_Routes_Removal_Template_BgpRpcClient2 ext_l3vpn_rt_arg ${RT_CONSTRAIN_DIR}
119 Play_To_Odl_Routes_Removal_Template_BgpRpcClient4 rt_constrain_type_1 ${RT_CONSTRAIN_DIR}
121 Kill_Talking_BGP_Speakers
122 [Documentation] Abort all Python speakers.
123 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
124 BGPcliKeywords.Store_File_To_Workspace play.py.090.2 090_rt_constrain_play_1.log
125 BGPcliKeywords.Store_File_To_Workspace play.py.090.3 090_rt_constrain_play_2.log
126 BGPcliKeywords.Store_File_To_Workspace play.py.090.4 090_rt_constrain_play_3.log
127 BGPSpeaker.Kill_All_BGP_Speakers
129 Delete_Bgp_Peers_Configuration
130 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
131 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
132 : FOR ${i} ${type} IN ZIP ${ODL_IP_INDICES_ALL} ${BGP_PEER_TYPES}
133 \ &{ODL_CONFIG} = BuiltIn.Create_Dictionary IP=${ODL_${i}_IP} TYPE=${type} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
134 \ ... INITIATE=false BGP_RIB=${RIB_NAME} PASSIVE_MODE=true
135 \ TemplatedRequests.Delete_Templated ${EBGP_DIR} mapping=${ODL_CONFIG} session=${CONFIG_SESSION}
139 [Documentation] Initialize SetupUtils. Suite setup keyword.
140 SetupUtils.Setup_Utils_For_Setup_And_Teardown
141 ${conn_id} = SSHLibrary.Open Connection ${ODL_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
142 Builtin.Set_Suite_Variable ${conn_id}
143 SSHKeywords.Flexible_Controller_Login
144 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
145 SSHLibrary.Put_File ${PLAY_SCRIPT} .
146 SSHKeywords.Assure_Library_Ipaddr target_dir=.
147 ${AS_PATH} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH}
148 BuiltIn.Set_Suite_Variable ${AS_PATH}
151 [Documentation] Suite teardown keyword
152 SSHLibrary.Close_All_Connections
153 RequestsLibrary.Delete_All_Sessions
156 [Arguments] ${ip} ${as_number} ${port} ${filename}
157 [Documentation] Starts bgp peer.
158 ${command} = BuiltIn.Set_Variable python 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} &
159 BuiltIn.Log ${command}
160 ${output} = SSHLibrary.Write ${command}
162 Play_To_Odl_Non_Removal_BgpRpcClient2
163 [Arguments] ${totest} ${dir} ${ipv}=ipv4
164 [Documentation] Read contents of file ${dir}/${totest}/announce_${totest}.hex and send it to odl.
165 ${announce_hex} = OperatingSystem.Get_File ${dir}/${totest}/announce_${totest}.hex
166 BgpRpcClient2.play_send ${announce_hex}
168 Play_To_Odl_Non_Removal_BgpRpcClient3
169 [Arguments] ${totest} ${dir} ${ipv}=ipv4
170 [Documentation] Read contents of file ${dir}/${totest}/announce_${totest}.hex and send it to odl.
171 ${announce_hex} = OperatingSystem.Get_File ${dir}/${totest}/announce_${totest}.hex
172 BgpRpcClient3.play_send ${announce_hex}
174 Play_To_Odl_Non_Removal_BgpRpcClient4
175 [Arguments] ${totest} ${dir} ${ipv}=ipv4
176 [Documentation] Read contents of file ${dir}/${totest}/announce_${totest}.hex and send it to odl.
177 ${announce_hex} = OperatingSystem.Get_File ${dir}/${totest}/announce_${totest}.hex
178 BgpRpcClient4.play_send ${announce_hex}
180 Play_To_Odl_Routes_Removal_Template_BgpRpcClient2
181 [Arguments] ${totest} ${dir} ${ipv}=ipv4
182 [Documentation] Read contents of file ${dir}/${totest}/withdraw_${totest}.hex and send it to odl to remove rt argument from odl.
183 ${withdraw_hex} = OperatingSystem.Get_File ${dir}/${totest}/withdraw_${totest}.hex
184 BgpRpcClient2.play_clean
185 BgpRpcClient2.play_send ${withdraw_hex}
187 Play_To_Odl_Routes_Removal_Template_BgpRpcClient3
188 [Arguments] ${totest} ${dir} ${ipv}=ipv4
189 [Documentation] Read contents of file ${dir}/${totest}/withdraw_${totest}.hex and send it to odl to remove rt argument from odl.
190 ${withdraw_hex} = OperatingSystem.Get_File ${dir}/${totest}/withdraw_${totest}.hex
191 BgpRpcClient3.play_clean
192 BgpRpcClient3.play_send ${withdraw_hex}
194 Play_To_Odl_Routes_Removal_Template_BgpRpcClient4
195 [Arguments] ${totest} ${dir} ${ipv}=ipv4
196 [Documentation] Read contents of file ${dir}/${totest}/withdraw_${totest}.hex and send it to odl to remove rt argument from odl.
197 ${withdraw_hex} = OperatingSystem.Get_File ${dir}/${totest}/withdraw_${totest}.hex
198 BgpRpcClient4.play_clean
199 BgpRpcClient4.play_send ${withdraw_hex}
201 Get_Update_Message_And_Compare_With_Hex_BgpRpcClient2
202 [Arguments] ${hex} ${option}
203 [Documentation] Returns hex update message and compares it to hex.
204 ${update} = BgpRpcClient2.play_get
205 BuiltIn.Run_Keyword_If "${option}" == "true" BuiltIn.Should_Be_Equal_As_Strings ${update} ${hex}
206 BuiltIn.Run_Keyword_If "${option}" == "false" BuiltIn.Should_Not_Be_Equal_As_Strings ${update} ${hex}
208 Get_Update_Message_And_Compare_With_Hex_BgpRpcClient3
209 [Arguments] ${hex} ${option}
210 [Documentation] Returns hex update message and compares it to hex.
211 ${update} = BgpRpcClient3.play_get
212 BuiltIn.Run_Keyword_If "${option}" == "true" BuiltIn.Should_Be_Equal_As_Strings ${update} ${hex}
213 BuiltIn.Run_Keyword_If "${option}" == "false" BuiltIn.Should_Not_Be_Equal_As_Strings ${update} ${hex}
215 Get_Update_Message_And_Compare_With_Hex_BgpRpcClient4
216 [Arguments] ${hex} ${option}
217 [Documentation] Returns hex update message and compares it to hex.
218 ${update} = BgpRpcClient4.play_get
219 BuiltIn.Run_Keyword_If "${option}" == "true" BuiltIn.Should_Be_Equal_As_Strings ${update} ${hex}
220 BuiltIn.Run_Keyword_If "${option}" == "false" BuiltIn.Should_Not_Be_Equal_As_Strings ${update} ${hex}
222 Check_For_L3VPN_Odl_Avertisement
223 [Arguments] ${announce_hex}
224 [Documentation] Checks that each node received or did not receive update message containing given hex message.
225 : FOR ${i} ${option} IN ZIP ${ODL_IP_INDICES_ALL} ${L3VPN_RT_CHECK}
226 \ ${keyword_name}= BuiltIn.Set_Variable Get_Update_Message_And_Compare_With_Hex_BgpRpcClient${i}
227 \ BuiltIn.Run_Keyword ${keyword_name} ${announce_hex} ${option}
230 [Arguments] ${url} ${exprspfile}
231 [Documentation] Verifies expected response
232 ${expresponse} = OperatingSystem.Get File ${exprspfile}
233 BuiltIn.Log expected_response: ${expresponse}
234 ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${url}
235 BuiltIn.Log actual_response: ${rsp}
236 BuiltIn.Log actual_response_content: ${rsp.content}
237 TemplatedRequests.Normalize_Jsons_And_Compare ${expresponse} ${rsp.content}
239 Verify_Empty_Reported_Data
240 [Documentation] Verify empty data response
241 CompareStream.Run_Keyword_If_At_Most_Fluorine TemplatedRequests.Get_As_Json_Templated ${RT_CONSTRAIN_DIR}${/}empty_l3vpn session=${CONFIG_SESSION} mapping=${ADJ_RIB_OUT} verify=True
242 CompareStream.Run_Keyword_If_At_Least_Neon Verify_Empty_Data_Neon
244 Verify_Empty_Data_Neon
245 [Documentation] Verify empty data on neon
246 TemplatedRequests.Get_As_Json_Templated ${RT_CONSTRAIN_DIR}${/}empty_route session=${CONFIG_SESSION} mapping=${ADJ_RIB_OUT} verify=True