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 21e78a4431SMichael WalshLibrary ../../lib/gen_robot_keyword.py 229f74d3afSCharles Paul HoferVariables ../../data/variables.py 239f74d3afSCharles Paul HoferResource ../../lib/boot_utils.robot 249f74d3afSCharles Paul HoferResource code_update_utils.robot 259f74d3afSCharles Paul HoferResource ../../lib/code_update_utils.robot 261eb85f57SGeorge KeishingResource ../../lib/openbmc_ffdc.robot 279f74d3afSCharles Paul HoferResource ../../lib/state_manager.robot 281eb85f57SGeorge KeishingResource ../../lib/dump_utils.robot 299f74d3afSCharles Paul Hofer 300071549eSGeorge KeishingTest Teardown Code Update Test Teardown 319f74d3afSCharles Paul Hofer 3209712a1eSGeorge KeishingForce Tags Host_Code_Update 3309712a1eSGeorge Keishing 349f74d3afSCharles Paul Hofer*** Variables *** 359f74d3afSCharles Paul Hofer 369f74d3afSCharles Paul Hofer${QUIET} ${1} 379f74d3afSCharles Paul Hofer${IMAGE_FILE_PATH} ${EMPTY} 389f74d3afSCharles Paul Hofer${DELETE_OLD_PNOR_IMAGES} false 3951b54c08SCharles Paul Hofer${DELETE_OLD_GUARD_FILE} false 40c1fa2bc9SCharles Paul Hofer${ALTERNATE_IMAGE_FILE_PATH} ${EMPTY} 419f74d3afSCharles Paul Hofer 429f74d3afSCharles Paul Hofer*** Test Cases *** 439f74d3afSCharles Paul Hofer 449f74d3afSCharles Paul HoferREST Host Code Update 459f74d3afSCharles Paul Hofer [Documentation] Do a PNOR code update by uploading image on BMC via REST. 460071549eSGeorge Keishing # 1. Delete error logs if there is any. 470071549eSGeorge Keishing # 1. Do code update. 480071549eSGeorge Keishing # 2. Do post update the following: 490071549eSGeorge Keishing # - Collect FFDC if error log exist and delete error logs. 509f74d3afSCharles Paul Hofer [Tags] REST_Host_Code_Update 519f74d3afSCharles Paul Hofer [Setup] Code Update Setup 529f74d3afSCharles Paul Hofer 538c7ada42SSweta Potthuri Run Keyword And Ignore Error List Installed Images Host 548c7ada42SSweta Potthuri 559f74d3afSCharles Paul Hofer Upload And Activate Image ${IMAGE_FILE_PATH} 569f74d3afSCharles Paul Hofer OBMC Reboot (off) 579f74d3afSCharles Paul Hofer 589f74d3afSCharles Paul Hofer 599f74d3afSCharles Paul HoferPost Update Boot To OS 609f74d3afSCharles Paul Hofer [Documentation] Boot the host OS 619f74d3afSCharles Paul Hofer [Tags] Post_Update_Boot_To_OS 620c4a87d0SCharles Paul Hofer [Setup] Start SOL Console Logging 63da6bace8SGeorge Keishing [Teardown] Run Keywords Stop SOL Console Logging 64da6bace8SGeorge Keishing ... AND Code Update Test Teardown 659f74d3afSCharles Paul Hofer 669f74d3afSCharles Paul Hofer Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 679f74d3afSCharles Paul Hofer ... Fail Code update failed. No need to boot to OS. 68*32fe4e11SGeorge Keishing Delete All Error Logs 699f74d3afSCharles Paul Hofer REST Power On 70e43fb2f7SCharles Paul Hofer Verify Running Host Image ${IMAGE_FILE_PATH} 719f74d3afSCharles Paul Hofer 729f74d3afSCharles Paul Hofer 737c6e7520SCharles Paul HoferREST Host Code Update While OS Is Running 747c6e7520SCharles Paul Hofer [Documentation] Do a PNOR code update while the host is running. 757c6e7520SCharles Paul Hofer [Tags] REST_Host_Code_Update_While_OS_Is_Running 764e8c09b1SCharles Paul Hofer [Teardown] Run Keywords REST Power Off stack_mode=skip 774e8c09b1SCharles Paul Hofer ... AND Code Update Test Teardown 787c6e7520SCharles Paul Hofer 797c6e7520SCharles Paul Hofer Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 807c6e7520SCharles Paul Hofer ... Fail Cannot boot the OS. 817c6e7520SCharles Paul Hofer 827c6e7520SCharles Paul Hofer REST Power On stack_mode=skip 8372373f88SGeorge Keishing Upload And Activate Image 8472373f88SGeorge Keishing ... ${ALTERNATE_IMAGE_FILE_PATH} skip_if_active=true 857c6e7520SCharles Paul Hofer REST Power On stack_mode=normal 867c6e7520SCharles Paul Hofer Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} 877c6e7520SCharles Paul Hofer 889f74d3afSCharles Paul HoferHost Image Priority Attribute Test 899f74d3afSCharles Paul Hofer [Documentation] Set "Priority" attribute. 909f74d3afSCharles Paul Hofer [Tags] Host_Image_Priority_Attribute_Test 919f74d3afSCharles Paul Hofer [Template] Temporarily Set PNOR Attribute 929f74d3afSCharles Paul Hofer 939f74d3afSCharles Paul Hofer # Property Value 949f74d3afSCharles Paul Hofer Priority ${0} 959f74d3afSCharles Paul Hofer Priority ${1} 969f74d3afSCharles Paul Hofer Priority ${127} 9797ecb270SGeorge Keishing Priority ${255} 989f74d3afSCharles Paul Hofer 999f74d3afSCharles Paul Hofer 10042f17468SCharles Paul HoferHost Set Priority To Invalid Values 10142f17468SCharles Paul Hofer [Documentation] Attempt to set the priority of an image to an invalid 10242f17468SCharles Paul Hofer ... value and expect an error. 10342f17468SCharles Paul Hofer [Tags] Host_Set_Priority_To_Invalid_Values 10442f17468SCharles Paul Hofer [Template] Set Priority To Invalid Value And Expect Error 10542f17468SCharles Paul Hofer 10642f17468SCharles Paul Hofer # Version Type Priority 10742f17468SCharles Paul Hofer ${VERSION_PURPOSE_HOST} ${-1} 10842f17468SCharles Paul Hofer ${VERSION_PURPOSE_HOST} ${256} 10942f17468SCharles Paul Hofer 11042f17468SCharles Paul Hofer 1119f74d3afSCharles Paul HoferSet RequestedActivation To None 1129f74d3afSCharles Paul Hofer [Documentation] Set the RequestedActivation of the image to None and 1139f74d3afSCharles Paul Hofer ... verify that it is in fact set to None. 1149f74d3afSCharles Paul Hofer [Tags] Set_RequestedActivation_To_None 1159f74d3afSCharles Paul Hofer 1169f74d3afSCharles Paul Hofer ${software_objects}= Get Software Objects 1179f74d3afSCharles Paul Hofer Set Host Software Property @{software_objects}[0] RequestedActivation 1189f74d3afSCharles Paul Hofer ... ${REQUESTED_NONE} 1199f74d3afSCharles Paul Hofer ${software_properties}= Get Host Software Property @{software_objects}[0] 1209f74d3afSCharles Paul Hofer Should Be Equal As Strings &{software_properties}[RequestedActivation] 1219f74d3afSCharles Paul Hofer ... ${REQUESTED_NONE} 1229f74d3afSCharles Paul Hofer 1239f74d3afSCharles Paul Hofer 1249f74d3afSCharles Paul HoferSet RequestedActivation And Activation To Invalid Value 1259f74d3afSCharles Paul Hofer [Documentation] Set the RequestedActivation and Activation propreties of 1269f74d3afSCharles Paul Hofer ... the image to an invalid value and verify that it was not 1279f74d3afSCharles Paul Hofer ... changed. 1289f74d3afSCharles Paul Hofer [Template] Set Property To Invalid Value And Verify No Change 1299f74d3afSCharles Paul Hofer [Tags] Set_RequestedActivation_And_Activation_To_Invalid_Value 1309f74d3afSCharles Paul Hofer 1319f74d3afSCharles Paul Hofer # Property Version Type 1329f74d3afSCharles Paul Hofer RequestedActivation ${VERSION_PURPOSE_HOST} 1339f74d3afSCharles Paul Hofer Activation ${VERSION_PURPOSE_HOST} 1349f74d3afSCharles Paul Hofer 1359f74d3afSCharles Paul Hofer 136c1fa2bc9SCharles Paul HoferUpload And Activate Multiple Host Images 137c1fa2bc9SCharles Paul Hofer [Documentation] Upload another PNOR image and verify that its state is 138c1fa2bc9SCharles Paul Hofer ... different from all others. 139c1fa2bc9SCharles Paul Hofer [Tags] Upload_And_Activate_Multiple_Host_Images 140c1fa2bc9SCharles Paul Hofer [Template] Activate Image And Verify No Duplicate Priorities 141c1fa2bc9SCharles Paul Hofer [Setup] Upload And Activate Multiple BMC Images Setup 142c1fa2bc9SCharles Paul Hofer 143c1fa2bc9SCharles Paul Hofer # Image File Path Image Purpose 144c1fa2bc9SCharles Paul Hofer ${ALTERNATE_IMAGE_FILE_PATH} ${VERSION_PURPOSE_HOST} 145c1fa2bc9SCharles Paul Hofer 146c1fa2bc9SCharles Paul Hofer 147a5673166SCharles Paul HoferSet Same Priority For Multiple Host Images 148a5673166SCharles Paul Hofer [Documentation] Attempt to set the priority to be the same for two PNOR 149a5673166SCharles Paul Hofer ... images and verify that the priorities are not the same. 150a5673166SCharles Paul Hofer [Tags] Set_Same_Priority_For_Multiple_Host_Images 151a5673166SCharles Paul Hofer 152a5673166SCharles Paul Hofer Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 153a5673166SCharles Paul Hofer ... Fail Activation of alternate image failed. Cannot set priority. 154a5673166SCharles Paul Hofer Set Same Priority For Multiple Images ${VERSION_PURPOSE_HOST} 155a5673166SCharles Paul Hofer 156a5673166SCharles Paul Hofer 1579f74d3afSCharles Paul HoferDelete Host Image 1589f74d3afSCharles Paul Hofer [Documentation] Delete a PNOR image from the BMC and PNOR flash chip. 1599f74d3afSCharles Paul Hofer [Tags] Delete_Host_Image 1609f74d3afSCharles Paul Hofer [Setup] Initiate Host PowerOff 1619f74d3afSCharles Paul Hofer 1629f74d3afSCharles Paul Hofer ${software_objects}= Get Software Objects 1639f74d3afSCharles Paul Hofer ... version_type=${VERSION_PURPOSE_HOST} 1649f74d3afSCharles Paul Hofer ${num_images}= Get Length ${software_objects} 1659f74d3afSCharles Paul Hofer Should Be True 0 < ${num_images} 1669f74d3afSCharles Paul Hofer ... msg=There are no PNOR images on the BMC to delete. 1679f74d3afSCharles Paul Hofer Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST} 1689f74d3afSCharles Paul Hofer 1699f74d3afSCharles Paul Hofer 170287faaf2SGeorge KeishingVerify Host Update When Host Reboot During Activation In Progress 171287faaf2SGeorge Keishing [Documentation] Attempt to reboot the host while an image is activating. 172287faaf2SGeorge Keishing [Tags] Verify_Host_Update_When_Host_Reboot_During_Activation_In_Progress 173287faaf2SGeorge Keishing 174287faaf2SGeorge Keishing Upload And Activate Image ${IMAGE_FILE_PATH} 175287faaf2SGeorge Keishing REST Power On 176*32fe4e11SGeorge Keishing Delete All Error Logs 177287faaf2SGeorge Keishing 178287faaf2SGeorge Keishing ${version_id}= Upload And Activate Image ${ALTERNATE_IMAGE_FILE_PATH} 179287faaf2SGeorge Keishing ... wait=${0} 180287faaf2SGeorge Keishing 181287faaf2SGeorge Keishing ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id} 182287faaf2SGeorge Keishing Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 183287faaf2SGeorge Keishing 184287faaf2SGeorge Keishing # Reboot Host during activation. 185287faaf2SGeorge Keishing Host Reboot 186287faaf2SGeorge Keishing 187287faaf2SGeorge Keishing Wait For Activation State Change ${version_id} ${ACTIVATING} 188287faaf2SGeorge Keishing 189287faaf2SGeorge Keishing # New image priority should be 0. 190287faaf2SGeorge Keishing ${new_host_properties}= 191287faaf2SGeorge Keishing ... Get Host Software Property ${SOFTWARE_VERSION_URI}${version_id} 192287faaf2SGeorge Keishing Should Be Equal As Integers ${new_host_properties["Priority"]} ${0} 193287faaf2SGeorge Keishing 194287faaf2SGeorge Keishing # Reboot host to boot up with the new host image version. 195287faaf2SGeorge Keishing Host Reboot 196287faaf2SGeorge Keishing Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} 197287faaf2SGeorge Keishing 198287faaf2SGeorge Keishing 1999f74d3afSCharles Paul Hofer*** Keywords *** 2009f74d3afSCharles Paul Hofer 2019f74d3afSCharles Paul HoferTemporarily Set PNOR Attribute 2029f74d3afSCharles Paul Hofer [Documentation] Update the PNOR attribute value. 2039f74d3afSCharles Paul Hofer [Arguments] ${attribute_name} ${attribute_value} 2049f74d3afSCharles Paul Hofer 2059f74d3afSCharles Paul Hofer # Description of argument(s): 2069f74d3afSCharles Paul Hofer # attribute_name Host software attribute name (e.g. "Priority"). 2079f74d3afSCharles Paul Hofer # attribute_value Value to be written. 2089f74d3afSCharles Paul Hofer 2099f74d3afSCharles Paul Hofer ${image_ids}= Get Software Objects 2109f74d3afSCharles Paul Hofer ${init_host_properties}= Get Host Software Property ${image_ids[0]} 2119f74d3afSCharles Paul Hofer ${initial_priority}= Set Variable ${init_host_properties["Priority"]} 2129f74d3afSCharles Paul Hofer 2139f74d3afSCharles Paul Hofer Set Host Software Property ${image_ids[0]} ${attribute_name} 2149f74d3afSCharles Paul Hofer ... ${attribute_value} 2159f74d3afSCharles Paul Hofer 2169f74d3afSCharles Paul Hofer ${cur_host_properties}= Get Host Software Property ${image_ids[0]} 2179f74d3afSCharles Paul Hofer Should Be Equal As Integers ${cur_host_properties["Priority"]} 2189f74d3afSCharles Paul Hofer ... ${attribute_value} 2199f74d3afSCharles Paul Hofer 2209f74d3afSCharles Paul Hofer # Revert to to initial value. 2219f74d3afSCharles Paul Hofer Set Host Software Property 2229f74d3afSCharles Paul Hofer ... ${image_ids[0]} ${attribute_name} ${initial_priority} 2239f74d3afSCharles Paul Hofer 2249f74d3afSCharles Paul Hofer 2259f74d3afSCharles Paul HoferCode Update Setup 2269f74d3afSCharles Paul Hofer [Documentation] Do code update test case setup. 2271eb85f57SGeorge Keishing # - Clean up all existing BMC dumps. 2281eb85f57SGeorge Keishing # - Clean up all currently install PNOR images. 2299f74d3afSCharles Paul Hofer 230b926408eSCharles Paul Hofer Run Keyword And Ignore Error Smart Power Off 231e78a4431SMichael Walsh Run Key Delete All Dumps ignore=1 232*32fe4e11SGeorge Keishing Run Key Delete All Error Logs ignore=1 2339f74d3afSCharles Paul Hofer Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}' 2349f74d3afSCharles Paul Hofer ... Delete All PNOR Images 23551b54c08SCharles Paul Hofer Run Keyword If 'true' == '${DELETE_OLD_GUARD_FILE}' BMC Execute Command 23651b54c08SCharles Paul Hofer ... rm -f /var/lib/phosphor-software-manager/pnor/prsv/GUARD 2379f74d3afSCharles Paul Hofer 2389f74d3afSCharles Paul Hofer 239c1fa2bc9SCharles Paul HoferUpload And Activate Multiple BMC Images Setup 240c1fa2bc9SCharles Paul Hofer [Documentation] Check that the ALTERNATE_FILE_PATH variable is set. 241c1fa2bc9SCharles Paul Hofer 242c1fa2bc9SCharles Paul Hofer Should Not Be Empty ${ALTERNATE_IMAGE_FILE_PATH} 2434e8c09b1SCharles Paul Hofer Delete All PNOR Images 24472373f88SGeorge Keishing Upload And Activate Image ${IMAGE_FILE_PATH} skip_if_active=true 245c1fa2bc9SCharles Paul Hofer 2469f74d3afSCharles Paul HoferGet PNOR Extended Version 2479f74d3afSCharles Paul Hofer [Documentation] Return the PNOR extended version. 2489f74d3afSCharles Paul Hofer [Arguments] ${manifest_path} 2499f74d3afSCharles Paul Hofer 2509f74d3afSCharles Paul Hofer # Description of argument(s): 2519f74d3afSCharles Paul Hofer # manifest_path Path of the MANIFEST file 2529f74d3afSCharles Paul Hofer # (e.g. "/tmp/images/abc123/MANIFEST"). 2539f74d3afSCharles Paul Hofer 2549f74d3afSCharles Paul Hofer ${version}= BMC Execute Command 2559f74d3afSCharles Paul Hofer ... grep extended_version= ${manifest_path} 2569f74d3afSCharles Paul Hofer [return] ${version.split(",")} 2570071549eSGeorge Keishing 2580071549eSGeorge Keishing 2590071549eSGeorge KeishingCode Update Test Teardown 2600071549eSGeorge Keishing [Documentation] Do code update test case teardown. 2610071549eSGeorge Keishing # 1. Collect FFDC if test case failed. 2620071549eSGeorge Keishing # 2. Collect FFDC if test PASS but error log exists. 2630071549eSGeorge Keishing 2640071549eSGeorge Keishing FFDC On Test Case Fail 2650071549eSGeorge Keishing Run Keyword If '${TEST_STATUS}' == 'PASS' Check Error And Collect FFDC 266