blob: e6bf7ef3f5d0d63fb49ef872f31228032d2b7c12 [file] [log] [blame]
Saqib Khanfb1f6ae2017-04-26 13:24:41 -05001*** Settings ***
Charles P. Hofer1d20acd2017-07-05 15:24:40 -05002Documentation Test upload image with both valid and invalid images.
3... This test expects there to be bad image tarballs named
Charles P. Hofer346c0452017-07-14 15:29:50 -05004... 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 Khanfb1f6ae2017-04-26 13:24:41 -05007... Execution Method :
8... python -m robot -v OPENBMC_HOST:<hostname>
9... -v TFTP_SERVER:<TFTP server IP>
Charles Paul Hofer6b972682017-07-20 11:36:56 -050010... -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 Keishing9571a932017-11-12 12:42:23 -060014... -v BAD_IMAGES_DIR_PATH:<path> test_image_upload.robot
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050015
Charles Paul Hofer7c191de2017-09-27 15:47:47 -050016Resource ../../lib/connection_client.robot
17Resource ../../lib/rest_client.robot
18Resource ../../lib/openbmc_ffdc.robot
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050019Library Collections
20Library String
21Library OperatingSystem
Charles Paul Hofer7c191de2017-09-27 15:47:47 -050022Library ../../lib/code_update_utils.py
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050023
24Test Teardown Upload Image Teardown
25
Sweta Potthuri5db43e42017-06-15 05:36:44 -050026Force Tags Upload_Test
27
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050028*** Variables ***
29${timeout} 10
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050030${QUIET} ${1}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050031
32*** Test Cases ***
33
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050034Upload Host Image Via REST
Charles Paul Hofer6b972682017-07-20 11:36:56 -050035 [Documentation] Upload a PNOR image via REST.
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050036 [Tags] Upload_Host_Image_Via_REST
George Keishing5abfe602018-07-05 11:54:37 -050037 [Template] Upload Image Via REST And Verify Success
38
39 # Image File Path
40 ${PNOR_IMAGE_FILE_PATH}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050041
Charles Paul Hofer6b972682017-07-20 11:36:56 -050042
43Upload BMC Image Via REST
Charles Paul Hofer6b972682017-07-20 11:36:56 -050044 [Documentation] Upload a BMC image via REST.
Charles Paul Hofer6b972682017-07-20 11:36:56 -050045 [Tags] Upload_BMC_Image_Via_REST
George Keishing5abfe602018-07-05 11:54:37 -050046 [Template] Upload Image Via REST And Verify Success
47
48 # Image File Path
49 ${BMC_IMAGE_FILE_PATH}
Charles Paul Hofer6b972682017-07-20 11:36:56 -050050
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050051
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050052Upload Host Image Via TFTP
Charles Paul Hofer6b972682017-07-20 11:36:56 -050053 [Documentation] Upload a PNOR image via TFTP.
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050054 [Tags] Upload_Host_Image_Via_TFTP
George Keishing5abfe602018-07-05 11:54:37 -050055 [Template] Upload Image Via TFTP And Verify Success
56
57 # Image File Path
58 ${PNOR_TFTP_FILE_NAME}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050059
Charles Paul Hofer6b972682017-07-20 11:36:56 -050060
61Upload BMC Image Via TFTP
Charles Paul Hofer6b972682017-07-20 11:36:56 -050062 [Documentation] Upload a BMC image via TFTP
Charles Paul Hofer6b972682017-07-20 11:36:56 -050063 [Tags] Upload_BMC_Image_Via_TFTP
George Keishing5abfe602018-07-05 11:54:37 -050064 [Template] Upload Image Via TFTP And Verify Success
65
66 # Image File Path
67 ${BMC_TFTP_FILE_NAME}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050068
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050069
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050070Upload Host Image With Bad Manifest Via REST
Charles P. Hofer346c0452017-07-14 15:29:50 -050071 [Documentation] Upload a PNOR image with a bad MANIFEST via REST and
72 ... verify that the BMC does not unpack it.
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050073 [Tags] Upload_Host_Image_With_Bad_Manifest_Via_REST
George Keishing5abfe602018-07-05 11:54:37 -050074 [Template] Upload Bad Image Via REST And Verify Failure
75
76 # Image File Name
77 pnor_bad_manifest.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050078
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050079
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050080Upload Host Image With No Squashfs Via REST
Charles P. Hofer346c0452017-07-14 15:29:50 -050081 [Documentation] Upload a PNOR image with just a MANIFEST file via REST
82 ... and verify that the BMC does not unpack it.
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050083 [Tags] Upload_Host_Image_With_No_Squashfs_Via_REST
George Keishing5abfe602018-07-05 11:54:37 -050084 [Template] Upload Bad Image Via REST And Verify Failure
85
86 # Image File Name
87 pnor_no_image.tar
Charles P. Hofer346c0452017-07-14 15:29:50 -050088
89
90Upload BMC Image With Bad Manifest Via REST
Charles P. Hofer346c0452017-07-14 15:29:50 -050091 [Documentation] Upload a BMC image with a bad MANFIEST file via REST and
92 ... verify that the BMC does not unpack it.
Charles P. Hofer346c0452017-07-14 15:29:50 -050093 [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_REST
George Keishing5abfe602018-07-05 11:54:37 -050094 [Template] Upload Bad Image Via REST And Verify Failure
95
96 # Image File Name
97 bmc_bad_manifest.tar
Charles P. Hofer346c0452017-07-14 15:29:50 -050098
99
100Upload BMC Image With No Image Via REST
Charles P. Hofer346c0452017-07-14 15:29:50 -0500101 [Documentation] Upload a BMC image with no just a MANIFEST file via REST
102 ... and verify that the BMC does not unpack it.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500103 [Tags] Upload_BMC_Image_With_No_Image_Via_REST
George Keishing5abfe602018-07-05 11:54:37 -0500104 [Template] Upload Bad Image Via REST And Verify Failure
105
106 # Image File Name
107 bmc_no_image.tar
Charles P. Hofer346c0452017-07-14 15:29:50 -0500108
109
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -0500110Upload Host Image With Bad Manifest Via TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500111 [Documentation] Upload a PNOR image with a bad MANIFEST file via TFTP and
112 ... verify that the BMC does not unpack it.
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -0500113 [Tags] Upload_Host_Image_With_Bad_Manifest_Via_TFTP
George Keishing5abfe602018-07-05 11:54:37 -0500114 [Template] Upload Bad Image Via TFTP And Verify Failure
115
116 # Image File Name
117 pnor_bad_manifest.tar
Charles P. Hofer346c0452017-07-14 15:29:50 -0500118
119
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -0500120Upload Host Image With No Squashfs Via TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500121 [Documentation] Upload a PNOR image with just a MANIFEST file via TFTP and
122 ... verify that the BMC does not unpack it.
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -0500123 [Tags] Upload_Host_Image_With_No_Squashfs_Via_TFTP
George Keishing5abfe602018-07-05 11:54:37 -0500124 [Template] Upload Bad Image Via TFTP And Verify Failure
125
126 # Image File Name
127 pnor_no_image.tar
Charles P. Hofer346c0452017-07-14 15:29:50 -0500128
129
130Upload BMC Image With Bad Manifest Via TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500131 [Documentation] Upload a BMC image with a bad MANIFEST file via TFTP and
132 ... verify that the BMC does not unpack it.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500133 [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_TFTP
George Keishing5abfe602018-07-05 11:54:37 -0500134 [Template] Upload Bad Image Via TFTP And Verify Failure
135
136 # Image File Name
137 bmc_bad_manifest.tar
Charles P. Hofer346c0452017-07-14 15:29:50 -0500138
139
140Upload BMC Image With No Image Via TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500141 [Documentation] Upload a BMC image with just a MANIFEST file via TFTP and
142 ... verify that the BMC does not unpack it.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500143 [Tags] Upload_BMC_Image_With_No_Image_Via_TFTP
George Keishing5abfe602018-07-05 11:54:37 -0500144 [Template] Upload Bad Image Via TFTP And Verify Failure
145
146 # Image File Name
147 bmc_no_image.tar
Charles P. Hofer346c0452017-07-14 15:29:50 -0500148
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500149
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500150*** Keywords ***
151
152Upload Image Teardown
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500153 [Documentation] Log FFDC if test fails for debugging purposes.
154
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500155 Close All Connections
156 FFDC On Test Case Fail
157
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500158
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500159Upload Post Request
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500160 [Documentation] Make POST request.
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500161 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
162
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500163 # Description of argument(s):
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500164 # 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. Hofer1d20acd2017-07-05 15:24:40 -0500179
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500180Get 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. Hofer346c0452017-07-14 15:29:50 -0500183 [Arguments] ${tftp_image_file_path}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500184
185 # Description of argument(s):
Charles P. Hofer346c0452017-07-14 15:29:50 -0500186 # tftp_image_file_path The path to the image on the TFTP server.
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500187
Charles P. Hofer346c0452017-07-14 15:29:50 -0500188 ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500189 ${rc}= OperatingSystem.Run And Return RC
Charles P. Hofer346c0452017-07-14 15:29:50 -0500190 ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500191 Should Be Equal As Integers 0 ${rc}
192 ... msg=Could not download image to check version.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500193 ${version}= Get Version Tar tftp_image.tar
194 OperatingSystem.Remove File tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500195 [Return] ${version}
Charles P. Hofer346c0452017-07-14 15:29:50 -0500196
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500197Upload Image Via REST And Verify Success
198 [Documentation] Upload an image to the BMC and check that it is unpacked.
199
200 # Upload the given good image to the BMC via REST, and check that the
201 # BMC has unpacked the image and created a valid D-Bus entry for it.
202
203 [Arguments] ${image_file_path}
204
205 # Description of argument(s):
206 # image_file_path The path to the image file to upload.
207
208 OperatingSystem.File Should Exist ${image_file_path}
209 ${image_version}= Get Version Tar ${image_file_path}
210 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
211 Upload Image To BMC /upload/image data=${image_data}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500212 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500213 Should Be True ${ret}
214
215Upload Image Via TFTP And Verify Success
216 [Documentation] Upload an image to the BMC and check that it was unpacked.
217
218 # Upload the given good image to the BMC via TFTP, and check that the
219 # BMC has unpacked the image and created a valid D-Bus entry for it.
220
221 [Arguments] ${image_file_name}
222
223 # Description of argument(s):
224 # image_file_name The name of the image file on the TFTP server.
225
226 @{image}= Create List ${image_file_name} ${TFTP_SERVER}
227 ${data}= Create Dictionary data=@{image}
228 ${resp}= OpenBMC Post Request
229 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
230 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
231 Sleep 1 minute
232 ${image_version}= Get Image Version From TFTP Server ${image_file_name}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500233 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500234 Should Be True ${ret}
235
Charles P. Hofer346c0452017-07-14 15:29:50 -0500236Upload Bad Image Via REST And Verify Failure
237 [Documentation] Upload the given bad image to the BMC via REST and check
238 ... that the BMC did not unpack the invalid image.
239 [Arguments] ${bad_image_file_name}
240
241 # Description of argument(s):
242 # image_file_name The name of the bad image to upload via REST.
243
244 ${bad_image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH}
245 ... ${bad_image_file_name}
246 OperatingSystem.File Should Exist ${bad_image_file_path}
247 ... msg=Bad image file ${bad_image_file_name} not found.
248 ${bad_image_version}= Get Version Tar ${bad_image_file_path}
249 ${bad_image_data}= OperatingSystem.Get Binary File ${bad_image_file_path}
250 Upload Post Request /upload/image data=${bad_image_data}
251 Verify Image Not In BMC Uploads Dir ${bad_image_version}
252
253Upload Bad Image Via TFTP And Verify Failure
254 [Documentation] Upload the given bad image to the BMC via TFTP and check
255 ... that the BMC did not unpack the invalid image.
256 [Arguments] ${bad_image_file_name}
257
258 # Description of argument(s):
259 # image_file_name The name of the bad image to upload via TFTP.
260
261 @{image}= Create List ${bad_image_file_name} ${TFTP_SERVER}
262 ${data}= Create Dictionary data=@{image}
263 ${resp}= OpenBMC Post Request
264 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
265 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
266 ${bad_image_version}= Get Image Version From TFTP Server
267 ... ${bad_image_file_name}
268 Verify Image Not In BMC Uploads Dir ${bad_image_version}