From 86a04bd530c78e1c9cca78ff81db3141e8bd4e9d Mon Sep 17 00:00:00 2001 From: "tomas.markovic" Date: Tue, 13 Nov 2018 11:13:57 +0100 Subject: [PATCH] Fix flowspec empty uri In neon, family ribs, are not initialized until we fill them, and therefore we have to check whether they are empty differently Change-Id: I12815bc3383e10942873a496bb7a71608d01410e Signed-off-by: tomas.markovic --- csit/libraries/norm_json.py | 2 +- .../bgpcep/bgpflowspec/010_bgp_flowspec.robot | 35 ++++++++++--------- .../data.json} | 0 .../bgpflowspec/bgp_flowspec/location.uri | 1 + .../data.json} | 0 .../bgp_flowspec_redirect/location.uri | 1 + .../bgpflowspec/empty_route/data.json | 11 ++++++ .../bgpflowspec/empty_route/location.uri | 1 + .../bgpflowspec/empty_route/volatiles.list | 1 + 9 files changed, 35 insertions(+), 17 deletions(-) rename csit/variables/bgpflowspec/{bgp-flowspec.json => bgp_flowspec/data.json} (100%) create mode 100644 csit/variables/bgpflowspec/bgp_flowspec/location.uri rename csit/variables/bgpflowspec/{bgp-flowspec-redirect.json => bgp_flowspec_redirect/data.json} (100%) create mode 100644 csit/variables/bgpflowspec/bgp_flowspec_redirect/location.uri create mode 100644 csit/variables/bgpflowspec/empty_route/data.json create mode 100644 csit/variables/bgpflowspec/empty_route/location.uri create mode 100644 csit/variables/bgpflowspec/empty_route/volatiles.list diff --git a/csit/libraries/norm_json.py b/csit/libraries/norm_json.py index c323c742a9..cc208277d8 100644 --- a/csit/libraries/norm_json.py +++ b/csit/libraries/norm_json.py @@ -167,7 +167,7 @@ def hide_volatile(obj, keys_with_volatiles=[]): # Unicode is not str and vice versa, isinstance has to check for both. # Luckily, "in" recognizes equivalent strings in different encodings. # Type "bytes" is added for Python 3 compatibility. - if key in keys_with_volatiles and isinstance(value, (unicode, str, bytes, int)): + if key in keys_with_volatiles and isinstance(value, (unicode, str, bytes, int, bool)): obj[key] = "*" else: hide_volatile(value, keys_with_volatiles) diff --git a/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot b/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot index adba040d3b..f09cdf5328 100644 --- a/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot +++ b/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot @@ -17,21 +17,19 @@ Resource ../../../libraries/TemplatedRequests.robot Resource ../../../variables/Variables.robot *** Variables *** -${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpflowspec +${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpflowspec/ ${CMD} env exabgp.tcp.port=1790 exabgp --debug ${HOLDTIME} 180 -${OLD_EMPTY} {"bgp-flowspec:flowspec-routes": {}} -${NEW_EMPTY} {} ${OLD_AS_PATH} \n"as-path": {}, ${NEW_AS_PATH} ${EMPTY} +${EXP0} {"bgp-flowspec:flowspec-routes": {}} ${CFG1} bgp-flowspec.cfg -${EXP1} bgp-flowspec.json +${EXP1} bgp_flowspec ${CFG2} bgp-flowspec-redirect.cfg -${EXP2} bgp-flowspec-redirect.json +${EXP2} bgp_flowspec_redirect ${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 ${CONFIG_SESSION} session ${DEVICE_NAME} controller-config -${BGP_PEER_NAME} example-bgp-peer ${RIB_INSTANCE} example-bgp-rib ${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE} @{EMPTY_LIST} @@ -44,8 +42,8 @@ Check_For_Empty_Topology_Before_Talking Reconfigure_ODL_To_Accept_Connection [Documentation] Configure BGP peer module with initiate-connection set to false. - &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} - ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} PASSIVE_MODE=true + &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} INITIATE=false BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} + ... PASSIVE_MODE=true TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION} FlowSpec_Test_1 @@ -62,7 +60,7 @@ FlowSpec_Test_2 Deconfigure_ODL_To_Accept_Connection [Documentation] Deconfigure BGP peer. - &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} + &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION} *** Keywords *** @@ -74,8 +72,6 @@ Start_Suite SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} Upload_Config_Files ${BGP_VARIABLES_FOLDER} - ${EXP0} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_EMPTY} ${OLD_EMPTY} - BuiltIn.Set_Suite_Variable ${EXP0} ${AS_PATH} = CompareStream.Set_Variable_If_At_Least_Neon ${NEW_AS_PATH} ${OLD_AS_PATH} BuiltIn.Set_Suite_Variable ${AS_PATH} @@ -102,13 +98,20 @@ Setup_Testcase Verify_Empty_Flowspec_Data [Documentation] Verify expected response. - ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${FLOWSPEC_URL} - TemplatedRequests.Normalize_Jsons_With_Bits_And_Compare ${EXP0} ${rsp.content} keys_with_bits=${EMPTY_LIST} + CompareStream.Run_Keyword_If_At_Most_Fluorine Normalize_And_Compare + CompareStream.Run_Keyword_If_At_Least_Neon Verify_Empty_Flowspec_Data_Neon Verify_Flowspec_Data - [Arguments] ${exprspfile} + [Arguments] ${exprspdir} [Documentation] Verify expected response &{mapping} BuiltIn.Create_Dictionary AS_PATH=${AS_PATH} - ${expected_rsp} = TemplatedRequests.Resolve_Text_From_Template_File ${BGP_VARIABLES_FOLDER} ${exprspfile} mapping=${mapping} + TemplatedRequests.Get_As_Json_Templated ${BGP_VARIABLES_FOLDER}${/}${exprspdir} session=${CONFIG_SESSION} mapping=${mapping} verify=True + +Normalize_And_Compare + [Documentation] Verify empty flowspec data ${rsp} = RequestsLibrary.Get_Request ${CONFIG_SESSION} ${FLOWSPEC_URL} - TemplatedRequests.Normalize_Jsons_With_Bits_And_Compare ${expected_rsp} ${rsp.content} keys_with_bits=${EMPTY_LIST} + TemplatedRequests.Normalize_Jsons_With_Bits_And_Compare ${EXP0} ${rsp.content} keys_with_bits=${EMPTY_LIST} + +Verify_Empty_Flowspec_Data_Neon + [Documentation] Verify empty flowspec data on neon + TemplatedRequests.Get_As_Json_Templated ${BGP_VARIABLES_FOLDER}${/}empty_route session=${CONFIG_SESSION} verify=True diff --git a/csit/variables/bgpflowspec/bgp-flowspec.json b/csit/variables/bgpflowspec/bgp_flowspec/data.json similarity index 100% rename from csit/variables/bgpflowspec/bgp-flowspec.json rename to csit/variables/bgpflowspec/bgp_flowspec/data.json diff --git a/csit/variables/bgpflowspec/bgp_flowspec/location.uri b/csit/variables/bgpflowspec/bgp_flowspec/location.uri new file mode 100644 index 0000000000..fc496ea460 --- /dev/null +++ b/csit/variables/bgpflowspec/bgp_flowspec/location.uri @@ -0,0 +1 @@ +/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 diff --git a/csit/variables/bgpflowspec/bgp-flowspec-redirect.json b/csit/variables/bgpflowspec/bgp_flowspec_redirect/data.json similarity index 100% rename from csit/variables/bgpflowspec/bgp-flowspec-redirect.json rename to csit/variables/bgpflowspec/bgp_flowspec_redirect/data.json diff --git a/csit/variables/bgpflowspec/bgp_flowspec_redirect/location.uri b/csit/variables/bgpflowspec/bgp_flowspec_redirect/location.uri new file mode 100644 index 0000000000..fc496ea460 --- /dev/null +++ b/csit/variables/bgpflowspec/bgp_flowspec_redirect/location.uri @@ -0,0 +1 @@ +/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 diff --git a/csit/variables/bgpflowspec/empty_route/data.json b/csit/variables/bgpflowspec/empty_route/data.json new file mode 100644 index 0000000000..0fe3dfd4fe --- /dev/null +++ b/csit/variables/bgpflowspec/empty_route/data.json @@ -0,0 +1,11 @@ +{ + "tables": [ + { + "afi": "bgp-types:ipv4-address-family", + "safi": "bgp-flowspec:flowspec-subsequent-address-family", + "attributes": { + "uptodate": "*" + } + } + ] +} diff --git a/csit/variables/bgpflowspec/empty_route/location.uri b/csit/variables/bgpflowspec/empty_route/location.uri new file mode 100644 index 0000000000..b8c52ac683 --- /dev/null +++ b/csit/variables/bgpflowspec/empty_route/location.uri @@ -0,0 +1 @@ +/restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv4-address-family/bgp-flowspec:flowspec-subsequent-address-family/ diff --git a/csit/variables/bgpflowspec/empty_route/volatiles.list b/csit/variables/bgpflowspec/empty_route/volatiles.list new file mode 100644 index 0000000000..e20793431c --- /dev/null +++ b/csit/variables/bgpflowspec/empty_route/volatiles.list @@ -0,0 +1 @@ +uptodate -- 2.36.6