2 Documentation Functional test suite for bgp - n-path and all-path selection
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 n-path and all-path selection policy.
11 ... It uses odl and exabgp as bgp peers. Routes advertized from odl
12 ... are configured via application peer.
13 Suite Setup Start_Suite
14 Suite Teardown Stop_Suite
15 Library RequestsLibrary
17 Variables ${CURDIR}/../../../variables/Variables.py
18 Resource ${CURDIR}/../../../libraries/Utils.robot
19 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
20 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
21 Library ${CURDIR}/../../../libraries/norm_json.py
22 Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
23 Resource ${CURDIR}/../../../libraries/BGPcliKeywords.robot
24 Resource ${CURDIR}/../../../libraries/KarafKeywords.robot
25 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
29 ${DEVICE_NAME} controller-config
30 ${BGP_PEER_NAME} example-bgp-peer
31 ${RIB_INSTANCE} example-bgp-rib
32 ${APP_PEER_NAME} example-bgp-peer-app
33 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
34 ${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
35 ${MULT_VAR_FOLDER} ${BGP_VAR_FOLDER}/multipaths
36 ${DEFAUTL_RPC_CFG} exa.cfg
37 ${CONFIG_SESSION} config-session
38 ${EXARPCSCRIPT} ${CURDIR}/../../../../tools/exabgp_files/exarpc.py
40 &{DEFAULT_MAPPING} ODLIP=${ODL_SYSTEM_IP} EXAIP=${TOOLS_SYSTEM_IP} NPATHS=${N_PATHS_VALUE}
43 ${NEXT_HOP_PREF} 100.100.100.
44 ${RIB_URI} /restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/odl-bgp-rib-impl-cfg:rib-impl/example-bgp-rib
45 ${PEER_CHECK_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
46 ${NPATHS_SELM} n-paths
47 ${ALLPATHS_SELM} all-paths
48 ${ADDPATHCAP_SR} send\\/receive
50 ${ADDPATHCAP_R} receive
51 ${ADDPATHCAP_D} disable
54 Reconfigure_ODL_To_Accept_Connection
55 [Documentation] Configure BGP peer module with initiate-connection set to false.
56 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
57 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
58 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE}
59 TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
61 Odl Allpaths Exa SendReceived
62 [Documentation] all-paths selected policy selected
63 [Setup] Configure_Path_Selection_And_App_Peer_And_Connect_Peer ${ALLPATHS_SELM} ${ADDPATHCAP_SR}
64 Log_Loc_Rib_Operational
65 BuiltIn.Wait_Until_Keyword_Succeeds 6x 2s Verify_Expected_Update_Count ${PATH_ID_LIST_LEN}
66 [Teardown] Remove_App_Peer_Configuration_And_Stop_Tool
68 Odl Npaths Exa SendReceived
69 [Documentation] n-paths policy selected on odl
70 [Setup] Configure_Path_Selection_And_App_Peer_And_Connect_Peer ${NPATHS_SELM} ${ADDPATHCAP_SR}
71 Log_Loc_Rib_Operational
72 BuiltIn.Wait_Until_Keyword_Succeeds 6x 2s Verify_Expected_Update_Count ${N_PATHS_VALUE}
73 [Teardown] Remove_App_Peer_Configuration_And_Stop_Tool
75 Delete_Bgp_Peer_Configuration
76 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
77 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
78 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME}
79 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
83 [Documentation] Suite setup keyword
84 SetupUtils.Setup_Utils_For_Setup_And_Teardown
85 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
86 Builtin.Set Suite Variable ${mininet_conn_id}
87 Utils.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
88 SSHKeywords.Virtual_Env_Create
89 SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16
90 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
92 Configure_Odl_With_Multipaths
95 [Documentation] Suite teardown keyword with ord rib restoration
96 SSHKeywords.Virtual_Env_Delete
97 TemplatedRequests.Put_As_Xml_To_Uri ${RIB_URI} ${rib_old} session=${CONFIG_SESSION}
98 SSHLibrary.Close_All_Connections
99 RequestsLibrary.Delete_All_Sessions
102 [Arguments] ${addpath}=disable
103 [Documentation] Uploads exabgp config files
104 SSHLibrary.Put_File ${BGP_VAR_FOLDER}/${DEFAUTL_RPC_CFG} .
105 SSHLibrary.Put_File ${EXARPCSCRIPT} .
106 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
107 : FOR ${cfgfile} IN @{cfgfiles}
108 \ SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
109 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
110 \ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/enable/g' ${cfgfile}
111 \ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/${addpath}/g' ${cfgfile}
112 \ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}
115 Configure_Path_Selection_And_App_Peer_And_Connect_Peer
116 [Arguments] ${odl_path_sel_mode} ${exa_add_path_value}
117 [Documentation] Setup test case keyword. Early after the path selection config the incomming connection
118 ... from exabgp towards odl may be rejected by odl due to config process not finished yet. Because of that
119 ... we try to start the tool 3 times in case early attempts fail.
120 KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
121 Configure_Path_Selection_Mode ${odl_path_sel_mode}
122 Configure_App_Peer_With_Routes
123 Upload_Config_Files addpath=${exa_add_path_value}
124 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start_Tool_And_Verify_Connected ${DEFAUTL_RPC_CFG}
127 [Arguments] ${cfg_template_file} ${mapping}={} ${new_cfg_name}=cfg.cfg
128 [Documentation] Returns a new config file from template
129 ${cfg_content}= TemplatedRequests.Resolve_Text_From_Template_File ${cfg_template} ${mapping}
130 SSHLibrary.Execute_Command echo ${cfg_content} > ${new_cfg_name}
131 [Return] ${new_cfg_name}
134 [Arguments] ${cfg_file} ${mapping}={}
135 [Documentation] Start the tool ${cmd} ${cfg_file}
136 ${start_cmd} BuiltIn.Set_Variable ${cmd} ${cfg_file}
137 BuiltIn.Log ${start_cmd}
138 SSHKeywords.Virtual_Env_Activate_On_Current_Session log_output=${True}
139 ${output}= SSHLibrary.Write ${start_cmd}
140 BuiltIn.Log ${output}
142 Verify_Tools_Connection
143 [Arguments] ${connected}=${True}
144 [Documentation] Checks peer presence in operational datastore
145 ${exp_status_code}= BuiltIn.Set_Variable_If ${connected} ${200} ${404}
146 ${rsp}= RequestsLibrary.Get Request ${CONFIG_SESSION} ${PEER_CHECK_URL}${TOOLS_SYSTEM_IP}
147 BuiltIn.Log ${rsp.content}
148 BuiltIn.Should_Be_Equal_As_Numbers ${exp_status_code} ${rsp.status_code}
150 Start_Tool_And_Verify_Connected
151 [Arguments] ${cfg_file}
152 [Documentation] Start the tool and verify its connection
153 Start_Tool ${cfg_file}
154 BuiltIn.Wait_Until_Keyword_Succeeds 3x 3s Verify_Tools_Connection connected=${True}
157 [Documentation] Stop the tool by sending ctrl+c
158 ${output}= SSHLibrary.Read
159 BuiltIn.Log ${output}
160 Utils.Write_Bare_Ctrl_C
161 ${output}= SSHLibrary.Read_Until_Prompt
162 BuiltIn.Log ${output}
163 SSHKeywords.Virtual_Env_Deactivate_On_Current_Session log_output=${True}
165 Remove_App_Peer_Configuration_And_Stop_Tool
169 Verify_Expected_Update_Count
170 [Arguments] ${exp_count}
171 [Documentation] Verify number of received update messages
172 ${tool_count}= BgpRpcClient.exa_get_received_update_count
173 BuiltIn.Should_Be_Equal_As_Numbers ${exp_count} ${tool_count}
175 Configure_Path_Selection_Mode
177 [Documentation] Configure path selection mode and get rib information for potential debug purposes
178 &{mapping} BuiltIn.Create_Dictionary PATHSELMODE=${psm}
179 TemplatedRequests.Get_As_Xml_Templated ${MULT_VAR_FOLDER}/rib mapping=${mapping} session=${CONFIG_SESSION}
180 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/module_psm mapping=${mapping} session=${CONFIG_SESSION}
182 Configure_Odl_With_Multipaths
183 [Documentation] Configures odl to support n-paths or all-paths selection
184 ${mapping}= BuiltIn.Set Variable ${DEFAULT_MAPPING}
185 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/module_n_paths mapping=${mapping} session=${CONFIG_SESSION}
186 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/module_all_paths mapping=${mapping} session=${CONFIG_SESSION}
187 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/service_psmf mapping=${mapping} session=${CONFIG_SESSION}
188 Configure_Path_Selection_Mode n-paths
189 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/service_bpsm mapping=${mapping} session=${CONFIG_SESSION}
190 ${rib_old}= TemplatedRequests.Get_As_Xml_Templated ${MULT_VAR_FOLDER}/rib mapping=${mapping} session=${CONFIG_SESSION}
191 BuiltIn.Set_Suite_Variable ${rib_old}
192 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/rib mapping=${mapping} session=${CONFIG_SESSION}
194 Log_Loc_Rib_Operational
195 ${rsp}= RequestsLibrary.Get Request ${CONFIG_SESSION} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/
196 BuiltIn.Log ${rsp.content}
198 Configure_App_Peer_With_Routes
199 [Documentation] Configure bgp application peer and fill it immediately with routes.
200 &{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}
201 TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
202 : FOR ${pathid} IN @{PATH_ID_LIST}
203 \ &{route_mapping} BuiltIn.Create_Dictionary NEXTHOP=${NEXT_HOP_PREF}${pathid} LOCALPREF=${pathid}00 PATHID=${pathid}
204 \ TemplatedRequests.Post_As_Xml_Templated ${MULT_VAR_FOLDER}/route mapping=${route_mapping} session=${CONFIG_SESSION}
207 [Documentation] Revert the BGP configuration to the original state: without application peer
208 &{route_mapping} BuiltIn.Create_Dictionary
209 TemplatedRequests.Delete_Templated ${MULT_VAR_FOLDER}/route mapping=${route_mapping} session=${CONFIG_SESSION}
210 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME}
211 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}