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} 41*9629b0e1SSteven Sombar${cache_files_dir_path} /var/lib/phosphor-software-manager/pnor/prsv/ 429f74d3afSCharles Paul Hofer 439f74d3afSCharles Paul Hofer*** Test Cases *** 449f74d3afSCharles Paul Hofer 459f74d3afSCharles Paul HoferREST Host Code Update 469f74d3afSCharles Paul Hofer [Documentation] Do a PNOR code update by uploading image on BMC via REST. 470071549eSGeorge Keishing # 1. Delete error logs if there is any. 480071549eSGeorge Keishing # 1. Do code update. 490071549eSGeorge Keishing # 2. Do post update the following: 500071549eSGeorge Keishing # - Collect FFDC if error log exist and delete error logs. 519f74d3afSCharles Paul Hofer [Tags] REST_Host_Code_Update 529f74d3afSCharles Paul Hofer [Setup] Code Update Setup 539f74d3afSCharles Paul Hofer 548c7ada42SSweta Potthuri Run Keyword And Ignore Error List Installed Images Host 558c7ada42SSweta Potthuri 569f74d3afSCharles Paul Hofer Upload And Activate Image ${IMAGE_FILE_PATH} 579f74d3afSCharles Paul Hofer OBMC Reboot (off) 589f74d3afSCharles Paul Hofer 599f74d3afSCharles Paul Hofer 609f74d3afSCharles Paul HoferPost Update Boot To OS 619f74d3afSCharles Paul Hofer [Documentation] Boot the host OS 629f74d3afSCharles Paul Hofer [Tags] Post_Update_Boot_To_OS 630c4a87d0SCharles Paul Hofer [Setup] Start SOL Console Logging 64da6bace8SGeorge Keishing [Teardown] Run Keywords Stop SOL Console Logging 65da6bace8SGeorge Keishing ... AND Code Update Test Teardown 669f74d3afSCharles Paul Hofer 679f74d3afSCharles Paul Hofer Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 689f74d3afSCharles Paul Hofer ... Fail Code update failed. No need to boot to OS. 6932fe4e11SGeorge Keishing Delete All Error Logs 709f74d3afSCharles Paul Hofer REST Power On 71e43fb2f7SCharles Paul Hofer Verify Running Host Image ${IMAGE_FILE_PATH} 729f74d3afSCharles Paul Hofer 739f74d3afSCharles Paul Hofer 74*9629b0e1SSteven SombarTest Boot With No VPD Cache 75*9629b0e1SSteven Sombar [Documentation] After having done a PNOR update and 76*9629b0e1SSteven Sombar ... booted the OS in the tests above, remove the cached 77*9629b0e1SSteven Sombar ... VPD files and verify that the OS can still boot. 78*9629b0e1SSteven Sombar [Tags] Test_Boot_With_No_VPD_Cache 79*9629b0e1SSteven Sombar [Setup] Start SOL Console Logging 80*9629b0e1SSteven Sombar [Teardown] Run Keywords Stop SOL Console Logging 81*9629b0e1SSteven Sombar ... AND Code Update Test Teardown 82*9629b0e1SSteven Sombar 83*9629b0e1SSteven Sombar ${num_vpd_files} ${stderr} ${rc}= BMC Execute Command 84*9629b0e1SSteven Sombar ... ls ${cache_files_dir_path} | grep VPD -c 85*9629b0e1SSteven Sombar # Typically, vpd files = "CVPD DJVPD MVPD NVRAM". 86*9629b0e1SSteven Sombar Should Be Equal As Integers ${num_vpd_files} ${3} 87*9629b0e1SSteven Sombar ... msg=Missing VPD files at ${cache_files_dir_path}. 88*9629b0e1SSteven Sombar 89*9629b0e1SSteven Sombar # Delete the *VPD* files. 90*9629b0e1SSteven Sombar BMC Execute Command rm -f ${xxx_dir_path}*VPD* 91*9629b0e1SSteven Sombar 92*9629b0e1SSteven Sombar REST Power On 93*9629b0e1SSteven Sombar 94*9629b0e1SSteven Sombar # After powering-on the system, the VPD files should be present. 95*9629b0e1SSteven Sombar ${num_vpd_files} ${stderr} ${rc}= BMC Execute Command 96*9629b0e1SSteven Sombar ... ls ${cache_files_dir_path} | grep VPD -c 97*9629b0e1SSteven Sombar Should Be Equal As Integers ${num_vpd_files} ${3} 98*9629b0e1SSteven Sombar ... msg=Three VPD files expected at ${cache_files_dir_path}. 99*9629b0e1SSteven Sombar 100*9629b0e1SSteven Sombar # Power off. The next test case will boot the OS with the new VPD files. 101*9629b0e1SSteven Sombar REST Power Off 102*9629b0e1SSteven Sombar 103*9629b0e1SSteven Sombar 1047c6e7520SCharles Paul HoferREST Host Code Update While OS Is Running 1057c6e7520SCharles Paul Hofer [Documentation] Do a PNOR code update while the host is running. 1067c6e7520SCharles Paul Hofer [Tags] REST_Host_Code_Update_While_OS_Is_Running 1074e8c09b1SCharles Paul Hofer [Teardown] Run Keywords REST Power Off stack_mode=skip 1084e8c09b1SCharles Paul Hofer ... AND Code Update Test Teardown 1097c6e7520SCharles Paul Hofer 1107c6e7520SCharles Paul Hofer Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 1117c6e7520SCharles Paul Hofer ... Fail Cannot boot the OS. 1127c6e7520SCharles Paul Hofer 1137c6e7520SCharles Paul Hofer REST Power On stack_mode=skip 11472373f88SGeorge Keishing Upload And Activate Image 11572373f88SGeorge Keishing ... ${ALTERNATE_IMAGE_FILE_PATH} skip_if_active=true 1167c6e7520SCharles Paul Hofer REST Power On stack_mode=normal 1177c6e7520SCharles Paul Hofer Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} 1187c6e7520SCharles Paul Hofer 1199f74d3afSCharles Paul HoferHost Image Priority Attribute Test 1209f74d3afSCharles Paul Hofer [Documentation] Set "Priority" attribute. 1219f74d3afSCharles Paul Hofer [Tags] Host_Image_Priority_Attribute_Test 1229f74d3afSCharles Paul Hofer [Template] Temporarily Set PNOR Attribute 1239f74d3afSCharles Paul Hofer 1249f74d3afSCharles Paul Hofer # Property Value 1259f74d3afSCharles Paul Hofer Priority ${0} 1269f74d3afSCharles Paul Hofer Priority ${1} 1279f74d3afSCharles Paul Hofer Priority ${127} 12897ecb270SGeorge Keishing Priority ${255} 1299f74d3afSCharles Paul Hofer 1309f74d3afSCharles Paul Hofer 13142f17468SCharles Paul HoferHost Set Priority To Invalid Values 13242f17468SCharles Paul Hofer [Documentation] Attempt to set the priority of an image to an invalid 13342f17468SCharles Paul Hofer ... value and expect an error. 13442f17468SCharles Paul Hofer [Tags] Host_Set_Priority_To_Invalid_Values 13542f17468SCharles Paul Hofer [Template] Set Priority To Invalid Value And Expect Error 13642f17468SCharles Paul Hofer 13742f17468SCharles Paul Hofer # Version Type Priority 13842f17468SCharles Paul Hofer ${VERSION_PURPOSE_HOST} ${-1} 13942f17468SCharles Paul Hofer ${VERSION_PURPOSE_HOST} ${256} 14042f17468SCharles Paul Hofer 14142f17468SCharles Paul Hofer 1429f74d3afSCharles Paul HoferSet RequestedActivation To None 1439f74d3afSCharles Paul Hofer [Documentation] Set the RequestedActivation of the image to None and 1449f74d3afSCharles Paul Hofer ... verify that it is in fact set to None. 1459f74d3afSCharles Paul Hofer [Tags] Set_RequestedActivation_To_None 1469f74d3afSCharles Paul Hofer 1479f74d3afSCharles Paul Hofer ${software_objects}= Get Software Objects 1489f74d3afSCharles Paul Hofer Set Host Software Property @{software_objects}[0] RequestedActivation 1499f74d3afSCharles Paul Hofer ... ${REQUESTED_NONE} 1509f74d3afSCharles Paul Hofer ${software_properties}= Get Host Software Property @{software_objects}[0] 1519f74d3afSCharles Paul Hofer Should Be Equal As Strings &{software_properties}[RequestedActivation] 1529f74d3afSCharles Paul Hofer ... ${REQUESTED_NONE} 1539f74d3afSCharles Paul Hofer 1549f74d3afSCharles Paul Hofer 1559f74d3afSCharles Paul HoferSet RequestedActivation And Activation To Invalid Value 1569f74d3afSCharles Paul Hofer [Documentation] Set the RequestedActivation and Activation propreties of 1579f74d3afSCharles Paul Hofer ... the image to an invalid value and verify that it was not 1589f74d3afSCharles Paul Hofer ... changed. 1599f74d3afSCharles Paul Hofer [Template] Set Property To Invalid Value And Verify No Change 1609f74d3afSCharles Paul Hofer [Tags] Set_RequestedActivation_And_Activation_To_Invalid_Value 1619f74d3afSCharles Paul Hofer 1629f74d3afSCharles Paul Hofer # Property Version Type 1639f74d3afSCharles Paul Hofer RequestedActivation ${VERSION_PURPOSE_HOST} 1649f74d3afSCharles Paul Hofer Activation ${VERSION_PURPOSE_HOST} 1659f74d3afSCharles Paul Hofer 1669f74d3afSCharles Paul Hofer 167c1fa2bc9SCharles Paul HoferUpload And Activate Multiple Host Images 168c1fa2bc9SCharles Paul Hofer [Documentation] Upload another PNOR image and verify that its state is 169c1fa2bc9SCharles Paul Hofer ... different from all others. 170c1fa2bc9SCharles Paul Hofer [Tags] Upload_And_Activate_Multiple_Host_Images 171c1fa2bc9SCharles Paul Hofer [Template] Activate Image And Verify No Duplicate Priorities 172c1fa2bc9SCharles Paul Hofer [Setup] Upload And Activate Multiple BMC Images Setup 173c1fa2bc9SCharles Paul Hofer 174c1fa2bc9SCharles Paul Hofer # Image File Path Image Purpose 175c1fa2bc9SCharles Paul Hofer ${ALTERNATE_IMAGE_FILE_PATH} ${VERSION_PURPOSE_HOST} 176c1fa2bc9SCharles Paul Hofer 177c1fa2bc9SCharles Paul Hofer 178a5673166SCharles Paul HoferSet Same Priority For Multiple Host Images 179a5673166SCharles Paul Hofer [Documentation] Attempt to set the priority to be the same for two PNOR 180a5673166SCharles Paul Hofer ... images and verify that the priorities are not the same. 181a5673166SCharles Paul Hofer [Tags] Set_Same_Priority_For_Multiple_Host_Images 182a5673166SCharles Paul Hofer 183a5673166SCharles Paul Hofer Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 184a5673166SCharles Paul Hofer ... Fail Activation of alternate image failed. Cannot set priority. 185a5673166SCharles Paul Hofer Set Same Priority For Multiple Images ${VERSION_PURPOSE_HOST} 186a5673166SCharles Paul Hofer 187a5673166SCharles Paul Hofer 1889f74d3afSCharles Paul HoferDelete Host Image 1899f74d3afSCharles Paul Hofer [Documentation] Delete a PNOR image from the BMC and PNOR flash chip. 1909f74d3afSCharles Paul Hofer [Tags] Delete_Host_Image 1919f74d3afSCharles Paul Hofer [Setup] Initiate Host PowerOff 1929f74d3afSCharles Paul Hofer 1939f74d3afSCharles Paul Hofer ${software_objects}= Get Software Objects 1949f74d3afSCharles Paul Hofer ... version_type=${VERSION_PURPOSE_HOST} 1959f74d3afSCharles Paul Hofer ${num_images}= Get Length ${software_objects} 1969f74d3afSCharles Paul Hofer Should Be True 0 < ${num_images} 1979f74d3afSCharles Paul Hofer ... msg=There are no PNOR images on the BMC to delete. 1989f74d3afSCharles Paul Hofer Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST} 1999f74d3afSCharles Paul Hofer 2009f74d3afSCharles Paul Hofer 201287faaf2SGeorge KeishingVerify Host Update When Host Reboot During Activation In Progress 202287faaf2SGeorge Keishing [Documentation] Attempt to reboot the host while an image is activating. 203287faaf2SGeorge Keishing [Tags] Verify_Host_Update_When_Host_Reboot_During_Activation_In_Progress 204287faaf2SGeorge Keishing 205287faaf2SGeorge Keishing Upload And Activate Image ${IMAGE_FILE_PATH} 206287faaf2SGeorge Keishing REST Power On 20732fe4e11SGeorge Keishing Delete All Error Logs 208287faaf2SGeorge Keishing 209287faaf2SGeorge Keishing ${version_id}= Upload And Activate Image ${ALTERNATE_IMAGE_FILE_PATH} 210287faaf2SGeorge Keishing ... wait=${0} 211287faaf2SGeorge Keishing 212287faaf2SGeorge Keishing ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id} 213287faaf2SGeorge Keishing Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 214287faaf2SGeorge Keishing 215287faaf2SGeorge Keishing # Reboot Host during activation. 216287faaf2SGeorge Keishing Host Reboot 217287faaf2SGeorge Keishing 218287faaf2SGeorge Keishing Wait For Activation State Change ${version_id} ${ACTIVATING} 219287faaf2SGeorge Keishing 220287faaf2SGeorge Keishing # New image priority should be 0. 221287faaf2SGeorge Keishing ${new_host_properties}= 222287faaf2SGeorge Keishing ... Get Host Software Property ${SOFTWARE_VERSION_URI}${version_id} 223287faaf2SGeorge Keishing Should Be Equal As Integers ${new_host_properties["Priority"]} ${0} 224287faaf2SGeorge Keishing 225287faaf2SGeorge Keishing # Reboot host to boot up with the new host image version. 226287faaf2SGeorge Keishing Host Reboot 227287faaf2SGeorge Keishing Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} 228287faaf2SGeorge Keishing 229287faaf2SGeorge Keishing 2309f74d3afSCharles Paul Hofer*** Keywords *** 2319f74d3afSCharles Paul Hofer 2329f74d3afSCharles Paul HoferTemporarily Set PNOR Attribute 2339f74d3afSCharles Paul Hofer [Documentation] Update the PNOR attribute value. 2349f74d3afSCharles Paul Hofer [Arguments] ${attribute_name} ${attribute_value} 2359f74d3afSCharles Paul Hofer 2369f74d3afSCharles Paul Hofer # Description of argument(s): 2379f74d3afSCharles Paul Hofer # attribute_name Host software attribute name (e.g. "Priority"). 2389f74d3afSCharles Paul Hofer # attribute_value Value to be written. 2399f74d3afSCharles Paul Hofer 2409f74d3afSCharles Paul Hofer ${image_ids}= Get Software Objects 2419f74d3afSCharles Paul Hofer ${init_host_properties}= Get Host Software Property ${image_ids[0]} 2429f74d3afSCharles Paul Hofer ${initial_priority}= Set Variable ${init_host_properties["Priority"]} 2439f74d3afSCharles Paul Hofer 2449f74d3afSCharles Paul Hofer Set Host Software Property ${image_ids[0]} ${attribute_name} 2459f74d3afSCharles Paul Hofer ... ${attribute_value} 2469f74d3afSCharles Paul Hofer 2479f74d3afSCharles Paul Hofer ${cur_host_properties}= Get Host Software Property ${image_ids[0]} 2489f74d3afSCharles Paul Hofer Should Be Equal As Integers ${cur_host_properties["Priority"]} 2499f74d3afSCharles Paul Hofer ... ${attribute_value} 2509f74d3afSCharles Paul Hofer 2519f74d3afSCharles Paul Hofer # Revert to to initial value. 2529f74d3afSCharles Paul Hofer Set Host Software Property 2539f74d3afSCharles Paul Hofer ... ${image_ids[0]} ${attribute_name} ${initial_priority} 2549f74d3afSCharles Paul Hofer 2559f74d3afSCharles Paul Hofer 2569f74d3afSCharles Paul HoferCode Update Setup 2579f74d3afSCharles Paul Hofer [Documentation] Do code update test case setup. 2581eb85f57SGeorge Keishing # - Clean up all existing BMC dumps. 2591eb85f57SGeorge Keishing # - Clean up all currently install PNOR images. 2609f74d3afSCharles Paul Hofer 261b926408eSCharles Paul Hofer Run Keyword And Ignore Error Smart Power Off 262e78a4431SMichael Walsh Run Key Delete All Dumps ignore=1 26332fe4e11SGeorge Keishing Run Key Delete All Error Logs ignore=1 2649f74d3afSCharles Paul Hofer Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}' 2659f74d3afSCharles Paul Hofer ... Delete All PNOR Images 26651b54c08SCharles Paul Hofer Run Keyword If 'true' == '${DELETE_OLD_GUARD_FILE}' BMC Execute Command 26751b54c08SCharles Paul Hofer ... rm -f /var/lib/phosphor-software-manager/pnor/prsv/GUARD 2689f74d3afSCharles Paul Hofer 2699f74d3afSCharles Paul Hofer 270c1fa2bc9SCharles Paul HoferUpload And Activate Multiple BMC Images Setup 271c1fa2bc9SCharles Paul Hofer [Documentation] Check that the ALTERNATE_FILE_PATH variable is set. 272c1fa2bc9SCharles Paul Hofer 273c1fa2bc9SCharles Paul Hofer Should Not Be Empty ${ALTERNATE_IMAGE_FILE_PATH} 2744e8c09b1SCharles Paul Hofer Delete All PNOR Images 27572373f88SGeorge Keishing Upload And Activate Image ${IMAGE_FILE_PATH} skip_if_active=true 276c1fa2bc9SCharles Paul Hofer 2779f74d3afSCharles Paul HoferGet PNOR Extended Version 2789f74d3afSCharles Paul Hofer [Documentation] Return the PNOR extended version. 2799f74d3afSCharles Paul Hofer [Arguments] ${manifest_path} 2809f74d3afSCharles Paul Hofer 2819f74d3afSCharles Paul Hofer # Description of argument(s): 2829f74d3afSCharles Paul Hofer # manifest_path Path of the MANIFEST file 2839f74d3afSCharles Paul Hofer # (e.g. "/tmp/images/abc123/MANIFEST"). 2849f74d3afSCharles Paul Hofer 2859f74d3afSCharles Paul Hofer ${version}= BMC Execute Command 2869f74d3afSCharles Paul Hofer ... grep extended_version= ${manifest_path} 2879f74d3afSCharles Paul Hofer [return] ${version.split(",")} 2880071549eSGeorge Keishing 2890071549eSGeorge Keishing 2900071549eSGeorge KeishingCode Update Test Teardown 2910071549eSGeorge Keishing [Documentation] Do code update test case teardown. 2920071549eSGeorge Keishing # 1. Collect FFDC if test case failed. 2930071549eSGeorge Keishing # 2. Collect FFDC if test PASS but error log exists. 2940071549eSGeorge Keishing 2950071549eSGeorge Keishing FFDC On Test Case Fail 2960071549eSGeorge Keishing Run Keyword If '${TEST_STATUS}' == 'PASS' Check Error And Collect FFDC 297