X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FTemplatedRequests.robot;h=6bc0e241fd45808cc0c165fbbb937c9354ffadfe;hb=ab2ca43d8088b84f51764ba79f2321786ecbe8c7;hp=928a84f137aeae8afe04c974b44cdb1cc673cbe5;hpb=d93e03c5139a87d1ab792943034a606f1620837f;p=integration%2Ftest.git diff --git a/csit/libraries/TemplatedRequests.robot b/csit/libraries/TemplatedRequests.robot index 928a84f137..6bc0e241fd 100644 --- a/csit/libraries/TemplatedRequests.robot +++ b/csit/libraries/TemplatedRequests.robot @@ -110,24 +110,26 @@ Documentation Resource for supporting http Requests based on data stored in ... perhaps explicit ${ACCEPT_JSON} will be better, even if it sends few bytes more? Library Collections Library OperatingSystem +Library String Library RequestsLibrary Library ${CURDIR}/norm_json.py -Variables ${CURDIR}/../variables/Variables.py +Resource ${CURDIR}/../variables/Variables.robot *** Variables *** # TODO: Make the following list more narrow when streams without Bug 2594 fix (up to beryllium) are no longer used. +@{ALLOWED_DELETE_STATUS_CODES} ${200} ${201} ${204} ${404} # List of integers, not strings. Used by DELETE if the resource may be not present. @{ALLOWED_STATUS_CODES} ${200} ${201} ${204} # List of integers, not strings. Used by both PUT and DELETE (if the resource should have been present). -@{DATA_VALIDATION_ERROR} ${500} +@{DATA_VALIDATION_ERROR} ${400} # For testing mildly negative scenarios where ODL reports user error. @{DELETED_STATUS_CODE} ${404} # List of integers, not strings. Used by DELETE if the resource may be not present. +# TODO: Add option for delete to require 404. +@{INTERNAL_SERVER_ERROR} ${500} # Only for testing severely negative scenarios where ODL cannot recover. +@{KEYS_WITH_BITS} op # the default list with keys to be sorted when norm_json libray is used @{NO_STATUS_CODES} -@{ALLOWED_DELETE_STATUS_CODES} ${200} ${201} ${204} ${404} # List of integers, not strings. Used by DELETE if the resource may be not present. @{UNAUTHORIZED_STATUS_CODES} ${401} # List of integers, not strings. Used in Keystone Authentication when the user is not authorized to use the requested resource. -@{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 *** Create_Default_Session - [Arguments] ${url}=http://${ODL_SYSTEM_IP}:${RESTCONFPORT} ${auth}=${AUTH} ${timeout}=1 ${max_retries}=0 + [Arguments] ${url}=http://${ODL_SYSTEM_IP}:${RESTCONFPORT} ${auth}=${AUTH} ${timeout}=${DEFAULT_TIMEOUT_HTTP} ${max_retries}=0 [Documentation] Create "default" session to ${url} with authentication and connection parameters. ... This Keyword is in this Resource only so that user do not need to call RequestsLibrary directly. RequestsLibrary.Create_Session alias=default url=${url} auth=${auth} timeout=${timeout} max_retries=${max_retries} @@ -209,9 +211,9 @@ Post_As_Xml_Templated [Return] ${response_text} Delete_Templated - [Arguments] ${folder} ${mapping}={} ${session}=default ${additional_allowed_status_codes}=${NO_STATUS_CODES} ${http_timeout}=${EMPTY} + [Arguments] ${folder} ${mapping}={} ${session}=default ${additional_allowed_status_codes}=${NO_STATUS_CODES} ${http_timeout}=${EMPTY} ${location}=location [Documentation] Resolve URI from folder, issue DELETE request. - ${uri} = Resolve_Text_From_Template_Folder folder=${folder} base_name=location extension=uri mapping=${mapping} + ${uri} = Resolve_Text_From_Template_Folder folder=${folder} base_name=${location} extension=uri mapping=${mapping} ${response_text} = Delete_From_Uri uri=${uri} session=${session} additional_allowed_status_codes=${additional_allowed_status_codes} http_timeout=${http_timeout} [Return] ${response_text} @@ -291,13 +293,24 @@ Resolve_Jmes_Path ${expression} = BuiltIn.Set Variable If ${read_jmes_file} == ${true} ${jmes_expression} ${EMPTY} [Return] ${expression} +Resolve_Volatiles_Path + [Arguments] ${folder} + [Documentation] Reads Volatiles List from file ${folder}${/}volatiles.list if the file exists and + ... returns the Volatiles List. Empty string is returned otherwise. + ${read_volatiles_file} = BuiltIn.Run Keyword And Return Status OperatingSystem.File Should Exist ${folder}${/}volatiles.list + Return From Keyword If ${read_volatiles_file} == ${false} ${EMPTY} + ${volatiles}= OperatingSystem.Get_File ${folder}${/}volatiles.list + ${volatiles_list}= String.Split_String ${volatiles} ${\n} + [Return] ${volatiles_list} + Get_Templated [Arguments] ${folder} ${accept} ${mapping}={} ${session}=default ${normalize_json}=False ${http_timeout}=${EMPTY} [Documentation] Resolve URI from folder, call Get_From_Uri, return response text. ${uri} = Resolve_Text_From_Template_Folder folder=${folder} base_name=location extension=uri mapping=${mapping} ${jmes_expression} = Resolve_Jmes_Path ${folder} + ${volatiles_list}= Resolve_Volatiles_Path ${folder} ${response_text} = Get_From_Uri uri=${uri} accept=${accept} session=${session} normalize_json=${normalize_json} jmes_path=${jmes_expression} - ... http_timeout=${http_timeout} + ... http_timeout=${http_timeout} keys_with_volatiles=${volatiles_list} [Return] ${response_text} Put_Templated @@ -339,6 +352,7 @@ Verify_Response_Templated Get_From_Uri [Arguments] ${uri} ${accept}=${ACCEPT_EMPTY} ${session}=default ${normalize_json}=False ${jmes_path}=${EMPTY} ${http_timeout}=${EMPTY} + ... ${keys_with_volatiles}=${EMPTY} [Documentation] GET data from given URI, check status code and return response text. ... \${accept} is a Python object with headers to use. ... If \${normalize_json}, normalize as JSON text before returning. @@ -348,7 +362,7 @@ Get_From_Uri ... ELSE RequestsLibrary.Get_Request alias=${session} uri=${uri} headers=${accept} timeout=${http_timeout} Check_Status_Code ${response} BuiltIn.Run_Keyword_Unless ${normalize_json} BuiltIn.Return_From_Keyword ${response.text} - ${text_normalized} = norm_json.normalize_json_text ${response.text} jmes_path=${jmes_path} + ${text_normalized} = norm_json.normalize_json_text ${response.text} jmes_path=${jmes_path} keys_with_volatiles=${keys_with_volatiles} [Return] ${text_normalized} Put_To_Uri