Robotframework request package upgrade changes
Current working package version
robotframework-requests 0.7.2
To Test:
pip3 install robotframework-requests -U
or
# Once this commit is merged.
pip3 install -r requirements.txt
Version latest:
robotframework-requests 0.9.3
Refer Documentation:
https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html
What is not changed:
- The test cases under directory tests/ is not modified and is
deprecated but you can continue using it with older package
and configuration using
git clone -b v3.0-stable https://github.com/openbmc/openbmc-test-automation
Tested:
Upstream HW_CI test list, firmware code update and few other
test suite like ipmi, certificate, dumps, ffdc and redfish
test suites.
Note: I have not tested end to end, so it is likely there could be
grey areas where it could fail but should be minor w.r.t
response data format.
Resolves: openbmc/openbmc-test-automation#2105
Change-Id: Ie03b25ff88948bcccb09e9d82f8da86e28c92697
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/extended/test_bmc_stress_buster.robot b/extended/test_bmc_stress_buster.robot
index 1b19ffe..977c8f9 100644
--- a/extended/test_bmc_stress_buster.robot
+++ b/extended/test_bmc_stress_buster.robot
@@ -23,6 +23,8 @@
Stress BMC REST Server
[Documentation] Execute maximum allowed REST operation.
[Tags] Stress_BMC_REST_Server
+
+ Log To Console REST call request burst ${REST_BUSTER_MAX}
${dict}= Execute Process
... ${REST_BUSTER_MAX} REST Enumerate Request On BMC
Dictionary Should Not Contain Value ${dict} False
@@ -32,6 +34,7 @@
Stress BMC SSH Server
[Documentation] Execute maximum allowed SSH operation.
[Tags] Stress_BMC_SSH_Server
+ Log To Console SSH call request burst ${SSH_BUSTER_MAX}
${dict}= Execute Process
... ${SSH_BUSTER_MAX} SSH Connect And Execute Command
Dictionary Should Not Contain Value ${dict} False
@@ -41,6 +44,7 @@
Stress BMC IPMI Server
[Documentation] Execute maximum allowed IPMI operation.
[Tags] Stress_BMC_IPMI_Server
+ Log To Console IPMI call request burst ${IPMI_BUSTER_MAX}
${dict}= Execute Process ${IPMI_BUSTER_MAX} IPMI Check Status
Dictionary Should Not Contain Value ${dict} False
... msg=One or more IPMI operations has failed.
@@ -53,13 +57,14 @@
# Create REST session.
Create Session openbmc ${AUTH_URI}
${headers}= Create Dictionary Content-Type=application/json
- @{credentials}= Create List ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
+ @{credentials}= Create List ${rest_username} ${rest_password}
${data}= Create Dictionary data=@{credentials}
- ${resp}= Post Request openbmc /login data=${data} headers=${headers}
+ ${resp}= POST On Session openbmc /login json=${data} headers=${headers}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
# Trigger GET REST enumeration.
- ${resp}= Get Request openbmc /xyz/openbmc_project/software/enumerate
+ ${resp}= GET On Session openbmc /redfish/v1/Managers/bmc expected_status=any
+ Log To Console GET Request /redfish/v1/Managers/bmc
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Delete All Sessions
diff --git a/extended/test_rest_user_management.robot b/extended/test_rest_user_management.robot
index 5919a83..479f9b4 100644
--- a/extended/test_rest_user_management.robot
+++ b/extended/test_rest_user_management.robot
@@ -45,7 +45,7 @@
# REST Login to BMC with new "root" password.
Initialize OpenBMC rest_password=${test_password}
- ${resp}= Get Request openbmc ${BMC_USER_URI}enumerate
+ ${resp}= GET On Session openbmc ${BMC_USER_URI}enumerate
Valid Value resp.status_code [${HTTP_OK}]
diff --git a/lib/certificate_utils.robot b/lib/certificate_utils.robot
index 7f14bf3..9930aac 100755
--- a/lib/certificate_utils.robot
+++ b/lib/certificate_utils.robot
@@ -30,14 +30,13 @@
... X-Auth-Token=${XAUTH_TOKEN}
Set To Dictionary ${kwargs} headers ${headers}
- ${ret}= Post Request openbmc ${uri} &{kwargs}
- ${content_json}= To JSON ${ret.content}
- ${cert_id}= Set Variable If '${ret.status_code}' == '${HTTP_OK}' ${content_json["Id"]} -1
+ ${resp}= POST On Session openbmc ${uri} &{kwargs} expected_status=any
+ ${cert_id}= Set Variable If '${resp.status_code}' == '${HTTP_OK}' ${resp.json()["Id"]} -1
Run Keyword If '${status}' == 'ok'
- ... Should Be Equal As Strings ${ret.status_code} ${HTTP_OK}
+ ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
... ELSE IF '${status}' == 'error'
- ... Should Be Equal As Strings ${ret.status_code} ${HTTP_INTERNAL_SERVER_ERROR}
+ ... Should Be Equal As Strings ${resp.status_code} ${HTTP_INTERNAL_SERVER_ERROR}
Delete All Sessions
diff --git a/lib/code_update_utils.robot b/lib/code_update_utils.robot
index 484b66d..c94d56d 100644
--- a/lib/code_update_utils.robot
+++ b/lib/code_update_utils.robot
@@ -60,8 +60,7 @@
${resp}= OpenBMC Get Request ${software_object}/attr/${attribute_name}
... quiet=${1}
Return From Keyword If ${resp.status_code} != ${HTTP_OK}
- ${content}= To JSON ${resp.content}
- [Return] ${content["data"]}
+ [Return] ${resp.json()["data"]}
Get Software Objects Id
@@ -103,8 +102,7 @@
${pnor_details}= Get Software Objects ${VERSION_PURPOSE_HOST}
FOR ${pnor} IN @{pnor_details}
${resp}= OpenBMC Get Request ${pnor} quiet=${1}
- ${json}= To JSON ${resp.content}
- Append To List ${software} ${json["data"]}
+ Append To List ${software} ${resp.json()["data"]}
END
[Return] ${software}
@@ -338,8 +336,7 @@
# Description of argument(s):
# software_object The URI to the software image to delete.
- ${arglist}= Create List
- ${args}= Create Dictionary data=${arglist}
+ ${args}= Set Variable {"data": []}
${resp}= OpenBMC Post Request ${software_object}/action/Delete
... data=${args}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
@@ -374,9 +371,8 @@
Delete All Non Running BMC Images
[Documentation] Delete all BMC images that are not running on the BMC.
- @{datalist}= Create List
- ${data}= Create Dictionary data=@{datalist}
- Call Method ${SOFTWARE_VERSION_URI} DeleteAll data=${data}
+ ${args}= Set Variable {"data": []}
+ Call Method ${SOFTWARE_VERSION_URI} DeleteAll data=${args}
Check Error And Collect FFDC
@@ -497,8 +493,7 @@
FOR ${uri} IN @{installed_images}
${resp}= OpenBMC Get Request ${uri}
- ${json}= To JSON ${resp.content}
- Log ${json["data"]}
+ Log ${resp.json()["data"]}
END
diff --git a/lib/dump_utils.robot b/lib/dump_utils.robot
index fcdd793..85a88cf 100644
--- a/lib/dump_utils.robot
+++ b/lib/dump_utils.robot
@@ -51,9 +51,8 @@
# The "data" field conveys the id number of the created dump.
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
- ${json}= To JSON ${resp.content}
- Run Keyword If ${json["data"]} == ${None}
+ Run Keyword If ${resp.json()["data"]} == ${None}
... Fail Dump id returned null.
${dump_id}= Set Variable ${json["data"]}
@@ -84,8 +83,7 @@
Run Keyword If '${resp.status_code}' == '${HTTP_OK}'
... Run Keyword And Return Get The Dump Id ${resp}
- ${json}= To JSON ${resp.content}
- ${exception}= Set Variable ${json["message"]}
+ ${exception}= Set Variable ${resp.json()["message"]}
${at_capacity}= Set Variable Dump not captured due to a cap
${too_many_dumps}= Evaluate $at_capacity in $exception
Printn
@@ -131,9 +129,9 @@
Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
... Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
- ${data}= Create Dictionary data=@{EMPTY}
+ ${args}= Set Variable {"data": []}
${resp}= OpenBMC Post Request
- ... ${DUMP_ENTRY_URI}${dump_id}/action/Delete data=${data}
+ ... ${DUMP_ENTRY_URI}${dump_id}/action/Delete data=${args}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
@@ -189,8 +187,8 @@
Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
... Set Global Variable ${REST_DUMP_URI} /xyz/openbmc_project/dump/
- ${data}= Create Dictionary data=@{EMPTY}
- ${resp}= Openbmc Post Request ${REST_DUMP_URI}action/DeleteAll data=${data}
+ ${args}= Set Variable {"data": []}
+ ${resp}= Openbmc Post Request ${REST_DUMP_URI}action/DeleteAll data=${args}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Dump Should Not Exist
diff --git a/lib/esel_utils.robot b/lib/esel_utils.robot
index 754f5f9..5423a66 100755
--- a/lib/esel_utils.robot
+++ b/lib/esel_utils.robot
@@ -36,8 +36,7 @@
[Documentation] Count eSEL entries logged.
${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
- ${jsondata}= To JSON ${resp.content}
- ${count}= Get Length ${jsondata["data"]}
+ ${count}= Get Length ${resp.json()["data"]}
[Return] ${count}
diff --git a/lib/fan_utils.robot b/lib/fan_utils.robot
index d7b6a3c..9d2d615 100755
--- a/lib/fan_utils.robot
+++ b/lib/fan_utils.robot
@@ -110,8 +110,7 @@
${paths}= Get Endpoint Paths ${SENSORS_URI}fan_tach/ 0
FOR ${path} IN @{paths}
${response}= OpenBMC Get Request ${path}
- ${json}= To JSON ${response.content}
- ${target_speed}= Set Variable ${json["data"]["Target"]}
+ ${target_speed}= Set Variable ${response.json()["data"]["Target"]}
${max_target}= Run Keyword If ${target_speed} > ${max_target}
... Set Variable ${target_speed} ELSE Set Variable ${max_target}
END
@@ -132,15 +131,13 @@
# Get the fan target speed and the clockwise blade speed.
${path}= Catenate ${SENSORS_URI}fan_tach/${fan_name}_0
${response}= OpenBMC Get Request ${path}
- ${json}= To JSON ${response.content}
- ${fan_clockwise_speed}= Set Variable ${json["data"]["Value"]}
- ${target_speed}= Set Variable ${json["data"]["Target"]}
+ ${fan_clockwise_speed}= Set Variable ${response.json()["data"]["Value"]}
+ ${target_speed}= Set Variable ${response.json["data"]["Target"]}
# Get the counter-clockwise blade speed.
${path}= Catenate ${SENSORS_URI}fan_tach/${fan_name}_1
${response}= OpenBMC Get Request ${path}
- ${json}= To JSON ${response.content}
- ${fan_counterclockwise_speed}= Set Variable ${json["data"]["Value"]}
+ ${fan_counterclockwise_speed}= Set Variable ${response.json()["data"]["Value"]}
[Return] ${target_speed} ${fan_clockwise_speed}
... ${fan_counterclockwise_speed}
diff --git a/lib/logging_utils.robot b/lib/logging_utils.robot
index 84104a7..9bb9821 100644
--- a/lib/logging_utils.robot
+++ b/lib/logging_utils.robot
@@ -26,9 +26,8 @@
${entry_list}= Create List
${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
- ${jsondata}= To JSON ${resp.content}
- FOR ${entry} IN @{jsondata["data"]}
+ FOR ${entry} IN @{resp.json()["data"]}
Continue For Loop If '${entry.rsplit('/', 1)[1]}' == 'callout'
Append To List ${entry_list} ${entry}
END
@@ -200,8 +199,7 @@
${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
... msg=Failed to get error logs.
- ${jsondata}= To JSON ${resp.content}
- ${count}= Get Length ${jsondata["data"]}
+ ${count}= Get Length ${resp.json()["data"]}
[Return] ${count}
Verify Test Error Log
diff --git a/lib/open_power_utils.robot b/lib/open_power_utils.robot
index c6fe106..a3cb470 100644
--- a/lib/open_power_utils.robot
+++ b/lib/open_power_utils.robot
@@ -75,8 +75,7 @@
${resp}= OpenBMC Get Request
... ${object_base_uri_path}/attr/${attribute_name} quiet=${1}
Return From Keyword If ${resp.status_code} != ${HTTP_OK}
- ${content}= To JSON ${resp.content}
- [Return] ${content["data"]}
+ [Return] ${resp.json()["data"]}
Get Functional Processor Count
@@ -225,12 +224,11 @@
# ]
${resp}= OpenBMC Get Request ${object_base_uri_path}list quiet=${1}
- ${content}= To JSON ${resp.content}
${power_supply_avg_list}= Create List
${power_supply_max_list}= Create List
- FOR ${entry} IN @{content["data"]}
+ FOR ${entry} IN @{resp.json()["data"]}
Run Keyword If 'average' in '${entry}' Append To List ${power_supply_avg_list} ${entry}
Run Keyword If 'maximum' in '${entry}' Append To List ${power_supply_max_list} ${entry}
END
diff --git a/lib/openbmc_ffdc_methods.robot b/lib/openbmc_ffdc_methods.robot
index fe68c9f..339bc8e 100755
--- a/lib/openbmc_ffdc_methods.robot
+++ b/lib/openbmc_ffdc_methods.robot
@@ -297,8 +297,7 @@
${resp}= OpenBMC Get Request ${cmd[1]} quiet=${1} timeout=${30}
${status}= Run Keyword and Return Status Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Run Keyword If '${status}' == '${False}' Continue For Loop
- ${jsondata}= to json ${resp.content} pretty_print=True
- Write Data To File ${\n}${jsondata}${\n} ${logpath}
+ Write Data To File ${\n}${resp.json()}${\n} ${logpath}
Append To List ${ffdc_file_list} ${logpath}
END
diff --git a/lib/pdu/synaccess.robot b/lib/pdu/synaccess.robot
index c76553c..f6eb957 100644
--- a/lib/pdu/synaccess.robot
+++ b/lib/pdu/synaccess.robot
@@ -2,7 +2,7 @@
Documentation Synaccess Protocol Distribution Unit (PDU) library
Resource ../../lib/pdu/pdu.robot
-Library RequestsLibrary.RequestsKeywords
+Library RequestsLibrary
*** Keywords ***
Connect and Login
@@ -15,7 +15,7 @@
Power Cycle
[Documentation] Perform PDU power cycle.
Connect and Login
- ${resp}= Get Request pdu /cmd.cgi?$A4 ${PDU_SLOT_NO}
+ ${resp}= GET On Session pdu /cmd.cgi?$A4 ${PDU_SLOT_NO}
${error_message}= Catenate Power cycle of slot ${PDU_SLOT_NO} failed.
... PDU returned RC=${resp}.
diff --git a/lib/redfish_request.robot b/lib/redfish_request.robot
index 4e66c5c..670df01 100644
--- a/lib/redfish_request.robot
+++ b/lib/redfish_request.robot
@@ -47,9 +47,8 @@
Set To Dictionary ${session_dict} headers ${auth_token}
Set To Dictionary ${session_dict} Location ${session_resp.headers['Location']}
- ${content}= To JSON ${session_resp.content}
- Set To Dictionary ${session_dict} Content ${content}
+ Set To Dictionary ${session_dict} Content ${session_resp.content}
Set Global Variable ${active_session_info} ${session_dict}
Append To List ${session_dict_list} ${session_dict}
diff --git a/lib/resource.robot b/lib/resource.robot
index 50015b3..1e08066 100755
--- a/lib/resource.robot
+++ b/lib/resource.robot
@@ -1,7 +1,7 @@
*** Settings ***
Library Collections
Library String
-Library RequestsLibrary.RequestsKeywords
+Library RequestsLibrary
Library OperatingSystem
Variables ../data/variables.py
diff --git a/lib/rest_client.robot b/lib/rest_client.robot
index d8e9590..649352b 100644
--- a/lib/rest_client.robot
+++ b/lib/rest_client.robot
@@ -1,7 +1,7 @@
*** Settings ***
Library Collections
Library String
-Library RequestsLibrary.RequestsKeywords
+Library RequestsLibrary
Library OperatingSystem
Resource resource.robot
Library disable_warning_urllib.py
@@ -47,10 +47,10 @@
Set To Dictionary ${kwargs} headers ${headers}
Run Keyword If '${quiet}' == '${0}' Log Request method=Get
... base_uri=${base_uri} args=&{kwargs}
- ${ret}= Get Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
- Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
+ ${resp}= GET On Session openbmc ${base_uri} &{kwargs} timeout=${timeout} expected_status=any
+ Run Keyword If '${quiet}' == '${0}' Log Response ${resp}
Delete All Sessions
- [Return] ${ret}
+ [Return] ${resp}
OpenBMC Post Request
[Documentation] Do REST POST request and return the result.
@@ -71,10 +71,10 @@
${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
${headers}= Create Dictionary Content-Type=application/json
... X-Auth-Token=${XAUTH_TOKEN}
- set to dictionary ${kwargs} headers ${headers}
+ Set To Dictionary ${kwargs} headers ${headers}
Run Keyword If '${quiet}' == '${0}' Log Request method=Post
... base_uri=${base_uri} args=&{kwargs}
- ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
+ ${ret}= POST On Session openbmc ${base_uri} &{kwargs} timeout=${timeout}
Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
Delete All Sessions
[Return] ${ret}
@@ -93,15 +93,14 @@
# ${kwargs}= Create Dictionary allow_redirect=${True}.
Initialize OpenBMC ${timeout}
- ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
- ${headers}= Create Dictionary Content-Type=application/json
+ ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
+ ${headers}= Create Dictionary Content-Type=application/json
... X-Auth-Token=${XAUTH_TOKEN}
- set to dictionary ${kwargs} headers ${headers}
- Log Request method=Put base_uri=${base_uri} args=&{kwargs}
- ${ret}= Put Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
- Log Response ${ret}
+ Log Request method=Put base_uri=${base_uri} args=&{kwargs}
+ ${resp}= PUT On Session openbmc ${base_uri} json=${kwargs["data"]} headers=${headers}
+ Log Response ${resp}
Delete All Sessions
- [Return] ${ret}
+ [Return] ${resp}
OpenBMC Delete Request
[Documentation] Do REST request to delete the resource identified by the
@@ -124,7 +123,7 @@
Set To Dictionary ${kwargs} headers ${headers}
Run Keyword If '${quiet}' == '${0}' Log Request method=Delete
... base_uri=${base_uri} args=&{kwargs}
- ${ret}= Delete Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
+ ${ret}= DELETE On Session openbmc ${base_uri} &{kwargs} timeout=${timeout}
Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
Delete All Sessions
[Return] ${ret}
@@ -167,7 +166,7 @@
${headers}= Create Dictionary Content-Type=application/json
@{credentials}= Create List ${rest_username} ${rest_password}
${data}= Create Dictionary data=@{credentials}
- ${resp}= Post Request openbmc /login data=${data} headers=${headers}
+ ${resp}= POST On Session openbmc /login json=${data} headers=${headers}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
${processed_token_data}=
@@ -197,7 +196,7 @@
${headers}= Create Dictionary Content-Type=application/json
@{credentials}= Create List ${rest_username} ${rest_password}
${data}= create dictionary data=@{credentials}
- ${status} ${resp}= Run Keyword And Ignore Error Post Request openbmc
+ ${status} ${resp}= Run Keyword And Ignore Error POST On Session openbmc
... /login data=${data} headers=${headers}
Should Be Equal ${status} PASS msg=${resp}
@@ -213,12 +212,13 @@
# If there is no active sesion it will throw the following exception
# "Non-existing index or alias 'openbmc'"
- ${resp}= Post Request openbmc
+ ${resp}= POST On Session openbmc
... /logout data=${data} headers=${headers}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
... msg=${resp}
+
Log Request
[Documentation] Log the specific REST URI, method name on the console.
[Arguments] &{kwargs}
@@ -226,17 +226,21 @@
... , method: ${kwargs["method"]} , args: ${kwargs["args"]}
Logging ${msg} console=True
+
Log Response
[Documentation] Log the response code on the console.
[Arguments] ${resp}
+
${msg}= Catenate SEPARATOR= Response code: ${resp.status_code}
... , Content: ${resp.content}
Logging ${msg} console=True
+
Logging
[Documentation] Log the specified message on the console.
[Arguments] ${msg} ${console}=default False
- Log ${msg} console=True
+ Log ${msg} console=True
+
Read Attribute
[Documentation] Retrieve attribute value from URI and return result.
@@ -260,10 +264,9 @@
${resp}= OpenBMC Get Request ${uri}attr/${attr} timeout=${timeout}
... quiet=${quiet}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
- ${content}= To Json ${resp.content}
Run Keyword If '${expected_value}' != '${EMPTY}'
- ... Should Be Equal As Strings ${expected_value} ${content["data"]}
- [Return] ${content["data"]}
+ ... Should Be Equal As Strings ${expected_value} ${resp.json()["data"]}
+ [Return] ${resp.json()["data"]}
Write Attribute
@@ -319,9 +322,8 @@
${resp}= OpenBMC Get Request ${uri} timeout=${timeout} quiet=${quiet}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
- ${content}= To Json Ordered ${resp.content}
- [Return] ${content["data"]}
+ [Return] ${resp.json()["data"]}
Call Method
[Documentation] Invoke the specific REST service method.
@@ -365,7 +367,7 @@
Set To Dictionary ${kwargs} headers ${headers}
Run Keyword If '${quiet}' == '${0}' Log Request method=Post
... base_uri=${base_uri} args=&{kwargs}
- ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
+ ${ret}= POST On Session openbmc ${base_uri} &{kwargs} timeout=${timeout}
Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
Valid Value ret.status_code ${valid_status_codes}
Delete All Sessions
@@ -393,15 +395,13 @@
... {"UserName":"${rest_username}", "Password":"${rest_password}"}
... {"UserName":"${rest_username}", "Password":"${rest_password}", ${kwargs}}
- ${resp}= Post Request redfish /redfish/v1/SessionService/Sessions
+ ${resp}= POST On Session redfish /redfish/v1/SessionService/Sessions
... data=${data} headers=${headers}
Should Be Equal As Strings ${resp.status_code} ${HTTP_CREATED}
- ${content}= To JSON ${resp.content}
-
Set Global Variable ${XAUTH_TOKEN} ${resp.headers["X-Auth-Token"]}
- [Return] ${content}
+ [Return] ${resp.json()}
Redfish Get Request
@@ -422,7 +422,7 @@
${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN}
Set To Dictionary ${kwargs} headers ${headers}
Run Keyword If '${quiet}' == '${0}' Log Request method=Post base_uri=${base_uri} args=&{kwargs}
- ${resp}= Get Request redfish ${base_uri} &{kwargs} timeout=${timeout}
+ ${resp}= GET On Session redfish ${base_uri} &{kwargs} timeout=${timeout}
Run Keyword If '${quiet}' == '${0}' Log Response ${resp}
[Return] ${resp}
@@ -446,7 +446,7 @@
${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN}
Set To Dictionary ${kwargs} headers ${headers}
Run Keyword If '${quiet}' == '${0}' Log Request method=Post base_uri=${base_uri} args=&{kwargs}
- ${resp}= Post Request redfish ${base_uri} &{kwargs} timeout=${timeout}
+ ${resp}= POST On Session redfish ${base_uri} &{kwargs} timeout=${timeout} expected_status=any
Run Keyword If '${quiet}' == '${0}' Log Response ${resp}
[Return] ${resp}
diff --git a/lib/utils.robot b/lib/utils.robot
index a306dc5..0c572c2 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -396,7 +396,7 @@
log to console "Triggering warm reset"
${data}= create dictionary data=@{EMPTY}
- ${resp}= openbmc post request
+ ${resp}= Openbmc Post Request
... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
${session_active}= Check If warmReset is Initiated
@@ -421,9 +421,8 @@
${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
... data=${args} quiet=${quiet}
Should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${content}= to json ${resp.content}
- [Return] ${content["data"]}
+ [Return] ${resp.json()["data"]}
Clear BMC Gard Record
@@ -567,9 +566,9 @@
Delete All Error Logs
[Documentation] Delete all error log entries using "DeleteAll" interface.
- ${data}= Create Dictionary data=@{EMPTY}
+ ${args}= Set Variable {"data": []}
${resp}= Openbmc Post Request ${BMC_LOGGING_URI}action/DeleteAll
- ... data=${data}
+ ... data=${args}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
@@ -803,7 +802,7 @@
${data}= Create Dictionary data=@{password}
${headers}= Create Dictionary Content-Type=application/json X-Auth-Token=${XAUTH_TOKEN}
- ${resp}= Post Request openbmc ${BMC_USER_URI}root/action/SetPassword
+ ${resp}= POST On Session openbmc ${BMC_USER_URI}root/action/SetPassword
... data=${data} headers=${headers}
Valid Value resp.status_code [${HTTP_OK}]
diff --git a/openpower/ext_interfaces/test_client_identifier.robot b/openpower/ext_interfaces/test_client_identifier.robot
index d9592dd..8cfa771 100644
--- a/openpower/ext_interfaces/test_client_identifier.robot
+++ b/openpower/ext_interfaces/test_client_identifier.robot
@@ -182,13 +182,12 @@
FOR ${client} ${session} IN ZIP ${client_ids} ${session_ids}
${resp}= Redfish Get Request /redfish/v1/SessionService/Sessions/${session["Id"]}
- ${sessions}= To Json ${resp.content}
- Rprint Vars sessions
- @{words} = Split String ${sessions["ClientOriginIPAddress"]} :
+ Rprint Vars resp.json()
+ @{words} = Split String ${resp.json()["ClientOriginIPAddress"]} :
${ip_address}= Get Running System IP
Set Test Variable ${temp_ipaddr} ${words}[-1]
- Valid Value client ['${sessions["Oem"]["OpenBMC"]["ClientID"]}']
- Valid Value session["Id"] ['${sessions["Id"]}']
+ Valid Value client ['${resp.json()["Oem"]["OpenBMC"]["ClientID"]}']
+ Valid Value session["Id"] ['${resp.json()["Id"]}']
Valid Value temp_ipaddr ${ip_address}
END
diff --git a/openpower/ext_interfaces/test_lock_management.robot b/openpower/ext_interfaces/test_lock_management.robot
index 4ca37e5..16f6e8b 100644
--- a/openpower/ext_interfaces/test_lock_management.robot
+++ b/openpower/ext_interfaces/test_lock_management.robot
@@ -8,6 +8,7 @@
Resource ../../lib/external_intf/management_console_utils.robot
Resource ../../lib/rest_response_code.robot
Library ../../lib/bmc_network_utils.py
+Library JSONLibrary
Suite Setup Run Keyword And Ignore Error Delete All Redfish Sessions
Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions
@@ -454,8 +455,10 @@
# status_code HTTP status code.
${lock_dict_param}= Form Data To Acquire Lock ${lock_type}
+ ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
${resp}= Redfish Post Request
... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
+ ... expected_status=any
Should Be Equal As Strings ${resp.status_code} ${status_code}
Run Keyword If ${status_code} == ${HTTP_BAD_REQUEST}
@@ -475,8 +478,10 @@
# status_code HTTP status code.
${lock_dict_param}= Create Data To Acquire List Of Lock ${lock_type}
+ ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
${resp}= Redfish Post Request
... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
+ ... expected_status=any
Should Be Equal As Strings ${resp.status_code} ${status_code}
Run Keyword If ${status_code} == ${HTTP_CONFLICT}
@@ -497,6 +502,7 @@
# status_code HTTP status code.
${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type}
+ ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
${resp}= Redfish Post Request
... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Should Be Equal As Strings ${resp.status_code} ${status_code}
@@ -516,6 +522,7 @@
${lock_dict_param}=
... Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type}
+ ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
${resp}= Redfish Post Request
... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Should Be Equal As Strings ${resp.status_code} ${status_code}
@@ -1236,7 +1243,7 @@
# exp_status_code Expected HTTP status code.
${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
- ... data={"SessionIDs": ${session_id_list}}
+ ... data={"SessionIDs":${session_id_list}} expected_status=any
Should Be Equal As Strings ${resp.status_code} ${exp_status_code}
${locks}= Evaluate json.loads('''${resp.text}''') json
diff --git a/openpower/ext_interfaces/test_savearea_management.robot b/openpower/ext_interfaces/test_savearea_management.robot
index ed0a123..6c122d1 100644
--- a/openpower/ext_interfaces/test_savearea_management.robot
+++ b/openpower/ext_interfaces/test_savearea_management.robot
@@ -366,7 +366,8 @@
${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN}
Set To Dictionary ${data} headers ${headers}
- ${resp}= Delete Request openbmc /ibm/v1/Host/ConfigFiles/${conf_file} &{data}
+ ${resp}= DELETE On Session openbmc /ibm/v1/Host/ConfigFiles/${conf_file} &{data}
+ ... expected_status=any
Should Be Equal As Strings ${resp.status_code} ${status_code}
${description}= Return Description Of Response ${resp.text}
@@ -386,7 +387,8 @@
${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN}
Set To Dictionary ${data} headers ${headers}
- ${resp}= Post Request openbmc /ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll &{data}
+ ${resp}= POST On Session openbmc /ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll &{data}
+ ... expected_status=any
Should Be Equal As Strings ${resp.status_code} ${status_code}
@@ -428,7 +430,8 @@
${kwargs}= Create Dictionary data=${image_data}
Set To Dictionary ${kwargs} headers ${headers}
- ${resp}= Put Request openbmc /ibm/v1/Host/ConfigFiles/${conf_file} &{kwargs} timeout=10
+ ${resp}= PUT On Session openbmc /ibm/v1/Host/ConfigFiles/${conf_file} &{kwargs} timeout=10
+ ... expected_status=any
Should Be Equal As Strings ${resp.status_code} ${status_code}
${description}= Return Description Of Response ${resp.text}
@@ -592,7 +595,8 @@
# status_code HTTPS status code.
FOR ${conf_file} IN @{file_name}
- ${resp}= Get Request openbmc /ibm/v1/Host/ConfigFiles/${conf_file}
+ ${resp}= GET On Session openbmc /ibm/v1/Host/ConfigFiles/${conf_file}
+ ... expected_status=any
Should Be Equal As Strings ${resp.status_code} ${status_code}
${Partition_file_data}= Remove String ${resp.text} \\n
diff --git a/openpower/ext_interfaces/test_vmicert_management.robot b/openpower/ext_interfaces/test_vmicert_management.robot
index 02b0e3a..9eeb34b 100644
--- a/openpower/ext_interfaces/test_vmicert_management.robot
+++ b/openpower/ext_interfaces/test_vmicert_management.robot
@@ -614,7 +614,8 @@
${csr_data}= Create Dictionary CsrString ${csr}
Set To Dictionary ${data} data ${csr_data}
- ${resp}= Post Request openbmc ${cert_uri} &{data} headers=${headers} timeout=${read_timeout}
+ ${resp}= POST On Session openbmc ${cert_uri} &{data} headers=${headers}
+ ... timeout=${read_timeout} expected_status=any
Log to console ${resp.content}
[Return] ${resp}
@@ -643,7 +644,8 @@
${cert_uri}= Set Variable ${VMI_BASE_URI}Host/Certificate/root
- ${resp}= Get Request openbmc ${cert_uri} &{data} headers=${headers}
+ ${resp}= GET On Session openbmc ${cert_uri} &{data} headers=${headers}
+ ... expected_status=any
Should Be Equal As Strings ${resp.status_code} ${valid_status_code}
Return From Keyword If ${resp.status_code} != ${HTTP_OK}
diff --git a/openpower/test_inband_bmc_auth_reset.robot b/openpower/test_inband_bmc_auth_reset.robot
index 5b9f1fa..e6f9237 100644
--- a/openpower/test_inband_bmc_auth_reset.robot
+++ b/openpower/test_inband_bmc_auth_reset.robot
@@ -23,7 +23,8 @@
${headers}= Create Dictionary Content-Type=application/json
@{credentials}= Create List ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
${data}= create dictionary data=@{credentials}
- ${resp}= Post Request openbmc /login data=${data} headers=${headers}
+ ${resp}= POST On Session openbmc /login data=${data} headers=${headers}
+ ... expected_status=any
Should Be Equal As Strings ${resp.status_code} ${HTTP_UNAUTHORIZED}
# Call reset method.
diff --git a/redfish/dmtf_tools/test_redfishtool_certificate.robot b/redfish/dmtf_tools/test_redfishtool_certificate.robot
index 5c84b62..63d0280 100644
--- a/redfish/dmtf_tools/test_redfishtool_certificate.robot
+++ b/redfish/dmtf_tools/test_redfishtool_certificate.robot
@@ -6,6 +6,7 @@
Library OperatingSystem
Library String
Library Collections
+Library JSONLibrary
Resource ../../lib/resource.robot
Resource ../../lib/bmc_redfish_resource.robot
@@ -284,8 +285,8 @@
[Documentation] Delete all CA certificate via Redfish.
${cmd_output}= Redfishtool Get /redfish/v1/Managers/bmc/Truststore/Certificates
- ${json_object}= To JSON ${cmd_output}
- ${cert_list}= Set Variable ${json_object["Members"]}
+ ${cmd_output}= Convert String to JSON ${cmd_output}
+ ${cert_list}= Set Variable ${cmd_output["Members"]}
FOR ${cert} IN @{cert_list}
Redfishtool Delete ${cert["@odata.id"]} ${root_cmd_args}
END
@@ -333,14 +334,13 @@
... X-Auth-Token=${XAUTH_TOKEN}
Set To Dictionary ${kwargs} headers ${headers}
- ${ret}= Post Request openbmc ${uri} &{kwargs}
- ${content_json}= To JSON ${ret.content}
- ${cert_id}= Set Variable If '${ret.status_code}' == '${HTTP_OK}' ${content_json["Id"]} -1
+ ${resp}= POST On Session openbmc ${uri} &{kwargs}
+ ${cert_id}= Set Variable If '${resp.status_code}' == '${HTTP_OK}' ${resp.json()["Id"]} -1
Run Keyword If '${status}' == 'ok'
- ... Should Be Equal As Strings ${ret.status_code} ${HTTP_OK}
+ ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
... ELSE IF '${status}' == 'error'
- ... Should Be Equal As Strings ${ret.status_code} ${HTTP_INTERNAL_SERVER_ERROR}
+ ... Should Be Equal As Strings ${resp.status_code} ${HTTP_INTERNAL_SERVER_ERROR}
Delete All Sessions
@@ -409,9 +409,10 @@
${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri}
Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
- ${json_object}= To JSON ${cmd_output}
- [Return] ${json_object["CertificateString"]}
+ ${cmd_output}= Convert String to JSON ${cmd_output}
+
+ [Return] ${cmd_output["CertificateString"]}
Suite Setup Execution
diff --git a/redfish/dmtf_tools/test_redfishtool_local_user.robot b/redfish/dmtf_tools/test_redfishtool_local_user.robot
index a27d339..5b0ca54 100644
--- a/redfish/dmtf_tools/test_redfishtool_local_user.robot
+++ b/redfish/dmtf_tools/test_redfishtool_local_user.robot
@@ -249,24 +249,6 @@
[return] ${status}
-Redfishtool GetAttribute
- [Documentation] Execute redfishtool for GET operation.
- [Arguments] ${uri} ${Attribute} ${cmd_args}=${root_cmd_args} ${expected_error}=""
-
- # Description of argument(s):
- # uri URI for GET operation (e.g. /redfish/v1/AccountService/Accounts/).
- # Attribute The specific attribute to be retrieved with the URI.
- # cmd_args Commandline arguments.
- # expected_error Expected error optionally provided in testcase (e.g. 401 /
- # authentication error, etc. ).
-
- ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri}
- Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
- ${json_object}= To JSON ${cmd_output}
-
- [Return] ${json_object["${Attribute}"]}
-
-
Suite Setup Execution
[Documentation] Do suite setup execution.
diff --git a/redfish/service_root/test_service_root.robot b/redfish/service_root/test_service_root.robot
index 5c378c5..f5c03ce 100644
--- a/redfish/service_root/test_service_root.robot
+++ b/redfish/service_root/test_service_root.robot
@@ -64,8 +64,9 @@
${headers}= Create Dictionary Content-Type=application/json
... X-Auth-Token=deadbeef
- ${resp}= Get Request
+ ${resp}= GET On Session
... openbmc /redfish/v1/SessionService/Sessions headers=${headers}
+ ... expected_status=${HTTP_UNAUTHORIZED}
Should Be Equal As Strings ${resp.status_code} ${HTTP_UNAUTHORIZED}
@@ -106,15 +107,14 @@
Create Session openbmc https://${OPENBMC_HOST}
${headers}= Create Dictionary Content-Type=application/json
- ${data}= Create Dictionary UserName=${OPENBMC_USERNAME} Password=${OPENBMC_PASSWORD}
+ ${data}= Set Variable {"UserName":"${OPENBMC_USERNAME}", "Password":"${OPENBMC_PASSWORD}"}
- ${resp}= Post Request openbmc /redfish/v1/SessionService/Sessions data=${data} headers=${headers}
+ ${resp}= POST On Session openbmc /redfish/v1/SessionService/Sessions data=${data} headers=${headers}
Should Be Equal As Strings ${resp.status_code} ${HTTP_CREATED}
- ${content}= To JSON ${resp.content}
${headers}= Create Dictionary Content-Type=application/json
... X-Auth-Token=${resp.headers["X-Auth-Token"]}
- ${resp}= Delete Request openbmc ${REDFISH_SESSION}${/}${content["Id"]} headers=${headers}
+ ${resp}= DELETE On Session openbmc ${REDFISH_SESSION}${/}${resp.json()["Id"]} headers=${headers}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
diff --git a/redfish/service_root/test_service_root_security.robot b/redfish/service_root/test_service_root_security.robot
index c0a8d89..0686d6f 100644
--- a/redfish/service_root/test_service_root_security.robot
+++ b/redfish/service_root/test_service_root_security.robot
@@ -46,7 +46,7 @@
${headers}= Create Dictionary Content-Type=application/json
Run Keyword And Expect Error *Connection refused*
- ... Post Request openbmc /redfish/v1/SessionService/Sessions
+ ... POST On Session openbmc /redfish/v1/SessionService/Sessions
... data=${data} headers=${headers}
@@ -61,7 +61,7 @@
${headers}= Create Dictionary Content-Type=application/json
Run Keyword And Expect Error *Connection refused*
- ... Post Request openbmc /redfish/v1/SessionService/Sessions
+ ... POST On Session openbmc /redfish/v1/SessionService/Sessions
... data=${data} headers=${headers}
diff --git a/redfish/systems/eventlog/test_association.robot b/redfish/systems/eventlog/test_association.robot
index 3dc8d79..093aff0 100755
--- a/redfish/systems/eventlog/test_association.robot
+++ b/redfish/systems/eventlog/test_association.robot
@@ -45,10 +45,9 @@
Create Test Error With Callout
${elog_entry}= Get Elog URL List
${resp}= OpenBMC Get Request ${elog_entry[0]}
- ${jsondata}= To JSON ${resp.content}
List Should Contain Value
- ... ${jsondata["data"]["AdditionalData"]} CALLOUT_DEVICE_PATH_TEST=${target_device_path}
- List Should Contain Value ${jsondata["data"]["AdditionalData"]} DEV_ADDR=0x0DEADEAD
+ ... ${resp.json()["data"]["AdditionalData"]} CALLOUT_DEVICE_PATH_TEST=${target_device_path}
+ List Should Contain Value ${resp.json()["data"]["AdditionalData"]} DEV_ADDR=0x0DEADEAD
Create Test Error Callout And Verify Associations
@@ -67,11 +66,10 @@
Create Test Error With Callout
${elog_entry}= Get Elog URL List
${resp}= OpenBMC Get Request ${elog_entry[0]}
- ${jsondata}= To JSON ${resp.content}
- List Should Contain Value ${jsondata["data"]["Associations"][0]} callout
- List Should Contain Value ${jsondata["data"]["Associations"][0]} fault
+ List Should Contain Value ${resp.json()["data"]["Associations"][0]} callout
+ List Should Contain Value ${resp.json()["data"]["Associations"][0]} fault
List Should Contain Value
- ... ${jsondata["data"]["Associations"][0]}
+ ... ${resp.json()["data"]["Associations"][0]}
... /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
@@ -200,8 +198,7 @@
Create Test Error With Callout
${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
${resp}= OpenBMC Get Request ${elog_entry[0]}
- ${jsondata}= To JSON ${resp.content}
- Should Contain ${jsondata["data"]["Associations"][0]} callout
+ Should Contain ${resp.json()["data"]["Associations"][0]} callout
# Set the error log field "Resolved".
# By doing so, the callout object should get deleted automatically.
@@ -260,12 +257,11 @@
[Documentation] Verify test error log entries.
${elog_entry}= Get Elog URL List
${resp}= OpenBMC Get Request ${elog_entry[0]}
- ${json}= To JSON ${resp.content}
- Should Be Equal ${json["data"]["Message"]}
+ Should Be Equal ${resp.json()["data"]["Message"]}
... example.xyz.openbmc_project.Example.Elog.TestCallout
- Should Be Equal ${json["data"]["Severity"]}
+ Should Be Equal ${resp.json()["data"]["Severity"]}
... xyz.openbmc_project.Logging.Entry.Level.Error
${content}= Read Attribute ${elog_entry[0]}/callout endpoints
diff --git a/redfish/systems/eventlog/test_esel.robot b/redfish/systems/eventlog/test_esel.robot
index 4a2c85e..7381f6e 100644
--- a/redfish/systems/eventlog/test_esel.robot
+++ b/redfish/systems/eventlog/test_esel.robot
@@ -104,7 +104,6 @@
${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
${resp}= OpenBMC Get Request ${elog_entry[0]}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
- ${jsondata}= To JSON ${resp.content}
# "/xyz/openbmc_project/logging/entry/1": {
# "Timestamp": 1487743771812,
# "AdditionalData": [],
@@ -112,7 +111,7 @@
# "Id": 1,
# "Severity": "xyz.openbmc_project.Logging.Entry.Level.Emergency"
# }
- Should Not Be Empty ${jsondata["data"]["AdditionalData"]}
+ Should Not Be Empty ${resp.json()["data"]["AdditionalData"]}
Test Wrong Reservation_ID
diff --git a/requirements.txt b/requirements.txt
index 0aa6f28..30233ba 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,7 @@
robotframework
requests
-robotframework-requests>=0.3.9,<0.8.0
+robotframework-requests
+robotframework-jsonlibrary
paramiko>=2.5.0
robotframework-sshlibrary
robotframework-scplibrary
diff --git a/templates/test_openbmc_setup.robot b/templates/test_openbmc_setup.robot
index eaefc30..b7b0748 100644
--- a/templates/test_openbmc_setup.robot
+++ b/templates/test_openbmc_setup.robot
@@ -29,10 +29,9 @@
# REST Connection and request.
Initialize OpenBMC
# Raw GET REST operation to verify session is established.
- ${resp}= Get Request openbmc /xyz/openbmc_project/
+ ${resp}= GET On Session openbmc /xyz/openbmc_project/ expected_status=any
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
- ${content}= To JSON ${resp.content} pretty_print=True
- Log To Console \n ${content}
+ Log To Console \n ${resp.json()}
Test SSH Setup