xref: /openbmc/openbmc-test-automation/extended/code_update/host_code_update.robot (revision 42f17468d58eadb9d006ac378bd75a134d704a20)
19f74d3afSCharles Paul Hofer*** Settings ***
29f74d3afSCharles Paul HoferDocumentation     Update the PNOR code on a target BMC.
39f74d3afSCharles Paul Hofer...               Execution Method:
49f74d3afSCharles Paul Hofer...               python -m robot -v OPENBMC_HOST:<hostname>
59f74d3afSCharles Paul Hofer...               -v DELETE_OLD_PNOR_IMAGES:<"true" or "false">
6a5673166SCharles Paul Hofer...               -v IMAGE_FILE_PATH:<path/*.tar>
7a5673166SCharles Paul Hofer...               -v ALTERNATE_IMAGE_FILE_PATH:<path/*.tar>
8a5673166SCharles Paul Hofer...               host_code_update.robot
99f74d3afSCharles Paul Hofer...
109f74d3afSCharles Paul Hofer...               Code update method BMC
119f74d3afSCharles Paul Hofer...               Update work flow sequence:
129f74d3afSCharles Paul Hofer...                 - Upload image via REST
139f74d3afSCharles Paul Hofer...                 - Verify that the file exists on the BMC
149f74d3afSCharles Paul Hofer...                 - Check that software "Activation" is set to "Ready"
159f74d3afSCharles Paul Hofer...                 - Set "Requested Activation" to "Active"
169f74d3afSCharles Paul Hofer...                 - Wait for code update to complete
179f74d3afSCharles Paul Hofer...                 - Verify the new version
189f74d3afSCharles Paul Hofer
199f74d3afSCharles Paul HoferLibrary           ../../lib/bmc_ssh_utils.py
209f74d3afSCharles Paul HoferLibrary           ../../lib/code_update_utils.py
219f74d3afSCharles Paul HoferVariables         ../../data/variables.py
229f74d3afSCharles Paul HoferResource          ../../lib/boot_utils.robot
239f74d3afSCharles Paul HoferResource          code_update_utils.robot
249f74d3afSCharles Paul HoferResource          ../../lib/code_update_utils.robot
251eb85f57SGeorge KeishingResource          ../../lib/openbmc_ffdc.robot
269f74d3afSCharles Paul HoferResource          ../../lib/state_manager.robot
271eb85f57SGeorge KeishingResource          ../../lib/dump_utils.robot
289f74d3afSCharles Paul Hofer
290071549eSGeorge KeishingTest Teardown     Code Update Test Teardown
309f74d3afSCharles Paul Hofer
319f74d3afSCharles Paul Hofer*** Variables ***
329f74d3afSCharles Paul Hofer
339f74d3afSCharles Paul Hofer${QUIET}                          ${1}
349f74d3afSCharles Paul Hofer${IMAGE_FILE_PATH}                ${EMPTY}
359f74d3afSCharles Paul Hofer${DELETE_OLD_PNOR_IMAGES}         false
3651b54c08SCharles Paul Hofer${DELETE_OLD_GUARD_FILE}          false
37c1fa2bc9SCharles Paul Hofer${ALTERNATE_IMAGE_FILE_PATH}      ${EMPTY}
389f74d3afSCharles Paul Hofer
399f74d3afSCharles Paul Hofer*** Test Cases ***
409f74d3afSCharles Paul Hofer
419f74d3afSCharles Paul HoferREST Host Code Update
429f74d3afSCharles Paul Hofer    [Documentation]  Do a PNOR code update by uploading image on BMC via REST.
430071549eSGeorge Keishing    # 1. Delete error logs if there is any.
440071549eSGeorge Keishing    # 1. Do code update.
450071549eSGeorge Keishing    # 2. Do post update the following:
460071549eSGeorge Keishing    #    - Collect FFDC if error log exist and delete error logs.
479f74d3afSCharles Paul Hofer    [Tags]  REST_Host_Code_Update
489f74d3afSCharles Paul Hofer    [Setup]  Code Update Setup
499f74d3afSCharles Paul Hofer
509f74d3afSCharles Paul Hofer    Upload And Activate Image  ${IMAGE_FILE_PATH}
519f74d3afSCharles Paul Hofer    OBMC Reboot (off)
529f74d3afSCharles Paul Hofer
539f74d3afSCharles Paul Hofer
549f74d3afSCharles Paul HoferPost Update Boot To OS
559f74d3afSCharles Paul Hofer    [Documentation]  Boot the host OS
569f74d3afSCharles Paul Hofer    [Tags]  Post_Update_Boot_To_OS
57da6bace8SGeorge Keishing    [Teardown]  Run Keywords  Stop SOL Console Logging
58da6bace8SGeorge Keishing    ...         AND  Code Update Test Teardown
599f74d3afSCharles Paul Hofer
609f74d3afSCharles Paul Hofer    Run Keyword If  '${PREV_TEST_STATUS}' == 'FAIL'
619f74d3afSCharles Paul Hofer    ...  Fail  Code update failed. No need to boot to OS.
629f74d3afSCharles Paul Hofer    Start SOL Console Logging
630071549eSGeorge Keishing    Delete Error Logs
649f74d3afSCharles Paul Hofer    REST Power On
659f74d3afSCharles Paul Hofer
669f74d3afSCharles Paul Hofer
679f74d3afSCharles Paul HoferHost Image Priority Attribute Test
689f74d3afSCharles Paul Hofer    [Documentation]  Set "Priority" attribute.
699f74d3afSCharles Paul Hofer    [Tags]  Host_Image_Priority_Attribute_Test
709f74d3afSCharles Paul Hofer    [Template]  Temporarily Set PNOR Attribute
719f74d3afSCharles Paul Hofer
729f74d3afSCharles Paul Hofer    # Property        Value
739f74d3afSCharles Paul Hofer    Priority          ${0}
749f74d3afSCharles Paul Hofer    Priority          ${1}
759f74d3afSCharles Paul Hofer    Priority          ${127}
769f74d3afSCharles Paul Hofer
779f74d3afSCharles Paul Hofer
78*42f17468SCharles Paul HoferHost Set Priority To Invalid Values
79*42f17468SCharles Paul Hofer    [Documentation]  Attempt to set the priority of an image to an invalid
80*42f17468SCharles Paul Hofer    ...              value and expect an error.
81*42f17468SCharles Paul Hofer    [Tags]  Host_Set_Priority_To_Invalid_Values
82*42f17468SCharles Paul Hofer    [Template]  Set Priority To Invalid Value And Expect Error
83*42f17468SCharles Paul Hofer
84*42f17468SCharles Paul Hofer    # Version Type              Priority
85*42f17468SCharles Paul Hofer    ${VERSION_PURPOSE_HOST}    ${-1}
86*42f17468SCharles Paul Hofer    ${VERSION_PURPOSE_HOST}    ${256}
87*42f17468SCharles Paul Hofer
88*42f17468SCharles Paul Hofer
899f74d3afSCharles Paul HoferSet RequestedActivation To None
909f74d3afSCharles Paul Hofer    [Documentation]  Set the RequestedActivation of the image to None and
919f74d3afSCharles Paul Hofer    ...              verify that it is in fact set to None.
929f74d3afSCharles Paul Hofer    [Tags]  Set_RequestedActivation_To_None
939f74d3afSCharles Paul Hofer
949f74d3afSCharles Paul Hofer    ${software_objects}=  Get Software Objects
959f74d3afSCharles Paul Hofer    Set Host Software Property  @{software_objects}[0]  RequestedActivation
969f74d3afSCharles Paul Hofer    ...  ${REQUESTED_NONE}
979f74d3afSCharles Paul Hofer    ${software_properties}=  Get Host Software Property  @{software_objects}[0]
989f74d3afSCharles Paul Hofer    Should Be Equal As Strings  &{software_properties}[RequestedActivation]
999f74d3afSCharles Paul Hofer    ...  ${REQUESTED_NONE}
1009f74d3afSCharles Paul Hofer
1019f74d3afSCharles Paul Hofer
1029f74d3afSCharles Paul HoferSet RequestedActivation And Activation To Invalid Value
1039f74d3afSCharles Paul Hofer    [Documentation]  Set the RequestedActivation and Activation propreties of
1049f74d3afSCharles Paul Hofer    ...              the image to an invalid value and verify that it was not
1059f74d3afSCharles Paul Hofer    ...              changed.
1069f74d3afSCharles Paul Hofer    [Template]  Set Property To Invalid Value And Verify No Change
1079f74d3afSCharles Paul Hofer    [Tags]  Set_RequestedActivation_And_Activation_To_Invalid_Value
1089f74d3afSCharles Paul Hofer
1099f74d3afSCharles Paul Hofer    # Property              Version Type
1109f74d3afSCharles Paul Hofer    RequestedActivation     ${VERSION_PURPOSE_HOST}
1119f74d3afSCharles Paul Hofer    Activation              ${VERSION_PURPOSE_HOST}
1129f74d3afSCharles Paul Hofer
1139f74d3afSCharles Paul Hofer
114c1fa2bc9SCharles Paul HoferUpload And Activate Multiple Host Images
115c1fa2bc9SCharles Paul Hofer    [Documentation]  Upload another PNOR image and verify that its state is
116c1fa2bc9SCharles Paul Hofer    ...              different from all others.
117c1fa2bc9SCharles Paul Hofer    [Tags]  Upload_And_Activate_Multiple_Host_Images
118c1fa2bc9SCharles Paul Hofer    [Template]  Activate Image And Verify No Duplicate Priorities
119c1fa2bc9SCharles Paul Hofer    [Setup]  Upload And Activate Multiple BMC Images Setup
120c1fa2bc9SCharles Paul Hofer
121c1fa2bc9SCharles Paul Hofer    # Image File Path              Image Purpose
122c1fa2bc9SCharles Paul Hofer    ${ALTERNATE_IMAGE_FILE_PATH}   ${VERSION_PURPOSE_HOST}
123c1fa2bc9SCharles Paul Hofer
124c1fa2bc9SCharles Paul Hofer
125a5673166SCharles Paul HoferSet Same Priority For Multiple Host Images
126a5673166SCharles Paul Hofer    [Documentation]  Attempt to set the priority to be the same for two PNOR
127a5673166SCharles Paul Hofer    ...              images and verify that the priorities are not the same.
128a5673166SCharles Paul Hofer    [Tags]  Set_Same_Priority_For_Multiple_Host_Images
129a5673166SCharles Paul Hofer
130a5673166SCharles Paul Hofer    Run Keyword If  '${PREV_TEST_STATUS}' == 'FAIL'
131a5673166SCharles Paul Hofer    ...  Fail  Activation of alternate image failed. Cannot set priority.
132a5673166SCharles Paul Hofer    Set Same Priority For Multiple Images  ${VERSION_PURPOSE_HOST}
133a5673166SCharles Paul Hofer
134a5673166SCharles Paul Hofer
1359f74d3afSCharles Paul HoferDelete Host Image
1369f74d3afSCharles Paul Hofer    [Documentation]  Delete a PNOR image from the BMC and PNOR flash chip.
1379f74d3afSCharles Paul Hofer    [Tags]  Delete_Host_Image
1389f74d3afSCharles Paul Hofer    [Setup]  Initiate Host PowerOff
1399f74d3afSCharles Paul Hofer
1409f74d3afSCharles Paul Hofer    ${software_objects}=  Get Software Objects
1419f74d3afSCharles Paul Hofer    ...  version_type=${VERSION_PURPOSE_HOST}
1429f74d3afSCharles Paul Hofer    ${num_images}=  Get Length  ${software_objects}
1439f74d3afSCharles Paul Hofer    Should Be True  0 < ${num_images}
1449f74d3afSCharles Paul Hofer    ...  msg=There are no PNOR images on the BMC to delete.
1459f74d3afSCharles Paul Hofer    Delete Image And Verify  @{software_objects}[0]  ${VERSION_PURPOSE_HOST}
1469f74d3afSCharles Paul Hofer
1479f74d3afSCharles Paul Hofer
1489f74d3afSCharles Paul Hofer*** Keywords ***
1499f74d3afSCharles Paul Hofer
1509f74d3afSCharles Paul HoferTemporarily Set PNOR Attribute
1519f74d3afSCharles Paul Hofer    [Documentation]  Update the PNOR attribute value.
1529f74d3afSCharles Paul Hofer    [Arguments]  ${attribute_name}  ${attribute_value}
1539f74d3afSCharles Paul Hofer
1549f74d3afSCharles Paul Hofer    # Description of argument(s):
1559f74d3afSCharles Paul Hofer    # attribute_name    Host software attribute name (e.g. "Priority").
1569f74d3afSCharles Paul Hofer    # attribute_value   Value to be written.
1579f74d3afSCharles Paul Hofer
1589f74d3afSCharles Paul Hofer    ${image_ids}=  Get Software Objects
1599f74d3afSCharles Paul Hofer    ${init_host_properties}=  Get Host Software Property  ${image_ids[0]}
1609f74d3afSCharles Paul Hofer    ${initial_priority}=  Set Variable  ${init_host_properties["Priority"]}
1619f74d3afSCharles Paul Hofer
1629f74d3afSCharles Paul Hofer    Set Host Software Property  ${image_ids[0]}  ${attribute_name}
1639f74d3afSCharles Paul Hofer    ...  ${attribute_value}
1649f74d3afSCharles Paul Hofer
1659f74d3afSCharles Paul Hofer    ${cur_host_properties}=  Get Host Software Property  ${image_ids[0]}
1669f74d3afSCharles Paul Hofer    Should Be Equal As Integers  ${cur_host_properties["Priority"]}
1679f74d3afSCharles Paul Hofer    ...  ${attribute_value}
1689f74d3afSCharles Paul Hofer
1699f74d3afSCharles Paul Hofer    # Revert to to initial value.
1709f74d3afSCharles Paul Hofer    Set Host Software Property
1719f74d3afSCharles Paul Hofer    ...  ${image_ids[0]}  ${attribute_name}  ${initial_priority}
1729f74d3afSCharles Paul Hofer
1739f74d3afSCharles Paul Hofer
1749f74d3afSCharles Paul HoferCode Update Setup
1759f74d3afSCharles Paul Hofer    [Documentation]  Do code update test case setup.
1761eb85f57SGeorge Keishing    # - Clean up all existing BMC dumps.
1771eb85f57SGeorge Keishing    # - Clean up all currently install PNOR images.
1789f74d3afSCharles Paul Hofer
17951b54c08SCharles Paul Hofer    Initiate Host PowerOff
1801eb85f57SGeorge Keishing    Delete All Dumps
1810071549eSGeorge Keishing    Delete Error Logs
1829f74d3afSCharles Paul Hofer    Run Keyword If  'true' == '${DELETE_OLD_PNOR_IMAGES}'
1839f74d3afSCharles Paul Hofer    ...  Delete All PNOR Images
18451b54c08SCharles Paul Hofer    Run Keyword If  'true' == '${DELETE_OLD_GUARD_FILE}'  BMC Execute Command
18551b54c08SCharles Paul Hofer    ...  rm -f /var/lib/phosphor-software-manager/pnor/prsv/GUARD
1869f74d3afSCharles Paul Hofer
1879f74d3afSCharles Paul Hofer
188c1fa2bc9SCharles Paul HoferUpload And Activate Multiple BMC Images Setup
189c1fa2bc9SCharles Paul Hofer    [Documentation]  Check that the ALTERNATE_FILE_PATH variable is set.
190c1fa2bc9SCharles Paul Hofer
191c1fa2bc9SCharles Paul Hofer    Should Not Be Empty  ${ALTERNATE_IMAGE_FILE_PATH}
192c1fa2bc9SCharles Paul Hofer
193c1fa2bc9SCharles Paul Hofer
1949f74d3afSCharles Paul HoferGet PNOR Extended Version
1959f74d3afSCharles Paul Hofer    [Documentation]  Return the PNOR extended version.
1969f74d3afSCharles Paul Hofer    [Arguments]  ${manifest_path}
1979f74d3afSCharles Paul Hofer
1989f74d3afSCharles Paul Hofer    # Description of argument(s):
1999f74d3afSCharles Paul Hofer    # manifest_path  Path of the MANIFEST file
2009f74d3afSCharles Paul Hofer    #                (e.g. "/tmp/images/abc123/MANIFEST").
2019f74d3afSCharles Paul Hofer
2029f74d3afSCharles Paul Hofer    ${version}= BMC Execute Command
2039f74d3afSCharles Paul Hofer    ...  grep extended_version= ${manifest_path}
2049f74d3afSCharles Paul Hofer    [return] ${version.split(",")}
2050071549eSGeorge Keishing
2060071549eSGeorge Keishing
2070071549eSGeorge KeishingCode Update Test Teardown
2080071549eSGeorge Keishing    [Documentation]  Do code update test case teardown.
2090071549eSGeorge Keishing    # 1. Collect FFDC if test case failed.
2100071549eSGeorge Keishing    # 2. Collect FFDC if test PASS but error log exists.
2110071549eSGeorge Keishing
2120071549eSGeorge Keishing    FFDC On Test Case Fail
2130071549eSGeorge Keishing    Run Keyword If  '${TEST_STATUS}' == 'PASS'  Check Error And Collect FFDC
214