From e89fa8e32b9160f274c468eb105a2eff399953c3 Mon Sep 17 00:00:00 2001 From: Peter Gubka Date: Thu, 13 Oct 2016 10:02:44 +0200 Subject: [PATCH] creating Normalize_Jsons_With_Bits_And_Compare to TemplatedRequests implementing https://trello.com/c/SavMOS52/332-int-test-create-a-new-kw-in-templatedrequests-for-comparison Change-Id: I7ecd79b2c5e2763067d2fc3c1138e3b3b5268fe7 Signed-off-by: Peter Gubka --- csit/libraries/TemplatedRequests.robot | 8 ++++++++ .../bgpcep/bgpflowspec/010_bgp_flowspec.robot | 9 ++------- .../bgpcep/bgpfunct/010_bgp_functional_l3vpn.robot | 14 ++------------ .../bgpfunct/020_bgp_functional_multipath.robot | 1 - .../bgpcep/bgpfunct/030_bgp_functional_evpn.robot | 8 +------- .../bgpfunct/040_bgp_functional_route_ref.robot | 1 - 6 files changed, 13 insertions(+), 28 deletions(-) diff --git a/csit/libraries/TemplatedRequests.robot b/csit/libraries/TemplatedRequests.robot index 008a666b4f..4b87ee5411 100644 --- a/csit/libraries/TemplatedRequests.robot +++ b/csit/libraries/TemplatedRequests.robot @@ -115,6 +115,7 @@ Variables ${CURDIR}/../variables/Variables.py # TODO: Make the following list more narrow when streams without Bug 2594 fix (up to beryllium) are no longer used. @{ALLOWED_STATUS_CODES} ${200} ${201} ${204} # List of integers, not strings. Used by both PUT and DELETE (if the resource should have been present). @{ALLOWED_DELETE_STATUS_CODES} ${200} ${201} ${204} ${404} # List of integers, not strings. Used by DELETE if the resource may be not present. +@{KEYS_WITH_BITS} op # the default list with keys to be sorted when norm_json libray is used # TODO: Add option for delete to require 404. *** Keywords *** @@ -401,3 +402,10 @@ Normalize_Jsons_And_Compare # Should_Be_Equal shall print nice diff-style line comparison. BuiltIn.Should_Be_Equal ${expected_normalized} ${actual_normalized} # TODO: Add garbage collection? Check whether the temporary data accumulates. + +Normalize_Jsons_With_Bits_And_Compare + [Arguments] ${expected_raw} ${actual_raw} ${keys_with_bits}=${KEYS_WITH_BITS} + [Documentation] Use norm_json to normalize both JSON arguments, call Should_Be_Equal. + ${expected_normalized} = norm_json.normalize_json_text ${expected_raw} keys_with_bits=${keys_with_bits} + ${actual_normalized} = norm_json.normalize_json_text ${actual_raw} keys_with_bits=${keys_with_bits} + BuiltIn.Should_Be_Equal ${expected_normalized} ${actual_normalized} diff --git a/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot b/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot index 41b68dd633..328f5ae6eb 100644 --- a/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot +++ b/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot @@ -16,7 +16,7 @@ Resource ${CURDIR}/../../../libraries/Utils.robot Resource ${CURDIR}/../../../libraries/SetupUtils.robot Resource ${CURDIR}/../../../libraries/ConfigViaRestconf.robot Resource ${CURDIR}/../../../libraries/CompareStream.robot -Library ${CURDIR}/../../../libraries/norm_json.py +Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot *** Variables *** ${HOLDTIME} 180 @@ -124,13 +124,8 @@ Verify Flowspec Data ${keys_with_bits}= BuiltIn.Create_List CompareStream.Run_Keyword_If_At_Most boron Collections.Append_To_List ${keys_with_bits} op ${expected_rsp}= Get Expected Response From File ${exprspfile} - ${expected_json}= norm_json.Normalize Json Text ${expected_rsp} keys_with_bits=${keys_with_bits} ${rsp}= RequestsLibrary.Get Request session ${FLOWSPEC_URL} - BuiltIn.Log ${rsp.content} - ${received_json}= norm_json.Normalize Json Text ${rsp.content} keys_with_bits=${keys_with_bits} - BuiltIn.Log ${received_json} - BuiltIn.Log ${expected_json} - BuiltIn.Should Be Equal ${received_json} ${expected_json} + TemplatedRequests.Normalize_Jsons_With_Bits_And_Compare ${expected_rsp} ${rsp.content} keys_with_bits=${keys_with_bits} Get Expected Response From File [Arguments] ${exprspfile} diff --git a/csit/suites/bgpcep/bgpfunct/010_bgp_functional_l3vpn.robot b/csit/suites/bgpcep/bgpfunct/010_bgp_functional_l3vpn.robot index d9edaf4cf5..3a80c8ea00 100644 --- a/csit/suites/bgpcep/bgpfunct/010_bgp_functional_l3vpn.robot +++ b/csit/suites/bgpcep/bgpfunct/010_bgp_functional_l3vpn.robot @@ -21,7 +21,6 @@ Resource ${CURDIR}/../../../libraries/SetupUtils.robot Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot Resource ${CURDIR}/../../../libraries/KarafKeywords.robot Resource ${CURDIR}/../../../libraries/SSHKeywords.robot -Library ${CURDIR}/../../../libraries/norm_json.py Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP} *** Variables *** @@ -174,23 +173,14 @@ Verify_Tool_Received_Update ${exp_update}= Get_Expected_Response_From_File ${exp_update_fn} ${rcv_update_dict}= BgpRpcClient.exa_get_update_message msg_only=${True} ${rcv_update}= BuiltIn.Evaluate json.dumps(${rcv_update_dict}) modules=json - ${received_json}= norm_json.Normalize_Json_Text ${rcv_update} - ${expected_json}= norm_json.Normalize_Json_Text ${exp_update} - BuiltIn.Log ${received_json} - BuiltIn.Log ${expected_json} - BuiltIn.Should_Be_Equal ${received_json} ${expected_json} + TemplatedRequests.Normalize_Jsons_And_Compare ${exp_update} ${rcv_update} Verify_Reported_Data [Arguments] ${url} ${exprspfile} [Documentation] Verifies expected response ${expected_rsp}= Get_Expected_Response_From_File ${exprspfile} - ${expected_json}= norm_json.Normalize_Json_Text ${expected_rsp} ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${url} - BuiltIn.Log ${rsp.content} - ${received_json}= norm_json.Normalize_Json_Text ${rsp.content} - BuiltIn.Log ${received_json} - BuiltIn.Log ${expected_json} - BuiltIn.Should_Be_Equal ${received_json} ${expected_json} + TemplatedRequests.Normalize_Jsons_And_Compare ${expected_rsp} ${rsp.content} Get_Expected_Response_From_File [Arguments] ${exprspfile} diff --git a/csit/suites/bgpcep/bgpfunct/020_bgp_functional_multipath.robot b/csit/suites/bgpcep/bgpfunct/020_bgp_functional_multipath.robot index dbeb3f9b96..5dec69af11 100644 --- a/csit/suites/bgpcep/bgpfunct/020_bgp_functional_multipath.robot +++ b/csit/suites/bgpcep/bgpfunct/020_bgp_functional_multipath.robot @@ -18,7 +18,6 @@ Variables ${CURDIR}/../../../variables/Variables.py Resource ${CURDIR}/../../../libraries/Utils.robot Resource ${CURDIR}/../../../libraries/SetupUtils.robot Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot -Library ${CURDIR}/../../../libraries/norm_json.py Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP} Resource ${CURDIR}/../../../libraries/BGPcliKeywords.robot Resource ${CURDIR}/../../../libraries/KarafKeywords.robot diff --git a/csit/suites/bgpcep/bgpfunct/030_bgp_functional_evpn.robot b/csit/suites/bgpcep/bgpfunct/030_bgp_functional_evpn.robot index 656577650d..49d04dfebb 100644 --- a/csit/suites/bgpcep/bgpfunct/030_bgp_functional_evpn.robot +++ b/csit/suites/bgpcep/bgpfunct/030_bgp_functional_evpn.robot @@ -21,7 +21,6 @@ Variables ${CURDIR}/../../../variables/Variables.py Resource ${CURDIR}/../../../libraries/Utils.robot Resource ${CURDIR}/../../../libraries/SetupUtils.robot Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot -Library ${CURDIR}/../../../libraries/norm_json.py Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP} Resource ${CURDIR}/../../../libraries/BGPcliKeywords.robot Resource ${CURDIR}/../../../libraries/BGPSpeaker.robot @@ -416,9 +415,4 @@ Loc_Rib_Presnece [Arguments] ${exp_content} [Documentation] Verifies if loc-rib contains expected data ${rsp}= RequestsLibrary.Get_Request ${CONFIG_SESSION} ${LOC_RIB_URL} headers=${HEADERS} - Log ${rsp.content} - ${received_json}= norm_json.Normalize_Json_Text ${rsp.content} - BuiltIn.Log ${received_json} - ${expected_json}= norm_json.Normalize_Json_Text ${exp_content} - BuiltIn.Log ${expected_json} - BuiltIn.Should_Be_Equal ${received_json} ${expected_json} + TemplatedRequests.Normalize_Jsons_And_Compare ${exp_content} ${rsp.content} diff --git a/csit/suites/bgpcep/bgpfunct/040_bgp_functional_route_ref.robot b/csit/suites/bgpcep/bgpfunct/040_bgp_functional_route_ref.robot index 15bfaf3301..8ccab45860 100644 --- a/csit/suites/bgpcep/bgpfunct/040_bgp_functional_route_ref.robot +++ b/csit/suites/bgpcep/bgpfunct/040_bgp_functional_route_ref.robot @@ -24,7 +24,6 @@ Resource ${CURDIR}/../../../libraries/SetupUtils.robot Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot Resource ${CURDIR}/../../../libraries/KarafKeywords.robot Resource ${CURDIR}/../../../libraries/SSHKeywords.robot -Library ${CURDIR}/../../../libraries/norm_json.py Library ${CURDIR}/../../../libraries/BgpRpcClient.py ${TOOLS_SYSTEM_IP} *** Variables *** -- 2.36.6