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 request 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 received by odl also correct advertising of routes
14 ... is verified. Receiving of route refresh by odl is verified by
15 ... checking appropriate message counter via ${JOLOKURL}. Feature
16 ... odl-jolokia is required by this test suite.
17 Suite Setup Start_Suite
18 Suite Teardown Stop_Suite
19 Library RequestsLibrary
21 Variables ${CURDIR}/../../../variables/Variables.py
22 Resource ${CURDIR}/../../../libraries/Utils.robot
23 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
24 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
25 Resource ${CURDIR}/../../../libraries/KarafKeywords.robot
26 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
27 Library ${CURDIR}/../../../libraries/norm_json.py
28 Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
32 ${DEVICE_NAME} controller-config
33 ${BGP_PEER_NAME} example-bgp-peer
34 ${RIB_INSTANCE} example-bgp-rib
35 ${APP_PEER_NAME} example-bgp-peer-app
36 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
37 ${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
38 ${BGP_RR_VAR_FOLDER} ${BGP_VAR_FOLDER}/route_refresh
39 ${BGP_CFG_NAME} exa.cfg
40 ${CONFIG_SESSION} config-session
41 ${EXARPCSCRIPT} ${CURDIR}/../../../../tools/exabgp_files/exarpc.py
42 ${JOLOKURL} /jolokia/read/org.opendaylight.controller:instanceName=${BGP_PEER_NAME},type=RuntimeBean,moduleFactoryName=bgp-peer
43 ${PEER_CHECK_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
47 [Documentation] Configure bgp application peer
48 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
49 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME} RIB_INSTANCE_NAME=${RIB_INSTANCE} APP_PEER_ID=${ODL_SYSTEM_IP}
50 TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
52 Reconfigure_ODL_To_Accept_Connection
53 [Documentation] Configure BGP peer module with initiate-connection set to false.
54 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
55 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
56 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE}
57 TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
59 Exa_To_Send_Route_Request
60 [Documentation] Exabgp sends route refresh and count received updates
61 [Setup] Configure_Routes_And_Start_Tool ${BGP_CFG_NAME}
62 Verify_Odl_Received_Route_Request 0
63 BgpRpcClient.exa_clean_received_update_count
64 BgpRpcClient.exa_announce announce route-refresh ipv4 unicast
65 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_Odl_Received_Route_Request 1
66 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_Tool_Received_Updates ${nr_configured_routes}
67 [Teardown] Deconfigure_Routes_And_Stop_Tool
69 Odl_To_Send_Route_Request
70 [Documentation] Sends route requests and checks if exabgp receives it
71 [Setup] Start_Tool_And_Verify_Connected ${BGP_CFG_NAME}
72 BgpRpcClient.exa_clean_received_route_refresh_count
73 &{mapping} BuiltIn.Create_Dictionary BGP_PEER_IP=${TOOLS_SYSTEM_IP}
74 TemplatedRequests.Post_As_Xml_Templated ${BGP_VAR_FOLDER}/route_refresh mapping=${mapping} session=${CONFIG_SESSION}
75 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_Odl_Sent_Route_Request 1
78 Delete_Bgp_Peer_Configuration
79 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
80 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
81 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME}
82 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
85 [Documentation] Revert the BGP configuration to the original state: without application peer
86 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
87 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME}
88 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
92 [Documentation] Suite setup keyword
93 SetupUtils.Setup_Utils_For_Setup_And_Teardown
94 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
95 Builtin.Set_Suite_Variable ${mininet_conn_id}
96 Utils.Flexible_Mininet_Login ${TOOLS_SYSTEM_USER}
97 SSHKeywords.Virtual_Env_Create
98 SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16
99 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
103 [Documentation] Suite teardown keyword
104 SSHKeywords.Virtual_Env_Delete
105 SSHLibrary.Close_All_Connections
106 RequestsLibrary.Delete_All_Sessions
109 [Documentation] Uploads exabgp config files
110 SSHLibrary.Put_File ${BGP_VAR_FOLDER}/${BGP_CFG_NAME} .
111 SSHLibrary.Put_File ${EXARPCSCRIPT} .
112 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
113 : FOR ${cfgfile} IN @{cfgfiles}
114 \ SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
115 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
116 \ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/enable/g' ${cfgfile}
117 \ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
118 \ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}
122 [Arguments] ${cfg_file} ${mapping}={}
123 [Documentation] Start the tool ${cmd} ${cfg_file}
124 ${start_cmd} BuiltIn.Set_Variable ${cmd} ${cfg_file}
125 BuiltIn.Log ${start_cmd}
126 SSHKeywords.Virtual_Env_Activate_On_Current_Session log_output=${True}
127 ${output}= SSHLibrary.Write ${start_cmd}
128 BuiltIn.Log ${output}
130 Verify_Tools_Connection
131 [Arguments] ${connected}=${True}
132 [Documentation] Checks peer presence in operational datastore
133 ${exp_status_code}= BuiltIn.Set_Variable_If ${connected} ${200} ${404}
134 ${rsp}= RequestsLibrary.Get Request ${CONFIG_SESSION} ${PEER_CHECK_URL}${TOOLS_SYSTEM_IP}
135 BuiltIn.Log ${rsp.content}
136 BuiltIn.Should_Be_Equal_As_Numbers ${exp_status_code} ${rsp.status_code}
138 Start_Tool_And_Verify_Connected
139 [Arguments] ${cfg_file}
140 [Documentation] Start the tool and verify its connection
141 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
142 Start_Tool ${cfg_file}
143 BuiltIn.Wait_Until_Keyword_Succeeds 3x 3s Verify_Tools_Connection connected=${True}
146 [Documentation] Stop the tool by sending ctrl+c
147 ${output}= SSHLibrary.Read
148 BuiltIn.Log ${output}
149 Utils.Write_Bare_Ctrl_C
150 ${output}= SSHLibrary.Read_Until_Prompt
151 BuiltIn.Log ${output}
152 SSHKeywords.Virtual_Env_Deactivate_On_Current_Session log_output=${True}
154 Configure_Routes_And_Start_Tool
155 [Arguments] ${cfg_file}
156 [Documentation] Setup keyword for exa to odl test case
157 : FOR ${prefix} IN 1.1.1.1/32 2.2.2.2/32
158 \ &{mapping} BuiltIn.Create_Dictionary PREFIX=${prefix}
159 \ TemplatedRequests.Post_As_Xml_Templated ${BGP_RR_VAR_FOLDER}/route mapping=${mapping} session=${CONFIG_SESSION}
160 BuiltIn.Set_Suite_Variable ${nr_configured_routes} 2
161 Start_Tool_And_Verify_Connected ${cfg_file}
162 BuiltIn.Wait_Until_Keyword_Succeeds 3x 3s Verify_Tool_Received_Updates ${nr_configured_routes}
164 Deconfigure_Routes_And_Stop_Tool
165 [Documentation] Teardown keyword for exa to odl test case
167 &{mapping} BuiltIn.Create_Dictionary PREFIX=${prefix}
168 TemplatedRequests.Delete_Templated ${BGP_RR_VAR_FOLDER}/route mapping=${mapping} session=${CONFIG_SESSION}
170 Verify_Odl_Sent_Route_Request
171 [Arguments] ${expcount}
172 [Documentation] Compares expected count of route request messages on exabgp side
173 ${count}= BgpRpcClient.exa_get_received_route_refresh_count
174 BuiltIn.Should Be Equal As Numbers ${count} ${expcount}
176 Verify_Odl_Received_Route_Request
177 [Arguments] ${expcount}
178 [Documentation] Gets numebr of received route requests and compares with given expected count
179 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${JOLOKURL}
180 BuiltIn.Log ${rsp.content}
181 BuiltIn.Should_Be_Equal_As_Numbers ${rsp.status_code} 200
182 BuiltIn.Should_Be_Equal_As_Numbers ${rsp.json()['status']} 200
183 BuiltIn.Should_Be_Equal_As_Numbers ${rsp.json()['value']['BgpSessionState']['messagesStats']['routeRefreshMsgs']['received']['count']['value']} ${expcount}
185 Verify_Tool_Received_Updates
186 [Arguments] ${expcount}
187 [Documentation] Gets numebr of received update requests and compares with given expected count
188 ${count_recv}= BgpRpcClient.exa_get_received_update_count
189 BuiltIn.Should Be Equal As Numbers ${count_recv} ${expcount}