Change Post Log Check to accept list of codes 82/83282/10
authorJamo Luhrsen <jluhrsen@luminanetworks.com>
Fri, 26 Jul 2019 23:39:13 +0000 (16:39 -0700)
committerLuis Gomez <ecelgp@gmail.com>
Wed, 31 Jul 2019 22:16:40 +0000 (22:16 +0000)
This allows a list of acceptable codes to be checked so that
in the case where one release is giving a 200 response as
ok and another release has moved to 204 (Happened between
Neon and Sodium) we can keep the same test code

Change-Id: I682055fc84a7d6172b117f5a385c69a7e356d00b
Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com>
csit/libraries/LISPFlowMapping.robot
csit/libraries/TemplatedRequests.robot
csit/libraries/Utils.robot
csit/suites/genius/Configure_ITM.robot
csit/suites/lispflowmapping/all/020_RPC_CRUD.robot
csit/suites/lispflowmapping/msmr/020_RPC_CRUD.robot
csit/suites/lispflowmapping/msmr/030_RPC_Datatypes.robot

index e1efb78d476d8c5ce5178be772180bbb1a61cfe1..c12a02e4d1bb5f5d1b83e3a2a91e1711f3acb145 100644 (file)
@@ -54,11 +54,11 @@ Get Elp Hop
 
 Check Key Removal
     [Arguments]    ${json}
-    Post Log Check    ${LFM_RPC_API}:get-key    ${json}    404
+    Post Log Check    ${LFM_RPC_API}:get-key    ${json}    status_codes=${DELETED_STATUS_CODE}
 
 Check Mapping Removal
     [Arguments]    ${json}
-    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}    404
+    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}    status_codes=${DELETED_STATUS_CODE}
 
 Get Mapping JSON
     [Arguments]    ${eid}    ${rloc}
index 6bc0e241fd45808cc0c165fbbb937c9354ffadfe..17ad4b7c857d3ca191fd7a81ccd279280150a6a5 100644 (file)
@@ -411,8 +411,16 @@ Check_Status_Code
     # TODO: Remove overlap with keywords from Utils.robot
     BuiltIn.Log    ${response.text}
     BuiltIn.Log    ${response.status_code}
-    BuiltIn.Run_Keyword_And_Return_If    """${explicit_status_codes}""" != """${NO_STATUS_CODES}"""    Collections.List_Should_Contain_Value    ${explicit_status_codes}    ${response.status_code}
-    ${final_allowd_list} =    Collections.Combine_Lists    ${ALLOWED_STATUS_CODES}    ${additional_allowed_status_codes}
+    # In order to allow other existing keywords to consume this keyword by passing a single non-list status code, we need to
+    # check the type of the argument passed and convert those single non-list codes in to a one item list
+    ${status_codes_type} =    Evaluate    type($additional_allowed_status_codes).__name__
+    ${allowed_status_codes_list} =    Run Keyword If    "${status_codes_type}"!="list"    Create List    ${additional_allowed_status_codes}
+    ...    ELSE    Set Variable    ${additional_allowed_status_codes}
+    ${status_codes_type} =    Evaluate    type($explicit_status_codes).__name__
+    ${explicit_status_codes_list} =    Run Keyword If    "${status_codes_type}"!="list"    Create List    ${explicit_status_codes}
+    ...    ELSE    Set Variable    ${explicit_status_codes}
+    BuiltIn.Run_Keyword_And_Return_If    """${explicit_status_codes_list}""" != """${NO_STATUS_CODES}"""    Collections.List_Should_Contain_Value    ${explicit_status_codes_list}    ${response.status_code}
+    ${final_allowd_list} =    Collections.Combine_Lists    ${ALLOWED_STATUS_CODES}    ${allowed_status_codes_list}
     Collections.List_Should_Contain_Value    ${final_allowd_list}    ${response.status_code}
 
 Join_Two_Headers
index 00991c75b6773ba5495a1aa76f4ee38b195e7ee2..1289924eb6150229cfd48ada66e3d972c9fadd65 100644 (file)
@@ -423,11 +423,11 @@ Check Item Occurrence
     \    Should Contain X Times    ${string}    ${item}    &{dictionary_item_occurrence}[${item}]
 
 Post Log Check
-    [Arguments]    ${uri}    ${body}    ${status_code}=200    ${session}=session
+    [Arguments]    ${uri}    ${body}    ${session}=session    ${status_codes}=200
     [Documentation]    Post body to ${uri}, log response content, and check status
     ${resp}=    RequestsLibrary.Post Request    ${session}    ${uri}    ${body}
     Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    ${status_code}
+    TemplatedRequests.Check Status Code    ${resp}    ${status_codes}
     [Return]    ${resp}
 
 Get Log File Name
index aa5c8b19376619f3b5503421815fcb509dc8ba9d..074900781de37f3b905489b6f8da0cbf21086a36 100644 (file)
@@ -154,7 +154,7 @@ Create Vteps IPv6
     ${SUBNET_IPV6} =    BuiltIn.Catenate    ${substr}0
     BuiltIn.Set Suite Variable    ${SUBNET_IPV6}
     ${body} =    Genius.Set Json    ${vlan}    ${gateway_ip}    ${SUBNET_IPV6}    @{TOOLS_SYSTEM_IPV6_LIST}
-    Utils.Post Log Check    ${CONFIG_API}/itm:transport-zones/    ${body}    204
+    Utils.Post Log Check    ${CONFIG_API}/itm:transport-zones/    ${body}    status_codes=${204}
 
 Get Network Topology with Tunnel
     [Arguments]    ${url}    ${network_topology_list}
index 5fd2e39bfa8b9b679962ce0f5cd8d3afa8124a7b..e00dc45fc25edde1d8a47f86115f2ac470283648 100644 (file)
@@ -27,12 +27,12 @@ Create Key
 Attempt To Create Key Again
     [Documentation]    Try to overwrite existing IPv4 EID key
     ${add_key}=    OperatingSystem.Get File    ${IPV4_C_KEY}
-    Post Log Check    ${LFM_RPC_API_LI}:add-key    ${add_key}    409
+    Post Log Check    ${LFM_RPC_API_LI}:add-key    ${add_key}    status_codes=${409}
 
 Attempt To Read Non-Existing Key
     [Documentation]    Try to read a non-existing key for an IPv4 EID
     ${get_key}=    OperatingSystem.Get File    ${MISS_RD}
-    Post Log Check    ${LFM_RPC_API_LI}:get-key    ${get_key}    404
+    Post Log Check    ${LFM_RPC_API_LI}:get-key    ${get_key}    status_codes=${404}
 
 Read Key
     [Documentation]    Read an existing key for an IPv4 EID
@@ -59,12 +59,12 @@ Delete Key
 Attempt To Read Deleted Key
     [Documentation]    Try to read the key deleted in the previous test
     ${get_key}=    OperatingSystem.Get File    ${IPV4_RD}
-    Post Log Check    ${LFM_RPC_API_LI}:get-key    ${get_key}    404
+    Post Log Check    ${LFM_RPC_API_LI}:get-key    ${get_key}    status_codes=${404}
 
 Attempt To Update Non-Existing Key
     [Documentation]    Update a non-existing key for an IPv4 EID
     ${update_key}=    OperatingSystem.Get File    ${IPV4_U_KEY}
-    Post Log Check    ${LFM_RPC_API_LI}:update-key    ${update_key}    404
+    Post Log Check    ${LFM_RPC_API_LI}:update-key    ${update_key}    status_codes=${404}
 
 Create Mapping
     [Documentation]    Create a mapping for an IPv4 EID
index aec37c7359045145af729c9f5f76b675e4c41fe0..907764fae009eb77161341000409d00b6da851ad 100644 (file)
@@ -9,6 +9,7 @@ Library           ../../../libraries/Common.py
 Library           ../../../libraries/JsonGenerator.py
 Variables         ../../../variables/Variables.py
 Resource          ../../../libraries/LISPFlowMapping.robot
+Resource          ../../../libraries/TemplatedRequests.robot
 Resource          ../../../libraries/Utils.robot
 
 *** Test Cases ***
@@ -17,12 +18,12 @@ Create Key
     ${eid_json}=    Get LispAddress JSON    ipv4:192.0.2.1/32
     ${authkey_json}=    Get MappingAuthkey JSON
     ${add_key}=    Merge And Wrap input    ${eid_json}    ${authkey_json}
-    Post Log Check    ${LFM_RPC_API}:add-key    ${add_key}
+    Post Log Check    ${LFM_RPC_API}:add-key    ${add_key}    status_codes=${ALLOWED_STATUS_CODES}
 
 Attempt To Read Non-Existing Key
     [Documentation]    Try to read a non-existing key for an IPv4 EID
     ${get_key}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.255/32
-    Post Log Check    ${LFM_RPC_API}:get-key    ${get_key}    404
+    Post Log Check    ${LFM_RPC_API}:get-key    ${get_key}    status_codes=${DELETED_STATUS_CODE}
 
 Read Key
     [Documentation]    Read an existing key for an IPv4 EID
@@ -34,7 +35,7 @@ Update Key
     ${eid_json}=    Get LispAddress JSON    ipv4:192.0.2.1/32
     ${authkey_json}=    Get MappingAuthkey JSON    key_string=updated-password
     ${update_key}=    Merge And Wrap input    ${eid_json}    ${authkey_json}
-    Post Log Check    ${LFM_RPC_API}:update-key    ${update_key}
+    Post Log Check    ${LFM_RPC_API}:update-key    ${update_key}    status_codes=${ALLOWED_STATUS_CODES}
 
 Read Updated Key
     [Documentation]    Read the key updated in the previous test
@@ -44,7 +45,7 @@ Read Updated Key
 Delete Key
     [Documentation]    Delete an existing key for an IPv4 EID
     ${remove_key}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
-    Post Log Check    ${LFM_RPC_API}:remove-key    ${remove_key}
+    Post Log Check    ${LFM_RPC_API}:remove-key    ${remove_key}    status_codes=${ALLOWED_STATUS_CODES}
 
 Attempt To Read Deleted Key
     [Documentation]    Try to read the key deleted in the previous test
@@ -56,12 +57,12 @@ Attempt To Update Non-Existing Key
     ${eid_json}=    Get LispAddress JSON    ipv4:192.0.2.1/32
     ${authkey_json}=    Get MappingAuthkey JSON    key_string=updated-password
     ${update_key}=    Merge And Wrap input    ${eid_json}    ${authkey_json}
-    Post Log Check    ${LFM_RPC_API}:update-key    ${update_key}    404
+    Post Log Check    ${LFM_RPC_API}:update-key    ${update_key}    status_codes=${DELETED_STATUS_CODE}
 
 Create Mapping
     [Documentation]    Create a mapping for an IPv4 EID
     ${add_mapping}=    Get Mapping JSON    ipv4:192.0.2.1/32    ipv4:10.10.10.10
-    Post Log Check    ${LFM_RPC_API}:add-mapping    ${add_mapping}
+    Post Log Check    ${LFM_RPC_API}:add-mapping    ${add_mapping}    status_codes=${ALLOWED_STATUS_CODES}
 
 Attempt To Read Non-Existing Mapping
     [Documentation]    Try to read a non-existing mapping for an IPv4 EID
@@ -76,7 +77,7 @@ Read Mapping
 Update Mapping
     [Documentation]    Update an existing mapping for an IPv4 EID
     ${update_mapping}=    Get Mapping JSON    ipv4:192.0.2.1/32    ipv4:20.20.20.20
-    Post Log Check    ${LFM_RPC_API}:update-mapping    ${update_mapping}
+    Post Log Check    ${LFM_RPC_API}:update-mapping    ${update_mapping}    status_codes=${ALLOWED_STATUS_CODES}
 
 Read Updated Mapping
     [Documentation]    Read the mapping updated in the previous test
@@ -86,7 +87,7 @@ Read Updated Mapping
 Delete Mapping
     [Documentation]    Delete an existing mapping for an IPv4 EID
     ${remove_mapping}=    Get LispAddress JSON And Wrap input    ipv4:192.0.2.1/32
-    Post Log Check    ${LFM_RPC_API}:remove-mapping    ${remove_mapping}
+    Post Log Check    ${LFM_RPC_API}:remove-mapping    ${remove_mapping}    status_codes=${ALLOWED_STATUS_CODES}
 
 Attempt To Read Deleted Mapping
     [Documentation]    Try to read the mapping deleted in the previous test
index d6d956386e026cdeaa923e7054f5d7c91c91aa15..3c3d6fef0fd805f30dda1333026eac826b715c19 100644 (file)
@@ -66,11 +66,11 @@ Check Datatype
     ${add_mapping}=    Get Mapping JSON    ${add_mapping_eid}    ${add_mapping_rloc}
     ${get_mapping}=    Get LispAddress JSON And Wrap input    ${get_mapping_eid}
     Set Suite Variable    ${RPC_Datatype__current_json}    ${get_mapping}
-    Post Log Check    ${LFM_RPC_API}:add-mapping    ${add_mapping}
+    Post Log Check    ${LFM_RPC_API}:add-mapping    ${add_mapping}    status_codes=${ALLOWED_STATUS_CODES}
     Wait Until Keyword Succeeds    5s    200ms    Post Log Check LocatorRecord    ${get_mapping}
 
 Remove Datatype And Check Removal
     Variable Should Exist    ${RPC_Datatype__current_json}
-    Post Log Check    ${LFM_RPC_API}:remove-mapping    ${RPC_Datatype__current_json}
+    Post Log Check    ${LFM_RPC_API}:remove-mapping    ${RPC_Datatype__current_json}    status_codes=${ALLOWED_STATUS_CODES}
     Wait Until Keyword Succeeds    5s    200ms    Check Mapping Removal    ${RPC_Datatype__current_json}
     Set Suite Variable    ${RPC_Datatype__current_json}    ${EMPTY}