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 32*6fb70d98SMatt FischerTest 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} 411ca51447SMichael Walsh${SKIP_UPDATE_IF_ACTIVE} false 429629b0e1SSteven Sombar${cache_files_dir_path} /var/lib/phosphor-software-manager/pnor/prsv/ 439f74d3afSCharles Paul Hofer 449f74d3afSCharles Paul Hofer*** Test Cases *** 459f74d3afSCharles Paul Hofer 469f74d3afSCharles Paul HoferREST Host Code Update 479f74d3afSCharles Paul Hofer [Documentation] Do a PNOR code update by uploading image on BMC via REST. 480071549eSGeorge Keishing # 1. Delete error logs if there is any. 490071549eSGeorge Keishing # 1. Do code update. 500071549eSGeorge Keishing # 2. Do post update the following: 510071549eSGeorge Keishing # - Collect FFDC if error log exist and delete error logs. 529f74d3afSCharles Paul Hofer [Tags] REST_Host_Code_Update 539f74d3afSCharles Paul Hofer [Setup] Code Update Setup 549f74d3afSCharles Paul Hofer 558c7ada42SSweta Potthuri Run Keyword And Ignore Error List Installed Images Host 568c7ada42SSweta Potthuri 579f74d3afSCharles Paul Hofer Upload And Activate Image ${IMAGE_FILE_PATH} 581ca51447SMichael Walsh ... skip_if_active=${SKIP_UPDATE_IF_ACTIVE} 599f74d3afSCharles Paul Hofer OBMC Reboot (off) 609f74d3afSCharles Paul Hofer 619f74d3afSCharles Paul Hofer 629f74d3afSCharles Paul HoferPost Update Boot To OS 639f74d3afSCharles Paul Hofer [Documentation] Boot the host OS 649f74d3afSCharles Paul Hofer [Tags] Post_Update_Boot_To_OS 650c4a87d0SCharles Paul Hofer [Setup] Start SOL Console Logging 66da6bace8SGeorge Keishing [Teardown] Run Keywords Stop SOL Console Logging 67da6bace8SGeorge Keishing ... AND Code Update Test Teardown 689f74d3afSCharles Paul Hofer 699f74d3afSCharles Paul Hofer Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 709f74d3afSCharles Paul Hofer ... Fail Code update failed. No need to boot to OS. 7132fe4e11SGeorge Keishing Delete All Error Logs 729f74d3afSCharles Paul Hofer REST Power On 73e43fb2f7SCharles Paul Hofer Verify Running Host Image ${IMAGE_FILE_PATH} 749f74d3afSCharles Paul Hofer 759f74d3afSCharles Paul Hofer 769629b0e1SSteven SombarTest Boot With No VPD Cache 779629b0e1SSteven Sombar [Documentation] After having done a PNOR update and 789629b0e1SSteven Sombar ... booted the OS in the tests above, remove the cached 799629b0e1SSteven Sombar ... VPD files and verify that the OS can still boot. 809629b0e1SSteven Sombar [Tags] Test_Boot_With_No_VPD_Cache 819629b0e1SSteven Sombar [Setup] Start SOL Console Logging 829629b0e1SSteven Sombar [Teardown] Run Keywords Stop SOL Console Logging 839629b0e1SSteven Sombar ... AND Code Update Test Teardown 849629b0e1SSteven Sombar 859629b0e1SSteven Sombar ${num_vpd_files} ${stderr} ${rc}= BMC Execute Command 869629b0e1SSteven Sombar ... ls ${cache_files_dir_path} | grep VPD -c 879629b0e1SSteven Sombar # Typically, vpd files = "CVPD DJVPD MVPD NVRAM". 889629b0e1SSteven Sombar Should Be Equal As Integers ${num_vpd_files} ${3} 899629b0e1SSteven Sombar ... msg=Missing VPD files at ${cache_files_dir_path}. 909629b0e1SSteven Sombar 919629b0e1SSteven Sombar # Delete the *VPD* files. 929629b0e1SSteven Sombar BMC Execute Command rm -f ${xxx_dir_path}*VPD* 939629b0e1SSteven Sombar 949629b0e1SSteven Sombar REST Power On 959629b0e1SSteven Sombar 969629b0e1SSteven Sombar # After powering-on the system, the VPD files should be present. 979629b0e1SSteven Sombar ${num_vpd_files} ${stderr} ${rc}= BMC Execute Command 989629b0e1SSteven Sombar ... ls ${cache_files_dir_path} | grep VPD -c 999629b0e1SSteven Sombar Should Be Equal As Integers ${num_vpd_files} ${3} 1009629b0e1SSteven Sombar ... msg=Three VPD files expected at ${cache_files_dir_path}. 1019629b0e1SSteven Sombar 1029629b0e1SSteven Sombar # Power off. The next test case will boot the OS with the new VPD files. 1039629b0e1SSteven Sombar REST Power Off 1049629b0e1SSteven Sombar 1059629b0e1SSteven Sombar 1067c6e7520SCharles Paul HoferREST Host Code Update While OS Is Running 1077c6e7520SCharles Paul Hofer [Documentation] Do a PNOR code update while the host is running. 1087c6e7520SCharles Paul Hofer [Tags] REST_Host_Code_Update_While_OS_Is_Running 1094e8c09b1SCharles Paul Hofer [Teardown] Run Keywords REST Power Off stack_mode=skip 1104e8c09b1SCharles Paul Hofer ... AND Code Update Test Teardown 1117c6e7520SCharles Paul Hofer 1127c6e7520SCharles Paul Hofer Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 1137c6e7520SCharles Paul Hofer ... Fail Cannot boot the OS. 1147c6e7520SCharles Paul Hofer 1157c6e7520SCharles Paul Hofer REST Power On stack_mode=skip 11672373f88SGeorge Keishing Upload And Activate Image 11772373f88SGeorge Keishing ... ${ALTERNATE_IMAGE_FILE_PATH} skip_if_active=true 1187c6e7520SCharles Paul Hofer REST Power On stack_mode=normal 1197c6e7520SCharles Paul Hofer Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} 1207c6e7520SCharles Paul Hofer 1219f74d3afSCharles Paul HoferHost Image Priority Attribute Test 1229f74d3afSCharles Paul Hofer [Documentation] Set "Priority" attribute. 1239f74d3afSCharles Paul Hofer [Tags] Host_Image_Priority_Attribute_Test 1249f74d3afSCharles Paul Hofer [Template] Temporarily Set PNOR Attribute 1259f74d3afSCharles Paul Hofer 1269f74d3afSCharles Paul Hofer # Property Value 1279f74d3afSCharles Paul Hofer Priority ${0} 1289f74d3afSCharles Paul Hofer Priority ${1} 1299f74d3afSCharles Paul Hofer Priority ${127} 13097ecb270SGeorge Keishing Priority ${255} 1319f74d3afSCharles Paul Hofer 1329f74d3afSCharles Paul Hofer 13342f17468SCharles Paul HoferHost Set Priority To Invalid Values 13442f17468SCharles Paul Hofer [Documentation] Attempt to set the priority of an image to an invalid 13542f17468SCharles Paul Hofer ... value and expect an error. 13642f17468SCharles Paul Hofer [Tags] Host_Set_Priority_To_Invalid_Values 13742f17468SCharles Paul Hofer [Template] Set Priority To Invalid Value And Expect Error 13842f17468SCharles Paul Hofer 13942f17468SCharles Paul Hofer # Version Type Priority 14042f17468SCharles Paul Hofer ${VERSION_PURPOSE_HOST} ${-1} 14142f17468SCharles Paul Hofer ${VERSION_PURPOSE_HOST} ${256} 14242f17468SCharles Paul Hofer 14342f17468SCharles Paul Hofer 1449f74d3afSCharles Paul HoferSet RequestedActivation To None 1459f74d3afSCharles Paul Hofer [Documentation] Set the RequestedActivation of the image to None and 1469f74d3afSCharles Paul Hofer ... verify that it is in fact set to None. 1479f74d3afSCharles Paul Hofer [Tags] Set_RequestedActivation_To_None 1489f74d3afSCharles Paul Hofer 1499f74d3afSCharles Paul Hofer ${software_objects}= Get Software Objects 1509f74d3afSCharles Paul Hofer Set Host Software Property @{software_objects}[0] RequestedActivation 1519f74d3afSCharles Paul Hofer ... ${REQUESTED_NONE} 1529f74d3afSCharles Paul Hofer ${software_properties}= Get Host Software Property @{software_objects}[0] 153a2f6d421SGeorge Keishing Should Be Equal As Strings ${software_properties}[RequestedActivation] 1549f74d3afSCharles Paul Hofer ... ${REQUESTED_NONE} 1559f74d3afSCharles Paul Hofer 1569f74d3afSCharles Paul Hofer 1579f74d3afSCharles Paul HoferSet RequestedActivation And Activation To Invalid Value 158e16f158fSGeorge Keishing [Documentation] Set the RequestedActivation and Activation properties of 1599f74d3afSCharles Paul Hofer ... the image to an invalid value and verify that it was not 1609f74d3afSCharles Paul Hofer ... changed. 1619f74d3afSCharles Paul Hofer [Template] Set Property To Invalid Value And Verify No Change 1629f74d3afSCharles Paul Hofer [Tags] Set_RequestedActivation_And_Activation_To_Invalid_Value 1639f74d3afSCharles Paul Hofer 1649f74d3afSCharles Paul Hofer # Property Version Type 1659f74d3afSCharles Paul Hofer RequestedActivation ${VERSION_PURPOSE_HOST} 1669f74d3afSCharles Paul Hofer Activation ${VERSION_PURPOSE_HOST} 1679f74d3afSCharles Paul Hofer 1689f74d3afSCharles Paul Hofer 169c1fa2bc9SCharles Paul HoferUpload And Activate Multiple Host Images 170c1fa2bc9SCharles Paul Hofer [Documentation] Upload another PNOR image and verify that its state is 171c1fa2bc9SCharles Paul Hofer ... different from all others. 172c1fa2bc9SCharles Paul Hofer [Tags] Upload_And_Activate_Multiple_Host_Images 173c1fa2bc9SCharles Paul Hofer [Template] Activate Image And Verify No Duplicate Priorities 174c1fa2bc9SCharles Paul Hofer [Setup] Upload And Activate Multiple BMC Images Setup 175c1fa2bc9SCharles Paul Hofer 176c1fa2bc9SCharles Paul Hofer # Image File Path Image Purpose 177c1fa2bc9SCharles Paul Hofer ${ALTERNATE_IMAGE_FILE_PATH} ${VERSION_PURPOSE_HOST} 178c1fa2bc9SCharles Paul Hofer 179c1fa2bc9SCharles Paul Hofer 180a5673166SCharles Paul HoferSet Same Priority For Multiple Host Images 181a5673166SCharles Paul Hofer [Documentation] Attempt to set the priority to be the same for two PNOR 182a5673166SCharles Paul Hofer ... images and verify that the priorities are not the same. 183a5673166SCharles Paul Hofer [Tags] Set_Same_Priority_For_Multiple_Host_Images 184a5673166SCharles Paul Hofer 185a5673166SCharles Paul Hofer Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 186a5673166SCharles Paul Hofer ... Fail Activation of alternate image failed. Cannot set priority. 187a5673166SCharles Paul Hofer Set Same Priority For Multiple Images ${VERSION_PURPOSE_HOST} 188a5673166SCharles Paul Hofer 189a5673166SCharles Paul Hofer 1909f74d3afSCharles Paul HoferDelete Host Image 1919f74d3afSCharles Paul Hofer [Documentation] Delete a PNOR image from the BMC and PNOR flash chip. 1929f74d3afSCharles Paul Hofer [Tags] Delete_Host_Image 1939f74d3afSCharles Paul Hofer [Setup] Initiate Host PowerOff 1949f74d3afSCharles Paul Hofer 1959f74d3afSCharles Paul Hofer ${software_objects}= Get Software Objects 1969f74d3afSCharles Paul Hofer ... version_type=${VERSION_PURPOSE_HOST} 1979f74d3afSCharles Paul Hofer ${num_images}= Get Length ${software_objects} 1989f74d3afSCharles Paul Hofer Should Be True 0 < ${num_images} 1999f74d3afSCharles Paul Hofer ... msg=There are no PNOR images on the BMC to delete. 2009f74d3afSCharles Paul Hofer Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST} 2019f74d3afSCharles Paul Hofer 2029f74d3afSCharles Paul Hofer 203287faaf2SGeorge KeishingVerify Host Update When Host Reboot During Activation In Progress 204287faaf2SGeorge Keishing [Documentation] Attempt to reboot the host while an image is activating. 205287faaf2SGeorge Keishing [Tags] Verify_Host_Update_When_Host_Reboot_During_Activation_In_Progress 206287faaf2SGeorge Keishing 207287faaf2SGeorge Keishing Upload And Activate Image ${IMAGE_FILE_PATH} 208287faaf2SGeorge Keishing REST Power On 20932fe4e11SGeorge Keishing Delete All Error Logs 210287faaf2SGeorge Keishing 211287faaf2SGeorge Keishing ${version_id}= Upload And Activate Image ${ALTERNATE_IMAGE_FILE_PATH} 212287faaf2SGeorge Keishing ... wait=${0} 213287faaf2SGeorge Keishing 214287faaf2SGeorge Keishing ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id} 215287faaf2SGeorge Keishing Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 216287faaf2SGeorge Keishing 217287faaf2SGeorge Keishing # Reboot Host during activation. 218287faaf2SGeorge Keishing Host Reboot 219287faaf2SGeorge Keishing 220287faaf2SGeorge Keishing Wait For Activation State Change ${version_id} ${ACTIVATING} 221287faaf2SGeorge Keishing 222287faaf2SGeorge Keishing # New image priority should be 0. 223287faaf2SGeorge Keishing ${new_host_properties}= 224287faaf2SGeorge Keishing ... Get Host Software Property ${SOFTWARE_VERSION_URI}${version_id} 225287faaf2SGeorge Keishing Should Be Equal As Integers ${new_host_properties["Priority"]} ${0} 226287faaf2SGeorge Keishing 227287faaf2SGeorge Keishing # Reboot host to boot up with the new host image version. 228287faaf2SGeorge Keishing Host Reboot 229287faaf2SGeorge Keishing Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} 230287faaf2SGeorge Keishing 231287faaf2SGeorge Keishing 2329f74d3afSCharles Paul Hofer*** Keywords *** 2339f74d3afSCharles Paul Hofer 2349f74d3afSCharles Paul HoferTemporarily Set PNOR Attribute 2359f74d3afSCharles Paul Hofer [Documentation] Update the PNOR attribute value. 2369f74d3afSCharles Paul Hofer [Arguments] ${attribute_name} ${attribute_value} 2379f74d3afSCharles Paul Hofer 2389f74d3afSCharles Paul Hofer # Description of argument(s): 2399f74d3afSCharles Paul Hofer # attribute_name Host software attribute name (e.g. "Priority"). 2409f74d3afSCharles Paul Hofer # attribute_value Value to be written. 2419f74d3afSCharles Paul Hofer 2429f74d3afSCharles Paul Hofer ${image_ids}= Get Software Objects 2439f74d3afSCharles Paul Hofer ${init_host_properties}= Get Host Software Property ${image_ids[0]} 2449f74d3afSCharles Paul Hofer ${initial_priority}= Set Variable ${init_host_properties["Priority"]} 2459f74d3afSCharles Paul Hofer 2469f74d3afSCharles Paul Hofer Set Host Software Property ${image_ids[0]} ${attribute_name} 2479f74d3afSCharles Paul Hofer ... ${attribute_value} 2489f74d3afSCharles Paul Hofer 2499f74d3afSCharles Paul Hofer ${cur_host_properties}= Get Host Software Property ${image_ids[0]} 2509f74d3afSCharles Paul Hofer Should Be Equal As Integers ${cur_host_properties["Priority"]} 2519f74d3afSCharles Paul Hofer ... ${attribute_value} 2529f74d3afSCharles Paul Hofer 2539f74d3afSCharles Paul Hofer # Revert to to initial value. 2549f74d3afSCharles Paul Hofer Set Host Software Property 2559f74d3afSCharles Paul Hofer ... ${image_ids[0]} ${attribute_name} ${initial_priority} 2569f74d3afSCharles Paul Hofer 2579f74d3afSCharles Paul Hofer 2589f74d3afSCharles Paul HoferCode Update Setup 2599f74d3afSCharles Paul Hofer [Documentation] Do code update test case setup. 2601eb85f57SGeorge Keishing # - Clean up all existing BMC dumps. 2611eb85f57SGeorge Keishing # - Clean up all currently install PNOR images. 2629f74d3afSCharles Paul Hofer 263b926408eSCharles Paul Hofer Run Keyword And Ignore Error Smart Power Off 264e78a4431SMichael Walsh Run Key Delete All Dumps ignore=1 26532fe4e11SGeorge Keishing Run Key Delete All Error Logs ignore=1 2669f74d3afSCharles Paul Hofer Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}' 2679f74d3afSCharles Paul Hofer ... Delete All PNOR Images 26851b54c08SCharles Paul Hofer Run Keyword If 'true' == '${DELETE_OLD_GUARD_FILE}' BMC Execute Command 26951b54c08SCharles Paul Hofer ... rm -f /var/lib/phosphor-software-manager/pnor/prsv/GUARD 2709f74d3afSCharles Paul Hofer 271fd71756fSGeorge Keishing BMC Execute Command rm -rf /tmp/images/* 2729f74d3afSCharles Paul Hofer 273c1fa2bc9SCharles Paul HoferUpload And Activate Multiple BMC Images Setup 274c1fa2bc9SCharles Paul Hofer [Documentation] Check that the ALTERNATE_FILE_PATH variable is set. 275c1fa2bc9SCharles Paul Hofer 276c1fa2bc9SCharles Paul Hofer Should Not Be Empty ${ALTERNATE_IMAGE_FILE_PATH} 2774e8c09b1SCharles Paul Hofer Delete All PNOR Images 27872373f88SGeorge Keishing Upload And Activate Image ${IMAGE_FILE_PATH} skip_if_active=true 279c1fa2bc9SCharles Paul Hofer 2809f74d3afSCharles Paul HoferGet PNOR Extended Version 2819f74d3afSCharles Paul Hofer [Documentation] Return the PNOR extended version. 2829f74d3afSCharles Paul Hofer [Arguments] ${manifest_path} 2839f74d3afSCharles Paul Hofer 2849f74d3afSCharles Paul Hofer # Description of argument(s): 2859f74d3afSCharles Paul Hofer # manifest_path Path of the MANIFEST file 2869f74d3afSCharles Paul Hofer # (e.g. "/tmp/images/abc123/MANIFEST"). 2879f74d3afSCharles Paul Hofer 2889f74d3afSCharles Paul Hofer ${version}= BMC Execute Command 2899f74d3afSCharles Paul Hofer ... grep extended_version= ${manifest_path} 290409df05dSGeorge Keishing RETURN ${version.split(",")} 2910071549eSGeorge Keishing 2920071549eSGeorge Keishing 2930071549eSGeorge KeishingCode Update Test Teardown 2940071549eSGeorge Keishing [Documentation] Do code update test case teardown. 2950071549eSGeorge Keishing # 1. Collect FFDC if test case failed. 2960071549eSGeorge Keishing # 2. Collect FFDC if test PASS but error log exists. 2970071549eSGeorge Keishing 2980071549eSGeorge Keishing FFDC On Test Case Fail 2990071549eSGeorge Keishing Run Keyword If '${TEST_STATUS}' == 'PASS' Check Error And Collect FFDC 300