xref: /openbmc/openbmc-test-automation/extended/code_update/bmc_code_update.robot (revision 8c7ada42b6ba884ebdc652fa1d26979557884f21)
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
977c6919bSSivas SRRResource          ../../lib/utils.robot
109f74d3afSCharles Paul HoferResource          ../../lib/boot_utils.robot
119f74d3afSCharles Paul HoferResource          code_update_utils.robot
129f74d3afSCharles Paul HoferResource          ../../lib/code_update_utils.robot
131eb85f57SGeorge KeishingResource          ../../lib/openbmc_ffdc.robot
141eb85f57SGeorge KeishingResource          ../../lib/dump_utils.robot
159f74d3afSCharles Paul Hofer
16d66c5dceSCharles Paul HoferSuite Setup       Suite Setup Execution
17d66c5dceSCharles Paul Hofer
18d66c5dceSCharles Paul HoferTest Teardown     Test Teardown Execution
199f74d3afSCharles Paul Hofer
2009712a1eSGeorge KeishingForce Tags        BMC_Code_Update
2109712a1eSGeorge Keishing
229f74d3afSCharles Paul Hofer*** Variables ***
239f74d3afSCharles Paul Hofer
249f74d3afSCharles Paul Hofer${QUIET}                          ${1}
259f74d3afSCharles Paul Hofer${IMAGE_FILE_PATH}                ${EMPTY}
26c1fa2bc9SCharles Paul Hofer${ALTERNATE_IMAGE_FILE_PATH}      ${EMPTY}
27b7842a59SCharles Paul Hofer${SKIP_UPDATE_IF_ACTIVE}          false
28d66c5dceSCharles Paul Hofer${dump_id}                        ${EMPTY}
29d66c5dceSCharles Paul Hofer${running_persistence_test}       ${FALSE}
30d66c5dceSCharles Paul Hofer${test_errlog_text}               AutoTestSimple
319f74d3afSCharles Paul Hofer
329f74d3afSCharles Paul Hofer*** Test Cases ***
339f74d3afSCharles Paul Hofer
3477c6919bSSivas SRRTest Basic BMC Performance Before BMC Code Update
3577c6919bSSivas SRR    [Documentation]  Check performance of memory, CPU & file system of BMC.
3677c6919bSSivas SRR    [Tags]  Test_Basic_BMC_Performance_Before_BMC_Code_Update
3777c6919bSSivas SRR
3877c6919bSSivas SRR    Open Connection And Log In
3977c6919bSSivas SRR    Check BMC Performance
4077c6919bSSivas SRR
41d66c5dceSCharles Paul HoferPrepare Persistent Data
42d66c5dceSCharles Paul Hofer    [Documentation]  Set data that should persist across the code update.
43d66c5dceSCharles Paul Hofer    [Tags]  Prepare_Persistent_Data
44d66c5dceSCharles Paul Hofer
45d66c5dceSCharles Paul Hofer    # Install the debug tarball.
46d66c5dceSCharles Paul Hofer    BMC Execute Command  rm -rf /tmp/tarball
47d66c5dceSCharles Paul Hofer    Install Debug Tarball On BMC  tarball_file_path=${DEBUG_TARBALL_PATH}
48d66c5dceSCharles Paul Hofer
49d66c5dceSCharles Paul Hofer    # Create a dummy error log and dump.
50d66c5dceSCharles Paul Hofer    BMC Execute Command  /tmp/tarball/bin/logging-test -c ${test_errlog_text}
51d66c5dceSCharles Paul Hofer    ${dump_id}=  Create User Initiated Dump
52d66c5dceSCharles Paul Hofer    Check Dump Existence  ${dump_id}
53d66c5dceSCharles Paul Hofer    Set Suite Variable  ${dump_id}
54d66c5dceSCharles Paul Hofer
55d66c5dceSCharles Paul Hofer    # Set persistent settings.
56d66c5dceSCharles Paul Hofer    ${autoreboot_dict}=  Create Dictionary  data=${0}
57d66c5dceSCharles Paul Hofer    Write Attribute  ${CONTROL_HOST_URI}auto_reboot  AutoReboot
58d66c5dceSCharles Paul Hofer    ...  data=${autoreboot_dict}
59d66c5dceSCharles Paul Hofer    ${onetime_dict}=  Create Dictionary  data=${0}
60d66c5dceSCharles Paul Hofer    Write Attribute  ${CONTROL_HOST_URI}boot/one_time  Enabled
61d66c5dceSCharles Paul Hofer    ...  data=${onetime_dict}
62d66c5dceSCharles Paul Hofer
63d66c5dceSCharles Paul Hofer    # Let the remaining test cases know we are doing a persistence test so we
64d66c5dceSCharles Paul Hofer    # do not delete logs.
65d66c5dceSCharles Paul Hofer    Set Suite Variable  ${running_persistence_test}  ${TRUE}
66d66c5dceSCharles Paul Hofer
67d66c5dceSCharles Paul Hofer
689f74d3afSCharles Paul HoferREST BMC Code Update
699f74d3afSCharles Paul Hofer    [Documentation]  Do a BMC code update by uploading image on BMC via REST.
709f74d3afSCharles Paul Hofer    [Tags]  REST_BMC_Code_Update
71d66c5dceSCharles Paul Hofer    [Teardown]  REST BMC Code Update Teardown
729f74d3afSCharles Paul Hofer
73*8c7ada42SSweta Potthuri    Run Keyword And Ignore Error  List Installed Images  BMC
74*8c7ada42SSweta Potthuri
7521845469SCharles Paul Hofer    Upload And Activate Image  ${IMAGE_FILE_PATH}
7621845469SCharles Paul Hofer    ...  skip_if_active=${SKIP_UPDATE_IF_ACTIVE}
779f74d3afSCharles Paul Hofer    OBMC Reboot (off)
78e43fb2f7SCharles Paul Hofer    Verify Running BMC Image  ${IMAGE_FILE_PATH}
799f74d3afSCharles Paul Hofer
809f74d3afSCharles Paul Hofer
81d66c5dceSCharles Paul HoferVerify Error Log Persistency
82d66c5dceSCharles Paul Hofer    [Documentation]  Check that the error log is still present after a
83d66c5dceSCharles Paul Hofer    ...              code update.
84d66c5dceSCharles Paul Hofer    [Tags]  Verify_Error_Log_Persistency
85d66c5dceSCharles Paul Hofer
86d66c5dceSCharles Paul Hofer    ${error_log_paths}=  Read Properties  ${BMC_LOGGING_URI}/list
87d66c5dceSCharles Paul Hofer    Log To Console  ${error_log_paths}
88d66c5dceSCharles Paul Hofer    ${test_error_message}=  Read Attribute  @{error_log_paths}[-1]  Message
89d66c5dceSCharles Paul Hofer    Should Be Equal  ${test_error_message}
90d66c5dceSCharles Paul Hofer    ...  example.xyz.openbmc_project.Example.Elog.${test_errlog_text}
91d66c5dceSCharles Paul Hofer    Delete Error Log Entry  @{error_log_paths}[-1]
92d66c5dceSCharles Paul Hofer
93d66c5dceSCharles Paul Hofer
94d66c5dceSCharles Paul HoferVerify BMC Dump Persistency
95d66c5dceSCharles Paul Hofer    [Documentation]  Check that the BMC dump present after a code update.
96d66c5dceSCharles Paul Hofer    [Tags]  Verify_BMC_Dump_Persistency
97d66c5dceSCharles Paul Hofer    [Teardown]  Set Suite Variable  ${running_persistence_test}  ${FALSE}
98d66c5dceSCharles Paul Hofer
99d66c5dceSCharles Paul Hofer    Check Dump Existence  ${dump_id}
100d66c5dceSCharles Paul Hofer    Delete BMC Dump  ${dump_id}
101d66c5dceSCharles Paul Hofer
102d66c5dceSCharles Paul Hofer
103d66c5dceSCharles Paul HoferVerify Settings Persistency
104d66c5dceSCharles Paul Hofer    [Documentation]  Verify that the settings from 'Prepare Persistent Data'
105d66c5dceSCharles Paul Hofer    ...              are still set correctly after the code update.
106d66c5dceSCharles Paul Hofer    [Tags]  Verify_Settings_Persistency
107d66c5dceSCharles Paul Hofer
108d66c5dceSCharles Paul Hofer    ${autoreboot_enabled}=  Read Attribute  ${CONTROL_HOST_URI}auto_reboot
109d66c5dceSCharles Paul Hofer    ...  AutoReboot
110d66c5dceSCharles Paul Hofer    Should Be Equal  ${autoreboot_enabled}  ${0}
111d66c5dceSCharles Paul Hofer    ${onetime_enabled}=  Read Attribute  ${CONTROL_HOST_URI}boot/one_time
112d66c5dceSCharles Paul Hofer    ...  Enabled
113d66c5dceSCharles Paul Hofer    Should Be Equal  ${onetime_enabled}  ${0}
114d66c5dceSCharles Paul Hofer
115d66c5dceSCharles Paul Hofer    # Set values back to their defaults
116d66c5dceSCharles Paul Hofer    ${autoreboot_dict}=  Create Dictionary  data=${1}
117d66c5dceSCharles Paul Hofer    Write Attribute  ${CONTROL_HOST_URI}auto_reboot  AutoReboot
118d66c5dceSCharles Paul Hofer    ...  data=${autoreboot_dict}
119d66c5dceSCharles Paul Hofer    ${onetime_dict}=  Create Dictionary  data=${1}
120d66c5dceSCharles Paul Hofer    Write Attribute  ${CONTROL_HOST_URI}boot/one_time  Enabled
121d66c5dceSCharles Paul Hofer    ...  data=${onetime_dict}
122d66c5dceSCharles Paul Hofer
123d66c5dceSCharles Paul Hofer
124c1fa2bc9SCharles Paul HoferUpload And Activate Multiple BMC Images
125c1fa2bc9SCharles Paul Hofer    [Documentation]  Upload another BMC image and verify that its state is
126c1fa2bc9SCharles Paul Hofer    ...              different from all others.
127c1fa2bc9SCharles Paul Hofer    [Tags]  Upload_And_Activate_Multiple_BMC_Images
128c1fa2bc9SCharles Paul Hofer    [Template]  Activate Image And Verify No Duplicate Priorities
129c1fa2bc9SCharles Paul Hofer    [Setup]  Upload And Activate Multiple BMC Images Setup
130c1fa2bc9SCharles Paul Hofer
131c1fa2bc9SCharles Paul Hofer    # Image File Path              Image Purpose
132c1fa2bc9SCharles Paul Hofer    ${ALTERNATE_IMAGE_FILE_PATH}   ${VERSION_PURPOSE_BMC}
133c1fa2bc9SCharles Paul Hofer
134c1fa2bc9SCharles Paul Hofer
13542f17468SCharles Paul HoferBMC Set Priority To Invalid Values
13642f17468SCharles Paul Hofer    [Documentation]  Attempt to set the priority of an image to an invalid
13742f17468SCharles Paul Hofer    ...              value and expect an error.
13842f17468SCharles Paul Hofer    [Tags]  BMC_Set_Priority_To_Invalid_Values
13942f17468SCharles Paul Hofer    [Template]  Set Priority To Invalid Value And Expect Error
14042f17468SCharles Paul Hofer
14142f17468SCharles Paul Hofer    # Version Type              Priority
14242f17468SCharles Paul Hofer    ${VERSION_PURPOSE_BMC}     ${-1}
14342f17468SCharles Paul Hofer    ${VERSION_PURPOSE_BMC}     ${256}
14442f17468SCharles Paul Hofer
14542f17468SCharles Paul Hofer
1469f74d3afSCharles Paul HoferDelete BMC Image
1479f74d3afSCharles Paul Hofer    [Documentation]  Delete a BMC image from the BMC flash chip.
1489f74d3afSCharles Paul Hofer    [Tags]  Delete_BMC_Image
1499f74d3afSCharles Paul Hofer
1509f74d3afSCharles Paul Hofer    ${software_object}=  Get Non Running BMC Software Object
1519f74d3afSCharles Paul Hofer    Delete Image And Verify  ${software_object}  ${VERSION_PURPOSE_BMC}
152c1fa2bc9SCharles Paul Hofer
153c1fa2bc9SCharles Paul Hofer
15497ecb270SGeorge KeishingBMC Image Priority Attribute Test
15597ecb270SGeorge Keishing    [Documentation]  Set "Priority" attribute.
15697ecb270SGeorge Keishing    [Tags]  BMC_Image_Priority_Attribute_Test
15797ecb270SGeorge Keishing    [Template]  Temporarily Set BMC Attribute
15897ecb270SGeorge Keishing
15997ecb270SGeorge Keishing    # Property        Value
16097ecb270SGeorge Keishing    Priority          ${0}
16197ecb270SGeorge Keishing    Priority          ${1}
16297ecb270SGeorge Keishing    Priority          ${127}
16397ecb270SGeorge Keishing    Priority          ${255}
16497ecb270SGeorge Keishing
16597ecb270SGeorge Keishing
166e8dc5253SCharles Paul HoferDelete All Non Running BMC Images
167e8dc5253SCharles Paul Hofer    [Documentation]  Delete all non running BMC images.
168e8dc5253SCharles Paul Hofer    [Tags]  Delete_All_Non_Running_BMC_Images
169e8dc5253SCharles Paul Hofer
170e8dc5253SCharles Paul Hofer    ${version_id}=  Upload And Activate Image  ${ALTERNATE_IMAGE_FILE_PATH}
1710889d43bSGeorge Keishing    ...  skip_if_active=true
172e8dc5253SCharles Paul Hofer    Delete All Non Running BMC Images
173e8dc5253SCharles Paul Hofer
174e8dc5253SCharles Paul Hofer    ${software_ids}=  Get Software Objects Id
175e8dc5253SCharles Paul Hofer    ...  version_type=${VERSION_PURPOSE_BMC}
176e8dc5253SCharles Paul Hofer    Should Not Contain  ${software_ids}  ${version_id}
177e8dc5253SCharles Paul Hofer
17877c6919bSSivas SRRTest Basic BMC Performance After Code Update
17977c6919bSSivas SRR    [Documentation]  Check performance of memory, CPU & file system of BMC.
18077c6919bSSivas SRR    [Tags]  Test_Basic_BMC_Performance_After_Code_Update
18177c6919bSSivas SRR
18277c6919bSSivas SRR    Open Connection And Log In
18377c6919bSSivas SRR    Check BMC Performance
18477c6919bSSivas SRR
185e8dc5253SCharles Paul Hofer
186c1fa2bc9SCharles Paul Hofer*** Keywords ***
187c1fa2bc9SCharles Paul Hofer
18897ecb270SGeorge KeishingTemporarily Set BMC Attribute
18997ecb270SGeorge Keishing    [Documentation]  Update the BMC attribute value.
19097ecb270SGeorge Keishing    [Arguments]  ${attribute_name}  ${attribute_value}
19197ecb270SGeorge Keishing
19297ecb270SGeorge Keishing    # Description of argument(s):
19397ecb270SGeorge Keishing    # attribute_name    BMC software attribute name (e.g. "Priority").
19497ecb270SGeorge Keishing    # attribute_value   Value to be written.
19597ecb270SGeorge Keishing
19697ecb270SGeorge Keishing    ${image_ids}=  Get Software Objects  ${VERSION_PURPOSE_BMC}
19797ecb270SGeorge Keishing    ${init_bmc_properties}=  Get Host Software Property  ${image_ids[0]}
19897ecb270SGeorge Keishing    ${initial_priority}=  Set Variable  ${init_bmc_properties["Priority"]}
19997ecb270SGeorge Keishing
20097ecb270SGeorge Keishing    Set Host Software Property  ${image_ids[0]}  ${attribute_name}
20197ecb270SGeorge Keishing    ...  ${attribute_value}
20297ecb270SGeorge Keishing
20397ecb270SGeorge Keishing    ${cur_bmc_properties}=  Get Host Software Property  ${image_ids[0]}
20497ecb270SGeorge Keishing    Should Be Equal As Integers  ${cur_bmc_properties["Priority"]}
20597ecb270SGeorge Keishing    ...  ${attribute_value}
20697ecb270SGeorge Keishing
20797ecb270SGeorge Keishing    # Revert to to initial value.
20897ecb270SGeorge Keishing    Set Host Software Property
20997ecb270SGeorge Keishing    ...  ${image_ids[0]}  ${attribute_name}  ${initial_priority}
21097ecb270SGeorge Keishing
21197ecb270SGeorge Keishing
212c1fa2bc9SCharles Paul HoferUpload And Activate Multiple BMC Images Setup
213c1fa2bc9SCharles Paul Hofer    [Documentation]  Check that the ALTERNATE_FILE_PATH variable is set.
214c1fa2bc9SCharles Paul Hofer
215c1fa2bc9SCharles Paul Hofer    Should Not Be Empty  ${ALTERNATE_IMAGE_FILE_PATH}
2161eb85f57SGeorge Keishing
217d66c5dceSCharles Paul Hofer
218d66c5dceSCharles Paul HoferREST BMC Code Update Teardown
219d66c5dceSCharles Paul Hofer    [Documentation]  Do code update test teardown.
220d66c5dceSCharles Paul Hofer
221d66c5dceSCharles Paul Hofer    FFDC On Test Case Fail
222d66c5dceSCharles Paul Hofer    Run Keyword If Test Failed  Fatal Error  msg=Code update failed.
223d66c5dceSCharles Paul Hofer
224d66c5dceSCharles Paul Hofer
225d66c5dceSCharles Paul HoferSuite Setup Execution
2261eb85f57SGeorge Keishing    [Documentation]  Do code update test case setup.
2271eb85f57SGeorge Keishing    # - Clean up all existing BMC dumps.
2281eb85f57SGeorge Keishing
2291eb85f57SGeorge Keishing    Delete All Dumps
230b926408eSCharles Paul Hofer    Run Keyword And Ignore Error  Smart Power Off
2310071549eSGeorge Keishing
232d66c5dceSCharles Paul HoferTest Teardown Execution
2330071549eSGeorge Keishing    [Documentation]  Do code update test case teardown.
2340071549eSGeorge Keishing    # 1. Collect FFDC if test case failed.
2350071549eSGeorge Keishing    # 2. Collect FFDC if test PASS but error log exists.
2360071549eSGeorge Keishing
237d66c5dceSCharles Paul Hofer    # Don't delete our logs if we want to persist them for tests.
238d66c5dceSCharles Paul Hofer    Return From Keyword If  ${running_persistence_test}
239d66c5dceSCharles Paul Hofer
2400071549eSGeorge Keishing    FFDC On Test Case Fail
2410071549eSGeorge Keishing    Run Keyword If  '${TEST_STATUS}' == 'PASS'  Check Error And Collect FFDC
24277c6919bSSivas SRR    Close All Connections
243