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}
57 [Documentation] Start 6 exabgps as processes in background, each with it's own configuration.
58 SSHKeywords.Virtual_Env_Activate_On_Current_Session log_output=${True}
59 : FOR ${index} IN @{NUMBERS}
60 \ ${start_cmd} BuiltIn.Set_Variable ${CMD} exabgp${index}.cfg > exa${index}.log &
61 \ BuiltIn.Log ${start_cmd}
62 \ ${output} SSHLibrary.Write ${start_cmd}
63 \ BuiltIn.Log ${output}
66 [Documentation] Verifies that sent routes are present in particular ribs.
71 [Documentation] Send command to kill all exabgp processes running on controller
72 ExaBgpLib.Stop_All_ExaBgps
73 : FOR ${index} IN @{NUMBERS}
74 \ BGPcliKeywords.Store_File_To_Workspace exa${index}.log exa${index}.log
76 Delete_Bgp_Peer_Configuration
77 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
78 : FOR ${index} ${peer_type} IN ZIP ${NUMBERS} ${PEER_TYPES}
79 \ &{mapping} Create Dictionary IP=127.0.0.${index} HOLDTIME=${HOLDTIME} PASSIVE_MODE=true BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
80 \ ... RIB_INSTANCE_NAME=${RIB_INSTANCE}
81 \ TemplatedRequests.Delete_Templated ${POLICIES_VAR}/${peer_type} mapping=${mapping} session=${CONFIG_SESSION}
84 [Documentation] Revert the BGP configuration to the original state: without application peer
85 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
86 TemplatedRequests.Delete_Templated ${POLICIES_VAR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
87 TemplatedRequests.Delete_Templated ${POLICIES_VAR}/app_peer_route mapping=${mapping} session=${CONFIG_SESSION}
91 [Documentation] Suite setup keyword.
92 SetupUtils.Setup_Utils_For_Setup_And_Teardown
93 ${conn_id}= SSHLibrary.Open Connection ${ODL_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=10s
94 Builtin.Set_Suite_Variable ${conn_id}
95 SSHKeywords.Flexible_Controller_Login
96 SSHKeywords.Virtual_Env_Create upgrade_pip=False
97 SSHKeywords.Virtual_Env_Install_Package exabgp==4.0.5
98 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
102 [Documentation] Suite teardown keyword
103 SSHKeywords.Virtual_Env_Delete
104 SSHLibrary.Close_All_Connections
105 RequestsLibrary.Delete_All_Sessions
108 [Documentation] Verify output from effective-rib-in for each of the 6 exabgp peers and app peer.
109 ... First request is for full example-bgp-rib and it's output is logged for debug purposes.
110 ... Each of the peers have different output which is stored in folder by their respective
111 ... numbers as peer_${index} (peer_1, peer_2 ...)
112 # gets and outputs full rib output for debug purposes if one of the peers reports faulty data.
113 ${output} TemplatedRequests.Get_As_Json_Templated ${POLICIES_VAR}/rib_state session=${CONFIG_SESSION}
114 BuiltIn.Log ${output}
115 ${AS_PATH} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH}
116 : FOR ${index} IN @{NUMBERS}
117 \ &{mapping} BuiltIn.Create_Dictionary IP=127.0.0.${index} AS_PATH=${AS_PATH}
118 \ BuiltIn.Wait_Until_Keyword_Succeeds 5x 3s TemplatedRequests.Get_As_Json_Templated ${POLICIES_VAR}/effective_rib_in/peer_${index} mapping=${mapping}
119 \ ... session=${CONFIG_SESSION} verify=True
120 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} AS_PATH=${AS_PATH}
121 # application peer verification
122 BuiltIn.Wait_Until_Keyword_Succeeds 5x 3s TemplatedRequests.Get_As_Json_Templated ${POLICIES_VAR}/app_peer_rib mapping=${mapping} session=${CONFIG_SESSION}
125 Verify_Rib_Status_Empty
126 [Documentation] Checks that example-ipv4-topology is ready, and therefore full rib is ready to be configured.
127 BuiltIn.Wait_Until_Keyword_Succeeds 60s 3s TemplatedRequests.Get_As_Json_Templated ${POLICIES_VAR}/topology_state session=${CONFIG_SESSION} verify=True
130 [Documentation] Uploads exabgp config files and replaces variables within those
131 ... config files with desired values.
132 : FOR ${index} IN @{NUMBERS}
133 \ SSHLibrary.Put_File ${POLICIES_VAR}/exabgp_configs/exabgp${index}.cfg .
134 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
135 : FOR ${cfgfile} IN @{cfgfiles}
136 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
137 \ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
138 \ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
139 \ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}