George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Firmware image (BMC and Host) upload test using TFTP protocol. |
| 3 | |
| 4 | # Test Parameters: |
| 5 | # TFTP_SERVER The TFTP server host name or IP address. |
| 6 | # IMAGE_FILE_NAME The BMC or Host image file name. |
| 7 | # |
| 8 | # Firmware update states: |
| 9 | # Enabled -> Image is installed and either functional or active. |
| 10 | # Disabled -> Image installation failed or ready for activation. |
| 11 | # Updating -> Image installation currently in progress. |
| 12 | |
| 13 | Resource ../../lib/resource.robot |
| 14 | Resource ../../lib/boot_utils.robot |
| 15 | Resource ../../lib/bmc_redfish_resource.robot |
| 16 | Resource ../../lib/openbmc_ffdc.robot |
| 17 | Resource ../../lib/code_update_utils.robot |
Sushil Singh | f953d74 | 2019-11-08 10:09:44 -0600 | [diff] [blame] | 18 | Resource ../../lib/redfish_code_update_utils.robot |
Sushil Singh | 8033d66 | 2020-02-10 07:19:25 -0600 | [diff] [blame] | 19 | Resource ../../lib/utils.robot |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 20 | Library ../../lib/code_update_utils.py |
| 21 | Library ../../lib/gen_robot_valid.py |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 22 | Library ../../lib/tftp_update_utils.py |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 23 | |
| 24 | Suite Setup Suite Setup Execution |
| 25 | Suite Teardown Redfish.Logout |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 26 | Test Setup Run Keywords Redfish Power Off stack_mode=skip quiet=1 AND Redfish.Login |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 27 | Test Teardown FFDC On Test Case Fail |
| 28 | |
| 29 | Force Tags tftp_update |
| 30 | |
| 31 | *** Test Cases *** |
| 32 | |
| 33 | TFTP Download Install With ApplyTime OnReset Policy |
| 34 | [Documentation] Download image to BMC using TFTP with OnReset policy and verify installation. |
| 35 | [Tags] TFTP_Download_Install_With_ApplyTime_OnReset_Policy |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 36 | [Template] TFTP Download Install |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 37 | |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 38 | # policy |
| 39 | OnReset |
| 40 | |
| 41 | |
| 42 | TFTP Download Install With ApplyTime Immediate Policy |
| 43 | [Documentation] Download image to BMC using TFTP with Immediate policy and verify installation. |
| 44 | [Tags] TFTP_Download_Install_With_ApplyTime_Immediate_Policy |
| 45 | [Template] TFTP Download Install |
| 46 | |
| 47 | # policy |
| 48 | Immediate |
| 49 | |
| 50 | |
| 51 | ImageURI Download Install With ApplyTime OnReset Policy |
| 52 | [Documentation] Download image to BMC using ImageURI with OnReset policy and verify installation. |
| 53 | [Tags] ImageURI_Download_Install_With_ApplyTime_OnReset_Policy |
| 54 | [Template] ImageURI Download Install |
| 55 | |
| 56 | # policy |
| 57 | OnReset |
| 58 | |
| 59 | |
| 60 | ImageURI Download Install With ApplyTime Immediate Policy |
| 61 | [Documentation] Download image to BMC using ImageURI with Immediate policy and verify installation. |
| 62 | [Tags] ImageURI_Download_Install_With_ApplyTime_Immediate_Policy |
| 63 | [Template] ImageURI Download Install |
| 64 | |
| 65 | # policy |
| 66 | Immediate |
| 67 | |
Sushil Singh | f953d74 | 2019-11-08 10:09:44 -0600 | [diff] [blame] | 68 | |
| 69 | Install Same Image Two Times |
| 70 | [Documentation] Install firmware image and re-try using the same image which should fail. |
| 71 | [Tags] Install_Same_Image_Two_Times |
| 72 | [Template] Same Firmware Install Two Times |
| 73 | |
| 74 | # policy |
| 75 | Immediate |
| 76 | |
| 77 | |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 78 | *** Keywords *** |
| 79 | |
| 80 | Suite Setup Execution |
| 81 | [Documentation] Do the suite setup. |
| 82 | |
| 83 | Redfish.Login |
Michael Walsh | e7edb22 | 2019-08-19 17:39:38 -0500 | [diff] [blame] | 84 | Valid Value TFTP_SERVER |
| 85 | Valid Value IMAGE_FILE_NAME |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 86 | |
| 87 | |
| 88 | TFTP Download Install |
| 89 | [Documentation] Download image to BMC using TFTP with ApplyTime policy and verify installation. |
| 90 | [Arguments] ${policy} |
| 91 | |
| 92 | # Description of argument(s): |
| 93 | # policy ApplyTime allowed values (e.g. "OnReset", "Immediate"). |
| 94 | |
Sushil Singh | 8033d66 | 2020-02-10 07:19:25 -0600 | [diff] [blame] | 95 | ${post_code_update_actions}= Get Post Boot Action |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 96 | ${state}= Get Pre Reboot State |
| 97 | Rprint Vars state |
| 98 | |
| 99 | Set ApplyTime policy=${policy} |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 100 | |
| 101 | # Download image from TFTP server to BMC. |
| 102 | Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate |
| 103 | ... body={"TransferProtocol" : "TFTP", "ImageURI" : "${TFTP_SERVER}/${IMAGE_FILE_NAME}"} |
| 104 | |
| 105 | # Wait for image tar file to download complete. |
| 106 | ${image_id}= Wait Until Keyword Succeeds 60 sec 10 sec Get Latest Image ID |
| 107 | Rprint Vars image_id |
| 108 | |
| 109 | # Let the image get extracted and it should not fail. |
| 110 | Sleep 5s |
| 111 | Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id} |
| 112 | |
| 113 | # Get image version currently installation in progress. |
| 114 | ${install_version}= Get Firmware Image Version image_id=${image_id} |
| 115 | Rprint Vars install_version |
| 116 | |
| 117 | Check Image Update Progress State match_state='Updating' image_id=${image_id} |
| 118 | |
| 119 | # Wait for the image to install complete. |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 120 | Wait Until Keyword Succeeds 8 min 15 sec |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 121 | ... Check Image Update Progress State match_state='Enabled' image_id=${image_id} |
| 122 | |
Sushil Singh | 8033d66 | 2020-02-10 07:19:25 -0600 | [diff] [blame] | 123 | Run Key ${post_code_update_actions['BMC image']['${policy}']} |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 124 | |
| 125 | # Verify the image is installed and functional. |
| 126 | ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g' |
| 127 | ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd} |
Michael Walsh | e7edb22 | 2019-08-19 17:39:38 -0500 | [diff] [blame] | 128 | Valid Value functional_version valid_values=['${install_version}'] |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 129 | Rprint Vars functional_version |
| 130 | |
| 131 | |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 132 | ImageURI Download Install |
| 133 | [Documentation] Download image to BMC using ImageURI with ApplyTime policy and verify installation. |
| 134 | [Arguments] ${policy} |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 135 | |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 136 | # Description of argument(s): |
| 137 | # policy ApplyTime allowed values (e.g. "OnReset", "Immediate"). |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 138 | |
Sushil Singh | 8033d66 | 2020-02-10 07:19:25 -0600 | [diff] [blame] | 139 | ${post_code_update_actions}= Get Post Boot Action |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 140 | ${state}= Get Pre Reboot State |
| 141 | Rprint Vars state |
| 142 | |
| 143 | Set ApplyTime policy=${policy} |
| 144 | |
| 145 | # Download image from TFTP server via ImageURI to BMC. |
| 146 | Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate |
| 147 | ... body={"ImageURI": "tftp://${TFTP_SERVER}/${IMAGE_FILE_NAME}"} |
| 148 | |
| 149 | # Wait for image tar file download to complete. |
| 150 | ${image_id}= Wait Until Keyword Succeeds 60 sec 10 sec Get Latest Image ID |
| 151 | Rprint Vars image_id |
| 152 | |
| 153 | # Let the image get extracted and it should not fail. |
| 154 | Sleep 5s |
| 155 | Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id} |
| 156 | |
| 157 | ${install_version}= Get Firmware Image Version image_id=${image_id} |
| 158 | Rprint Vars install_version |
| 159 | |
| 160 | Check Image Update Progress State match_state='Updating' image_id=${image_id} |
| 161 | |
| 162 | # Wait for the image to install complete. |
| 163 | Wait Until Keyword Succeeds 8 min 15 sec |
| 164 | ... Check Image Update Progress State match_state='Enabled' image_id=${image_id} |
| 165 | |
Sushil Singh | 8033d66 | 2020-02-10 07:19:25 -0600 | [diff] [blame] | 166 | Run Key ${post_code_update_actions['BMC image']['${policy}']} |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 167 | |
| 168 | # Verify the image is installed and functional. |
| 169 | ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g' |
| 170 | ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd} |
Michael Walsh | e7edb22 | 2019-08-19 17:39:38 -0500 | [diff] [blame] | 171 | Valid Value functional_version valid_values=['${install_version}'] |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 172 | Rprint Vars functional_version |
| 173 | |
| 174 | |
Sushil Singh | f953d74 | 2019-11-08 10:09:44 -0600 | [diff] [blame] | 175 | Same Firmware Install Two Times |
| 176 | [Documentation] Download same image twice to BMC via ImageURI. Second attempt would fail. |
| 177 | [Arguments] ${apply_time} ${tftp_server}=${TFTP_SERVER} ${image_file_name}=${IMAGE_FILE_NAME} |
| 178 | |
| 179 | # Description of argument(s): |
| 180 | # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate"). |
| 181 | # tftp_server Server IP. |
| 182 | # image_file_name Image file name. |
| 183 | |
| 184 | ImageURI Download Install ${apply_time} |
| 185 | |
| 186 | # Download image from TFTP server via ImageURI to BMC. |
| 187 | Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate |
| 188 | ... body={"ImageURI": "tftp://${tftp_server}/${image_file_name}"} |
| 189 | |
| 190 | ${image_version}= Get Image Version From TFTP Server ${tftp_server} ${image_file_name} |
| 191 | ${software_inventory_record}= Get Software Inventory State By Version |
| 192 | ... ${image_version} |
| 193 | Rprint Vars software_inventory_record |
| 194 | |
| 195 | ${image_id}= Wait Until Keyword Succeeds 60 sec 10 sec Get Latest Image ID |
| 196 | Rprint Vars image_id |
| 197 | |
| 198 | Check Image Update Progress State match_state='Enabled' image_id=${image_id} |
| 199 | # Check if the existing firmware is functional. |
| 200 | Pass Execution If ${software_inventory_record['functional']} |
| 201 | ... The existing ${image_version} firmware is already functional. |
| 202 | |