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