From c3b3a7929bacc737d5b7e22a2ec9524fae339d6a Mon Sep 17 00:00:00 2001 From: Peter Gubka Date: Thu, 11 Feb 2016 11:42:25 +0100 Subject: [PATCH] flowspec tests it has two test cases -various flow details -redirect option Change-Id: I440ba40669711092917b9250e6546c3f8c891ce8 Signed-off-by: Peter Gubka --- .../bgpcep/bgpflowspec/010_bgp_flowspec.robot | 125 ++++++++++++++++++ csit/testplans/bgpcep-flowspec.txt | 8 ++ .../bgpflowspec/bgp-flowspec-redirect.cfg | 42 ++++++ .../bgpflowspec/bgp-flowspec-redirect.json | 99 ++++++++++++++ csit/variables/bgpflowspec/bgp-flowspec.cfg | 31 +++++ csit/variables/bgpflowspec/bgp-flowspec.json | 123 +++++++++++++++++ csit/variables/bgpflowspec/config.uri | 1 + csit/variables/bgpflowspec/data.xml | 36 +++++ .../variables/bgpflowspec/empty-flowspec.json | 1 + 9 files changed, 466 insertions(+) create mode 100644 csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot create mode 100644 csit/testplans/bgpcep-flowspec.txt create mode 100755 csit/variables/bgpflowspec/bgp-flowspec-redirect.cfg create mode 100644 csit/variables/bgpflowspec/bgp-flowspec-redirect.json create mode 100755 csit/variables/bgpflowspec/bgp-flowspec.cfg create mode 100644 csit/variables/bgpflowspec/bgp-flowspec.json create mode 100644 csit/variables/bgpflowspec/config.uri create mode 100644 csit/variables/bgpflowspec/data.xml create mode 100644 csit/variables/bgpflowspec/empty-flowspec.json diff --git a/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot b/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot new file mode 100644 index 0000000000..6e9507d8ae --- /dev/null +++ b/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot @@ -0,0 +1,125 @@ +*** Settings *** +Documentation Functional test for bgp flowspec. +... +... Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. +... +... This program and the accompanying materials are made available under the +... terms of the Eclipse Public License v1.0 which accompanies this distribution, +... and is available at http://www.eclipse.org/legal/epl-v10.html +Suite Setup Start Suite +Suite Teardown Stop Suite +Library RequestsLibrary +Library SSHLibrary +Variables ${CURDIR}/../../../variables/Variables.py +Variables ${CURDIR}/../../../variables/bgpuser/variables.py ${TOOLS_SYSTEM_IP} +Resource ${CURDIR}/../../../libraries/Utils.robot +Resource ${CURDIR}/../../../libraries/SetupUtils.robot +Resource ${CURDIR}/../../../libraries/ConfigViaRestconf.robot +Library ${CURDIR}/../../../libraries/norm_json.py + +*** Variables *** +${HOLDTIME} 180 +${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpflowspec +${CMD} env exabgp.tcp.port=1790 exabgp --debug +${EXP0} empty-flowspec.json +${CFG1} bgp-flowspec.cfg +${EXP1} bgp-flowspec.json +${CFG2} bgp-flowspec-redirect.cfg +${EXP2} bgp-flowspec-redirect.json +${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 + +*** Test Cases *** +Check_For_Empty_Topology_Before_Talking + [Documentation] Sanity check bgp-flowspec:flowspec-routes is up but empty. + [Tags] critical + BuiltIn.Wait Until Keyword Succeeds 60s 3s Verify Empty Flowspec Data + +Reconfigure_ODL_To_Accept_Connection + [Documentation] Configure BGP peer module with initiate-connection set to false. + ${template_as_string}= BuiltIn.Set_Variable {'NAME': 'example-bgp-peer', 'IP': '${TOOLS_SYSTEM_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}', 'INITIATE': 'false'} + ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${BGP_VARIABLES_FOLDER} ${template_as_string} + +FlowSpec Test 1 + [Documentation] Testing flowspec values for ${CFG1} + [Setup] Setup Testcase ${CFG1} + BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP1} + [Teardown] Stop_Tool + +FlowSpec Test 2 + [Documentation] Testing flowspec values for ${CFG2} + [Setup] Setup Testcase ${CFG2} + BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP2} + [Teardown] Stop_Tool + +*** Keywords *** +Start Suite + [Documentation] Suite setup keyword + ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s + Builtin.Set Suite Variable ${mininet_conn_id} + Utils.Flexible Mininet Login ${TOOLS_SYSTEM_USER} + ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command ls return_stdout=True return_stderr=True + ... return_rc=True + ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo apt-get install -y python-pip return_stdout=True return_stderr=True + ... return_rc=True + ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo pip install exabgp return_stdout=True return_stderr=True + ... return_rc=True + RequestsLibrary.Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} + ConfigViaRestconf.Setup_Config_Via_Restconf + Upload Config Files ${CURDIR}/../../../variables/bgpflowspec/ + +Stop Suite + [Documentation] Suite teardown keyword + ConfigViaRestconf.Teardown_Config_Via_Restconf + SSHLibrary.Close All Connections + RequestsLibrary.Delete All Sessions + +Upload Config Files + [Arguments] ${dir_name} + [Documentation] Uploads exabgp config files + SSHLibrary.Put Directory ${CURDIR}/../../../variables/bgpflowspec/ . + @{cfgfiles}= SSHLibrary.List Files In Directory . *.cfg + : FOR ${cfgfile} IN @{cfgfiles} + \ SSHLibrary.Execute Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile} + \ SSHLibrary.Execute Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile} + \ ${stdout}= SSHLibrary.Execute Command cat ${cfgfile} + \ Log ${stdout} + +Setup Testcase + [Arguments] ${cfg_file} + Verify Empty Flowspec Data + Start Tool ${cfg_file} + +Start_Tool + [Arguments] ${cfg_file} + [Documentation] Start the tool ${cmd} ${cfg_file} + BuiltIn.Log ${cmd} ${cfg_file} + ${output}= SSHLibrary.Write ${cmd} ${cfg_file} + BuiltIn.Log ${output} + +Wait_Until_Tool_Finish + [Arguments] ${timeout} + [Documentation] Wait ${timeout} for the tool exit. + BuiltIn.Wait Until Keyword Succeeds ${timeout} 1s SSHLibrary.Read Until Prompt + +Stop_Tool + [Documentation] Stop the tool if still running. + Utils.Write_Bare_Ctrl_C + ${output}= SSHLibrary.Read delay=1s + BuiltIn.Log ${output} + Verify Empty Flowspec Data + +Verify Empty Flowspec Data + [Documentation] Verify expected response. + Verify Flowspec Data ${EXP0} + +Verify Flowspec Data + [Arguments] ${exprspfile} + [Documentation] Verify expected response + ${rsp}= RequestsLibrary.Get Request session ${FLOWSPEC_URL} + Log ${rsp.content} + ${received_json}= Normalize Json Text ${rsp.content} + ${expected_rsp}= OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile} + ${expected_json}= Normalize Json Text ${expected_rsp} + Log ${received_json} + Log ${expected_json} + Should Be Equal ${received_json} ${expected_json} diff --git a/csit/testplans/bgpcep-flowspec.txt b/csit/testplans/bgpcep-flowspec.txt new file mode 100644 index 0000000000..482c81f30d --- /dev/null +++ b/csit/testplans/bgpcep-flowspec.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v1.0 which accompanies this distribution, +# and is available at http://www.eclipse.org/legal/epl-v10.html + +# Place the suites in run order: +integration/test/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot diff --git a/csit/variables/bgpflowspec/bgp-flowspec-redirect.cfg b/csit/variables/bgpflowspec/bgp-flowspec-redirect.cfg new file mode 100755 index 0000000000..ffab80b338 --- /dev/null +++ b/csit/variables/bgpflowspec/bgp-flowspec-redirect.cfg @@ -0,0 +1,42 @@ +neighbor ODLIP { +router-id EXABGPIP; +local-address EXABGPIP; +local-as 64496; +peer-as 64496; +family { + ipv4 flow; +} +flow { + route flow1 { + match { + source 10.0.0.1/32; + destination 192.168.0.1/32; + + } + then { + redirect 65500:12345; + } + } + route flow2 { + match { + source 10.0.0.2/32; + destination 192.168.0.2/32; + + } + then { + redirect 1.2.3.4; + } + } + route flow4 { + match { + source 10.0.0.4/32; + destination 192.168.0.4/32; + + } + next-hop 127.0.0.1; + then { + redirect-to-nexthop; + } + } +} +} diff --git a/csit/variables/bgpflowspec/bgp-flowspec-redirect.json b/csit/variables/bgpflowspec/bgp-flowspec-redirect.json new file mode 100644 index 0000000000..a98b15e302 --- /dev/null +++ b/csit/variables/bgpflowspec/bgp-flowspec-redirect.json @@ -0,0 +1,99 @@ +{ + "bgp-flowspec:flowspec-routes": { + "flowspec-route": [ + { + "route-key": "all packets to 192.168.0.2/32 AND from 10.0.0.2/32", + "attributes": { + "extended-communities": [ + { + "transitive": true, + "redirect-ip-nh-extended-community": { + "next-hop-address": "0.0.0.0", + "copy": false + } + } + ], + "ipv4-next-hop": { + "global": "1.2.3.4" + }, + "origin": { + "value": "igp" + }, + "as-path": {}, + "local-pref": { + "pref": 100 + } + }, + "flowspec": [ + { + "destination-prefix": "192.168.0.2/32" + }, + { + "source-prefix": "10.0.0.2/32" + } + ] + }, + { + "route-key": "all packets to 192.168.0.1/32 AND from 10.0.0.1/32", + "attributes": { + "extended-communities": [ + { + "transitive": true, + "redirect-extended-community": { + "global-administrator": 65500, + "local-administrator": "AAAwOQ==" + } + } + ], + "origin": { + "value": "igp" + }, + "as-path": {}, + "local-pref": { + "pref": 100 + } + }, + "flowspec": [ + { + "destination-prefix": "192.168.0.1/32" + }, + { + "source-prefix": "10.0.0.1/32" + } + ] + }, + { + "route-key": "all packets to 192.168.0.4/32 AND from 10.0.0.4/32", + "attributes": { + "extended-communities": [ + { + "transitive": true, + "redirect-ip-nh-extended-community": { + "next-hop-address": "0.0.0.0", + "copy": false + } + } + ], + "ipv4-next-hop": { + "global": "127.0.0.1" + }, + "origin": { + "value": "igp" + }, + "as-path": {}, + "local-pref": { + "pref": 100 + } + }, + "flowspec": [ + { + "destination-prefix": "192.168.0.4/32" + }, + { + "source-prefix": "10.0.0.4/32" + } + ] + } + ] + } +} diff --git a/csit/variables/bgpflowspec/bgp-flowspec.cfg b/csit/variables/bgpflowspec/bgp-flowspec.cfg new file mode 100755 index 0000000000..02c6d21ceb --- /dev/null +++ b/csit/variables/bgpflowspec/bgp-flowspec.cfg @@ -0,0 +1,31 @@ +neighbor ODLIP { +router-id EXABGPIP; +local-address EXABGPIP; +local-as 64496; +peer-as 64496; +family { + ipv4 flow; +} +flow { + route { + match { + source 10.0.0.1/32; + destination 192.168.0.1/32; + port =80; + destination-port >8080&<8088; + source-port >1024; + protocol tcp; + packet-length >400&<500; + fragment first-fragment; + icmp-type echo-reply; + icmp-code network-unreachable; + tcp-flags urgent; + dscp 20; + + } + then { + action sample-terminal; + } + } +} +} diff --git a/csit/variables/bgpflowspec/bgp-flowspec.json b/csit/variables/bgpflowspec/bgp-flowspec.json new file mode 100644 index 0000000000..56eb06b1a1 --- /dev/null +++ b/csit/variables/bgpflowspec/bgp-flowspec.json @@ -0,0 +1,123 @@ +{ + "bgp-flowspec:flowspec-routes": { + "flowspec-route": [ + { + "route-key": "all packets to 192.168.0.1/32 AND from 10.0.0.1/32 AND where IP protocol equals to 6 AND where port equals to 80 AND where destination port is greater than 8080 and is less than 8088 AND where source port is greater than 1024 AND where ICMP type equals to 0 AND where ICMP code equals to 0 AND where TCP flags does match 32 AND where packet length is greater than 400 and is less than 500 AND where DSCP equals to 20 AND where fragment does match 'IS FIRST' ", + "attributes": { + "extended-communities": [ + { + "transitive": true, + "traffic-action-extended-community": { + "sample": true, + "terminal-action": true + } + } + ], + "origin": { + "value": "igp" + }, + "as-path": {}, + "local-pref": { + "pref": 100 + } + }, + "flowspec": [ + { + "destination-prefix": "192.168.0.1/32" + }, + { + "source-prefix": "10.0.0.1/32" + }, + { + "protocol-ips": [ + { + "op": "equals end-of-list", + "value": 6 + } + ] + }, + { + "ports": [ + { + "op": "equals end-of-list", + "value": 80 + } + ] + }, + { + "destination-ports": [ + { + "op": "greater-than", + "value": 8080 + }, + { + "op": "end-of-list less-than and-bit", + "value": 8088 + } + ] + }, + { + "source-ports": [ + { + "op": "end-of-list greater-than", + "value": 1024 + } + ] + }, + { + "types": [ + { + "op": "equals end-of-list", + "value": 0 + } + ] + }, + { + "codes": [ + { + "op": "equals end-of-list", + "value": 0 + } + ] + }, + { + "tcp-flags": [ + { + "op": "match end-of-list", + "value": 32 + } + ] + }, + { + "packet-lengths": [ + { + "op": "greater-than", + "value": 400 + }, + { + "op": "end-of-list less-than and-bit", + "value": 500 + } + ] + }, + { + "dscps": [ + { + "op": "equals end-of-list", + "value": 20 + } + ] + }, + { + "fragments": [ + { + "op": "match end-of-list", + "value": "first" + } + ] + } + ] + } + ] + } +} diff --git a/csit/variables/bgpflowspec/config.uri b/csit/variables/bgpflowspec/config.uri new file mode 100644 index 0000000000..383950a4f1 --- /dev/null +++ b/csit/variables/bgpflowspec/config.uri @@ -0,0 +1 @@ +config:modules/module/odl-bgp-rib-impl-cfg:bgp-peer/$NAME diff --git a/csit/variables/bgpflowspec/data.xml b/csit/variables/bgpflowspec/data.xml new file mode 100644 index 0000000000..61c962542f --- /dev/null +++ b/csit/variables/bgpflowspec/data.xml @@ -0,0 +1,36 @@ + + prefix:bgp-peer + $NAME + $IP + $PEER_PORT + $HOLDTIME + $INITIATE + + prefix:rib-instance + example-bgp-rib + + + prefix:bgp-peer-registry + global-bgp-peer-registry + + + prefix:bgp-table-type + ipv4-unicast + + + prefix:bgp-table-type + ipv6-unicast + + + prefix:bgp-table-type + linkstate + + + prefix:bgp-table-type + ipv4-flowspec + + + prefix:bgp-table-type + ipv6-flowspec + + diff --git a/csit/variables/bgpflowspec/empty-flowspec.json b/csit/variables/bgpflowspec/empty-flowspec.json new file mode 100644 index 0000000000..d406b3cb93 --- /dev/null +++ b/csit/variables/bgpflowspec/empty-flowspec.json @@ -0,0 +1 @@ +{"bgp-flowspec:flowspec-routes": {}} -- 2.36.6