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}
15 Resource ${CURDIR}/../../../libraries/Utils.robot
16 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
17 Resource ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
18 Library ${CURDIR}/../../../libraries/norm_json.py
22 ${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpflowspec
23 ${CMD} env exabgp.tcp.port=1790 exabgp --debug
24 ${EXP0} empty-flowspec.json
25 ${CFG1} bgp-flowspec.cfg
26 ${EXP1} bgp-flowspec.json
27 ${CFG2} bgp-flowspec-redirect.cfg
28 ${EXP2} bgp-flowspec-redirect.json
29 ${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
32 Check_For_Empty_Topology_Before_Talking
33 [Documentation] Sanity check bgp-flowspec:flowspec-routes is up but empty.
35 BuiltIn.Wait Until Keyword Succeeds 60s 3s Verify Empty Flowspec Data
37 Reconfigure_ODL_To_Accept_Connection
38 [Documentation] Configure BGP peer module with initiate-connection set to false.
39 ${template_as_string}= BuiltIn.Set_Variable {'NAME': 'example-bgp-peer', 'IP': '${TOOLS_SYSTEM_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}', 'INITIATE': 'false'}
40 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${BGP_VARIABLES_FOLDER} ${template_as_string}
43 [Documentation] Testing flowspec values for ${CFG1}
44 [Setup] Setup Testcase ${CFG1}
45 BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP1}
49 [Documentation] Testing flowspec values for ${CFG2}
50 [Setup] Setup Testcase ${CFG2}
51 BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP2}
56 [Documentation] Suite setup keyword
57 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
58 Builtin.Set Suite Variable ${mininet_conn_id}
59 Utils.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
60 ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command ls return_stdout=True return_stderr=True
62 ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo apt-get install -y python-pip return_stdout=True return_stderr=True
64 ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo pip install exabgp return_stdout=True return_stderr=True
66 RequestsLibrary.Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
67 ConfigViaRestconf.Setup_Config_Via_Restconf
68 Upload Config Files ${CURDIR}/../../../variables/bgpflowspec/
71 [Documentation] Suite teardown keyword
72 ConfigViaRestconf.Teardown_Config_Via_Restconf
73 SSHLibrary.Close All Connections
74 RequestsLibrary.Delete All Sessions
77 [Arguments] ${dir_name}
78 [Documentation] Uploads exabgp config files
79 SSHLibrary.Put Directory ${CURDIR}/../../../variables/bgpflowspec/ .
80 @{cfgfiles}= SSHLibrary.List Files In Directory . *.cfg
81 : FOR ${cfgfile} IN @{cfgfiles}
82 \ SSHLibrary.Execute Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
83 \ SSHLibrary.Execute Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
84 \ ${stdout}= SSHLibrary.Execute Command cat ${cfgfile}
88 [Arguments] ${cfg_file}
89 Verify Empty Flowspec Data
90 Start Tool ${cfg_file}
93 [Arguments] ${cfg_file}
94 [Documentation] Start the tool ${cmd} ${cfg_file}
95 BuiltIn.Log ${cmd} ${cfg_file}
96 ${output}= SSHLibrary.Write ${cmd} ${cfg_file}
99 Wait_Until_Tool_Finish
100 [Arguments] ${timeout}
101 [Documentation] Wait ${timeout} for the tool exit.
102 BuiltIn.Wait Until Keyword Succeeds ${timeout} 1s SSHLibrary.Read Until Prompt
105 [Documentation] Stop the tool if still running.
106 Utils.Write_Bare_Ctrl_C
107 ${output}= SSHLibrary.Read delay=1s
108 BuiltIn.Log ${output}
109 Verify Empty Flowspec Data
111 Verify Empty Flowspec Data
112 [Documentation] Verify expected response.
113 Verify Flowspec Data ${EXP0}
116 [Arguments] ${exprspfile}
117 [Documentation] Verify expected response
118 ${rsp}= RequestsLibrary.Get Request session ${FLOWSPEC_URL}
120 ${received_json}= Normalize Json Text ${rsp.content}
121 ${expected_rsp}= OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile}
122 ${expected_json}= Normalize Json Text ${expected_rsp}
125 Should Be Equal ${received_json} ${expected_json}