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/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}
54 Deconfigure_ODL_To_Accept_Connection
55 [Documentation] Deconfigure BGP peer.
56 ${template_as_string}= BuiltIn.Set_Variable {'NAME': 'example-bgp-peer', 'IP': '${TOOLS_SYSTEM_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}', 'INITIATE': 'false'}
57 ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf ${BGP_VARIABLES_FOLDER} ${template_as_string}
61 [Documentation] Suite setup keyword
62 ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
63 Builtin.Set Suite Variable ${mininet_conn_id}
64 Utils.Flexible Mininet Login ${TOOLS_SYSTEM_USER}
65 ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command ls return_stdout=True return_stderr=True
67 ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo apt-get install -y python-pip return_stdout=True return_stderr=True
69 ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo pip install exabgp return_stdout=True return_stderr=True
71 RequestsLibrary.Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
72 ConfigViaRestconf.Setup_Config_Via_Restconf
73 Upload Config Files ${CURDIR}/../../../variables/bgpflowspec/
76 [Documentation] Suite teardown keyword
77 ConfigViaRestconf.Teardown_Config_Via_Restconf
78 SSHLibrary.Close All Connections
79 RequestsLibrary.Delete All Sessions
82 [Arguments] ${dir_name}
83 [Documentation] Uploads exabgp config files
84 SSHLibrary.Put Directory ${CURDIR}/../../../variables/bgpflowspec/ .
85 @{cfgfiles}= SSHLibrary.List Files In Directory . *.cfg
86 : FOR ${cfgfile} IN @{cfgfiles}
87 \ SSHLibrary.Execute Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
88 \ SSHLibrary.Execute Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
89 \ ${stdout}= SSHLibrary.Execute Command cat ${cfgfile}
93 [Arguments] ${cfg_file}
94 Verify Empty Flowspec Data
95 Start Tool ${cfg_file}
98 [Arguments] ${cfg_file}
99 [Documentation] Start the tool ${cmd} ${cfg_file}
100 BuiltIn.Log ${cmd} ${cfg_file}
101 ${output}= SSHLibrary.Write ${cmd} ${cfg_file}
102 BuiltIn.Log ${output}
104 Wait_Until_Tool_Finish
105 [Arguments] ${timeout}
106 [Documentation] Wait ${timeout} for the tool exit.
107 BuiltIn.Wait Until Keyword Succeeds ${timeout} 1s SSHLibrary.Read Until Prompt
110 [Documentation] Stop the tool if still running.
111 Utils.Write_Bare_Ctrl_C
112 ${output}= SSHLibrary.Read delay=1s
113 BuiltIn.Log ${output}
114 Verify Empty Flowspec Data
116 Verify Empty Flowspec Data
117 [Documentation] Verify expected response.
118 Verify Flowspec Data ${EXP0}
121 [Arguments] ${exprspfile}
122 [Documentation] Verify expected response
123 ${keys_with_bits}= BuiltIn.Create_List op
124 ${expected_rsp}= Get Expected Response From File ${exprspfile}
125 ${expected_json}= norm_json.Normalize Json Text ${expected_rsp} keys_with_bits=${keys_with_bits}
126 ${rsp}= RequestsLibrary.Get Request session ${FLOWSPEC_URL}
127 BuiltIn.Log ${rsp.content}
128 ${received_json}= norm_json.Normalize Json Text ${rsp.content} keys_with_bits=${keys_with_bits}
129 BuiltIn.Log ${received_json}
130 BuiltIn.Log ${expected_json}
131 BuiltIn.Should Be Equal ${received_json} ${expected_json}
133 Get Expected Response From File
134 [Arguments] ${exprspfile}
135 [Documentation] Looks for release specific response first, then take default.
136 ${status} ${expresponse}= BuiltIn.Run_Keyword_And_Ignore_Error OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile}.${ODL_STREAM}
137 Return From Keyword If '${status}' == 'PASS' ${expresponse}
138 ${expresponse}= OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile}
139 [Return] ${expresponse}