Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Update the PNOR code on a target BMC. |
| 3 | ... Execution Method: |
| 4 | ... python -m robot -v OPENBMC_HOST:<hostname> |
| 5 | ... -v DELETE_OLD_PNOR_IMAGES:<"true" or "false"> |
Charles Paul Hofer | a567316 | 2017-08-30 09:49:16 -0500 | [diff] [blame] | 6 | ... -v IMAGE_FILE_PATH:<path/*.tar> |
| 7 | ... -v ALTERNATE_IMAGE_FILE_PATH:<path/*.tar> |
| 8 | ... host_code_update.robot |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 9 | ... |
| 10 | ... Code update method BMC |
| 11 | ... Update work flow sequence: |
| 12 | ... - Upload image via REST |
| 13 | ... - Verify that the file exists on the BMC |
| 14 | ... - Check that software "Activation" is set to "Ready" |
| 15 | ... - Set "Requested Activation" to "Active" |
| 16 | ... - Wait for code update to complete |
| 17 | ... - Verify the new version |
| 18 | |
| 19 | Library ../../lib/bmc_ssh_utils.py |
| 20 | Library ../../lib/code_update_utils.py |
Michael Walsh | e78a443 | 2018-03-29 16:36:04 -0500 | [diff] [blame] | 21 | Library ../../lib/gen_robot_keyword.py |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 22 | Variables ../../data/variables.py |
| 23 | Resource ../../lib/boot_utils.robot |
| 24 | Resource code_update_utils.robot |
| 25 | Resource ../../lib/code_update_utils.robot |
George Keishing | 1eb85f5 | 2017-08-30 22:55:13 -0500 | [diff] [blame] | 26 | Resource ../../lib/openbmc_ffdc.robot |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 27 | Resource ../../lib/state_manager.robot |
George Keishing | 1eb85f5 | 2017-08-30 22:55:13 -0500 | [diff] [blame] | 28 | Resource ../../lib/dump_utils.robot |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 29 | |
George Keishing | 0071549 | 2017-08-18 11:46:37 -0500 | [diff] [blame] | 30 | Test Teardown Code Update Test Teardown |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 31 | |
George Keishing | 09712a1 | 2017-10-16 12:52:42 -0500 | [diff] [blame] | 32 | Force Tags Host_Code_Update |
| 33 | |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 34 | *** Variables *** |
| 35 | |
Steven Sombar | 9629b0e | 2018-08-23 07:26:58 -0500 | [diff] [blame] | 36 | ${QUIET} ${1} |
| 37 | ${IMAGE_FILE_PATH} ${EMPTY} |
| 38 | ${DELETE_OLD_PNOR_IMAGES} false |
| 39 | ${DELETE_OLD_GUARD_FILE} false |
| 40 | ${ALTERNATE_IMAGE_FILE_PATH} ${EMPTY} |
Michael Walsh | 1ca5144 | 2018-09-18 16:38:43 -0500 | [diff] [blame] | 41 | ${SKIP_UPDATE_IF_ACTIVE} false |
Steven Sombar | 9629b0e | 2018-08-23 07:26:58 -0500 | [diff] [blame] | 42 | ${cache_files_dir_path} /var/lib/phosphor-software-manager/pnor/prsv/ |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 43 | |
| 44 | *** Test Cases *** |
| 45 | |
| 46 | REST Host Code Update |
| 47 | [Documentation] Do a PNOR code update by uploading image on BMC via REST. |
George Keishing | 0071549 | 2017-08-18 11:46:37 -0500 | [diff] [blame] | 48 | # 1. Delete error logs if there is any. |
| 49 | # 1. Do code update. |
| 50 | # 2. Do post update the following: |
| 51 | # - Collect FFDC if error log exist and delete error logs. |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 52 | [Tags] REST_Host_Code_Update |
| 53 | [Setup] Code Update Setup |
| 54 | |
Sweta Potthuri | 8c7ada4 | 2018-01-15 05:05:59 -0600 | [diff] [blame] | 55 | Run Keyword And Ignore Error List Installed Images Host |
| 56 | |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 57 | Upload And Activate Image ${IMAGE_FILE_PATH} |
Michael Walsh | 1ca5144 | 2018-09-18 16:38:43 -0500 | [diff] [blame] | 58 | ... skip_if_active=${SKIP_UPDATE_IF_ACTIVE} |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 59 | OBMC Reboot (off) |
| 60 | |
| 61 | |
| 62 | Post Update Boot To OS |
| 63 | [Documentation] Boot the host OS |
| 64 | [Tags] Post_Update_Boot_To_OS |
Charles Paul Hofer | 0c4a87d | 2017-10-11 17:27:40 -0500 | [diff] [blame] | 65 | [Setup] Start SOL Console Logging |
George Keishing | da6bace | 2017-09-14 07:42:27 -0500 | [diff] [blame] | 66 | [Teardown] Run Keywords Stop SOL Console Logging |
| 67 | ... AND Code Update Test Teardown |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 68 | |
| 69 | Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' |
| 70 | ... Fail Code update failed. No need to boot to OS. |
George Keishing | 32fe4e1 | 2018-07-13 05:06:47 -0500 | [diff] [blame] | 71 | Delete All Error Logs |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 72 | REST Power On |
Charles Paul Hofer | e43fb2f | 2017-09-26 15:36:18 -0500 | [diff] [blame] | 73 | Verify Running Host Image ${IMAGE_FILE_PATH} |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 74 | |
| 75 | |
Steven Sombar | 9629b0e | 2018-08-23 07:26:58 -0500 | [diff] [blame] | 76 | Test Boot With No VPD Cache |
| 77 | [Documentation] After having done a PNOR update and |
| 78 | ... booted the OS in the tests above, remove the cached |
| 79 | ... VPD files and verify that the OS can still boot. |
| 80 | [Tags] Test_Boot_With_No_VPD_Cache |
| 81 | [Setup] Start SOL Console Logging |
| 82 | [Teardown] Run Keywords Stop SOL Console Logging |
| 83 | ... AND Code Update Test Teardown |
| 84 | |
| 85 | ${num_vpd_files} ${stderr} ${rc}= BMC Execute Command |
| 86 | ... ls ${cache_files_dir_path} | grep VPD -c |
| 87 | # Typically, vpd files = "CVPD DJVPD MVPD NVRAM". |
| 88 | Should Be Equal As Integers ${num_vpd_files} ${3} |
| 89 | ... msg=Missing VPD files at ${cache_files_dir_path}. |
| 90 | |
| 91 | # Delete the *VPD* files. |
| 92 | BMC Execute Command rm -f ${xxx_dir_path}*VPD* |
| 93 | |
| 94 | REST Power On |
| 95 | |
| 96 | # After powering-on the system, the VPD files should be present. |
| 97 | ${num_vpd_files} ${stderr} ${rc}= BMC Execute Command |
| 98 | ... ls ${cache_files_dir_path} | grep VPD -c |
| 99 | Should Be Equal As Integers ${num_vpd_files} ${3} |
| 100 | ... msg=Three VPD files expected at ${cache_files_dir_path}. |
| 101 | |
| 102 | # Power off. The next test case will boot the OS with the new VPD files. |
| 103 | REST Power Off |
| 104 | |
| 105 | |
Charles Paul Hofer | 7c6e752 | 2017-10-18 17:09:27 -0500 | [diff] [blame] | 106 | REST Host Code Update While OS Is Running |
| 107 | [Documentation] Do a PNOR code update while the host is running. |
| 108 | [Tags] REST_Host_Code_Update_While_OS_Is_Running |
Charles Paul Hofer | 4e8c09b | 2017-11-03 14:59:05 -0500 | [diff] [blame] | 109 | [Teardown] Run Keywords REST Power Off stack_mode=skip |
| 110 | ... AND Code Update Test Teardown |
Charles Paul Hofer | 7c6e752 | 2017-10-18 17:09:27 -0500 | [diff] [blame] | 111 | |
| 112 | Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' |
| 113 | ... Fail Cannot boot the OS. |
| 114 | |
| 115 | REST Power On stack_mode=skip |
George Keishing | 72373f8 | 2017-11-20 09:18:41 -0600 | [diff] [blame] | 116 | Upload And Activate Image |
| 117 | ... ${ALTERNATE_IMAGE_FILE_PATH} skip_if_active=true |
Charles Paul Hofer | 7c6e752 | 2017-10-18 17:09:27 -0500 | [diff] [blame] | 118 | REST Power On stack_mode=normal |
| 119 | Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} |
| 120 | |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 121 | Host Image Priority Attribute Test |
| 122 | [Documentation] Set "Priority" attribute. |
| 123 | [Tags] Host_Image_Priority_Attribute_Test |
| 124 | [Template] Temporarily Set PNOR Attribute |
| 125 | |
| 126 | # Property Value |
| 127 | Priority ${0} |
| 128 | Priority ${1} |
| 129 | Priority ${127} |
George Keishing | 97ecb27 | 2017-09-12 04:30:20 -0500 | [diff] [blame] | 130 | Priority ${255} |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 131 | |
| 132 | |
Charles Paul Hofer | 42f1746 | 2017-09-12 14:09:32 -0500 | [diff] [blame] | 133 | Host Set Priority To Invalid Values |
| 134 | [Documentation] Attempt to set the priority of an image to an invalid |
| 135 | ... value and expect an error. |
| 136 | [Tags] Host_Set_Priority_To_Invalid_Values |
| 137 | [Template] Set Priority To Invalid Value And Expect Error |
| 138 | |
| 139 | # Version Type Priority |
| 140 | ${VERSION_PURPOSE_HOST} ${-1} |
| 141 | ${VERSION_PURPOSE_HOST} ${256} |
| 142 | |
| 143 | |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 144 | Set RequestedActivation To None |
| 145 | [Documentation] Set the RequestedActivation of the image to None and |
| 146 | ... verify that it is in fact set to None. |
| 147 | [Tags] Set_RequestedActivation_To_None |
| 148 | |
| 149 | ${software_objects}= Get Software Objects |
| 150 | Set Host Software Property @{software_objects}[0] RequestedActivation |
| 151 | ... ${REQUESTED_NONE} |
| 152 | ${software_properties}= Get Host Software Property @{software_objects}[0] |
George Keishing | a2f6d42 | 2023-06-28 18:58:05 +0530 | [diff] [blame] | 153 | Should Be Equal As Strings ${software_properties}[RequestedActivation] |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 154 | ... ${REQUESTED_NONE} |
| 155 | |
| 156 | |
| 157 | Set RequestedActivation And Activation To Invalid Value |
George Keishing | e16f158 | 2022-12-15 07:32:21 -0600 | [diff] [blame] | 158 | [Documentation] Set the RequestedActivation and Activation properties of |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 159 | ... the image to an invalid value and verify that it was not |
| 160 | ... changed. |
| 161 | [Template] Set Property To Invalid Value And Verify No Change |
| 162 | [Tags] Set_RequestedActivation_And_Activation_To_Invalid_Value |
| 163 | |
| 164 | # Property Version Type |
| 165 | RequestedActivation ${VERSION_PURPOSE_HOST} |
| 166 | Activation ${VERSION_PURPOSE_HOST} |
| 167 | |
| 168 | |
Charles Paul Hofer | c1fa2bc | 2017-08-18 16:44:03 -0500 | [diff] [blame] | 169 | Upload And Activate Multiple Host Images |
| 170 | [Documentation] Upload another PNOR image and verify that its state is |
| 171 | ... different from all others. |
| 172 | [Tags] Upload_And_Activate_Multiple_Host_Images |
| 173 | [Template] Activate Image And Verify No Duplicate Priorities |
| 174 | [Setup] Upload And Activate Multiple BMC Images Setup |
| 175 | |
| 176 | # Image File Path Image Purpose |
| 177 | ${ALTERNATE_IMAGE_FILE_PATH} ${VERSION_PURPOSE_HOST} |
| 178 | |
| 179 | |
Charles Paul Hofer | a567316 | 2017-08-30 09:49:16 -0500 | [diff] [blame] | 180 | Set Same Priority For Multiple Host Images |
| 181 | [Documentation] Attempt to set the priority to be the same for two PNOR |
| 182 | ... images and verify that the priorities are not the same. |
| 183 | [Tags] Set_Same_Priority_For_Multiple_Host_Images |
| 184 | |
| 185 | Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' |
| 186 | ... Fail Activation of alternate image failed. Cannot set priority. |
| 187 | Set Same Priority For Multiple Images ${VERSION_PURPOSE_HOST} |
| 188 | |
| 189 | |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 190 | Delete Host Image |
| 191 | [Documentation] Delete a PNOR image from the BMC and PNOR flash chip. |
| 192 | [Tags] Delete_Host_Image |
| 193 | [Setup] Initiate Host PowerOff |
| 194 | |
| 195 | ${software_objects}= Get Software Objects |
| 196 | ... version_type=${VERSION_PURPOSE_HOST} |
| 197 | ${num_images}= Get Length ${software_objects} |
| 198 | Should Be True 0 < ${num_images} |
| 199 | ... msg=There are no PNOR images on the BMC to delete. |
| 200 | Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST} |
| 201 | |
| 202 | |
George Keishing | 287faaf | 2017-11-21 12:31:03 -0600 | [diff] [blame] | 203 | Verify Host Update When Host Reboot During Activation In Progress |
| 204 | [Documentation] Attempt to reboot the host while an image is activating. |
| 205 | [Tags] Verify_Host_Update_When_Host_Reboot_During_Activation_In_Progress |
| 206 | |
| 207 | Upload And Activate Image ${IMAGE_FILE_PATH} |
| 208 | REST Power On |
George Keishing | 32fe4e1 | 2018-07-13 05:06:47 -0500 | [diff] [blame] | 209 | Delete All Error Logs |
George Keishing | 287faaf | 2017-11-21 12:31:03 -0600 | [diff] [blame] | 210 | |
| 211 | ${version_id}= Upload And Activate Image ${ALTERNATE_IMAGE_FILE_PATH} |
| 212 | ... wait=${0} |
| 213 | |
| 214 | ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id} |
| 215 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 216 | |
| 217 | # Reboot Host during activation. |
| 218 | Host Reboot |
| 219 | |
| 220 | Wait For Activation State Change ${version_id} ${ACTIVATING} |
| 221 | |
| 222 | # New image priority should be 0. |
| 223 | ${new_host_properties}= |
| 224 | ... Get Host Software Property ${SOFTWARE_VERSION_URI}${version_id} |
| 225 | Should Be Equal As Integers ${new_host_properties["Priority"]} ${0} |
| 226 | |
| 227 | # Reboot host to boot up with the new host image version. |
| 228 | Host Reboot |
| 229 | Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} |
| 230 | |
| 231 | |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 232 | *** Keywords *** |
| 233 | |
| 234 | Temporarily Set PNOR Attribute |
| 235 | [Documentation] Update the PNOR attribute value. |
| 236 | [Arguments] ${attribute_name} ${attribute_value} |
| 237 | |
| 238 | # Description of argument(s): |
| 239 | # attribute_name Host software attribute name (e.g. "Priority"). |
| 240 | # attribute_value Value to be written. |
| 241 | |
| 242 | ${image_ids}= Get Software Objects |
| 243 | ${init_host_properties}= Get Host Software Property ${image_ids[0]} |
| 244 | ${initial_priority}= Set Variable ${init_host_properties["Priority"]} |
| 245 | |
| 246 | Set Host Software Property ${image_ids[0]} ${attribute_name} |
| 247 | ... ${attribute_value} |
| 248 | |
| 249 | ${cur_host_properties}= Get Host Software Property ${image_ids[0]} |
| 250 | Should Be Equal As Integers ${cur_host_properties["Priority"]} |
| 251 | ... ${attribute_value} |
| 252 | |
| 253 | # Revert to to initial value. |
| 254 | Set Host Software Property |
| 255 | ... ${image_ids[0]} ${attribute_name} ${initial_priority} |
| 256 | |
| 257 | |
| 258 | Code Update Setup |
| 259 | [Documentation] Do code update test case setup. |
George Keishing | 1eb85f5 | 2017-08-30 22:55:13 -0500 | [diff] [blame] | 260 | # - Clean up all existing BMC dumps. |
| 261 | # - Clean up all currently install PNOR images. |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 262 | |
Charles Paul Hofer | b926408 | 2017-09-29 15:00:19 -0500 | [diff] [blame] | 263 | Run Keyword And Ignore Error Smart Power Off |
Michael Walsh | e78a443 | 2018-03-29 16:36:04 -0500 | [diff] [blame] | 264 | Run Key Delete All Dumps ignore=1 |
George Keishing | 32fe4e1 | 2018-07-13 05:06:47 -0500 | [diff] [blame] | 265 | Run Key Delete All Error Logs ignore=1 |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 266 | Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}' |
| 267 | ... Delete All PNOR Images |
Charles Paul Hofer | 51b54c0 | 2017-09-13 22:13:49 -0500 | [diff] [blame] | 268 | Run Keyword If 'true' == '${DELETE_OLD_GUARD_FILE}' BMC Execute Command |
| 269 | ... rm -f /var/lib/phosphor-software-manager/pnor/prsv/GUARD |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 270 | |
George Keishing | fd71756 | 2019-07-02 13:30:04 -0500 | [diff] [blame] | 271 | BMC Execute Command rm -rf /tmp/images/* |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 272 | |
Charles Paul Hofer | c1fa2bc | 2017-08-18 16:44:03 -0500 | [diff] [blame] | 273 | Upload And Activate Multiple BMC Images Setup |
| 274 | [Documentation] Check that the ALTERNATE_FILE_PATH variable is set. |
| 275 | |
| 276 | Should Not Be Empty ${ALTERNATE_IMAGE_FILE_PATH} |
Charles Paul Hofer | 4e8c09b | 2017-11-03 14:59:05 -0500 | [diff] [blame] | 277 | Delete All PNOR Images |
George Keishing | 72373f8 | 2017-11-20 09:18:41 -0600 | [diff] [blame] | 278 | Upload And Activate Image ${IMAGE_FILE_PATH} skip_if_active=true |
Charles Paul Hofer | c1fa2bc | 2017-08-18 16:44:03 -0500 | [diff] [blame] | 279 | |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 280 | Get PNOR Extended Version |
| 281 | [Documentation] Return the PNOR extended version. |
| 282 | [Arguments] ${manifest_path} |
| 283 | |
| 284 | # Description of argument(s): |
| 285 | # manifest_path Path of the MANIFEST file |
| 286 | # (e.g. "/tmp/images/abc123/MANIFEST"). |
| 287 | |
| 288 | ${version}= BMC Execute Command |
| 289 | ... grep extended_version= ${manifest_path} |
| 290 | [return] ${version.split(",")} |
George Keishing | 0071549 | 2017-08-18 11:46:37 -0500 | [diff] [blame] | 291 | |
| 292 | |
| 293 | Code Update Test Teardown |
| 294 | [Documentation] Do code update test case teardown. |
| 295 | # 1. Collect FFDC if test case failed. |
| 296 | # 2. Collect FFDC if test PASS but error log exists. |
| 297 | |
| 298 | FFDC On Test Case Fail |
| 299 | Run Keyword If '${TEST_STATUS}' == 'PASS' Check Error And Collect FFDC |