2 Documentation Functional test suite for bgp - l3vpn-ipv4
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 advertising and receiveing routes with l3vpn content.
11 ... It uses odl and exabgp as bgp peers. Routes advertized from odl
12 ... are configured via application peer. Routes advertised from exabgp is
13 ... statically configured in exabgp config file.
15 ... For fluorine and further, instead of exabgp, play.py is used. When sending
16 ... routes from odl to peer, first route containg route-target argument have to
17 ... be send from peer to odl, so odl can identify this peer. Than it sends l3vpn
18 ... route containg this argument to odl app peer, and we check that app peer
19 ... advertizes this route back to the peer.
20 Suite Setup Start_Suite
21 Suite Teardown Stop_Suite
22 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
23 Library RequestsLibrary
25 Library ../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
26 Resource ../../../libraries/BGPcliKeywords.robot
27 Resource ../../../libraries/BgpOperations.robot
28 Resource ../../../libraries/BGPSpeaker.robot
29 Resource ../../../libraries/CompareStream.robot
30 Resource ../../../libraries/ExaBgpLib.robot
31 Resource ../../../libraries/KarafKeywords.robot
32 Resource ../../../libraries/SetupUtils.robot
33 Resource ../../../libraries/SSHKeywords.robot
34 Resource ../../../libraries/TemplatedRequests.robot
35 Resource ../../../libraries/Utils.robot
36 Resource ../../../variables/Variables.robot
39 ${BGP_L3VPN_DIR} ${BGP_VAR_FOLDER}/l3vpn_ipv4
40 ${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
41 ${CONFIG_SESSION} config-session
42 ${DEFAULT_BGPCEP_LOG_LEVEL} INFO
43 ${DEFAULT_EXA_CFG} exa.cfg
44 ${EXARPCSCRIPT} ${CURDIR}/../../../../tools/exabgp_files/exarpc.py
46 ${L3VPN_EXA_CFG} bgp-l3vpn-ipv4.cfg
47 ${L3VPN_EXP} ${BGP_L3VPN_DIR}/route_expected/exa-expected.json
48 ${L3VPN_RSP} ${BGP_L3VPN_DIR}/bgp-l3vpn-ipv4.json
49 ${L3VPN_RSPEMPTY} ${BGP_L3VPN_DIR}/bgp-l3vpn-ipv4-empty.json
50 ${L3VPN_RSP_PATH} ${BGP_L3VPN_DIR}/bgp-l3vpn-ipv4-path.json
51 ${L3VPN_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv4-address-family/bgp-types:mpls-labeled-vpn-subsequent-address-family/bgp-vpn-ipv4:vpn-ipv4-routes
52 ${PEER_CHECK_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
53 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
54 ${RIB_INSTANCE} example-bgp-rib
55 ${RT_CONSTRAIN_DIR} ${CURDIR}/../../../variables/bgpfunctional/rt_constrain
59 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
60 &{mapping} BuiltIn.Create_Dictionary BGP_RIB=${RIB_INSTANCE} IP=${ODL_SYSTEM_IP}
61 TemplatedRequests.Put_As_Xml_Templated ${RT_CONSTRAIN_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
63 Reconfigure_ODL_To_Accept_Connection
64 [Documentation] Configures BGP peer module with initiate-connection set to false.
65 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB=${RIB_INSTANCE} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} INITIATE=false
66 ... BGP_RIB_OPENCONFIG=${RIB_INSTANCE} PASSIVE_MODE=true
67 CompareStream.Run_Keyword_If_At_Least_Fluorine TemplatedRequests.Put_As_Xml_Templated ${RT_CONSTRAIN_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
68 CompareStream.Run_Keyword_If_Less_Than_Fluorine TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
71 [Documentation] Testing mpls vpn ipv4 routes reported to odl from exabgp
72 [Setup] Setup_Testcase ${L3VPN_EXA_CFG}
73 ${L3VPN_RESPONSE} CompareStream.Set_Variable_If_At_Least_Fluorine ${L3VPN_RSP_PATH} ${L3VPN_RSP}
74 BuiltIn.Wait_Until_Keyword_Succeeds 15s 1s Verify Reported Data ${L3VPN_URL} ${L3VPN_RESPONSE}
75 [Teardown] Teardown_Simple
78 [Documentation] Start Python speaker to connect to ODL. We need to do WUKS until odl really starts to accept incomming bgp connection. The failure happens if the incomming connection comes too quickly after configuring the peer in the previous test case.
79 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
80 CompareStream.Run_Keyword_If_Less_Than_Fluorine BuiltIn.Pass_Execution "Only run on Fluorine and later"
81 SSHLibrary.Put File ${PLAY_SCRIPT} .
82 SSHKeywords.Assure_Library_Ipaddr target_dir=.
84 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start_Bgp_Peer
86 Play_To_Odl_rt_constrain_type_0
87 [Documentation] This keyword sends route-target route containg route-target argument so odl
88 ... can identify this peer as appropriate for advertizement when it recieves such route.
89 CompareStream.Run_Keyword_If_Less_Than_Fluorine BuiltIn.Pass_Execution "Only run on Fluorine and later"
90 BgpOperations.Play_To_Odl_Non_Removal_Template rt_constrain_type_0 ${RT_CONSTRAIN_DIR}
93 [Documentation] Send l3vpn route to app peer, and than checks that app peer advertizes this route.
94 CompareStream.Run_Keyword_If_At_Least_Fluorine BuiltIn.Pass_Execution "Only run on less than Fluorine"
95 Setup_Testcase ${DEFAULT_EXA_CFG}
97 [Teardown] CompareStream.Run_Keyword_If_Less_Than_Fluorine Teardowm_With_Remove_Route
99 Odl_To_Play_l3vpn_rt_arg
100 [Documentation] Same as TC before but fluorine and further this l3vpn route also needs to contain route-target argument.
101 CompareStream.Run_Keyword_If_Less_Than_Fluorine BuiltIn.Pass_Execution "Only run on Fluorine and later"
102 BgpOperations.Odl_To_Play_Template l3vpn_rt_arg ${RT_CONSTRAIN_DIR} False
104 Kill_Talking_BGP_Speaker
105 [Documentation] Abort the Python speaker
106 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
107 CompareStream.Run_Keyword_If_Less_Than_Fluorine BuiltIn.Pass_Execution "Only run on Fluorine and later"
108 BGPSpeaker.Kill_BGP_Speaker
109 BGPcliKeywords.Store_File_To_Workspace play.py.out 010_l3vpn_play.log
111 Delete_Bgp_Peer_Configuration
112 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
113 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB=${RIB_INSTANCE}
114 TemplatedRequests.Delete_Templated ${RT_CONSTRAIN_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
117 [Documentation] Revert the BGP configuration to the original state: without application peer
118 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB=${RIB_INSTANCE}
119 TemplatedRequests.Delete_Templated ${RT_CONSTRAIN_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
123 [Documentation] Suite setup keyword.
124 SetupUtils.Setup_Utils_For_Setup_And_Teardown
125 ${tools_system_conn_id}= SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
126 Builtin.Set_Suite_Variable ${tools_system_conn_id}
127 SSHKeywords.Flexible_Mininet_Login ${TOOLS_SYSTEM_USER}
128 SSHKeywords.Virtual_Env_Create
129 SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16
130 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
134 [Documentation] Suite teardown keyword
135 SSHKeywords.Virtual_Env_Delete
136 SSHLibrary.Close_All_Connections
137 RequestsLibrary.Delete_All_Sessions
140 [Documentation] Uploads exabgp config files and needed scripts
141 SSHLibrary.Put_File ${BGP_VAR_FOLDER}/${DEFAULT_EXA_CFG} .
142 SSHLibrary.Put_File ${BGP_L3VPN_DIR}/${L3VPN_EXA_CFG} .
143 SSHLibrary.Put_File ${EXARPCSCRIPT} .
144 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
145 : FOR ${cfgfile} IN @{cfgfiles}
146 \ SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
147 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
148 \ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
149 \ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
150 \ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}
154 [Arguments] ${cfg_file}
155 [Documentation] Verifies initial test condition and starts the exabgp
156 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
157 Verify_Reported_Data ${L3VPN_URL} ${L3VPN_RSPEMPTY}
158 ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${cfg_file} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP} connection_retries=${3}
160 Teardowm_With_Remove_Route
161 [Documentation] Removes configured route from application peer and stops the exabgp
162 &{mapping} BuiltIn.Create_Dictionary APP_PEER_IP=${ODL_SYSTEM_IP}
163 TemplatedRequests.Delete_Templated ${BGP_L3VPN_DIR}/route mapping=${mapping} session=${CONFIG_SESSION}
167 [Documentation] Testcse teardown with data verification
168 ExaBgpLib.Stop_ExaBgp
169 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Verify_Reported_Data ${L3VPN_URL} ${L3VPN_RSPEMPTY}
171 Verify_ExaBgp_Received_Update
172 [Arguments] ${exp_update_fn}
173 [Documentation] Verification of receiving particular update message
174 ${exp_update}= Get_Expected_Response_From_File ${exp_update_fn}
175 ${rcv_update_dict}= BgpRpcClient.exa_get_update_message msg_only=${True}
176 ${rcv_update}= BuiltIn.Evaluate json.dumps(${rcv_update_dict}) modules=json
177 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_update} ${rcv_update}
180 [Arguments] ${url} ${exprspfile}
181 [Documentation] Verifies expected response
182 ${expected_rsp}= Get_Expected_Response_From_File ${exprspfile}
183 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${url}
184 TemplatedRequests.Normalize_Jsons_And_Compare ${expected_rsp} ${rsp.content}
186 Get_Expected_Response_From_File
187 [Arguments] ${exprspfile}
188 [Documentation] Looks for release specific response first, then take default.
189 ${status} ${expresponse}= BuiltIn.Run_Keyword_And_Ignore_Error OperatingSystem.Get File ${exprspfile}.${ODL_STREAM}
190 Return From Keyword If '${status}' == 'PASS' ${expresponse}
191 ${expresponse}= OperatingSystem.Get File ${exprspfile}
192 [Return] ${expresponse}
195 [Documentation] Starts bgp peer and verifies that the peer runs.
196 BGPSpeaker.Start_BGP_Speaker --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --debug --allf --wfr 1
197 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
200 [Documentation] Testing mpls vpn ipv4 routes reported to odl from exabgp
201 BgpRpcClient.exa_clean_update_message
202 &{mapping} BuiltIn.Create_Dictionary BGP_PEER_IP=${TOOLS_SYSTEM_IP} APP_PEER_IP=${ODL_SYSTEM_IP}
203 TemplatedRequests.Post_As_Xml_Templated ${BGP_L3VPN_DIR}/route mapping=${mapping} session=${CONFIG_SESSION}
204 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_ExaBgp_Received_Update ${L3VPN_EXP}