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 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
16 Library RequestsLibrary
18 Variables ${CURDIR}/../../../variables/Variables.py
19 Resource ${CURDIR}/../../../libraries/ExaBgpLib.robot
20 Resource ${CURDIR}/../../../libraries/Utils.robot
21 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
22 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
23 Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
24 Resource ${CURDIR}/../../../libraries/BGPcliKeywords.robot
25 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
26 Resource ${CURDIR}/../../../libraries/CompareStream.robot
30 ${DEVICE_NAME} controller-config
31 ${BGP_PEER_NAME} example-bgp-peer
32 ${RIB_INSTANCE} example-bgp-rib
33 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
34 ${APP_PEER_NAME} example-bgp-peer-app
35 ${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
36 ${MULT_VAR_FOLDER} ${BGP_VAR_FOLDER}/multipaths
37 ${DEFAUTL_RPC_CFG} exa.cfg
38 ${CONFIG_SESSION} config-session
39 ${EXARPCSCRIPT} ${CURDIR}/../../../../tools/exabgp_files/exarpc.py
41 &{DEFAULT_MAPPING} ODLIP=${ODL_SYSTEM_IP} EXAIP=${TOOLS_SYSTEM_IP} NPATHS=${N_PATHS_VALUE}
44 ${NEXT_HOP_PREF} 100.100.100.
45 ${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
46 ${OPENCONFIG_RIB_URI} /restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/example-bgp-rib
47 ${NPATHS_SELM} n-paths
48 ${ALLPATHS_SELM} all-paths
49 ${ADDPATHCAP_SR} send\\/receive
51 ${ADDPATHCAP_R} receive
52 ${ADDPATHCAP_D} disable
55 Reconfigure_ODL_To_Accept_Connection
56 [Documentation] Configures BGP peer module with initiate-connection set to false.
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} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} PASSIVE_MODE=true
59 # configuration of the peer and multipath for carbon and above is done in the testcase at once
60 CompareStream.Run_Keyword_If_At_Most_Boron TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
62 Odl Allpaths Exa SendReceived
63 [Documentation] all-paths selected policy selected
65 [Setup] Configure_Path_Selection_And_App_Peer_And_Connect_Peer ${ALLPATHS_SELM} ${ADDPATHCAP_SR}
66 Log_Loc_Rib_Operational
67 BuiltIn.Wait_Until_Keyword_Succeeds 6x 2s Verify_Expected_Update_Count ${PATH_ID_LIST_LEN}
68 [Teardown] Remove_Odl_And_App_Peer_Configuration_And_Stop_ExaBgp
70 Odl Npaths Exa SendReceived
71 [Documentation] n-paths policy selected on odl
73 [Setup] Configure_Path_Selection_And_App_Peer_And_Connect_Peer ${NPATHS_SELM} ${ADDPATHCAP_SR}
74 Log_Loc_Rib_Operational
75 BuiltIn.Wait_Until_Keyword_Succeeds 6x 2s Verify_Expected_Update_Count ${N_PATHS_VALUE}
76 [Teardown] Remove_Odl_And_App_Peer_Configuration_And_Stop_ExaBgp
78 Delete_Bgp_Peer_Configuration
79 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
80 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
81 CompareStream.Run_Keyword_If_At_Most_Boron TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
85 [Documentation] Suite setup keyword.
86 SetupUtils.Setup_Utils_For_Setup_And_Teardown
87 ${tools_system_conn_id}= SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
88 Builtin.Set_Suite_Variable ${tools_system_conn_id}
89 Utils.Flexible_Mininet_Login ${TOOLS_SYSTEM_USER}
90 SSHKeywords.Virtual_Env_Create
91 SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16
92 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
94 CompareStream.Run_Keyword_If_At_Most_Boron Configure_Odl_With_Multipaths
95 CompareStream.Run_Keyword_If_At_Least_Carbon Store_Rib_Configuration
98 [Documentation] Suite teardown keyword with old rib restoration
99 SSHKeywords.Virtual_Env_Delete
100 CompareStream.Run_Keyword_If_At_Most_Boron TemplatedRequests.Put_As_Xml_To_Uri ${RIB_URI} ${rib_old} session=${CONFIG_SESSION}
101 CompareStream.Run_Keyword_If_At_Least_Carbon TemplatedRequests.Put_As_Xml_To_Uri ${OPENCONFIG_RIB_URI} ${rib_old} session=${CONFIG_SESSION}
102 SSHLibrary.Close_All_Connections
103 RequestsLibrary.Delete_All_Sessions
106 [Arguments] ${addpath}=disable
107 [Documentation] Uploads exabgp config files
108 SSHLibrary.Put_File ${BGP_VAR_FOLDER}/${DEFAUTL_RPC_CFG} .
109 SSHLibrary.Put_File ${EXARPCSCRIPT} .
110 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
111 : FOR ${cfgfile} IN @{cfgfiles}
112 \ SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
113 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
114 \ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/enable/g' ${cfgfile}
115 \ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/${addpath}/g' ${cfgfile}
116 \ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}
119 Configure_Path_Selection_And_App_Peer_And_Connect_Peer
120 [Arguments] ${odl_path_sel_mode} ${exa_add_path_value}
121 [Documentation] Setup test case keyword. Early after the path selection config the incomming connection
122 ... from exabgp towards odl may be rejected by odl due to config process not finished yet. Because of that
123 ... we try to start the tool 3 times in case early attempts fail.
124 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
125 CompareStream.Run_Keyword_If_At_Most_Boron Configure_Path_Selection_Mode ${odl_path_sel_mode}
126 CompareStream.Run_Keyword_If_At_Least_Carbon Configure_Odl_Peer_With_Path_Selection_Mode ${odl_path_sel_mode}
127 Configure_App_Peer_With_Routes
128 Upload_Config_Files addpath=${exa_add_path_value}
129 ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${DEFAUTL_RPC_CFG} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP} connection_retries=${3}
131 Remove_Odl_And_App_Peer_Configuration_And_Stop_ExaBgp
132 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
133 CompareStream.Run_Keyword_If_At_Least_Carbon TemplatedRequests.Delete_Templated ${MULT_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
135 ExaBgpLib.Stop_ExaBgp
136 SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
138 Verify_Expected_Update_Count
139 [Arguments] ${exp_count}
140 [Documentation] Verify number of received update messages
141 ${tool_count}= BgpRpcClient.exa_get_received_update_count
142 BuiltIn.Should_Be_Equal_As_Numbers ${exp_count} ${tool_count}
144 Configure_Path_Selection_Mode
146 [Documentation] Configure path selection mode and get rib information for potential debug purposes
147 &{mapping} BuiltIn.Create_Dictionary PATHSELMODE=${psm}
148 TemplatedRequests.Get_As_Xml_Templated ${MULT_VAR_FOLDER}/rib mapping=${mapping} session=${CONFIG_SESSION}
149 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/module_psm mapping=${mapping} session=${CONFIG_SESSION}
151 Configure_Odl_Peer_With_Path_Selection_Mode
153 [Documentation] Configures odl peer with path selection mode
154 ${npaths}= BuiltIn.Set_Variable_If "${psm}"=="${ALLPATHS_SELM}" 0 ${N_PATHS_VALUE}
155 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} PASSIVE_MODE=true MULTIPATH=${npaths}
156 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
157 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/rib mapping=${mapping} session=${CONFIG_SESSION}
158 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
160 Configure_Odl_With_Multipaths
161 [Documentation] Configures odl to support n-paths or all-paths selection
162 ${mapping}= BuiltIn.Set Variable ${DEFAULT_MAPPING}
163 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/module_n_paths mapping=${mapping} session=${CONFIG_SESSION}
164 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/module_all_paths mapping=${mapping} session=${CONFIG_SESSION}
165 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/service_psmf mapping=${mapping} session=${CONFIG_SESSION}
166 Configure_Path_Selection_Mode n-paths
167 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/service_bpsm mapping=${mapping} session=${CONFIG_SESSION}
168 Store_Rib_Configuration
169 TemplatedRequests.Put_As_Xml_Templated ${MULT_VAR_FOLDER}/rib mapping=${mapping} session=${CONFIG_SESSION}
171 Store_Rib_Configuration
172 [Documentation] Stores rib configuration
173 ${mapping}= BuiltIn.Set Variable ${DEFAULT_MAPPING}
174 ${rib_old}= TemplatedRequests.Get_As_Xml_Templated ${MULT_VAR_FOLDER}/rib mapping=${mapping} session=${CONFIG_SESSION}
175 BuiltIn.Set_Suite_Variable ${rib_old}
177 Log_Loc_Rib_Operational
178 ${rsp}= RequestsLibrary.Get Request ${CONFIG_SESSION} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/
179 BuiltIn.Log ${rsp.content}
181 Configure_App_Peer_With_Routes
182 [Documentation] Configure bgp application peer and fill it immediately with routes.
183 &{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} IP=${ODL_SYSTEM_IP}
184 ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
185 TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
186 ${app_rib} CompareStream.Set_Variable_If_At_Most_Boron example-app-rib ${ODL_SYSTEM_IP}
187 : FOR ${pathid} IN @{PATH_ID_LIST}
188 \ &{route_mapping} BuiltIn.Create_Dictionary NEXTHOP=${NEXT_HOP_PREF}${pathid} LOCALPREF=${pathid}00 PATHID=${pathid} APP_RIB=${app_rib}
189 \ TemplatedRequests.Post_As_Xml_Templated ${MULT_VAR_FOLDER}/route mapping=${route_mapping} session=${CONFIG_SESSION}
192 [Documentation] Revert the BGP configuration to the original state: without application peer
193 ${app_rib} CompareStream.Set_Variable_If_At_Most_Boron example-app-rib ${ODL_SYSTEM_IP}
194 &{route_mapping} BuiltIn.Create_Dictionary APP_RIB=${app_rib} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
195 TemplatedRequests.Delete_Templated ${MULT_VAR_FOLDER}/route mapping=${route_mapping} session=${CONFIG_SESSION}
196 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME} IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
197 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}