Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 1 | *** Settings *** |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 2 | Documentation Test upload image with both valid and invalid images. |
| 3 | ... This test expects there to be bad image tarballs named |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 4 | ... pnor_bad_manifest.tar, pnor_no_image.tar, |
| 5 | ... bmc_bad_manifest.tar, and bmc_no_image.tar on the TFTP |
| 6 | ... server and in the BAD_IMAGES_DIR_PATH directory. |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 7 | ... Execution Method : |
| 8 | ... python -m robot -v OPENBMC_HOST:<hostname> |
| 9 | ... -v TFTP_SERVER:<TFTP server IP> |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 10 | ... -v PNOR_TFTP_FILE_NAME:<filename.tar> |
| 11 | ... -v BMC_TFTP_FILE_NAME:<filename.tar> |
| 12 | ... -v PNOR_IMAGE_FILE_PATH:<path/*.tar> |
| 13 | ... -v BMC_IMAGE_FILE_PATH:<path/*.tar> |
George Keishing | 9571a93 | 2017-11-12 12:42:23 -0600 | [diff] [blame] | 14 | ... -v BAD_IMAGES_DIR_PATH:<path> test_image_upload.robot |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 15 | |
Charles Paul Hofer | 7c191de | 2017-09-27 15:47:47 -0500 | [diff] [blame] | 16 | Resource ../../lib/connection_client.robot |
| 17 | Resource ../../lib/rest_client.robot |
| 18 | Resource ../../lib/openbmc_ffdc.robot |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 19 | Library Collections |
| 20 | Library String |
| 21 | Library OperatingSystem |
Charles Paul Hofer | 7c191de | 2017-09-27 15:47:47 -0500 | [diff] [blame] | 22 | Library ../../lib/code_update_utils.py |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 23 | |
| 24 | Test Teardown Upload Image Teardown |
| 25 | |
Sweta Potthuri | 5db43e4 | 2017-06-15 05:36:44 -0500 | [diff] [blame] | 26 | Force Tags Upload_Test |
| 27 | |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 28 | *** Variables *** |
| 29 | ${timeout} 10 |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 30 | ${QUIET} ${1} |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 31 | |
| 32 | *** Test Cases *** |
| 33 | |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 34 | Upload Host Image Via REST |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 35 | # Image File Path |
| 36 | |
| 37 | ${PNOR_IMAGE_FILE_PATH} |
| 38 | |
| 39 | [Documentation] Upload a PNOR image via REST. |
| 40 | [Template] Upload Image Via REST And Verify Success |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 41 | [Tags] Upload_Host_Image_Via_REST |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 42 | |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 43 | |
| 44 | Upload BMC Image Via REST |
| 45 | # Image File Path |
| 46 | |
| 47 | ${BMC_IMAGE_FILE_PATH} |
| 48 | |
| 49 | [Documentation] Upload a BMC image via REST. |
| 50 | [Template] Upload Image Via REST And Verify Success |
| 51 | [Tags] Upload_BMC_Image_Via_REST |
| 52 | |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 53 | |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 54 | Upload Host Image Via TFTP |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 55 | # Image File Path |
| 56 | |
| 57 | ${PNOR_TFTP_FILE_NAME} |
| 58 | |
| 59 | [Documentation] Upload a PNOR image via TFTP. |
| 60 | [Template] Upload Image Via TFTP And Verify Success |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 61 | [Tags] Upload_Host_Image_Via_TFTP |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 62 | |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 63 | |
| 64 | Upload BMC Image Via TFTP |
| 65 | # Image File Path |
| 66 | |
| 67 | ${BMC_TFTP_FILE_NAME} |
| 68 | |
| 69 | [Documentation] Upload a BMC image via TFTP |
| 70 | [Template] Upload Image Via TFTP And Verify Success |
| 71 | [Tags] Upload_BMC_Image_Via_TFTP |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 72 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 73 | |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 74 | Upload Host Image With Bad Manifest Via REST |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 75 | # Image File Name |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 76 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 77 | pnor_bad_manifest.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 78 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 79 | [Documentation] Upload a PNOR image with a bad MANIFEST via REST and |
| 80 | ... verify that the BMC does not unpack it. |
| 81 | [Template] Upload Bad Image Via REST And Verify Failure |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 82 | [Tags] Upload_Host_Image_With_Bad_Manifest_Via_REST |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 83 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 84 | |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 85 | Upload Host Image With No Squashfs Via REST |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 86 | # Image File Name |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 87 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 88 | pnor_no_image.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 89 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 90 | [Documentation] Upload a PNOR image with just a MANIFEST file via REST |
| 91 | ... and verify that the BMC does not unpack it. |
| 92 | [Template] Upload Bad Image Via REST And Verify Failure |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 93 | [Tags] Upload_Host_Image_With_No_Squashfs_Via_REST |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 94 | |
| 95 | |
| 96 | Upload BMC Image With Bad Manifest Via REST |
| 97 | # Image File Name |
| 98 | |
| 99 | bmc_bad_manifest.tar |
| 100 | |
| 101 | [Documentation] Upload a BMC image with a bad MANFIEST file via REST and |
| 102 | ... verify that the BMC does not unpack it. |
| 103 | [Template] Upload Bad Image Via REST And Verify Failure |
| 104 | [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_REST |
| 105 | |
| 106 | |
| 107 | Upload BMC Image With No Image Via REST |
| 108 | # Image File Name |
| 109 | |
| 110 | bmc_no_image.tar |
| 111 | |
| 112 | [Documentation] Upload a BMC image with no just a MANIFEST file via REST |
| 113 | ... and verify that the BMC does not unpack it. |
| 114 | [Template] Upload Bad Image Via REST And Verify Failure |
| 115 | [Tags] Upload_BMC_Image_With_No_Image_Via_REST |
| 116 | |
| 117 | |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 118 | Upload Host Image With Bad Manifest Via TFTP |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 119 | # Image File Name |
| 120 | |
| 121 | pnor_bad_manifest.tar |
| 122 | |
| 123 | [Documentation] Upload a PNOR image with a bad MANIFEST file via TFTP and |
| 124 | ... verify that the BMC does not unpack it. |
| 125 | [Template] Upload Bad Image Via TFTP And Verify Failure |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 126 | [Tags] Upload_Host_Image_With_Bad_Manifest_Via_TFTP |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 127 | |
| 128 | |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 129 | Upload Host Image With No Squashfs Via TFTP |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 130 | # Image File Name |
| 131 | |
| 132 | pnor_no_image.tar |
| 133 | |
| 134 | [Documentation] Upload a PNOR image with just a MANIFEST file via TFTP and |
| 135 | ... verify that the BMC does not unpack it. |
| 136 | [Template] Upload Bad Image Via TFTP And Verify Failure |
Charles Paul Hofer | 9a5c722 | 2017-08-03 18:21:08 -0500 | [diff] [blame] | 137 | [Tags] Upload_Host_Image_With_No_Squashfs_Via_TFTP |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 138 | |
| 139 | |
| 140 | Upload BMC Image With Bad Manifest Via TFTP |
| 141 | # Image File Name |
| 142 | |
| 143 | bmc_bad_manifest.tar |
| 144 | |
| 145 | [Documentation] Upload a BMC image with a bad MANIFEST file via TFTP and |
| 146 | ... verify that the BMC does not unpack it. |
| 147 | [Template] Upload Bad Image Via TFTP And Verify Failure |
| 148 | [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_TFTP |
| 149 | |
| 150 | |
| 151 | Upload BMC Image With No Image Via TFTP |
| 152 | # Image File Name |
| 153 | |
| 154 | bmc_no_image.tar |
| 155 | |
| 156 | [Documentation] Upload a BMC image with just a MANIFEST file via TFTP and |
| 157 | ... verify that the BMC does not unpack it. |
| 158 | [Template] Upload Bad Image Via TFTP And Verify Failure |
| 159 | [Tags] Upload_BMC_Image_With_No_Image_Via_TFTP |
| 160 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 161 | |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 162 | *** Keywords *** |
| 163 | |
| 164 | Upload Image Teardown |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 165 | [Documentation] Log FFDC if test fails for debugging purposes. |
| 166 | |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 167 | Close All Connections |
| 168 | FFDC On Test Case Fail |
| 169 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 170 | |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 171 | Upload Post Request |
| 172 | [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs} |
| 173 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 174 | # Description of argument(s): |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 175 | # uri URI for uploading image via REST. |
| 176 | # timeout Time allocated for the REST command to return status. |
| 177 | # quiet If enabled turns off logging to console. |
| 178 | # kwargs A dictionary that maps each keyword to a value. |
| 179 | |
| 180 | Initialize OpenBMC ${timeout} quiet=${quiet} |
| 181 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
| 182 | ${headers}= Create Dictionary Content-Type=application/octet-stream |
| 183 | ... Accept=application/octet-stream |
| 184 | Set To Dictionary ${kwargs} headers ${headers} |
| 185 | Run Keyword If '${quiet}' == '${0}' Log Request method=Post |
| 186 | ... base_uri=${base_uri} args=&{kwargs} |
| 187 | ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout} |
| 188 | Run Keyword If '${quiet}' == '${0}' Log Response ${ret} |
| 189 | Should Be Equal As Strings ${ret.status_code} ${HTTP_OK} |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 190 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 191 | Get Image Version From TFTP Server |
| 192 | [Documentation] Get the version dfound in the MANIFEST file of |
| 193 | ... an image on the given TFTP server. |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 194 | [Arguments] ${tftp_image_file_path} |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 195 | |
| 196 | # Description of argument(s): |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 197 | # tftp_image_file_path The path to the image on the TFTP server. |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 198 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 199 | ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/ |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 200 | ${rc}= OperatingSystem.Run And Return RC |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 201 | ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 202 | Should Be Equal As Integers 0 ${rc} |
| 203 | ... msg=Could not download image to check version. |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 204 | ${version}= Get Version Tar tftp_image.tar |
| 205 | OperatingSystem.Remove File tftp_image.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 206 | [Return] ${version} |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 207 | |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 208 | Upload Image Via REST And Verify Success |
| 209 | [Documentation] Upload an image to the BMC and check that it is unpacked. |
| 210 | |
| 211 | # Upload the given good image to the BMC via REST, and check that the |
| 212 | # BMC has unpacked the image and created a valid D-Bus entry for it. |
| 213 | |
| 214 | [Arguments] ${image_file_path} |
| 215 | |
| 216 | # Description of argument(s): |
| 217 | # image_file_path The path to the image file to upload. |
| 218 | |
| 219 | OperatingSystem.File Should Exist ${image_file_path} |
| 220 | ${image_version}= Get Version Tar ${image_file_path} |
| 221 | ${image_data}= OperatingSystem.Get Binary File ${image_file_path} |
| 222 | Upload Image To BMC /upload/image data=${image_data} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 223 | ${ret} ${version_id}= Verify Image Upload ${image_version} |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 224 | Should Be True ${ret} |
| 225 | |
| 226 | Upload Image Via TFTP And Verify Success |
| 227 | [Documentation] Upload an image to the BMC and check that it was unpacked. |
| 228 | |
| 229 | # Upload the given good image to the BMC via TFTP, and check that the |
| 230 | # BMC has unpacked the image and created a valid D-Bus entry for it. |
| 231 | |
| 232 | [Arguments] ${image_file_name} |
| 233 | |
| 234 | # Description of argument(s): |
| 235 | # image_file_name The name of the image file on the TFTP server. |
| 236 | |
| 237 | @{image}= Create List ${image_file_name} ${TFTP_SERVER} |
| 238 | ${data}= Create Dictionary data=@{image} |
| 239 | ${resp}= OpenBMC Post Request |
| 240 | ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data} |
| 241 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 242 | Sleep 1 minute |
| 243 | ${image_version}= Get Image Version From TFTP Server ${image_file_name} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 244 | ${ret} ${version_id}= Verify Image Upload ${image_version} |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 245 | Should Be True ${ret} |
| 246 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 247 | Upload Bad Image Via REST And Verify Failure |
| 248 | [Documentation] Upload the given bad image to the BMC via REST and check |
| 249 | ... that the BMC did not unpack the invalid image. |
| 250 | [Arguments] ${bad_image_file_name} |
| 251 | |
| 252 | # Description of argument(s): |
| 253 | # image_file_name The name of the bad image to upload via REST. |
| 254 | |
| 255 | ${bad_image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH} |
| 256 | ... ${bad_image_file_name} |
| 257 | OperatingSystem.File Should Exist ${bad_image_file_path} |
| 258 | ... msg=Bad image file ${bad_image_file_name} not found. |
| 259 | ${bad_image_version}= Get Version Tar ${bad_image_file_path} |
| 260 | ${bad_image_data}= OperatingSystem.Get Binary File ${bad_image_file_path} |
| 261 | Upload Post Request /upload/image data=${bad_image_data} |
| 262 | Verify Image Not In BMC Uploads Dir ${bad_image_version} |
| 263 | |
| 264 | Upload Bad Image Via TFTP And Verify Failure |
| 265 | [Documentation] Upload the given bad image to the BMC via TFTP and check |
| 266 | ... that the BMC did not unpack the invalid image. |
| 267 | [Arguments] ${bad_image_file_name} |
| 268 | |
| 269 | # Description of argument(s): |
| 270 | # image_file_name The name of the bad image to upload via TFTP. |
| 271 | |
| 272 | @{image}= Create List ${bad_image_file_name} ${TFTP_SERVER} |
| 273 | ${data}= Create Dictionary data=@{image} |
| 274 | ${resp}= OpenBMC Post Request |
| 275 | ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data} |
| 276 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 277 | ${bad_image_version}= Get Image Version From TFTP Server |
| 278 | ... ${bad_image_file_name} |
| 279 | Verify Image Not In BMC Uploads Dir ${bad_image_version} |