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.
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 ${CURDIR}/../../../variables/Variables.robot
20 Resource ${CURDIR}/../../../libraries/ExaBgpLib.robot
21 Resource ${CURDIR}/../../../libraries/Utils.robot
22 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
23 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
24 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
25 Resource ${CURDIR}/../../../libraries/CompareStream.robot
26 Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP}
30 ${DEVICE_NAME} controller-config
31 ${BGP_PEER_NAME} example-bgp-peer
32 ${RIB_INSTANCE} example-bgp-rib
33 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
34 ${APP_PEER_NAME} example-bgp-peer-app
35 ${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional
36 ${BGP_L3VPN_DIR} ${BGP_VAR_FOLDER}/l3vpn_ipv4
37 ${DEFAUTL_EXA_CFG} exa.cfg
38 ${L3VPN_EXA_CFG} bgp-l3vpn-ipv4.cfg
39 ${L3VPN_RSPEMPTY} ${BGP_L3VPN_DIR}/bgp-l3vpn-ipv4-empty.json
40 ${L3VPN_RSP} ${BGP_L3VPN_DIR}/bgp-l3vpn-ipv4.json
41 ${L3VPN_RSP_PATH} ${BGP_L3VPN_DIR}/bgp-l3vpn-ipv4-path.json
42 ${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
43 ${L3VPN_EXP} ${BGP_L3VPN_DIR}/route_expected/exa-expected.json
44 ${CONFIG_SESSION} config-session
45 ${EXARPCSCRIPT} ${CURDIR}/../../../../tools/exabgp_files/exarpc.py
46 ${PEER_CHECK_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
47 ${DEFAULT_BGPCEP_LOG_LEVEL} INFO
51 [Documentation] Configures bgp application peer. Openconfig is used for carbon and above.
52 &{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}
53 ... IP=${ODL_SYSTEM_IP}
54 TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
56 Reconfigure_ODL_To_Accept_Connection
57 [Documentation] Configures BGP peer module with initiate-connection set to false.
58 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
59 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} PASSIVE_MODE=true
60 TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
63 [Documentation] Testing mpls vpn ipv4 routes reported to odl from exabgp
64 [Setup] Setup_Testcase ${L3VPN_EXA_CFG}
65 ${L3VPN_RESPONSE} CompareStream.Set_Variable_If_At_Least_Fluorine ${L3VPN_RSP_PATH} ${L3VPN_RSP}
66 BuiltIn.Wait_Until_Keyword_Succeeds 15s 1s Verify Reported Data ${L3VPN_URL} ${L3VPN_RESPONSE}
67 [Teardown] Teardown_Simple
70 [Documentation] Testing mpls vpn ipv4 routes reported from odl to exabgp
71 [Setup] Setup_Testcase ${DEFAUTL_EXA_CFG}
72 BgpRpcClient.exa_clean_update_message
73 &{mapping} BuiltIn.Create_Dictionary BGP_PEER_IP=${TOOLS_SYSTEM_IP} APP_PEER_IP=${ODL_SYSTEM_IP}
74 ${BGP_L3VPN_DIR_ROUTE} CompareStream.Set_Variable_If_At_Least_Fluorine ${BGP_L3VPN_DIR}/route-path ${BGP_L3VPN_DIR}/route
75 TemplatedRequests.Post_As_Xml_Templated ${BGP_L3VPN_DIR_ROUTE} mapping=${mapping} session=${CONFIG_SESSION}
76 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_ExaBgp_Received_Update ${L3VPN_EXP}
77 [Teardown] Teardowm_With_Remove_Route
79 Delete_Bgp_Peer_Configuration
80 [Documentation] Revert the BGP configuration to the original state: without any configured peers.
81 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
82 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
85 [Documentation] Revert the BGP configuration to the original state: without application peer
86 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} APP_PEER_NAME=${APP_PEER_NAME} IP=${ODL_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
87 TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/app_peer mapping=${mapping} session=${CONFIG_SESSION}
91 [Documentation] Suite setup keyword.
92 SetupUtils.Setup_Utils_For_Setup_And_Teardown
93 ${tools_system_conn_id}= SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
94 Builtin.Set_Suite_Variable ${tools_system_conn_id}
95 SSHKeywords.Flexible_Mininet_Login ${TOOLS_SYSTEM_USER}
96 SSHKeywords.Virtual_Env_Create
97 SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16
98 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
100 KarafKeywords.Set_Bgpcep_Log_Levels # ${DEFAULT_BGPCEP_LOG_LEVEL} is applied by default
103 [Documentation] Suite teardown keyword
104 SSHKeywords.Virtual_Env_Delete
105 SSHLibrary.Close_All_Connections
106 RequestsLibrary.Delete_All_Sessions
109 [Documentation] Uploads exabgp config files and needed scripts
110 SSHLibrary.Put_File ${BGP_VAR_FOLDER}/${DEFAUTL_EXA_CFG} .
111 SSHLibrary.Put_File ${BGP_L3VPN_DIR}/${L3VPN_EXA_CFG} .
112 SSHLibrary.Put_File ${EXARPCSCRIPT} .
113 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
114 : FOR ${cfgfile} IN @{cfgfiles}
115 \ SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
116 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
117 \ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
118 \ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
119 \ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}
123 [Arguments] ${cfg_file}
124 [Documentation] Verifies initial test condition and starts the exabgp
125 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
126 Verify_Reported_Data ${L3VPN_URL} ${L3VPN_RSPEMPTY}
127 ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${cfg_file} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP} connection_retries=${3}
129 Teardowm_With_Remove_Route
130 [Documentation] Removes configured route from application peer and stops the exabgp
131 &{mapping} BuiltIn.Create_Dictionary APP_PEER_IP=${ODL_SYSTEM_IP}
132 TemplatedRequests.Delete_Templated ${BGP_L3VPN_DIR}/route mapping=${mapping} session=${CONFIG_SESSION}
136 [Documentation] Testcse teardown with data verification
137 ExaBgpLib.Stop_ExaBgp
138 BuiltIn.Wait_Until_Keyword_Succeeds 3x 1s Verify_Reported_Data ${L3VPN_URL} ${L3VPN_RSPEMPTY}
140 Verify_ExaBgp_Received_Update
141 [Arguments] ${exp_update_fn}
142 [Documentation] Verification of receiving particular update message
143 ${exp_update}= Get_Expected_Response_From_File ${exp_update_fn}
144 ${rcv_update_dict}= BgpRpcClient.exa_get_update_message msg_only=${True}
145 ${rcv_update}= BuiltIn.Evaluate json.dumps(${rcv_update_dict}) modules=json
146 TemplatedRequests.Normalize_Jsons_And_Compare ${exp_update} ${rcv_update}
149 [Arguments] ${url} ${exprspfile}
150 [Documentation] Verifies expected response
151 ${expected_rsp}= Get_Expected_Response_From_File ${exprspfile}
152 ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${url}
153 TemplatedRequests.Normalize_Jsons_And_Compare ${expected_rsp} ${rsp.content}
155 Get_Expected_Response_From_File
156 [Arguments] ${exprspfile}
157 [Documentation] Looks for release specific response first, then take default.
158 ${status} ${expresponse}= BuiltIn.Run_Keyword_And_Ignore_Error OperatingSystem.Get File ${exprspfile}.${ODL_STREAM}
159 Return From Keyword If '${status}' == 'PASS' ${expresponse}
160 ${expresponse}= OperatingSystem.Get File ${exprspfile}
161 [Return] ${expresponse}