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 | |
| 17 | #TODO: Move test_uploadimage.py to lib/ |
| 18 | Library ../test_uploadimage.py |
| 19 | Library code_update.py |
| 20 | Library OperatingSystem |
| 21 | Variables ../../data/variables.py |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 22 | Resource ../lib/rest_client.robot |
| 23 | Resource ../lib/openbmc_ffdc.robot |
George Keishing | d3fb592 | 2017-08-08 07:32:25 -0500 | [diff] [blame] | 24 | Resource ../../lib/code_update_utils.robot |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame] | 25 | Resource ../../lib/boot_utils.robot |
Charles Paul Hofer | d68d0fa | 2017-08-17 13:51:24 -0500 | [diff] [blame^] | 26 | Resource ../../lib/utils.robot |
| 27 | Resource code_update_utils.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 | d68d0fa | 2017-08-17 13:51:24 -0500 | [diff] [blame^] | 75 | # TODO: Switch OBMC Reboot (off) once it's fixed |
| 76 | Trigger Warm Reset Via Reboot |
| 77 | Check If BMC is Up |
| 78 | Wait For BMC Ready |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame] | 79 | |
| 80 | |
| 81 | Post Update Boot To OS |
| 82 | [Documentation] Boot the host OS |
| 83 | [Tags] Post_Update_Boot_To_OS |
| 84 | |
| 85 | Run Keyword Unless '${PREV_TEST_STATUS}' == 'PASS' |
| 86 | ... Fail Code update failed. No need to boot to OS. |
| 87 | REST Power On |
| 88 | |
George Keishing | d3fb592 | 2017-08-08 07:32:25 -0500 | [diff] [blame] | 89 | |
| 90 | Host Image Priority Attribute Test |
| 91 | [Documentation] Set "Priority" attribute. |
| 92 | [Tags] Host_Image_Priority_Attribute_Test |
| 93 | [Template] Set PNOR Attribute |
| 94 | |
| 95 | # Property Value |
| 96 | Priority ${0} |
| 97 | Priority ${1} |
| 98 | Priority ${127} |
| 99 | |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame] | 100 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 101 | *** Keywords *** |
| 102 | |
George Keishing | d3fb592 | 2017-08-08 07:32:25 -0500 | [diff] [blame] | 103 | Set PNOR Attribute |
| 104 | [Documentation] Update the attribute value. |
| 105 | [Arguments] ${attribute_name} ${value} |
| 106 | |
| 107 | # Description of argument(s): |
| 108 | # attribute_name Host software attribute name (e.g. "Priority"). |
| 109 | # value Value to be written. |
| 110 | |
| 111 | ${image_ids}= Get Software Objects |
| 112 | ${resp}= Get Host Software Property ${image_ids[0]} |
| 113 | ${initial_value}= Set Variable ${resp["Priority"]} |
| 114 | |
| 115 | Set Host Software Property ${image_ids[0]} ${attribute_name} ${value} |
| 116 | |
| 117 | ${resp}= Get Host Software Property ${image_ids[0]} |
| 118 | Should Be Equal As Integers ${resp["Priority"]} ${value} |
| 119 | |
| 120 | # Revert to to initial value. |
| 121 | Set Host Software Property |
| 122 | ... ${image_ids[0]} ${attribute_name} ${initial_value} |
| 123 | |
| 124 | |
Charles Paul Hofer | 2c73164 | 2017-08-03 18:13:27 -0500 | [diff] [blame] | 125 | Code Update Setup |
| 126 | [Documentation] Do code update test case setup. |
| 127 | |
| 128 | Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}' |
| 129 | ... Delete All PNOR Images |
| 130 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 131 | Code Update Teardown |
| 132 | [Documentation] Do code update test case teardown. |
| 133 | |
| 134 | #TODO: Use the Delete interface instead once delivered |
| 135 | Open Connection And Log In |
| 136 | Execute Command On BMC rm -rf /tmp/images/* |
| 137 | |
| 138 | Close All Connections |
| 139 | FFDC On Test Case Fail |
| 140 | |
| 141 | Get PNOR Extended Version |
| 142 | [Documentation] Return the PNOR extended version. |
| 143 | ... Description of arguments: |
| 144 | ... path Path of the MANIFEST file |
| 145 | [Arguments] ${path} |
| 146 | |
| 147 | Open Connection And Log In |
| 148 | ${version}= Execute Command On BMC |
| 149 | ... "grep \"extended_version=\" " + ${path} |
| 150 | [return] ${version.split(",")} |