2 Documentation Functional test for bgp routing policies
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 distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
10 ... This suite uses 7 peers: app peer, 2x rr-client, 2x ebgp, 2x ibgp
11 ... Tests results on effective-rib-in dependant on their respective configurations.
12 ... Peers 1,2,4,5 are testing multiple ipv4 routes with additional arguments.
13 ... Peers 3,6 have ipv4 and ipv6 mpls-labeled routes.
15 Library RequestsLibrary
17 Resource ../../../variables/Variables.robot
18 Resource ../../../libraries/CompareStream.robot
19 Resource ../../../libraries/ExaBgpLib.robot
20 Resource ../../../libraries/SetupUtils.robot
21 Resource ../../../libraries/TemplatedRequests.robot
22 Resource ../../../libraries/SSHKeywords.robot
24 Suite Setup Start_Suite
25 Suite Teardown Stop_Suite
26 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
30 ${POLICIES_VAR} ${CURDIR}/../../../variables/bgpfunctional/bgppolicies
31 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
32 @{PEER_TYPES} ibgp_peer ibgp_peer ebgp_peer ebgp_peer rr_client_peer rr_client_peer
33 @{NUMBERS} 1 2 3 4 5 6
35 ${RIB_INSTANCE} example-bgp-rib
36 ${CONFIG_SESSION} config-session
37 ${OLD_AS_PATH} \n"as-path": {},
38 ${NEW_AS_PATH} ${EMPTY}
43 [Documentation] Checks empty example-ipv4-topology ready.
44 Verify_Rib_Status_Empty
47 [Documentation] Configures bgp application peer, and configures it's routes.
48 &{mapping} BuiltIn.Create_Dictionary
49 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
50 ... APP_PEER_ID=${ODL_SYSTEM_IP}
51 ... BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
52 ... IP=${ODL_SYSTEM_IP}
53 TemplatedRequests.Post_As_Xml_Templated
54 ... ${POLICIES_VAR}/app_peer
55 ... mapping=${mapping}
56 ... session=${CONFIG_SESSION}
57 TemplatedRequests.Post_As_Xml_Templated
58 ... ${POLICIES_VAR}/app_peer_route
59 ... mapping=${mapping}
60 ... session=${CONFIG_SESSION}
62 Reconfigure_ODL_To_Accept_Connections
63 [Documentation] Configure BGP peer modules with initiate-connection set to false.
64 ... Configures 6 different peers, two internal, two external and two route-reflectors.
65 FOR ${index} ${peer_type} IN ZIP ${NUMBERS} ${PEER_TYPES}
66 &{mapping} Create Dictionary
67 ... IP=127.0.0.${index}
68 ... HOLDTIME=${HOLDTIME}
70 ... BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
71 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
72 TemplatedRequests.Put_As_Xml_Templated
73 ... ${POLICIES_VAR}${/}${peer_type}
74 ... mapping=${mapping}
75 ... session=${CONFIG_SESSION}
79 [Documentation] Start 6 exabgps as processes in background, each with it's own configuration.
80 SSHKeywords.Virtual_Env_Activate_On_Current_Session log_output=${True}
81 FOR ${index} IN @{NUMBERS}
82 ${start_cmd} BuiltIn.Set_Variable ${CMD} exabgp${index}.cfg > exa${index}.log &
83 BuiltIn.Log ${start_cmd}
84 ${output} SSHLibrary.Write ${start_cmd}
89 [Documentation] Verifies that sent routes are present in particular ribs.
94 [Documentation] Send command to kill all exabgp processes running on controller
95 ExaBgpLib.Stop_All_ExaBgps
96 FOR ${index} IN @{NUMBERS}
97 BGPcliKeywords.Store_File_To_Workspace exa${index}.log exa${index}.log
100 Delete_Bgp_Peer_Configuration
101 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
102 FOR ${index} ${peer_type} IN ZIP ${NUMBERS} ${PEER_TYPES}
103 &{mapping} Create Dictionary
104 ... IP=127.0.0.${index}
105 ... HOLDTIME=${HOLDTIME}
106 ... PASSIVE_MODE=true
107 ... BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
108 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
109 TemplatedRequests.Delete_Templated
110 ... ${POLICIES_VAR}/${peer_type}
111 ... mapping=${mapping}
112 ... session=${CONFIG_SESSION}
116 [Documentation] Revert the BGP configuration to the original state: without application peer
117 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
118 TemplatedRequests.Delete_Templated ${POLICIES_VAR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
119 TemplatedRequests.Delete_Templated
120 ... ${POLICIES_VAR}/app_peer_route
121 ... mapping=${mapping}
122 ... session=${CONFIG_SESSION}
127 [Documentation] Suite setup keyword.
128 SetupUtils.Setup_Utils_For_Setup_And_Teardown
129 ${conn_id} SSHLibrary.Open Connection ${ODL_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=10s
130 Builtin.Set_Suite_Variable ${conn_id}
131 SSHKeywords.Flexible_Controller_Login
132 SSHKeywords.Virtual_Env_Create upgrade_pip=False
133 SSHKeywords.Virtual_Env_Install_Package exabgp==4.0.5
134 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
138 [Documentation] Suite teardown keyword
139 SSHKeywords.Virtual_Env_Delete
140 SSHLibrary.Close_All_Connections
141 RequestsLibrary.Delete_All_Sessions
144 [Documentation] Verify output from effective-rib-in for each of the 6 exabgp peers and app peer.
145 ... First request is for full example-bgp-rib and it's output is logged for debug purposes.
146 ... Each of the peers have different output which is stored in folder by their respective
147 ... numbers as peer_${index} (peer_1, peer_2 ...)
148 # gets and outputs full rib output for debug purposes if one of the peers reports faulty data.
149 ${output} TemplatedRequests.Get_As_Json_Templated ${POLICIES_VAR}/rib_state session=${CONFIG_SESSION}
150 BuiltIn.Log ${output}
151 ${AS_PATH} CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH}
152 FOR ${index} IN @{NUMBERS}
153 &{mapping} BuiltIn.Create_Dictionary IP=127.0.0.${index} AS_PATH=${AS_PATH}
154 BuiltIn.Wait_Until_Keyword_Succeeds
157 ... TemplatedRequests.Get_As_Json_Templated
158 ... ${POLICIES_VAR}/effective_rib_in/peer_${index}
159 ... mapping=${mapping}
160 ... session=${CONFIG_SESSION}
163 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} AS_PATH=${AS_PATH}
164 # application peer verification
165 BuiltIn.Wait_Until_Keyword_Succeeds
168 ... TemplatedRequests.Get_As_Json_Templated
169 ... ${POLICIES_VAR}/app_peer_rib
170 ... mapping=${mapping}
171 ... session=${CONFIG_SESSION}
174 Verify_Rib_Status_Empty
175 [Documentation] Checks that example-ipv4-topology is ready, and therefore full rib is ready to be configured.
176 BuiltIn.Wait_Until_Keyword_Succeeds
179 ... TemplatedRequests.Get_As_Json_Templated
180 ... ${POLICIES_VAR}/topology_state
181 ... session=${CONFIG_SESSION}
185 [Documentation] Uploads exabgp config files and replaces variables within those
186 ... config files with desired values.
187 FOR ${index} IN @{NUMBERS}
188 SSHLibrary.Put_File ${POLICIES_VAR}/exabgp_configs/exabgp${index}.cfg .
190 @{cfgfiles} SSHLibrary.List_Files_In_Directory . *.cfg
191 FOR ${cfgfile} IN @{cfgfiles}
192 SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
193 SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
194 SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
195 ${stdout} SSHLibrary.Execute_Command cat ${cfgfile}