Skip to content

Commit

Permalink
Robotframework request package upgrade changes
Browse files Browse the repository at this point in the history
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:  #2105

Change-Id: Ie03b25ff88948bcccb09e9d82f8da86e28c92697
Signed-off-by: George Keishing <[email protected]>
  • Loading branch information
gkeishin committed Aug 17, 2022
1 parent 8b5d53a commit fbd6700
Show file tree
Hide file tree
Showing 28 changed files with 130 additions and 153 deletions.
11 changes: 8 additions & 3 deletions extended/test_bmc_stress_buster.robot
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ ${IPMI_BUSTER_MAX} ${5}
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
Expand All @@ -32,6 +34,7 @@ Stress BMC REST Server
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
Expand All @@ -41,6 +44,7 @@ Stress BMC SSH Server
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.
Expand All @@ -53,13 +57,14 @@ REST Enumerate Request On BMC
# 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

Expand Down
2 changes: 1 addition & 1 deletion extended/test_rest_user_management.robot
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Verify Root Password Update
# 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}]


Expand Down
9 changes: 4 additions & 5 deletions lib/certificate_utils.robot
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ Install Certificate File On BMC
... 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

Expand Down
17 changes: 6 additions & 11 deletions lib/code_update_utils.robot
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ Read Software Attribute
${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
Expand Down Expand Up @@ -103,8 +102,7 @@ Get Host Software Objects Details
${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}

Expand Down Expand Up @@ -338,8 +336,7 @@ Delete Software Object
# 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}
Expand Down Expand Up @@ -374,9 +371,8 @@ Delete Image And Verify
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
Expand Down Expand Up @@ -497,8 +493,7 @@ Get List of Images

FOR ${uri} IN @{installed_images}
${resp}= OpenBMC Get Request ${uri}
${json}= To JSON ${resp.content}
Log ${json["data"]}
Log ${resp.json()["data"]}
END


Expand Down
14 changes: 6 additions & 8 deletions lib/dump_utils.robot
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ Get The Dump Id
# 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"]}
Expand Down Expand Up @@ -84,8 +83,7 @@ Check For Too Many Dumps
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
Expand Down Expand Up @@ -131,9 +129,9 @@ Delete BMC Dump
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}

Expand Down Expand Up @@ -189,8 +187,8 @@ Delete All BMC Dump
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
Expand Down
3 changes: 1 addition & 2 deletions lib/esel_utils.robot
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ Count eSEL Entries
[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}


Expand Down
11 changes: 4 additions & 7 deletions lib/fan_utils.robot
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ Get Target Speed Of Fans
${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
Expand All @@ -132,15 +131,13 @@ Get Target And Blade Speeds
# 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}
Expand Down
6 changes: 2 additions & 4 deletions lib/logging_utils.robot
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ Get Logging Entry List
${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
Expand Down Expand Up @@ -200,8 +199,7 @@ Count Error Entries
${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
Expand Down
6 changes: 2 additions & 4 deletions lib/open_power_utils.robot
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ Read Object Attribute
${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
Expand Down Expand Up @@ -225,12 +224,11 @@ Get Sensors Aggregation URL List
# ]

${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
Expand Down
3 changes: 1 addition & 2 deletions lib/openbmc_ffdc_methods.robot
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ Log FFDC Get Requests
${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

Expand Down
4 changes: 2 additions & 2 deletions lib/pdu/synaccess.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,7 +15,7 @@ Connect and Login
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}.
Expand Down
3 changes: 1 addition & 2 deletions lib/redfish_request.robot
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ Redfish Generic Session Request
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}
Expand Down
2 changes: 1 addition & 1 deletion lib/resource.robot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*** Settings ***
Library Collections
Library String
Library RequestsLibrary.RequestsKeywords
Library RequestsLibrary
Library OperatingSystem
Variables ../data/variables.py

Expand Down
Loading

0 comments on commit fbd6700

Please sign in to comment.