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.
14 Suite Setup Start_Suite
15 Suite Teardown Stop_Suite
16 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
17 Library RequestsLibrary
19 Resource ../../../variables/Variables.robot
20 Resource ../../../libraries/CompareStream.robot
21 Resource ../../../libraries/ExaBgpLib.robot
22 Resource ../../../libraries/SetupUtils.robot
23 Resource ../../../libraries/TemplatedRequests.robot
24 Resource ../../../libraries/SSHKeywords.robot
27 ${POLICIES_VAR} ${CURDIR}/../../../variables/bgpfunctional/bgppolicies
28 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
29 @{PEER_TYPES} ibgp_peer ibgp_peer ebgp_peer ebgp_peer rr_client_peer rr_client_peer
30 @{NUMBERS} 1 2 3 4 5 6
32 ${RIB_INSTANCE} example-bgp-rib
33 ${CONFIG_SESSION} config-session
34 ${OLD_AS_PATH} \n"as-path": {},
35 ${NEW_AS_PATH} ${EMPTY}
39 [Documentation] Checks empty example-ipv4-topology ready.
40 Verify_Rib_Status_Empty
43 [Documentation] Configures bgp application peer, and configures it's routes.
44 &{mapping} BuiltIn.Create_Dictionary RIB_INSTANCE_NAME=${RIB_INSTANCE} APP_PEER_ID=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_INSTANCE} IP=${ODL_SYSTEM_IP}
45 TemplatedRequests.Post_As_Xml_Templated ${POLICIES_VAR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
46 TemplatedRequests.Post_As_Xml_Templated ${POLICIES_VAR}/app_peer_route mapping=${mapping} session=${CONFIG_SESSION}
48 Reconfigure_ODL_To_Accept_Connections
49 [Documentation] Configure BGP peer modules with initiate-connection set to false.
50 ... Configures 6 different peers, two internal, two external and two route-reflectors.
51 FOR ${index} ${peer_type} IN ZIP ${NUMBERS} ${PEER_TYPES}
52 &{mapping} Create Dictionary IP=127.0.0.${index} HOLDTIME=${HOLDTIME} PASSIVE_MODE=true BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
53 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
54 TemplatedRequests.Put_As_Xml_Templated ${POLICIES_VAR}${/}${peer_type} mapping=${mapping} session=${CONFIG_SESSION}
58 [Documentation] Start 6 exabgps as processes in background, each with it's own configuration.
59 SSHKeywords.Virtual_Env_Activate_On_Current_Session log_output=${True}
60 FOR ${index} IN @{NUMBERS}
61 ${start_cmd} BuiltIn.Set_Variable ${CMD} exabgp${index}.cfg > exa${index}.log &
62 BuiltIn.Log ${start_cmd}
63 ${output} SSHLibrary.Write ${start_cmd}
68 [Documentation] Verifies that sent routes are present in particular ribs.
73 [Documentation] Send command to kill all exabgp processes running on controller
74 ExaBgpLib.Stop_All_ExaBgps
75 FOR ${index} IN @{NUMBERS}
76 BGPcliKeywords.Store_File_To_Workspace exa${index}.log exa${index}.log
79 Delete_Bgp_Peer_Configuration
80 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
81 FOR ${index} ${peer_type} IN ZIP ${NUMBERS} ${PEER_TYPES}
82 &{mapping} Create Dictionary IP=127.0.0.${index} HOLDTIME=${HOLDTIME} PASSIVE_MODE=true BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
83 ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
84 TemplatedRequests.Delete_Templated ${POLICIES_VAR}/${peer_type} mapping=${mapping} session=${CONFIG_SESSION}
88 [Documentation] Revert the BGP configuration to the original state: without application peer
89 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
90 TemplatedRequests.Delete_Templated ${POLICIES_VAR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
91 TemplatedRequests.Delete_Templated ${POLICIES_VAR}/app_peer_route mapping=${mapping} session=${CONFIG_SESSION}
95 [Documentation] Suite setup keyword.
96 SetupUtils.Setup_Utils_For_Setup_And_Teardown
97 ${conn_id}= SSHLibrary.Open Connection ${ODL_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=10s
98 Builtin.Set_Suite_Variable ${conn_id}
99 SSHKeywords.Flexible_Controller_Login
100 SSHKeywords.Virtual_Env_Create upgrade_pip=False
101 SSHKeywords.Virtual_Env_Install_Package exabgp==4.0.5
102 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
106 [Documentation] Suite teardown keyword
107 SSHKeywords.Virtual_Env_Delete
108 SSHLibrary.Close_All_Connections
109 RequestsLibrary.Delete_All_Sessions
112 [Documentation] Verify output from effective-rib-in for each of the 6 exabgp peers and app peer.
113 ... First request is for full example-bgp-rib and it's output is logged for debug purposes.
114 ... Each of the peers have different output which is stored in folder by their respective
115 ... numbers as peer_${index} (peer_1, peer_2 ...)
116 # gets and outputs full rib output for debug purposes if one of the peers reports faulty data.
117 ${output} TemplatedRequests.Get_As_Json_Templated ${POLICIES_VAR}/rib_state session=${CONFIG_SESSION}
118 BuiltIn.Log ${output}
119 ${AS_PATH} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH}
120 FOR ${index} IN @{NUMBERS}
121 &{mapping} BuiltIn.Create_Dictionary IP=127.0.0.${index} AS_PATH=${AS_PATH}
122 BuiltIn.Wait_Until_Keyword_Succeeds 5x 3s TemplatedRequests.Get_As_Json_Templated ${POLICIES_VAR}/effective_rib_in/peer_${index} mapping=${mapping}
123 ... session=${CONFIG_SESSION} verify=True
125 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} AS_PATH=${AS_PATH}
126 # application peer verification
127 BuiltIn.Wait_Until_Keyword_Succeeds 5x 3s TemplatedRequests.Get_As_Json_Templated ${POLICIES_VAR}/app_peer_rib mapping=${mapping} session=${CONFIG_SESSION}
130 Verify_Rib_Status_Empty
131 [Documentation] Checks that example-ipv4-topology is ready, and therefore full rib is ready to be configured.
132 BuiltIn.Wait_Until_Keyword_Succeeds 60s 3s TemplatedRequests.Get_As_Json_Templated ${POLICIES_VAR}/topology_state session=${CONFIG_SESSION} verify=True
135 [Documentation] Uploads exabgp config files and replaces variables within those
136 ... config files with desired values.
137 FOR ${index} IN @{NUMBERS}
138 SSHLibrary.Put_File ${POLICIES_VAR}/exabgp_configs/exabgp${index}.cfg .
140 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
141 FOR ${cfgfile} IN @{cfgfiles}
142 SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
143 SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
144 SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
145 ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}