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> |
| 10 | ... -v TFTP_FILE_NAME:<filename.tar> |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 11 | ... -v IMAGE_FILE_PATH:<path/*.tar> |
| 12 | ... -v BAD_IMAGES_DIR_PATH:<path> test_uploadimage.robot |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 13 | |
| 14 | Resource ../lib/connection_client.robot |
| 15 | Resource ../lib/rest_client.robot |
| 16 | Resource ../lib/openbmc_ffdc.robot |
| 17 | Library Collections |
| 18 | Library String |
| 19 | Library OperatingSystem |
| 20 | Library test_uploadimage.py |
| 21 | |
| 22 | Test Teardown Upload Image Teardown |
| 23 | |
Sweta Potthuri | 5db43e4 | 2017-06-15 05:36:44 -0500 | [diff] [blame] | 24 | Force Tags Upload_Test |
| 25 | |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 26 | *** Variables *** |
| 27 | ${timeout} 10 |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 28 | ${upload_dir_path} /tmp/images/ |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 29 | ${QUIET} ${1} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 30 | ${image_version} ${EMPTY} |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 31 | |
| 32 | *** Test Cases *** |
| 33 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 34 | Upload PNOR Image Via REST |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 35 | [Documentation] Upload an image via REST. |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 36 | [Tags] Upload_PNOR_Image_Via_REST |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 37 | |
| 38 | OperatingSystem.File Should Exist ${IMAGE_FILE_PATH} |
| 39 | ${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH} |
| 40 | ${image_data}= OperatingSystem.Get Binary File ${IMAGE_FILE_PATH} |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 41 | Upload Image To BMC /upload/image data=${image_data} |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 42 | ${ret}= Verify Image Upload |
| 43 | Should Be True True == ${ret} |
| 44 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 45 | Upload PNOR Image Via TFTP |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 46 | [Documentation] Upload an image via TFTP. |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 47 | [Tags] Upload_PNOR_Image_Via_TFTP |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 48 | |
| 49 | @{image}= Create List ${TFTP_FILE_NAME} ${TFTP_SERVER} |
| 50 | ${data}= Create Dictionary data=@{image} |
| 51 | ${resp}= OpenBMC Post Request |
George Keishing | ff1e3ec | 2017-07-20 01:58:21 -0500 | [diff] [blame] | 52 | ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data} |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 53 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 54 | Sleep 1 minute |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 55 | ${image_version}= Get Image Version From TFTP Server ${TFTP_FILE_NAME} |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 56 | ${ret}= Verify Image Upload |
| 57 | Should Be True True == ${ret} |
| 58 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 59 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 60 | Upload PNOR Image With Bad Manifest Via REST |
| 61 | # Image File Name |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 62 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 63 | pnor_bad_manifest.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 64 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 65 | [Documentation] Upload a PNOR image with a bad MANIFEST via REST and |
| 66 | ... verify that the BMC does not unpack it. |
| 67 | [Template] Upload Bad Image Via REST And Verify Failure |
| 68 | [Tags] Upload_PNOR_Image_With_Bad_Manifest_Via_REST |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 69 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 70 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 71 | Upload PNOR Image With No Squashfs Via REST |
| 72 | # Image File Name |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 73 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 74 | pnor_no_image.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 75 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 76 | [Documentation] Upload a PNOR image with just a MANIFEST file via REST |
| 77 | ... and verify that the BMC does not unpack it. |
| 78 | [Template] Upload Bad Image Via REST And Verify Failure |
| 79 | [Tags] Upload_PNOR_Image_With_No_Squashfs_Via_REST |
| 80 | |
| 81 | |
| 82 | Upload BMC Image With Bad Manifest Via REST |
| 83 | # Image File Name |
| 84 | |
| 85 | bmc_bad_manifest.tar |
| 86 | |
| 87 | [Documentation] Upload a BMC image with a bad MANFIEST file via REST and |
| 88 | ... verify that the BMC does not unpack it. |
| 89 | [Template] Upload Bad Image Via REST And Verify Failure |
| 90 | [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_REST |
| 91 | |
| 92 | |
| 93 | Upload BMC Image With No Image Via REST |
| 94 | # Image File Name |
| 95 | |
| 96 | bmc_no_image.tar |
| 97 | |
| 98 | [Documentation] Upload a BMC image with no just a MANIFEST file via REST |
| 99 | ... and verify that the BMC does not unpack it. |
| 100 | [Template] Upload Bad Image Via REST And Verify Failure |
| 101 | [Tags] Upload_BMC_Image_With_No_Image_Via_REST |
| 102 | |
| 103 | |
| 104 | Upload PNOR Image With Bad Manifest Via TFTP |
| 105 | # Image File Name |
| 106 | |
| 107 | pnor_bad_manifest.tar |
| 108 | |
| 109 | [Documentation] Upload a PNOR image with a bad MANIFEST file via TFTP and |
| 110 | ... verify that the BMC does not unpack it. |
| 111 | [Template] Upload Bad Image Via TFTP And Verify Failure |
| 112 | [Tags] Upload_PNOR_Image_With_Bad_Manifest_Via_TFTP |
| 113 | |
| 114 | |
| 115 | Upload PNOR Image With No Squashfs Via TFTP |
| 116 | # Image File Name |
| 117 | |
| 118 | pnor_no_image.tar |
| 119 | |
| 120 | [Documentation] Upload a PNOR image with just a MANIFEST file via TFTP and |
| 121 | ... verify that the BMC does not unpack it. |
| 122 | [Template] Upload Bad Image Via TFTP And Verify Failure |
| 123 | [Tags] Upload_PNOR_Image_With_No_Squashfs_Via_TFTP |
| 124 | |
| 125 | |
| 126 | Upload BMC Image With Bad Manifest Via TFTP |
| 127 | # Image File Name |
| 128 | |
| 129 | bmc_bad_manifest.tar |
| 130 | |
| 131 | [Documentation] Upload a BMC image with a bad MANIFEST file via TFTP and |
| 132 | ... verify that the BMC does not unpack it. |
| 133 | [Template] Upload Bad Image Via TFTP And Verify Failure |
| 134 | [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_TFTP |
| 135 | |
| 136 | |
| 137 | Upload BMC Image With No Image Via TFTP |
| 138 | # Image File Name |
| 139 | |
| 140 | bmc_no_image.tar |
| 141 | |
| 142 | [Documentation] Upload a BMC image with just a MANIFEST file via TFTP and |
| 143 | ... verify that the BMC does not unpack it. |
| 144 | [Template] Upload Bad Image Via TFTP And Verify Failure |
| 145 | [Tags] Upload_BMC_Image_With_No_Image_Via_TFTP |
| 146 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 147 | |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 148 | *** Keywords *** |
| 149 | |
| 150 | Upload Image Teardown |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 151 | [Documentation] Log FFDC if test fails for debugging purposes. |
| 152 | |
| 153 | Open Connection And Log In |
| 154 | Execute Command On BMC rm -rf /tmp/images/* |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 155 | |
| 156 | Close All Connections |
| 157 | FFDC On Test Case Fail |
| 158 | |
Saqib Khan | bb8b63f | 2017-05-24 10:58:01 -0500 | [diff] [blame] | 159 | |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 160 | Upload Post Request |
| 161 | [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs} |
| 162 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 163 | # Description of argument(s): |
Saqib Khan | fb1f6ae | 2017-04-26 13:24:41 -0500 | [diff] [blame] | 164 | # uri URI for uploading image via REST. |
| 165 | # timeout Time allocated for the REST command to return status. |
| 166 | # quiet If enabled turns off logging to console. |
| 167 | # kwargs A dictionary that maps each keyword to a value. |
| 168 | |
| 169 | Initialize OpenBMC ${timeout} quiet=${quiet} |
| 170 | ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri} |
| 171 | ${headers}= Create Dictionary Content-Type=application/octet-stream |
| 172 | ... Accept=application/octet-stream |
| 173 | Set To Dictionary ${kwargs} headers ${headers} |
| 174 | Run Keyword If '${quiet}' == '${0}' Log Request method=Post |
| 175 | ... base_uri=${base_uri} args=&{kwargs} |
| 176 | ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout} |
| 177 | Run Keyword If '${quiet}' == '${0}' Log Response ${ret} |
| 178 | Should Be Equal As Strings ${ret.status_code} ${HTTP_OK} |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 179 | |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 180 | Get Image Version From TFTP Server |
| 181 | [Documentation] Get the version dfound in the MANIFEST file of |
| 182 | ... an image on the given TFTP server. |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 183 | [Arguments] ${tftp_image_file_path} |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 184 | |
| 185 | # Description of argument(s): |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 186 | # 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] | 187 | |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 188 | ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/ |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 189 | ${rc}= OperatingSystem.Run And Return RC |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 190 | ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 191 | Should Be Equal As Integers 0 ${rc} |
| 192 | ... msg=Could not download image to check version. |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 193 | ${version}= Get Version Tar tftp_image.tar |
| 194 | OperatingSystem.Remove File tftp_image.tar |
Charles P. Hofer | 1d20acd | 2017-07-05 15:24:40 -0500 | [diff] [blame] | 195 | [Return] ${version} |
Charles P. Hofer | 346c045 | 2017-07-14 15:29:50 -0500 | [diff] [blame] | 196 | |
| 197 | Upload Bad Image Via REST And Verify Failure |
| 198 | [Documentation] Upload the given bad image to the BMC via REST and check |
| 199 | ... that the BMC did not unpack the invalid image. |
| 200 | [Arguments] ${bad_image_file_name} |
| 201 | |
| 202 | # Description of argument(s): |
| 203 | # image_file_name The name of the bad image to upload via REST. |
| 204 | |
| 205 | ${bad_image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH} |
| 206 | ... ${bad_image_file_name} |
| 207 | OperatingSystem.File Should Exist ${bad_image_file_path} |
| 208 | ... msg=Bad image file ${bad_image_file_name} not found. |
| 209 | ${bad_image_version}= Get Version Tar ${bad_image_file_path} |
| 210 | ${bad_image_data}= OperatingSystem.Get Binary File ${bad_image_file_path} |
| 211 | Upload Post Request /upload/image data=${bad_image_data} |
| 212 | Verify Image Not In BMC Uploads Dir ${bad_image_version} |
| 213 | |
| 214 | Upload Bad Image Via TFTP And Verify Failure |
| 215 | [Documentation] Upload the given bad image to the BMC via TFTP and check |
| 216 | ... that the BMC did not unpack the invalid image. |
| 217 | [Arguments] ${bad_image_file_name} |
| 218 | |
| 219 | # Description of argument(s): |
| 220 | # image_file_name The name of the bad image to upload via TFTP. |
| 221 | |
| 222 | @{image}= Create List ${bad_image_file_name} ${TFTP_SERVER} |
| 223 | ${data}= Create Dictionary data=@{image} |
| 224 | ${resp}= OpenBMC Post Request |
| 225 | ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data} |
| 226 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 227 | ${bad_image_version}= Get Image Version From TFTP Server |
| 228 | ... ${bad_image_file_name} |
| 229 | Verify Image Not In BMC Uploads Dir ${bad_image_version} |