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 |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 26 | |
| 27 | Test Teardown Code Update Teardown |
| 28 | |
| 29 | *** Variables *** |
| 30 | |
| 31 | ${QUIET} ${1} |
| 32 | ${version_id} ${EMPTY} |
| 33 | ${upload_dir_path} /tmp/images/ |
| 34 | ${image_version} ${EMPTY} |
| 35 | ${image_purpose} ${EMPTY} |
| 36 | ${activation_state} ${EMPTY} |
| 37 | ${requested_state} ${EMPTY} |
| 38 | ${IMAGE_FILE_PATH} ${EMPTY} |
Charles Paul Hofer | 2c73164 | 2017-08-03 18:13:27 -0500 | [diff] [blame] | 39 | ${DELETE_OLD_PNOR_IMAGES} false |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 40 | |
| 41 | *** Test Cases *** |
| 42 | |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 43 | REST Host Code Update |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 44 | [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] | 45 | [Tags] REST_Host_Code_Update |
Charles Paul Hofer | 2c73164 | 2017-08-03 18:13:27 -0500 | [diff] [blame] | 46 | [Setup] Code Update Setup |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 47 | |
| 48 | OperatingSystem.File Should Exist ${IMAGE_FILE_PATH} |
| 49 | ${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH} |
| 50 | |
| 51 | ${image_data}= OperatingSystem.Get Binary File ${IMAGE_FILE_PATH} |
| 52 | Upload Image To BMC /upload/image data=${image_data} |
| 53 | ${ret}= Verify Image Upload |
| 54 | Should Be True ${ret} |
| 55 | |
| 56 | # Verify the image is 'READY' to be activated. |
George Keishing | ff1e3ec | 2017-07-20 01:58:21 -0500 | [diff] [blame] | 57 | ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 58 | Should Be Equal As Strings &{software_state}[Activation] ${READY} |
| 59 | |
| 60 | # Request the image to be activated. |
| 61 | ${args}= Create Dictionary data=${REQUESTED_ACTIVE} |
George Keishing | ff1e3ec | 2017-07-20 01:58:21 -0500 | [diff] [blame] | 62 | Write Attribute ${SOFTWARE_VERSION_URI}${version_id} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 63 | ... RequestedActivation data=${args} |
George Keishing | ff1e3ec | 2017-07-20 01:58:21 -0500 | [diff] [blame] | 64 | ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 65 | Should Be Equal As Strings &{software_state}[RequestedActivation] |
| 66 | ... ${REQUESTED_ACTIVE} |
| 67 | |
| 68 | # Verify code update was successful and Activation state is Active. |
| 69 | Wait For Activation State Change ${version_id} ${ACTIVATING} |
George Keishing | ff1e3ec | 2017-07-20 01:58:21 -0500 | [diff] [blame] | 70 | ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 71 | Should Be Equal As Strings &{software_state}[Activation] ${ACTIVE} |
| 72 | |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame^] | 73 | OBMC Reboot (off) |
| 74 | |
| 75 | |
| 76 | Post Update Boot To OS |
| 77 | [Documentation] Boot the host OS |
| 78 | [Tags] Post_Update_Boot_To_OS |
| 79 | |
| 80 | Run Keyword Unless '${PREV_TEST_STATUS}' == 'PASS' |
| 81 | ... Fail Code update failed. No need to boot to OS. |
| 82 | REST Power On |
| 83 | |
George Keishing | d3fb592 | 2017-08-08 07:32:25 -0500 | [diff] [blame] | 84 | |
| 85 | Host Image Priority Attribute Test |
| 86 | [Documentation] Set "Priority" attribute. |
| 87 | [Tags] Host_Image_Priority_Attribute_Test |
| 88 | [Template] Set PNOR Attribute |
| 89 | |
| 90 | # Property Value |
| 91 | Priority ${0} |
| 92 | Priority ${1} |
| 93 | Priority ${127} |
| 94 | |
Charles Paul Hofer | e510082 | 2017-08-01 10:02:23 -0500 | [diff] [blame^] | 95 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 96 | *** Keywords *** |
| 97 | |
George Keishing | d3fb592 | 2017-08-08 07:32:25 -0500 | [diff] [blame] | 98 | Set PNOR Attribute |
| 99 | [Documentation] Update the attribute value. |
| 100 | [Arguments] ${attribute_name} ${value} |
| 101 | |
| 102 | # Description of argument(s): |
| 103 | # attribute_name Host software attribute name (e.g. "Priority"). |
| 104 | # value Value to be written. |
| 105 | |
| 106 | ${image_ids}= Get Software Objects |
| 107 | ${resp}= Get Host Software Property ${image_ids[0]} |
| 108 | ${initial_value}= Set Variable ${resp["Priority"]} |
| 109 | |
| 110 | Set Host Software Property ${image_ids[0]} ${attribute_name} ${value} |
| 111 | |
| 112 | ${resp}= Get Host Software Property ${image_ids[0]} |
| 113 | Should Be Equal As Integers ${resp["Priority"]} ${value} |
| 114 | |
| 115 | # Revert to to initial value. |
| 116 | Set Host Software Property |
| 117 | ... ${image_ids[0]} ${attribute_name} ${initial_value} |
| 118 | |
| 119 | |
Charles Paul Hofer | 2c73164 | 2017-08-03 18:13:27 -0500 | [diff] [blame] | 120 | Code Update Setup |
| 121 | [Documentation] Do code update test case setup. |
| 122 | |
| 123 | Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}' |
| 124 | ... Delete All PNOR Images |
| 125 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 126 | Code Update Teardown |
| 127 | [Documentation] Do code update test case teardown. |
| 128 | |
| 129 | #TODO: Use the Delete interface instead once delivered |
| 130 | Open Connection And Log In |
| 131 | Execute Command On BMC rm -rf /tmp/images/* |
| 132 | |
| 133 | Close All Connections |
| 134 | FFDC On Test Case Fail |
| 135 | |
| 136 | Get PNOR Extended Version |
| 137 | [Documentation] Return the PNOR extended version. |
| 138 | ... Description of arguments: |
| 139 | ... path Path of the MANIFEST file |
| 140 | [Arguments] ${path} |
| 141 | |
| 142 | Open Connection And Log In |
| 143 | ${version}= Execute Command On BMC |
| 144 | ... "grep \"extended_version=\" " + ${path} |
| 145 | [return] ${version.split(",")} |