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