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