xref: /openbmc/openbmc-test-automation/extended/code_update/bmc_code_update.robot (revision e8dc525359a7f920239fd6cdcd247d2ecbe5b357)
19f74d3afSCharles Paul Hofer*** Settings ***
29f74d3afSCharles Paul HoferDocumentation     Update the BMC code on a target BMC.
39f74d3afSCharles Paul Hofer...               Execution Method:
49f74d3afSCharles Paul Hofer...               python -m robot -v OPENBMC_HOST:<hostname>
59f74d3afSCharles Paul Hofer...               -v IMAGE_FILE_PATH:<path/*.tar>  bmc_code_update.robot
69f74d3afSCharles Paul Hofer
79f74d3afSCharles Paul HoferLibrary           ../../lib/code_update_utils.py
89f74d3afSCharles Paul HoferVariables         ../../data/variables.py
99f74d3afSCharles Paul HoferResource          ../../lib/boot_utils.robot
109f74d3afSCharles Paul HoferResource          code_update_utils.robot
119f74d3afSCharles Paul HoferResource          ../../lib/code_update_utils.robot
121eb85f57SGeorge KeishingResource          ../../lib/openbmc_ffdc.robot
131eb85f57SGeorge KeishingResource          ../../lib/dump_utils.robot
149f74d3afSCharles Paul Hofer
150071549eSGeorge KeishingTest Teardown     Code Update Test Teardown
169f74d3afSCharles Paul Hofer
1709712a1eSGeorge KeishingForce Tags        BMC_Code_Update
1809712a1eSGeorge Keishing
199f74d3afSCharles Paul Hofer*** Variables ***
209f74d3afSCharles Paul Hofer
219f74d3afSCharles Paul Hofer${QUIET}                          ${1}
229f74d3afSCharles Paul Hofer${IMAGE_FILE_PATH}                ${EMPTY}
23c1fa2bc9SCharles Paul Hofer${ALTERNATE_IMAGE_FILE_PATH}      ${EMPTY}
24b7842a59SCharles Paul Hofer${SKIP_UPDATE_IF_ACTIVE}          false
259f74d3afSCharles Paul Hofer
269f74d3afSCharles Paul Hofer*** Test Cases ***
279f74d3afSCharles Paul Hofer
289f74d3afSCharles Paul HoferREST BMC Code Update
299f74d3afSCharles Paul Hofer    [Documentation]  Do a BMC code update by uploading image on BMC via REST.
309f74d3afSCharles Paul Hofer    [Tags]  REST_BMC_Code_Update
311eb85f57SGeorge Keishing    [Setup]  Code Update Setup
329f74d3afSCharles Paul Hofer
3321845469SCharles Paul Hofer    Upload And Activate Image  ${IMAGE_FILE_PATH}
3421845469SCharles Paul Hofer    ...  skip_if_active=${SKIP_UPDATE_IF_ACTIVE}
359f74d3afSCharles Paul Hofer    OBMC Reboot (off)
36e43fb2f7SCharles Paul Hofer    Verify Running BMC Image  ${IMAGE_FILE_PATH}
379f74d3afSCharles Paul Hofer
389f74d3afSCharles Paul Hofer
39c1fa2bc9SCharles Paul HoferUpload And Activate Multiple BMC Images
40c1fa2bc9SCharles Paul Hofer    [Documentation]  Upload another BMC image and verify that its state is
41c1fa2bc9SCharles Paul Hofer    ...              different from all others.
42c1fa2bc9SCharles Paul Hofer    [Tags]  Upload_And_Activate_Multiple_BMC_Images
43c1fa2bc9SCharles Paul Hofer    [Template]  Activate Image And Verify No Duplicate Priorities
44c1fa2bc9SCharles Paul Hofer    [Setup]  Upload And Activate Multiple BMC Images Setup
45c1fa2bc9SCharles Paul Hofer
46c1fa2bc9SCharles Paul Hofer    # Image File Path              Image Purpose
47c1fa2bc9SCharles Paul Hofer    ${ALTERNATE_IMAGE_FILE_PATH}   ${VERSION_PURPOSE_BMC}
48c1fa2bc9SCharles Paul Hofer
49c1fa2bc9SCharles Paul Hofer
5042f17468SCharles Paul HoferBMC Set Priority To Invalid Values
5142f17468SCharles Paul Hofer    [Documentation]  Attempt to set the priority of an image to an invalid
5242f17468SCharles Paul Hofer    ...              value and expect an error.
5342f17468SCharles Paul Hofer    [Tags]  BMC_Set_Priority_To_Invalid_Values
5442f17468SCharles Paul Hofer    [Template]  Set Priority To Invalid Value And Expect Error
5542f17468SCharles Paul Hofer
5642f17468SCharles Paul Hofer    # Version Type              Priority
5742f17468SCharles Paul Hofer    ${VERSION_PURPOSE_BMC}     ${-1}
5842f17468SCharles Paul Hofer    ${VERSION_PURPOSE_BMC}     ${256}
5942f17468SCharles Paul Hofer
6042f17468SCharles Paul Hofer
619f74d3afSCharles Paul HoferDelete BMC Image
629f74d3afSCharles Paul Hofer    [Documentation]  Delete a BMC image from the BMC flash chip.
639f74d3afSCharles Paul Hofer    [Tags]  Delete_BMC_Image
649f74d3afSCharles Paul Hofer
659f74d3afSCharles Paul Hofer    ${software_object}=  Get Non Running BMC Software Object
669f74d3afSCharles Paul Hofer    Delete Image And Verify  ${software_object}  ${VERSION_PURPOSE_BMC}
67c1fa2bc9SCharles Paul Hofer
68c1fa2bc9SCharles Paul Hofer
6997ecb270SGeorge KeishingBMC Image Priority Attribute Test
7097ecb270SGeorge Keishing    [Documentation]  Set "Priority" attribute.
7197ecb270SGeorge Keishing    [Tags]  BMC_Image_Priority_Attribute_Test
7297ecb270SGeorge Keishing    [Template]  Temporarily Set BMC Attribute
7397ecb270SGeorge Keishing
7497ecb270SGeorge Keishing    # Property        Value
7597ecb270SGeorge Keishing    Priority          ${0}
7697ecb270SGeorge Keishing    Priority          ${1}
7797ecb270SGeorge Keishing    Priority          ${127}
7897ecb270SGeorge Keishing    Priority          ${255}
7997ecb270SGeorge Keishing
8097ecb270SGeorge Keishing
81*e8dc5253SCharles Paul HoferDelete All Non Running BMC Images
82*e8dc5253SCharles Paul Hofer    [Documentation]  Delete all non running BMC images.
83*e8dc5253SCharles Paul Hofer    [Tags]  Delete_All_Non_Running_BMC_Images
84*e8dc5253SCharles Paul Hofer
85*e8dc5253SCharles Paul Hofer    ${version_id}=  Upload And Activate Image  ${ALTERNATE_IMAGE_FILE_PATH}
86*e8dc5253SCharles Paul Hofer    Delete All Non Running BMC Images
87*e8dc5253SCharles Paul Hofer
88*e8dc5253SCharles Paul Hofer    ${software_ids}=  Get Software Objects Id
89*e8dc5253SCharles Paul Hofer    ...  version_type=${VERSION_PURPOSE_BMC}
90*e8dc5253SCharles Paul Hofer    Should Not Contain  ${software_ids}  ${version_id}
91*e8dc5253SCharles Paul Hofer
92*e8dc5253SCharles Paul Hofer
93c1fa2bc9SCharles Paul Hofer*** Keywords ***
94c1fa2bc9SCharles Paul Hofer
9597ecb270SGeorge KeishingTemporarily Set BMC Attribute
9697ecb270SGeorge Keishing    [Documentation]  Update the BMC attribute value.
9797ecb270SGeorge Keishing    [Arguments]  ${attribute_name}  ${attribute_value}
9897ecb270SGeorge Keishing
9997ecb270SGeorge Keishing    # Description of argument(s):
10097ecb270SGeorge Keishing    # attribute_name    BMC software attribute name (e.g. "Priority").
10197ecb270SGeorge Keishing    # attribute_value   Value to be written.
10297ecb270SGeorge Keishing
10397ecb270SGeorge Keishing    ${image_ids}=  Get Software Objects  ${VERSION_PURPOSE_BMC}
10497ecb270SGeorge Keishing    ${init_bmc_properties}=  Get Host Software Property  ${image_ids[0]}
10597ecb270SGeorge Keishing    ${initial_priority}=  Set Variable  ${init_bmc_properties["Priority"]}
10697ecb270SGeorge Keishing
10797ecb270SGeorge Keishing    Set Host Software Property  ${image_ids[0]}  ${attribute_name}
10897ecb270SGeorge Keishing    ...  ${attribute_value}
10997ecb270SGeorge Keishing
11097ecb270SGeorge Keishing    ${cur_bmc_properties}=  Get Host Software Property  ${image_ids[0]}
11197ecb270SGeorge Keishing    Should Be Equal As Integers  ${cur_bmc_properties["Priority"]}
11297ecb270SGeorge Keishing    ...  ${attribute_value}
11397ecb270SGeorge Keishing
11497ecb270SGeorge Keishing    # Revert to to initial value.
11597ecb270SGeorge Keishing    Set Host Software Property
11697ecb270SGeorge Keishing    ...  ${image_ids[0]}  ${attribute_name}  ${initial_priority}
11797ecb270SGeorge Keishing
11897ecb270SGeorge Keishing
119c1fa2bc9SCharles Paul HoferUpload And Activate Multiple BMC Images Setup
120c1fa2bc9SCharles Paul Hofer    [Documentation]  Check that the ALTERNATE_FILE_PATH variable is set.
121c1fa2bc9SCharles Paul Hofer
122c1fa2bc9SCharles Paul Hofer    Should Not Be Empty  ${ALTERNATE_IMAGE_FILE_PATH}
1231eb85f57SGeorge Keishing
1241eb85f57SGeorge KeishingCode Update Setup
1251eb85f57SGeorge Keishing    [Documentation]  Do code update test case setup.
1261eb85f57SGeorge Keishing    # - Clean up all existing BMC dumps.
1271eb85f57SGeorge Keishing
1281eb85f57SGeorge Keishing    Delete All Dumps
129b926408eSCharles Paul Hofer    Run Keyword And Ignore Error  Smart Power Off
1300071549eSGeorge Keishing
1310071549eSGeorge KeishingCode Update Test Teardown
1320071549eSGeorge Keishing    [Documentation]  Do code update test case teardown.
1330071549eSGeorge Keishing    # 1. Collect FFDC if test case failed.
1340071549eSGeorge Keishing    # 2. Collect FFDC if test PASS but error log exists.
1350071549eSGeorge Keishing
1360071549eSGeorge Keishing    FFDC On Test Case Fail
1370071549eSGeorge Keishing    Run Keyword If  '${TEST_STATUS}' == 'PASS'  Check Error And Collect FFDC
138