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 Resource ../../../libraries/ExaBgpLib.robot
14 Resource ../../../libraries/SetupUtils.robot
15 Resource ../../../libraries/SSHKeywords.robot
16 Resource ../../../libraries/TemplatedRequests.robot
17 Resource ../../../variables/Variables.robot
21 ${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpflowspec
22 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
23 ${EXP0} empty-flowspec.json
24 ${CFG1} bgp-flowspec.cfg
25 ${EXP1} bgp-flowspec.json
26 ${CFG2} bgp-flowspec-redirect.cfg
27 ${EXP2} bgp-flowspec-redirect.json
28 ${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
29 ${CONFIG_SESSION} session
30 ${DEVICE_NAME} controller-config
31 ${BGP_PEER_NAME} example-bgp-peer
32 ${RIB_INSTANCE} example-bgp-rib
33 ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
36 Check_For_Empty_Topology_Before_Talking
37 [Documentation] Sanity check bgp-flowspec:flowspec-routes is up but empty.
39 BuiltIn.Wait Until Keyword Succeeds 60s 3s Verify Empty Flowspec Data
41 Reconfigure_ODL_To_Accept_Connection
42 [Documentation] Configure BGP peer module with initiate-connection set to false.
43 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT}
44 ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} PASSIVE_MODE=true
45 TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
48 [Documentation] Testing flowspec values for ${CFG1}
49 [Setup] Setup Testcase ${CFG1}
50 BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP1}
51 [Teardown] ExaBgpLib.Stop_ExaBgp
54 [Documentation] Testing flowspec values for ${CFG2}
55 [Setup] Setup Testcase ${CFG2}
56 BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP2}
57 [Teardown] ExaBgpLib.Stop_ExaBgp
59 Deconfigure_ODL_To_Accept_Connection
60 [Documentation] Deconfigure BGP peer.
61 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
62 TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
66 [Documentation] Suite setup keyword
67 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
68 Builtin.Set Suite Variable ${mininet_conn_id}
69 SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
70 SSHKeywords.Virtual_Env_Create
71 SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16
72 RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
73 Upload Config Files ${CURDIR}/../../../variables/bgpflowspec/
76 [Documentation] Suite teardown keyword
77 SSHLibrary.Close All Connections
78 RequestsLibrary.Delete All Sessions
81 [Arguments] ${dir_name}
82 [Documentation] Uploads exabgp config files
83 SSHLibrary.Put Directory ${CURDIR}/../../../variables/bgpflowspec/ .
84 @{cfgfiles}= SSHLibrary.List Files In Directory . *.cfg
85 : FOR ${cfgfile} IN @{cfgfiles}
86 \ SSHLibrary.Execute Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
87 \ SSHLibrary.Execute Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
88 \ ${stdout}= SSHLibrary.Execute Command cat ${cfgfile}
92 [Arguments] ${cfg_file}
93 Verify Empty Flowspec Data
94 ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${cfg_file} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP} connection_retries=${3}
96 Verify Empty Flowspec Data
97 [Documentation] Verify expected response.
98 Verify Flowspec Data ${EXP0}
101 [Arguments] ${exprspfile}
102 [Documentation] Verify expected response
103 ${keys_with_bits}= BuiltIn.Create_List
104 ${expected_rsp}= Get Expected Response From File ${exprspfile}
105 ${rsp}= RequestsLibrary.Get Request ${CONFIG_SESSION} ${FLOWSPEC_URL}
106 TemplatedRequests.Normalize_Jsons_With_Bits_And_Compare ${expected_rsp} ${rsp.content} keys_with_bits=${keys_with_bits}
108 Get Expected Response From File
109 [Arguments] ${exprspfile}
110 [Documentation] Looks for release specific response first, then take default.
111 ${status} ${expresponse}= BuiltIn.Run_Keyword_And_Ignore_Error OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile}.${ODL_STREAM}
112 Return From Keyword If '${status}' == 'PASS' ${expresponse}
113 ${expresponse}= OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile}
114 [Return] ${expresponse}