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 | |
| 50 | OperatingSystem.File Should Exist ${IMAGE_FILE_PATH} |
| 51 | ${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH} |
| 52 | |
| 53 | ${image_data}= OperatingSystem.Get Binary File ${IMAGE_FILE_PATH} |
| 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 | da24d0a | 2017-08-09 15:03:40 -0500 | [diff] [blame^] | 100 | Delete Host Image |
| 101 | [Documentation] Delete a PNOR image from the BMC and PNOR flash chip. |
| 102 | [Tags] Delete_Host_Image |
| 103 | [Setup] Initiate Host PowerOff |
| 104 | |
| 105 | ${software_objects}= Get Software Objects |
| 106 | ... version_type=${VERSION_PURPOSE_HOST} |
| 107 | ${num_images}= Get Length ${software_objects} |
| 108 | Should Be True 0 < ${num_images} |
| 109 | ... msg=There are no PNOR images on the BMC to delete. |
| 110 | Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST} |
| 111 | |
| 112 | |
| 113 | Delete BMC Image |
| 114 | [Documentation] Delete a BMC image from the BMC flash chip. |
| 115 | [Tags] Delete_BMC_Image |
| 116 | |
| 117 | ${software_object}= Get Non Running BMC Software Object |
| 118 | Delete Image And Verify ${software_object} ${VERSION_PURPOSE_BMC} |
| 119 | |
| 120 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 121 | *** Keywords *** |
| 122 | |
George Keishing | d3fb592 | 2017-08-08 07:32:25 -0500 | [diff] [blame] | 123 | Set PNOR Attribute |
| 124 | [Documentation] Update the attribute value. |
| 125 | [Arguments] ${attribute_name} ${value} |
| 126 | |
| 127 | # Description of argument(s): |
| 128 | # attribute_name Host software attribute name (e.g. "Priority"). |
| 129 | # value Value to be written. |
| 130 | |
| 131 | ${image_ids}= Get Software Objects |
| 132 | ${resp}= Get Host Software Property ${image_ids[0]} |
| 133 | ${initial_value}= Set Variable ${resp["Priority"]} |
| 134 | |
| 135 | Set Host Software Property ${image_ids[0]} ${attribute_name} ${value} |
| 136 | |
| 137 | ${resp}= Get Host Software Property ${image_ids[0]} |
| 138 | Should Be Equal As Integers ${resp["Priority"]} ${value} |
| 139 | |
| 140 | # Revert to to initial value. |
| 141 | Set Host Software Property |
| 142 | ... ${image_ids[0]} ${attribute_name} ${initial_value} |
| 143 | |
| 144 | |
Charles Paul Hofer | 2c73164 | 2017-08-03 18:13:27 -0500 | [diff] [blame] | 145 | Code Update Setup |
| 146 | [Documentation] Do code update test case setup. |
| 147 | |
| 148 | Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}' |
| 149 | ... Delete All PNOR Images |
| 150 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 151 | Code Update Teardown |
| 152 | [Documentation] Do code update test case teardown. |
| 153 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 154 | Close All Connections |
| 155 | FFDC On Test Case Fail |
| 156 | |
| 157 | Get PNOR Extended Version |
| 158 | [Documentation] Return the PNOR extended version. |
| 159 | ... Description of arguments: |
| 160 | ... path Path of the MANIFEST file |
| 161 | [Arguments] ${path} |
| 162 | |
| 163 | Open Connection And Log In |
| 164 | ${version}= Execute Command On BMC |
| 165 | ... "grep \"extended_version=\" " + ${path} |
| 166 | [return] ${version.split(",")} |
Charles Paul Hofer | da24d0a | 2017-08-09 15:03:40 -0500 | [diff] [blame^] | 167 | |
| 168 | Delete Image And Verify |
| 169 | [Documentation] Delete an image from the BMC and verify that it was |
| 170 | ... removed from software and the /tmp/images directory. |
| 171 | [Arguments] ${software_object} ${version_type} |
| 172 | |
| 173 | # Description of argument(s): |
| 174 | # software_object The URI of the software object to delete. |
| 175 | # version_type The type of the software object, e.g. |
| 176 | # xyz.openbmc_project.Software.Version.VersionPurpose.Host |
| 177 | # or xyz.openbmc_project.Software.Version.VersionPurpose.BMC. |
| 178 | |
| 179 | # Delete the image. |
| 180 | Delete Software Object ${software_object} |
| 181 | # TODO: If/when we don't have to delete twice anymore, take this out |
| 182 | Run Keyword And Ignore Error Delete Software Object ${software_object} |
| 183 | |
| 184 | # Verify that it's gone from software. |
| 185 | ${software_objects}= Get Software Objects version_type=${version_type} |
| 186 | Should Not Contain ${software_objects} ${software_object} |
| 187 | |
| 188 | # Check that there is no file in the /tmp/images directory. |
| 189 | ${image_id}= Fetch From Right ${software_object} / |
| 190 | BMC Execute Command |
| 191 | ... [ ! -d "/tmp/images/${image_id}" ] |