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/SetupUtils.robot
32 Resource ../../../libraries/SSHKeywords.robot
33 Resource ../../../libraries/TemplatedRequests.robot
34 Resource ../../../variables/Variables.robot
37 ${BGP_L3VPN_DIR} ${BGP_VAR_FOLDER}/l3vpn_ipv4
38 ${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
39 ${CONFIG_SESSION} config-session
40 ${DEFAULT_BGPCEP_LOG_LEVEL} INFO
41 ${DEFAULT_EXA_CFG} exa.cfg
42 ${EXARPCSCRIPT} ${CURDIR}/../../../../tools/exabgp_files/exarpc.py
44 ${L3VPN_EXA_CFG} bgp-l3vpn-ipv4.cfg
45 ${L3VPN_EXP} exa_expected
46 ${L3VPN_RSP} bgp_l3vpn_ipv4
47 ${L3VPN_RSPEMPTY} bgp_l3vpn_ipv4_empty
48 ${L3VPN_RSP_PATH} bgp_l3vpn_ipv4_path
49 ${OLD_AS_PATH} \n"as-path": {},
50 ${NEW_AS_PATH} ${EMPTY}
51 ${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
52 ${RIB_INSTANCE} example-bgp-rib
53 ${RT_CONSTRAIN_DIR} ${CURDIR}/../../../variables/bgpfunctional/rt_constrain
57 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
58 &{mapping} BuiltIn.Create_Dictionary BGP_RIB=${RIB_INSTANCE} IP=${ODL_SYSTEM_IP}
59 TemplatedRequests.Put_As_Xml_Templated ${RT_CONSTRAIN_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
61 Reconfigure_ODL_To_Accept_Connection
62 [Documentation] Configures BGP peer module with initiate-connection set to false.
63 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB=${RIB_INSTANCE} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} INITIATE=false
64 ... BGP_RIB_OPENCONFIG=${RIB_INSTANCE} PASSIVE_MODE=true
65 CompareStream.Run_Keyword_If_At_Least_Fluorine TemplatedRequests.Put_As_Xml_Templated ${RT_CONSTRAIN_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
66 CompareStream.Run_Keyword_If_Less_Than_Fluorine TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
69 [Documentation] Testing mpls vpn ipv4 routes reported to odl from exabgp
70 [Setup] Setup_Testcase ${L3VPN_EXA_CFG}
71 ${L3VPN_RESPONSE} CompareStream.Set_Variable_If_At_Least_Fluorine ${L3VPN_RSP_PATH} ${L3VPN_RSP}
72 BuiltIn.Wait_Until_Keyword_Succeeds 15s 1s Verify_Reported_Data ${L3VPN_RESPONSE}
73 [Teardown] Teardown_Simple
76 [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.
77 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
78 CompareStream.Run_Keyword_If_Less_Than_Fluorine BuiltIn.Pass_Execution "Only run on Fluorine and later"
79 SSHLibrary.Put_File ${PLAY_SCRIPT} .
80 SSHKeywords.Assure_Library_Ipaddr target_dir=.
82 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Start_Bgp_Peer
84 Play_To_Odl_rt_constrain_type_0
85 [Documentation] This keyword sends route-target route containg route-target argument so odl
86 ... can identify this peer as appropriate for advertizement when it recieves such route.
87 CompareStream.Run_Keyword_If_Less_Than_Fluorine BuiltIn.Pass_Execution "Only run on Fluorine and later"
88 BgpOperations.Play_To_Odl_Non_Removal_Template rt_constrain_type_0 ${RT_CONSTRAIN_DIR}
91 [Documentation] Send l3vpn route to app peer, and than checks that app peer advertizes this route.
92 CompareStream.Run_Keyword_If_At_Least_Fluorine BuiltIn.Pass_Execution "Only run on less than Fluorine"
93 Setup_Testcase ${DEFAULT_EXA_CFG}
95 [Teardown] CompareStream.Run_Keyword_If_Less_Than_Fluorine Teardowm_With_Remove_Route
97 Odl_To_Play_l3vpn_rt_arg
98 [Documentation] Same as TC before but fluorine and further this l3vpn route also needs to contain route-target argument.
99 CompareStream.Run_Keyword_If_Less_Than_Fluorine BuiltIn.Pass_Execution "Only run on Fluorine and later"
100 BgpOperations.Odl_To_Play_Template l3vpn_rt_arg ${RT_CONSTRAIN_DIR} False
102 Kill_Talking_BGP_Speaker
103 [Documentation] Abort the Python speaker
104 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
105 CompareStream.Run_Keyword_If_Less_Than_Fluorine BuiltIn.Pass_Execution "Only run on Fluorine and later"
106 BGPSpeaker.Kill_BGP_Speaker
107 BGPcliKeywords.Store_File_To_Workspace play.py.out 010_l3vpn_play.log
109 Delete_Bgp_Peer_Configuration
110 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
111 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB=${RIB_INSTANCE}
112 TemplatedRequests.Delete_Templated ${RT_CONSTRAIN_DIR}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
115 [Documentation] Revert the BGP configuration to the original state: without application peer
116 &{mapping} BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP} BGP_RIB=${RIB_INSTANCE}
117 TemplatedRequests.Delete_Templated ${RT_CONSTRAIN_DIR}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
121 [Documentation] Suite setup keyword.
122 SetupUtils.Setup_Utils_For_Setup_And_Teardown
123 ${tools_system_conn_id} = SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
124 Builtin.Set_Suite_Variable ${tools_system_conn_id}
125 SSHKeywords.Flexible_Mininet_Login ${TOOLS_SYSTEM_USER}
126 SSHKeywords.Virtual_Env_Create
127 SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16
128 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
130 ${AS_PATH} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH}
131 BuiltIn.Set_Suite_Variable ${AS_PATH}
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}
155 [Arguments] ${cfg_file}
156 [Documentation] Verifies initial test condition and starts the exabgp
157 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
158 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Verify_Empty_Reported_Data
159 ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${cfg_file} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP} connection_retries=${3}
161 Teardowm_With_Remove_Route
162 [Documentation] Removes configured route from application peer and stops the exabgp
163 &{mapping} BuiltIn.Create_Dictionary APP_PEER_IP=${ODL_SYSTEM_IP}
164 TemplatedRequests.Delete_Templated ${BGP_L3VPN_DIR}/route mapping=${mapping} session=${CONFIG_SESSION}
168 [Documentation] Testcse teardown with data verification
169 ExaBgpLib.Stop_ExaBgp
170 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Verify_Empty_Reported_Data
172 Verify_ExaBgp_Received_Update
173 [Arguments] ${exp_update_fn}
174 [Documentation] Verification of receiving particular update message
175 ${exp_update} = TemplatedRequests.Resolve_Text_From_Template_File ${BGP_L3VPN_DIR}${/}${exp_update_fn} data.json
176 ${rcv_update_dict} = BgpRpcClient.exa_get_update_message msg_only=${True}
177 ${rcv_update} = BuiltIn.Evaluate json.dumps(${rcv_update_dict}) modules=json
178 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_update} ${rcv_update}
180 Verify_Empty_Reported_Data
181 [Documentation] Verfiy empty data response
182 CompareStream.Run_Keyword_If_At_Most_Fluorine TemplatedRequests.Get_As_Json_Templated ${BGP_L3VPN_DIR}${/}${L3VPN_RSPEMPTY} session=${CONFIG_SESSION} verify=True
183 CompareStream.Run_Keyword_If_At_Least_Neon Verify_Empty_Data_Neon
186 [Arguments] ${exprspdir}
187 [Documentation] Verifies expected response
188 &{mapping} BuiltIn.Create_Dictionary AS_PATH=${AS_PATH}
189 TemplatedRequests.Get_As_Json_Templated ${BGP_L3VPN_DIR}${/}${exprspdir} mapping=${mapping} session=${CONFIG_SESSION} verify=True
192 [Documentation] Starts bgp peer and verifies that the peer runs.
193 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
194 BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
197 [Documentation] Testing mpls vpn ipv4 routes reported to odl from exabgp
198 BgpRpcClient.exa_clean_update_message
199 &{mapping} BuiltIn.Create_Dictionary BGP_PEER_IP=${TOOLS_SYSTEM_IP} APP_PEER_IP=${ODL_SYSTEM_IP}
200 TemplatedRequests.Post_As_Xml_Templated ${BGP_L3VPN_DIR}/route mapping=${mapping} session=${CONFIG_SESSION}
201 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_ExaBgp_Received_Update ${L3VPN_EXP}
203 Verify_Empty_Data_Neon
204 [Documentation] Verify empty data on neon
205 TemplatedRequests.Get_As_Json_Templated ${BGP_L3VPN_DIR}${/}empty_route session=${CONFIG_SESSION} verify=True