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 |
Charles Paul Hofer | de7d408 | 2017-08-08 14:41:01 -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 | |
| 167 | Open Connection And Log In |
| 168 | Execute Command On BMC rm -rf /tmp/images/* |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 169 | |
| 170 | Close All Connections |
| 171 | FFDC On Test Case Fail |
| 172 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 173 | |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 174 | Upload Post Request |
| 175 | [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs} |
| 176 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 177 | # Description of argument(s): |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 178 | # uri URI for uploading image via REST. |
| 179 | # timeout Time allocated for the REST command to return status. |
| 180 | # quiet If enabled turns off logging to console. |
| 181 | # kwargs A dictionary that maps each keyword to a value. |
| 182 | |
| 183 | Initialize OpenBMC ${timeout} quiet=${quiet} |
| 184 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
| 185 | ${headers}= Create Dictionary Content-Type=application/octet-stream |
| 186 | ... Accept=application/octet-stream |
| 187 | Set To Dictionary ${kwargs} headers ${headers} |
| 188 | Run Keyword If '${quiet}' == '${0}' Log Request method=Post |
| 189 | ... base_uri=${base_uri} args=&{kwargs} |
| 190 | ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout} |
| 191 | Run Keyword If '${quiet}' == '${0}' Log Response ${ret} |
| 192 | Should Be Equal As Strings ${ret.status_code} ${HTTP_OK} |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 193 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 194 | Get Image Version From TFTP Server |
| 195 | [Documentation] Get the version dfound in the MANIFEST file of |
| 196 | ... an image on the given TFTP server. |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 197 | [Arguments] ${tftp_image_file_path} |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 198 | |
| 199 | # Description of argument(s): |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 200 | # 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] | 201 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 202 | ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/ |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 203 | ${rc}= OperatingSystem.Run And Return RC |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 204 | ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 205 | Should Be Equal As Integers 0 ${rc} |
| 206 | ... msg=Could not download image to check version. |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 207 | ${version}= Get Version Tar tftp_image.tar |
| 208 | OperatingSystem.Remove File tftp_image.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 209 | [Return] ${version} |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 210 | |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 211 | Upload Image Via REST And Verify Success |
| 212 | [Documentation] Upload an image to the BMC and check that it is unpacked. |
| 213 | |
| 214 | # Upload the given good image to the BMC via REST, and check that the |
| 215 | # BMC has unpacked the image and created a valid D-Bus entry for it. |
| 216 | |
| 217 | [Arguments] ${image_file_path} |
| 218 | |
| 219 | # Description of argument(s): |
| 220 | # image_file_path The path to the image file to upload. |
| 221 | |
| 222 | OperatingSystem.File Should Exist ${image_file_path} |
| 223 | ${image_version}= Get Version Tar ${image_file_path} |
| 224 | ${image_data}= OperatingSystem.Get Binary File ${image_file_path} |
| 225 | Upload Image To BMC /upload/image data=${image_data} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 226 | ${ret} ${version_id}= Verify Image Upload ${image_version} |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 227 | Should Be True ${ret} |
| 228 | |
| 229 | Upload Image Via TFTP And Verify Success |
| 230 | [Documentation] Upload an image to the BMC and check that it was unpacked. |
| 231 | |
| 232 | # Upload the given good image to the BMC via TFTP, and check that the |
| 233 | # BMC has unpacked the image and created a valid D-Bus entry for it. |
| 234 | |
| 235 | [Arguments] ${image_file_name} |
| 236 | |
| 237 | # Description of argument(s): |
| 238 | # image_file_name The name of the image file on the TFTP server. |
| 239 | |
| 240 | @{image}= Create List ${image_file_name} ${TFTP_SERVER} |
| 241 | ${data}= Create Dictionary data=@{image} |
| 242 | ${resp}= OpenBMC Post Request |
| 243 | ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data} |
| 244 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 245 | Sleep 1 minute |
| 246 | ${image_version}= Get Image Version From TFTP Server ${image_file_name} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 247 | ${ret} ${version_id}= Verify Image Upload ${image_version} |
Charles Paul Hofer | 6b97268 | 2017-07-20 11:36:56 -0500 | [diff] [blame] | 248 | Should Be True ${ret} |
| 249 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 250 | Upload Bad Image Via REST And Verify Failure |
| 251 | [Documentation] Upload the given bad image to the BMC via REST and check |
| 252 | ... that the BMC did not unpack the invalid image. |
| 253 | [Arguments] ${bad_image_file_name} |
| 254 | |
| 255 | # Description of argument(s): |
| 256 | # image_file_name The name of the bad image to upload via REST. |
| 257 | |
| 258 | ${bad_image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH} |
| 259 | ... ${bad_image_file_name} |
| 260 | OperatingSystem.File Should Exist ${bad_image_file_path} |
| 261 | ... msg=Bad image file ${bad_image_file_name} not found. |
| 262 | ${bad_image_version}= Get Version Tar ${bad_image_file_path} |
| 263 | ${bad_image_data}= OperatingSystem.Get Binary File ${bad_image_file_path} |
| 264 | Upload Post Request /upload/image data=${bad_image_data} |
| 265 | Verify Image Not In BMC Uploads Dir ${bad_image_version} |
| 266 | |
| 267 | Upload Bad Image Via TFTP And Verify Failure |
| 268 | [Documentation] Upload the given bad image to the BMC via TFTP and check |
| 269 | ... that the BMC did not unpack the invalid image. |
| 270 | [Arguments] ${bad_image_file_name} |
| 271 | |
| 272 | # Description of argument(s): |
| 273 | # image_file_name The name of the bad image to upload via TFTP. |
| 274 | |
| 275 | @{image}= Create List ${bad_image_file_name} ${TFTP_SERVER} |
| 276 | ${data}= Create Dictionary data=@{image} |
| 277 | ${resp}= OpenBMC Post Request |
| 278 | ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data} |
| 279 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 280 | ${bad_image_version}= Get Image Version From TFTP Server |
| 281 | ... ${bad_image_file_name} |
| 282 | Verify Image Not In BMC Uploads Dir ${bad_image_version} |