2 Documentation Functional test for bgp - route refresh
4 ... Copyright (c) 2016 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 ... This suite tests sending and receiveing route refresh message.
11 ... It uses odl and exabgp as bgp peers.
12 ... Sending route refresh message from odl is initiated via restconf.
13 ... If route refresh is received by odl, correct advertising of routes
14 ... is verified. Receiving of route refresh by odl is verified by
15 ... checking appropriate message counter via odl-bgpcep-bgp-cli and
16 ... restconf using BGP neighbor operational state
18 Library RequestsLibrary
21 Library ../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
22 Resource ../../../libraries/CompareStream.robot
23 Resource ../../../libraries/ExaBgpLib.robot
24 Resource ../../../libraries/KarafKeywords.robot
25 Resource ../../../libraries/SetupUtils.robot
26 Resource ../../../libraries/SSHKeywords.robot
27 Resource ../../../libraries/TemplatedRequests.robot
28 Resource ../../../variables/Variables.robot
30 Suite Setup Start_Suite
31 Suite Teardown Stop_Suite
32 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
36 ${APP_PEER_NAME} example-bgp-peer-app
37 ${BGP_CFG_NAME} exa.cfg
38 ${BGP_PEER_NAME} example-bgp-peer
39 ${BGP_RR_VAR_FOLDER} ${BGP_VAR_FOLDER}/route_refresh
40 ${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
41 ${CONFIG_SESSION} config-session
42 ${DEVICE_NAME} controller-config
43 ${EXARPCSCRIPT} ${CURDIR}/../../../../tools/exabgp_files/exarpc.py
45 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
46 ${RIB_INSTANCE} example-bgp-rib
47 ${MSG_STATE_OFFSET} 24
52 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
53 &{mapping} BuiltIn.Create_Dictionary
54 ... DEVICE_NAME=${DEVICE_NAME}
55 ... APP_PEER_NAME=${APP_PEER_NAME}
56 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
57 ... APP_PEER_ID=${ODL_SYSTEM_IP}
58 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
59 ... IP=${ODL_SYSTEM_IP}
60 TemplatedRequests.Put_As_Xml_Templated
61 ... ${BGP_VAR_FOLDER}/app_peer
62 ... mapping=${mapping}
63 ... session=${CONFIG_SESSION}
65 Reconfigure_ODL_To_Accept_Connection
66 [Documentation] Configures BGP peer module with initiate-connection set to false.
67 &{mapping} BuiltIn.Create_Dictionary
68 ... DEVICE_NAME=${DEVICE_NAME}
69 ... BGP_NAME=${BGP_PEER_NAME}
70 ... IP=${TOOLS_SYSTEM_IP}
71 ... HOLDTIME=${HOLDTIME}
72 ... PEER_PORT=${BGP_TOOL_PORT}
74 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
75 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
77 TemplatedRequests.Put_As_Xml_Templated
78 ... ${BGP_VAR_FOLDER}/bgp_peer
79 ... mapping=${mapping}
80 ... session=${CONFIG_SESSION}
82 Exa_To_Send_Route_Refresh
83 [Documentation] Exabgp sends route refresh and count received updates
85 [Setup] Configure_Routes_And_Start_ExaBgp ${BGP_CFG_NAME}
86 BgpRpcClient.exa_clean_received_update_count
87 BgpRpcClient.exa_announce announce route-refresh ipv4 unicast
88 Comment From neon onwards there are extra BGP End-Of-RIB message
89 ${update_count} CompareStream.Set_Variable_If_At_Most_Fluorine 2 3
90 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_ExaBgp_Received_Updates ${update_count}
91 Comment From neon onwards there are extra BGP End-Of-RIB message per address family
92 ${update_count} CompareStream.Set_Variable_If_At_Most_Fluorine 4 7
93 BuiltIn.Wait_Until_Keyword_Succeeds
96 ... Verify_Odl_Operational_State_Count
97 ... notification_count=0
98 ... update_count=${update_count}
100 [Teardown] Deconfigure_Routes_And_Stop_ExaBgp
102 Odl_To_Send_Route_Refresh
103 [Documentation] Sends route refresh request and checks if exabgp receives it
105 [Setup] ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${BGP_CFG_NAME} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP}
106 BgpRpcClient.exa_clean_received_route_refresh_count
107 &{mapping} BuiltIn.Create_Dictionary BGP_PEER_IP=${TOOLS_SYSTEM_IP}
108 TemplatedRequests.Post_As_Xml_Templated
109 ... ${BGP_VAR_FOLDER}/route_refresh
110 ... mapping=${mapping}
111 ... session=${CONFIG_SESSION}
112 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_ExaBgp_Received_Route_Refresh 1
113 Comment From neon onwards there are extra BGP End-Of-RIB message per address family
114 ${update_count} CompareStream.Set_Variable_If_At_Most_Fluorine 4 9
115 BuiltIn.Wait_Until_Keyword_Succeeds
118 ... Verify_Odl_Operational_State_Count
119 ... notification_count=1
120 ... update_count=${update_count}
122 [Teardown] ExaBgpLib.Stop_ExaBgp
124 Delete_Bgp_Peer_Configuration
125 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
126 &{mapping} BuiltIn.Create_Dictionary
127 ... DEVICE_NAME=${DEVICE_NAME}
128 ... BGP_NAME=${BGP_PEER_NAME}
129 ... IP=${TOOLS_SYSTEM_IP}
130 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
131 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
134 [Documentation] Revert the BGP configuration to the original state: without application peer
135 &{mapping} BuiltIn.Create_Dictionary
136 ... DEVICE_NAME=${DEVICE_NAME}
137 ... APP_PEER_NAME=${APP_PEER_NAME}
138 ... IP=${ODL_SYSTEM_IP}
139 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
140 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
145 [Documentation] Suite setup keyword.
146 SetupUtils.Setup_Utils_For_Setup_And_Teardown
147 ${mininet_conn_id} SSHLibrary.Open Connection
148 ... ${TOOLS_SYSTEM_IP}
149 ... prompt=${DEFAULT_LINUX_PROMPT}
151 Builtin.Set_Suite_Variable ${mininet_conn_id}
152 SSHKeywords.Flexible_Mininet_Login ${TOOLS_SYSTEM_USER}
153 SSHKeywords.Virtual_Env_Create
154 SSHKeywords.Virtual_Env_Install_Package setuptools==44.0.0
155 SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16
156 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
160 [Documentation] Suite teardown keyword
161 SSHKeywords.Virtual_Env_Delete
162 SSHLibrary.Close_All_Connections
163 RequestsLibrary.Delete_All_Sessions
166 [Documentation] Uploads exabgp config files
167 SSHLibrary.Put_File ${BGP_VAR_FOLDER}/${BGP_CFG_NAME} .
168 SSHLibrary.Put_File ${EXARPCSCRIPT} .
169 @{cfgfiles} SSHLibrary.List_Files_In_Directory . *.cfg
170 FOR ${cfgfile} IN @{cfgfiles}
171 SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
172 SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
173 SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/enable/g' ${cfgfile}
174 SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
175 ${stdout} SSHLibrary.Execute_Command cat ${cfgfile}
179 Configure_Routes_And_Start_ExaBgp
180 [Documentation] Setup keyword for exa to odl test case
181 [Arguments] ${cfg_file}
182 ${app_rib} Set Variable ${ODL_SYSTEM_IP}
183 FOR ${prefix} IN 1.1.1.1/32 2.2.2.2/32
184 &{mapping} BuiltIn.Create_Dictionary PREFIX=${prefix} APP_RIB=${app_rib}
185 TemplatedRequests.Post_As_Xml_Templated
186 ... ${BGP_RR_VAR_FOLDER}/route
187 ... mapping=${mapping}
188 ... session=${CONFIG_SESSION}
190 ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${cfg_file} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP}
191 Comment From neon onwards there are extra BGP End-Of-RIB message per address family
192 ${update_count} CompareStream.Set_Variable_If_At_Most_Fluorine 2 4
193 BuiltIn.Wait_Until_Keyword_Succeeds 3x 3s Verify_ExaBgp_Received_Updates ${update_count}
195 Deconfigure_Routes_And_Stop_ExaBgp
196 [Documentation] Teardown keyword for exa to odl test case
197 ExaBgpLib.Stop_ExaBgp
198 ${app_rib} Set Variable ${ODL_SYSTEM_IP}
199 &{mapping} BuiltIn.Create_Dictionary PREFIX=${prefix} APP_RIB=${app_rib}
200 TemplatedRequests.Delete_Templated ${BGP_RR_VAR_FOLDER}/route mapping=${mapping} session=${CONFIG_SESSION}
202 Verify_ExaBgp_Received_Updates
203 [Documentation] Gets number of received update requests and compares with given expected count
204 [Arguments] ${expcount}
205 ${count_recv} BgpRpcClient.exa_get_received_update_count
206 BuiltIn.Should Be Equal As Numbers ${count_recv} ${expcount}
208 Verify_ExaBgp_Received_Route_Refresh
209 [Documentation] Compares expected count of route request messages on exabgp side
210 [Arguments] ${expcount}
211 ${count} BgpRpcClient.exa_get_received_route_refresh_count
212 BuiltIn.Should Be Equal As Numbers ${count} ${expcount}
214 Verify_Odl_Operational_State_Count
215 [Documentation] Check notification and update count gained from operatial neighbor state
216 ... On versions oxygen and above, it verifies these counts also against cli output.
217 [Arguments] ${notification_count} ${update_count} ${receive_count}
218 &{mapping} BuiltIn.Create_Dictionary
219 ... IP=${TOOLS_SYSTEM_IP}
220 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
221 ... NOT_COUNT=${notification_count}
222 ... SEND_COUNT=${update_count}
223 ... RECV_COUNT=${receive_count}
224 ${ret} BuiltIn.Wait_Until_Keyword_Succeeds
227 ... TemplatedRequests.Get_As_Json_Templated
228 ... folder=${BGP_RR_VAR_FOLDER}/operational_state
229 ... mapping=${mapping}
230 ... session=${CONFIG_SESSION}
233 BuiltIn.Wait_Until_Keyword_Succeeds
236 ... Verify_Cli_Output_Count
237 ... ${notification_count}
241 Verify_Cli_Output_Count
242 [Documentation] Checks notification and update count from odl-bgpcep-bgp-cli.
243 ... odl-bgpcep-bgp-cli is only avaiable on versions oxygen and above.
244 [Arguments] ${notification_count} ${update_count} ${receive_count}
245 ${output} KarafKeywords.Safe_Issue_Command_On_Karaf_Console
246 ... bgp:operational-state -rib example-bgp-rib -neighbor ${TOOLS_SYSTEM_IP}
247 BuiltIn.Log ${output}
248 &{mapping} BuiltIn.Create_Dictionary
249 ... IP=${TOOLS_SYSTEM_IP}
250 ... NOT_COUNT=${notification_count}
251 ... SEND_COUNT=${update_count}
253 ... RECV_COUNT=${receive_count}
254 ${expstate} TemplatedRequests.Resolve_Text_From_Template_File
255 ... folder=${BGP_RR_VAR_FOLDER}/operational_cli
256 ... file_name=update.txt
257 ... mapping=${mapping}
258 String.Get Line Count ${output}
259 BuiltIn.Log ${expstate}
260 ${expected_line_count} String.Get Line Count ${expstate}
261 FOR ${expected_line_pos} IN RANGE 0 ${expected_line_count-1}
262 ${expected_line_offset} BuiltIn.Evaluate ${MSG_STATE_OFFSET} + ${expected_line_pos}
263 ${output_line} String.Get Line ${output} ${expected_line_offset}
264 ${expected_line} String.Get Line ${expstate} ${expected_line_pos}
265 BuiltIn.Should Match ${output_line} ${expected_line}