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