xref: /openbmc/openbmc-test-automation/redfish/update_service/test_redfish_host_code_update.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
132e2b589SSushil Singh*** Settings ***
232e2b589SSushil SinghDocumentation            Update firmware on a target Host via Redifsh.
332e2b589SSushil Singh
432e2b589SSushil Singh# Test Parameters:
532e2b589SSushil Singh# IMAGE_FILE_PATH        The path to the Host image file.
632e2b589SSushil Singh#
732e2b589SSushil Singh# Firmware update states:
832e2b589SSushil Singh#     Enabled            Image is installed and either functional or active.
932e2b589SSushil Singh#     Disabled           Image installation failed or ready for activation.
1032e2b589SSushil Singh#     Updating           Image installation currently in progress.
1132e2b589SSushil Singh
1232e2b589SSushil SinghResource                 ../../lib/resource.robot
1332e2b589SSushil SinghResource                 ../../lib/bmc_redfish_resource.robot
1432e2b589SSushil SinghResource                 ../../lib/boot_utils.robot
1532e2b589SSushil SinghResource                 ../../lib/openbmc_ffdc.robot
1632e2b589SSushil SinghResource                 ../../lib/common_utils.robot
1732e2b589SSushil SinghResource                 ../../lib/code_update_utils.robot
1832e2b589SSushil SinghResource                 ../../lib/dump_utils.robot
1932e2b589SSushil SinghResource                 ../../lib/logging_utils.robot
2032e2b589SSushil SinghResource                 ../../lib/redfish_code_update_utils.robot
219770daecSSushil SinghResource                 ../../lib/utils.robot
2232e2b589SSushil SinghLibrary                  ../../lib/gen_robot_valid.py
2332e2b589SSushil SinghLibrary                  ../../lib/tftp_update_utils.py
2432e2b589SSushil Singh
2532e2b589SSushil SinghSuite Setup              Suite Setup Execution
2632e2b589SSushil SinghSuite Teardown           Redfish.Logout
2732e2b589SSushil SinghTest Setup               Printn
2832e2b589SSushil SinghTest Teardown            FFDC On Test Case Fail
2932e2b589SSushil Singh
30*6fb70d98SMatt FischerTest Tags               Redfish_Host_Code_Update
3132e2b589SSushil Singh
3232e2b589SSushil Singh*** Test Cases ***
3332e2b589SSushil Singh
34dce3be1dSTony LeeRedfish Host Code Update With ApplyTime OnReset
3516b3c7bfSGeorge Keishing    [Documentation]  Update the firmware image with ApplyTime of OnReset.
36dce3be1dSTony Lee    [Tags]  Redfish_Host_Code_Update_With_ApplyTime_OnReset
3732e2b589SSushil Singh    [Template]  Redfish Update Firmware
3832e2b589SSushil Singh
3932e2b589SSushil Singh    # policy
4032e2b589SSushil Singh    OnReset
4132e2b589SSushil Singh
4232e2b589SSushil Singh
43dce3be1dSTony LeeRedfish Host Code Update With ApplyTime Immediate
4416b3c7bfSGeorge Keishing    [Documentation]  Update the firmware image with ApplyTime of Immediate.
45dce3be1dSTony Lee    [Tags]  Redfish_Host_Code_Update_With_ApplyTime_Immediate
4632e2b589SSushil Singh    [Template]  Redfish Update Firmware
4732e2b589SSushil Singh
4832e2b589SSushil Singh    # policy
4932e2b589SSushil Singh    Immediate
5032e2b589SSushil Singh
511620cfbaSSushil Singh
52bf2d10e8SSivas SRRBMC Reboot When PNOR Update Goes On
53bf2d10e8SSivas SRR    [Documentation]  Trigger PNOR update and do BMC reboot.
54bf2d10e8SSivas SRR    [Tags]  BMC_Reboot_When_PNOR_Update_Goes_On
55bf2d10e8SSivas SRR
56c32434a3SYi Hu    ${bios_version_before}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}/  BiosVersion
57bf2d10e8SSivas SRR    Redfish Firmware Update And Do BMC Reboot
58c32434a3SYi Hu    ${bios_version_after}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}/  BiosVersion
59bf2d10e8SSivas SRR    Valid Value  bios_version_after  ['${bios_version_before}']
60bf2d10e8SSivas SRR
61bf2d10e8SSivas SRR
6232e2b589SSushil Singh*** Keywords ***
6332e2b589SSushil Singh
6432e2b589SSushil SinghSuite Setup Execution
6532e2b589SSushil Singh    [Documentation]  Do the suite setup.
6632e2b589SSushil Singh
6732e2b589SSushil Singh    Valid File Path  IMAGE_FILE_PATH
6832e2b589SSushil Singh    Redfish.Login
6944c0910eSGeorge Keishing    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
7044c0910eSGeorge Keishing    Run Keyword And Ignore Error  Redfish Purge Event Log
71219c6330SGeorge Keishing    Redfish Power Off  stack_mode=skip
7232e2b589SSushil Singh
7332e2b589SSushil Singh
7432e2b589SSushil SinghRedfish Update Firmware
75a9763de7SGeorge Keishing    [Documentation]  Update the Host firmware via redfish interface.
7632e2b589SSushil Singh    [Arguments]  ${apply_time}
7732e2b589SSushil Singh
7832e2b589SSushil Singh    # Description of argument(s):
7932e2b589SSushil Singh    # policy     ApplyTime allowed values (e.g. "OnReset", "Immediate").
8032e2b589SSushil Singh
8132e2b589SSushil Singh    Redfish.Login
829770daecSSushil Singh    ${post_code_update_actions}=  Get Post Boot Action
836f86f179SSushil Singh    Set ApplyTime  policy=${apply_Time}
845eb37da8SSushil Singh
855eb37da8SSushil Singh    # URI : /redfish/v1/UpdateService
865eb37da8SSushil Singh    # "HttpPushUri": "/redfish/v1/UpdateService/update",
875eb37da8SSushil Singh
886f86f179SSushil Singh    Redfish Upload Image And Check Progress State
899770daecSSushil Singh    Run Key  ${post_code_update_actions['Host image']['${apply_time}']}
909770daecSSushil Singh    Redfish.Login
919770daecSSushil Singh    Redfish Verify Host Version  ${IMAGE_FILE_PATH}
92811ffae3SSushil Singh    Verify Get ApplyTime  ${apply_time}
9332e2b589SSushil Singh
94bf2d10e8SSivas SRR
95bf2d10e8SSivas SRRRedfish Firmware Update And Do BMC Reboot
96bf2d10e8SSivas SRR    [Documentation]  Update the firmware via redfish interface and do BMC reboot.
97bf2d10e8SSivas SRR
98bf2d10e8SSivas SRR    Set ApplyTime  policy="Immediate"
995eb37da8SSushil Singh
1005eb37da8SSushil Singh     # URI : /redfish/v1/UpdateService
1015eb37da8SSushil Singh     # "HttpPushUri": "/redfish/v1/UpdateService/update",
1025eb37da8SSushil Singh
1035eb37da8SSushil Singh    ${redfish_update_uri}=  Get Redfish Update Service URI
1045eb37da8SSushil Singh    Redfish Upload Image  ${redfish_update_uri}  ${IMAGE_FILE_PATH}
105bf2d10e8SSivas SRR    ${image_id}=  Get Latest Image ID
106bf2d10e8SSivas SRR    Wait Until Keyword Succeeds  1 min  10 sec
107bf2d10e8SSivas SRR    ...  Check Image Update Progress State  match_state='Updating'  image_id=${image_id}
108bf2d10e8SSivas SRR
109bf2d10e8SSivas SRR    # BMC reboot while PNOR update is in progress.
110bf2d10e8SSivas SRR    Redfish OBMC Reboot (off)
111