2 Documentation Functional test for bgp flowspec.
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
9 Suite Setup Start Suite
10 Suite Teardown Stop Suite
11 Library RequestsLibrary
13 Variables ${CURDIR}/../../../variables/Variables.py
14 Variables ${CURDIR}/../../../variables/bgpuser/variables.py ${TOOLS_SYSTEM_IP} ${ODL_STREAM}
15 Resource ${CURDIR}/../../../libraries/ExaBgpLib.robot
16 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
17 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
18 Resource ${CURDIR}/../../../libraries/CompareStream.robot
19 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
23 ${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpflowspec
24 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
25 ${EXP0} empty-flowspec.json
26 ${CFG1} bgp-flowspec.cfg
27 ${EXP1} bgp-flowspec.json
28 ${CFG2} bgp-flowspec-redirect.cfg
29 ${EXP2} bgp-flowspec-redirect.json
30 ${FLOWSPEC_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv4-address-family/bgp-flowspec:flowspec-subsequent-address-family/bgp-flowspec:flowspec-routes
31 ${CONFIG_SESSION} session
32 ${DEVICE_NAME} controller-config
33 ${BGP_PEER_NAME} example-bgp-peer
34 ${RIB_INSTANCE} example-bgp-rib
35 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
38 Check_For_Empty_Topology_Before_Talking
39 [Documentation] Sanity check bgp-flowspec:flowspec-routes is up but empty.
41 BuiltIn.Wait Until Keyword Succeeds 60s 3s Verify Empty Flowspec Data
43 Reconfigure_ODL_To_Accept_Connection
44 [Documentation] Configure BGP peer module with initiate-connection set to false.
45 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
46 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} PASSIVE_MODE=true
47 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
50 [Documentation] Testing flowspec values for ${CFG1}
51 [Setup] Setup Testcase ${CFG1}
52 BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP1}
53 [Teardown] ExaBgpLib.Stop_ExaBgp
56 [Documentation] Testing flowspec values for ${CFG2}
57 [Setup] Setup Testcase ${CFG2}
58 BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP2}
59 [Teardown] ExaBgpLib.Stop_ExaBgp
61 Deconfigure_ODL_To_Accept_Connection
62 [Documentation] Deconfigure BGP peer.
63 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
64 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
68 [Documentation] Suite setup keyword
69 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
70 Builtin.Set Suite Variable ${mininet_conn_id}
71 SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
72 ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command ls return_stdout=True return_stderr=True
74 ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo apt-get install -y python-pip return_stdout=True return_stderr=True
76 ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo pip install exabgp return_stdout=True return_stderr=True
78 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
79 Upload Config Files ${CURDIR}/../../../variables/bgpflowspec/
82 [Documentation] Suite teardown keyword
83 SSHLibrary.Close All Connections
84 RequestsLibrary.Delete All Sessions
87 [Arguments] ${dir_name}
88 [Documentation] Uploads exabgp config files
89 SSHLibrary.Put Directory ${CURDIR}/../../../variables/bgpflowspec/ .
90 @{cfgfiles}= SSHLibrary.List Files In Directory . *.cfg
91 : FOR ${cfgfile} IN @{cfgfiles}
92 \ SSHLibrary.Execute Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
93 \ SSHLibrary.Execute Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
94 \ ${stdout}= SSHLibrary.Execute Command cat ${cfgfile}
98 [Arguments] ${cfg_file}
99 Verify Empty Flowspec Data
100 ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${cfg_file} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP} connection_retries=${3}
102 Verify Empty Flowspec Data
103 [Documentation] Verify expected response.
104 Verify Flowspec Data ${EXP0}
107 [Arguments] ${exprspfile}
108 [Documentation] Verify expected response
109 ${keys_with_bits}= BuiltIn.Create_List
110 ${expected_rsp}= Get Expected Response From File ${exprspfile}
111 ${rsp}= RequestsLibrary.Get Request ${CONFIG_SESSION} ${FLOWSPEC_URL}
112 TemplatedRequests.Normalize_Jsons_With_Bits_And_Compare ${expected_rsp} ${rsp.content} keys_with_bits=${keys_with_bits}
114 Get Expected Response From File
115 [Arguments] ${exprspfile}
116 [Documentation] Looks for release specific response first, then take default.
117 ${status} ${expresponse}= BuiltIn.Run_Keyword_And_Ignore_Error OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile}.${ODL_STREAM}
118 Return From Keyword If '${status}' == 'PASS' ${expresponse}
119 ${expresponse}= OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile}
120 [Return] ${expresponse}