2 Documentation Functional test for bgp - route refresh
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 sending and receiveing route request message.
11 ... It uses odl and exabgp as bgp peers.
12 ... Sending route refresh message from odl is initiated via restconf.
13 ... If route refresh received by odl also correct advertising of routes
14 ... is verified. Receiving of route refresh by odl is verified by
15 ... checking appropriate message counter via ${JOLOKURL}. Feature
16 ... odl-jolokia is required by this test suite.
17 Suite Setup Start_Suite
18 Suite Teardown Stop_Suite
19 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
20 Library RequestsLibrary
22 Variables ${CURDIR}/../../../variables/Variables.py
23 Resource ${CURDIR}/../../../libraries/ExaBgpLib.robot
24 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
25 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
26 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
27 Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
31 ${DEVICE_NAME} controller-config
32 ${BGP_PEER_NAME} example-bgp-peer
33 ${RIB_INSTANCE} example-bgp-rib
34 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
35 ${APP_PEER_NAME} example-bgp-peer-app
36 ${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
37 ${BGP_RR_VAR_FOLDER} ${BGP_VAR_FOLDER}/route_refresh
38 ${BGP_CFG_NAME} exa.cfg
39 ${CONFIG_SESSION} config-session
40 ${EXARPCSCRIPT} ${CURDIR}/../../../../tools/exabgp_files/exarpc.py
41 ${JOLOKURL} /jolokia/read/org.opendaylight.controller:instanceName=${BGP_PEER_NAME},type=RuntimeBean,moduleFactoryName=bgp-peer
45 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
46 &{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} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
47 ... IP=${ODL_SYSTEM_IP}
48 TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
50 Reconfigure_ODL_To_Accept_Connection
51 [Documentation] Configures BGP peer module with initiate-connection set to false.
52 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
53 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} PASSIVE_MODE=true
54 TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
56 Exa_To_Send_Route_Request
57 [Documentation] Exabgp sends route refresh and count received updates
58 [Setup] Configure_Routes_And_Start_ExaBgp ${BGP_CFG_NAME}
59 BgpRpcClient.exa_clean_received_update_count
60 BgpRpcClient.exa_announce announce route-refresh ipv4 unicast
61 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_ExaBgp_Received_Updates ${nr_configured_routes}
62 [Teardown] Deconfigure_Routes_And_Stop_ExaBgp
64 Odl_To_Send_Route_Request
65 [Documentation] Sends route requests and checks if exabgp receives it
66 [Setup] ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${BGP_CFG_NAME} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP}
67 BgpRpcClient.exa_clean_received_route_refresh_count
68 &{mapping} BuiltIn.Create_Dictionary BGP_PEER_IP=${TOOLS_SYSTEM_IP}
69 TemplatedRequests.Post_As_Xml_Templated ${BGP_VAR_FOLDER}/route_refresh mapping=${mapping} session=${CONFIG_SESSION}
70 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_Odl_Sent_Route_Request 1
71 [Teardown] ExaBgpLib.Stop_ExaBgp
73 Delete_Bgp_Peer_Configuration
74 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
75 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
76 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
79 [Documentation] Revert the BGP configuration to the original state: without application peer
80 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME} IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
81 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
85 [Documentation] Suite setup keyword.
86 SetupUtils.Setup_Utils_For_Setup_And_Teardown
87 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
88 Builtin.Set_Suite_Variable ${mininet_conn_id}
89 SSHKeywords.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}
96 [Documentation] Suite teardown keyword
97 SSHKeywords.Virtual_Env_Delete
98 SSHLibrary.Close_All_Connections
99 RequestsLibrary.Delete_All_Sessions
102 [Documentation] Uploads exabgp config files
103 SSHLibrary.Put_File ${BGP_VAR_FOLDER}/${BGP_CFG_NAME} .
104 SSHLibrary.Put_File ${EXARPCSCRIPT} .
105 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
106 : FOR ${cfgfile} IN @{cfgfiles}
107 \ SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
108 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
109 \ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/enable/g' ${cfgfile}
110 \ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
111 \ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}
114 Configure_Routes_And_Start_ExaBgp
115 [Arguments] ${cfg_file}
116 [Documentation] Setup keyword for exa to odl test case
117 ${app_rib} Set Variable ${ODL_SYSTEM_IP}
118 : FOR ${prefix} IN 1.1.1.1/32 2.2.2.2/32
119 \ &{mapping} BuiltIn.Create_Dictionary PREFIX=${prefix} APP_RIB=${app_rib}
120 \ TemplatedRequests.Post_As_Xml_Templated ${BGP_RR_VAR_FOLDER}/route mapping=${mapping} session=${CONFIG_SESSION}
121 BuiltIn.Set_Suite_Variable ${nr_configured_routes} 2
122 ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${cfg_file} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP}
123 BuiltIn.Wait_Until_Keyword_Succeeds 3x 3s Verify_ExaBgp_Received_Updates ${nr_configured_routes}
125 Deconfigure_Routes_And_Stop_ExaBgp
126 [Documentation] Teardown keyword for exa to odl test case
127 ExaBgpLib.Stop_ExaBgp
128 ${app_rib} Set Variable ${ODL_SYSTEM_IP}
129 &{mapping} BuiltIn.Create_Dictionary PREFIX=${prefix} APP_RIB=${app_rib}
130 TemplatedRequests.Delete_Templated ${BGP_RR_VAR_FOLDER}/route mapping=${mapping} session=${CONFIG_SESSION}
132 Verify_Odl_Sent_Route_Request
133 [Arguments] ${expcount}
134 [Documentation] Compares expected count of route request messages on exabgp side
135 ${count}= BgpRpcClient.exa_get_received_route_refresh_count
136 BuiltIn.Should Be Equal As Numbers ${count} ${expcount}
138 Verify_Odl_Received_Route_Request
139 [Arguments] ${expcount}
140 [Documentation] Gets numebr of received route requests and compares with given expected count
141 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${JOLOKURL}
142 BuiltIn.Log ${rsp.content}
143 BuiltIn.Should_Be_Equal_As_Numbers ${rsp.status_code} 200
144 BuiltIn.Should_Be_Equal_As_Numbers ${rsp.json()['status']} 200
145 BuiltIn.Should_Be_Equal_As_Numbers ${rsp.json()['value']['BgpSessionState']['messagesStats']['routeRefreshMsgs']['received']['count']['value']} ${expcount}
147 Verify_ExaBgp_Received_Updates
148 [Arguments] ${expcount}
149 [Documentation] Gets numebr of received update requests and compares with given expected count
150 ${count_recv}= BgpRpcClient.exa_get_received_update_count
151 BuiltIn.Should Be Equal As Numbers ${count_recv} ${expcount}