Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Code update to a target BMC. |
| 3 | ... Execution Method: |
| 4 | ... python -m robot -v OPENBMC_HOST:<hostname> |
Charles Paul Hofer | 2c73164 | 2017-08-03 18:13:27 -0500 | [diff] [blame] | 5 | ... -v DELETE_OLD_PNOR_IMAGES:<"true" or "false"> |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 6 | ... -v IMAGE_FILE_PATH:<path/*.tar> code_update.robot |
| 7 | ... |
| 8 | ... Code update method BMC |
| 9 | ... Update work flow sequence: |
| 10 | ... - Upload image via REST |
| 11 | ... - Verify that the file exists on the BMC |
| 12 | ... - Check software "Activation" status to be "Ready" |
| 13 | ... - Set "Requested Activation" to "Active" |
| 14 | ... - Wait for code update to complete |
| 15 | ... - Verify the new version |
| 16 | |
Charles Paul Hofer | de7d408 | 2017-08-08 14:41:01 -0500 | [diff] [blame] | 17 | Library ../../lib/code_update_utils.py |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 18 | Library OperatingSystem |
Charles Paul Hofer | da24d0a | 2017-08-09 15:03:40 -0500 | [diff] [blame] | 19 | Library String |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 20 | Variables ../../data/variables.py |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 21 | Resource ../lib/rest_client.robot |
| 22 | Resource ../lib/openbmc_ffdc.robot |
George Keishing | d3fb592 | 2017-08-08 07:32:25 -0500 | [diff] [blame] | 23 | Resource ../../lib/code_update_utils.robot |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame] | 24 | Resource ../../lib/boot_utils.robot |
Charles Paul Hofer | d68d0fa | 2017-08-17 13:51:24 -0500 | [diff] [blame] | 25 | Resource ../../lib/utils.robot |
| 26 | Resource code_update_utils.robot |
Charles Paul Hofer | da24d0a | 2017-08-09 15:03:40 -0500 | [diff] [blame] | 27 | Resource ../../lib/state_manager.robot |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 28 | |
| 29 | Test Teardown Code Update Teardown |
| 30 | |
| 31 | *** Variables *** |
| 32 | |
| 33 | ${QUIET} ${1} |
| 34 | ${version_id} ${EMPTY} |
| 35 | ${upload_dir_path} /tmp/images/ |
| 36 | ${image_version} ${EMPTY} |
| 37 | ${image_purpose} ${EMPTY} |
| 38 | ${activation_state} ${EMPTY} |
| 39 | ${requested_state} ${EMPTY} |
| 40 | ${IMAGE_FILE_PATH} ${EMPTY} |
Charles Paul Hofer | 2c73164 | 2017-08-03 18:13:27 -0500 | [diff] [blame] | 41 | ${DELETE_OLD_PNOR_IMAGES} false |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 42 | |
| 43 | *** Test Cases *** |
| 44 | |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 45 | REST Host Code Update |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 46 | [Documentation] Do a PNOR code update by uploading image on BMC via REST. |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 47 | [Tags] REST_Host_Code_Update |
Charles Paul Hofer | 2c73164 | 2017-08-03 18:13:27 -0500 | [diff] [blame] | 48 | [Setup] Code Update Setup |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 49 | |
Charles Paul Hofer | 12a7c1d | 2017-08-01 13:44:02 -0500 | [diff] [blame^] | 50 | OperatingSystem.File Should Exist ${image_file_path} |
| 51 | ${image_version}= Get Version Tar ${image_file_path} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 52 | |
Charles Paul Hofer | 12a7c1d | 2017-08-01 13:44:02 -0500 | [diff] [blame^] | 53 | ${image_data}= OperatingSystem.Get Binary File ${image_file_path} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 54 | Upload Image To BMC /upload/image data=${image_data} |
| 55 | ${ret}= Verify Image Upload |
| 56 | Should Be True ${ret} |
| 57 | |
| 58 | # Verify the image is 'READY' to be activated. |
George Keishing | ff1e3ec | 2017-07-20 01:58:21 -0500 | [diff] [blame] | 59 | ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 60 | Should Be Equal As Strings &{software_state}[Activation] ${READY} |
| 61 | |
| 62 | # Request the image to be activated. |
| 63 | ${args}= Create Dictionary data=${REQUESTED_ACTIVE} |
George Keishing | ff1e3ec | 2017-07-20 01:58:21 -0500 | [diff] [blame] | 64 | Write Attribute ${SOFTWARE_VERSION_URI}${version_id} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 65 | ... RequestedActivation data=${args} |
George Keishing | ff1e3ec | 2017-07-20 01:58:21 -0500 | [diff] [blame] | 66 | ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 67 | Should Be Equal As Strings &{software_state}[RequestedActivation] |
| 68 | ... ${REQUESTED_ACTIVE} |
| 69 | |
| 70 | # Verify code update was successful and Activation state is Active. |
| 71 | Wait For Activation State Change ${version_id} ${ACTIVATING} |
George Keishing | ff1e3ec | 2017-07-20 01:58:21 -0500 | [diff] [blame] | 72 | ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 73 | Should Be Equal As Strings &{software_state}[Activation] ${ACTIVE} |
| 74 | |
Charles Paul Hofer | bdbabf1 | 2017-08-18 12:30:14 -0500 | [diff] [blame] | 75 | OBMC Reboot (off) |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame] | 76 | |
| 77 | |
| 78 | Post Update Boot To OS |
| 79 | [Documentation] Boot the host OS |
| 80 | [Tags] Post_Update_Boot_To_OS |
Charles Paul Hofer | 9910841 | 2017-08-21 09:22:36 -0500 | [diff] [blame] | 81 | [Teardown] Stop SOL Console Logging |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame] | 82 | |
| 83 | Run Keyword Unless '${PREV_TEST_STATUS}' == 'PASS' |
| 84 | ... Fail Code update failed. No need to boot to OS. |
Charles Paul Hofer | 9910841 | 2017-08-21 09:22:36 -0500 | [diff] [blame] | 85 | Start SOL Console Logging |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame] | 86 | REST Power On |
| 87 | |
George Keishing | d3fb592 | 2017-08-08 07:32:25 -0500 | [diff] [blame] | 88 | |
| 89 | Host Image Priority Attribute Test |
| 90 | [Documentation] Set "Priority" attribute. |
| 91 | [Tags] Host_Image_Priority_Attribute_Test |
| 92 | [Template] Set PNOR Attribute |
| 93 | |
| 94 | # Property Value |
| 95 | Priority ${0} |
| 96 | Priority ${1} |
| 97 | Priority ${127} |
| 98 | |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame] | 99 | |
Charles Paul Hofer | 12a7c1d | 2017-08-01 13:44:02 -0500 | [diff] [blame^] | 100 | Set RequestedActivation To None |
| 101 | [Documentation] Set the RequestedActivation of the image to None and |
| 102 | ... verify that it is in fact set to None. |
| 103 | [Tags] Set_RequestedActivation_To_None |
| 104 | |
| 105 | ${sw_objs}= Get Software Objects |
| 106 | Set Host Software Property @{sw_objs}[0] RequestedActivation |
| 107 | ... ${REQUESTED_NONE} |
| 108 | ${sw_props}= Get Host Software Property @{sw_objs}[0] |
| 109 | Should Be Equal As Strings &{sw_props}[RequestedActivation] |
| 110 | ... ${REQUESTED_NONE} |
| 111 | |
| 112 | |
| 113 | Set RequestedActivation To Invalid Value |
| 114 | [Documentation] Set the RequestedActivation proprety of the image to an |
| 115 | ... invalid value and verify that it was not changed. |
| 116 | [Template] Set Property To Invalid Value And Verify No Change |
| 117 | [Tags] Set_RequestedActivation_To_Invalid_Value |
| 118 | |
| 119 | # Property |
| 120 | RequestedActivation |
| 121 | |
| 122 | |
| 123 | Set Activation To Invalid Value |
| 124 | [Documentation] Set the Activation proprety of the image to an invalid |
| 125 | ... value and verify that it was not changed. |
| 126 | [Template] Set Property To Invalid Value And Verify No Change |
| 127 | [Tags] Set_Activation_To_Invalid_Value |
| 128 | |
| 129 | # Property |
| 130 | Activation |
| 131 | |
| 132 | |
Charles Paul Hofer | da24d0a | 2017-08-09 15:03:40 -0500 | [diff] [blame] | 133 | Delete Host Image |
| 134 | [Documentation] Delete a PNOR image from the BMC and PNOR flash chip. |
| 135 | [Tags] Delete_Host_Image |
| 136 | [Setup] Initiate Host PowerOff |
| 137 | |
| 138 | ${software_objects}= Get Software Objects |
| 139 | ... version_type=${VERSION_PURPOSE_HOST} |
| 140 | ${num_images}= Get Length ${software_objects} |
| 141 | Should Be True 0 < ${num_images} |
| 142 | ... msg=There are no PNOR images on the BMC to delete. |
| 143 | Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST} |
| 144 | |
| 145 | |
| 146 | Delete BMC Image |
| 147 | [Documentation] Delete a BMC image from the BMC flash chip. |
| 148 | [Tags] Delete_BMC_Image |
| 149 | |
| 150 | ${software_object}= Get Non Running BMC Software Object |
| 151 | Delete Image And Verify ${software_object} ${VERSION_PURPOSE_BMC} |
| 152 | |
| 153 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 154 | *** Keywords *** |
| 155 | |
George Keishing | d3fb592 | 2017-08-08 07:32:25 -0500 | [diff] [blame] | 156 | Set PNOR Attribute |
| 157 | [Documentation] Update the attribute value. |
| 158 | [Arguments] ${attribute_name} ${value} |
| 159 | |
| 160 | # Description of argument(s): |
| 161 | # attribute_name Host software attribute name (e.g. "Priority"). |
| 162 | # value Value to be written. |
| 163 | |
| 164 | ${image_ids}= Get Software Objects |
| 165 | ${resp}= Get Host Software Property ${image_ids[0]} |
| 166 | ${initial_value}= Set Variable ${resp["Priority"]} |
| 167 | |
| 168 | Set Host Software Property ${image_ids[0]} ${attribute_name} ${value} |
| 169 | |
| 170 | ${resp}= Get Host Software Property ${image_ids[0]} |
| 171 | Should Be Equal As Integers ${resp["Priority"]} ${value} |
| 172 | |
| 173 | # Revert to to initial value. |
| 174 | Set Host Software Property |
| 175 | ... ${image_ids[0]} ${attribute_name} ${initial_value} |
| 176 | |
| 177 | |
Charles Paul Hofer | 2c73164 | 2017-08-03 18:13:27 -0500 | [diff] [blame] | 178 | Code Update Setup |
| 179 | [Documentation] Do code update test case setup. |
| 180 | |
| 181 | Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}' |
| 182 | ... Delete All PNOR Images |
| 183 | |
Charles Paul Hofer | 12a7c1d | 2017-08-01 13:44:02 -0500 | [diff] [blame^] | 184 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 185 | Code Update Teardown |
| 186 | [Documentation] Do code update test case teardown. |
| 187 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 188 | FFDC On Test Case Fail |
| 189 | |
Charles Paul Hofer | 12a7c1d | 2017-08-01 13:44:02 -0500 | [diff] [blame^] | 190 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 191 | Get PNOR Extended Version |
| 192 | [Documentation] Return the PNOR extended version. |
Charles Paul Hofer | 12a7c1d | 2017-08-01 13:44:02 -0500 | [diff] [blame^] | 193 | [Arguments] ${path} |
| 194 | |
| 195 | # Description of argument(s): |
| 196 | # path Path of the MANIFEST file. |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 197 | |
| 198 | Open Connection And Log In |
| 199 | ${version}= Execute Command On BMC |
| 200 | ... "grep \"extended_version=\" " + ${path} |
| 201 | [return] ${version.split(",")} |
Charles Paul Hofer | da24d0a | 2017-08-09 15:03:40 -0500 | [diff] [blame] | 202 | |
Charles Paul Hofer | 12a7c1d | 2017-08-01 13:44:02 -0500 | [diff] [blame^] | 203 | |
Charles Paul Hofer | da24d0a | 2017-08-09 15:03:40 -0500 | [diff] [blame] | 204 | Delete Image And Verify |
| 205 | [Documentation] Delete an image from the BMC and verify that it was |
| 206 | ... removed from software and the /tmp/images directory. |
| 207 | [Arguments] ${software_object} ${version_type} |
| 208 | |
| 209 | # Description of argument(s): |
| 210 | # software_object The URI of the software object to delete. |
| 211 | # version_type The type of the software object, e.g. |
| 212 | # xyz.openbmc_project.Software.Version.VersionPurpose.Host |
| 213 | # or xyz.openbmc_project.Software.Version.VersionPurpose.BMC. |
| 214 | |
| 215 | # Delete the image. |
| 216 | Delete Software Object ${software_object} |
| 217 | # TODO: If/when we don't have to delete twice anymore, take this out |
| 218 | Run Keyword And Ignore Error Delete Software Object ${software_object} |
| 219 | |
| 220 | # Verify that it's gone from software. |
| 221 | ${software_objects}= Get Software Objects version_type=${version_type} |
| 222 | Should Not Contain ${software_objects} ${software_object} |
| 223 | |
| 224 | # Check that there is no file in the /tmp/images directory. |
| 225 | ${image_id}= Fetch From Right ${software_object} / |
| 226 | BMC Execute Command |
| 227 | ... [ ! -d "/tmp/images/${image_id}" ] |
Charles Paul Hofer | 12a7c1d | 2017-08-01 13:44:02 -0500 | [diff] [blame^] | 228 | |
| 229 | |
| 230 | Set Property To Invalid Value And Verify No Change |
| 231 | [Documentation] Attempt to set a property and check that the value didn't |
| 232 | ... change. |
| 233 | [Arguments] ${property} |
| 234 | |
| 235 | # Description of argument(s): |
| 236 | # property The property to attempt to set. |
| 237 | |
| 238 | ${sw_objs}= Get Software Objects |
| 239 | ${prev_props}= Get Host Software Property @{sw_objs}[0] |
| 240 | Run Keyword And Expect Error 500 != 200 |
| 241 | ... Set Host Software Property @{sw_objs}[0] ${property} foo |
| 242 | ${cur_props}= Get Host Software Property @{sw_objs}[0] |
| 243 | Should Be Equal As Strings &{prev_props}[${property}] |
| 244 | ... &{cur_props}[${property}] |