blob: 2fc615fd16a0353371d33dec1ab0b1296ba7b88b [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 # 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 Hofer9a5c7222017-08-03 18:21:08 -050041 [Tags] Upload_Host_Image_Via_REST
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050042
Charles Paul Hofer6b972682017-07-20 11:36:56 -050043
44Upload 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 Khanfb1f6ae2017-04-26 13:24:41 -050053
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050054Upload Host Image Via TFTP
Charles Paul Hofer6b972682017-07-20 11:36:56 -050055 # 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 Hofer9a5c7222017-08-03 18:21:08 -050061 [Tags] Upload_Host_Image_Via_TFTP
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050062
Charles Paul Hofer6b972682017-07-20 11:36:56 -050063
64Upload 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 Khanfb1f6ae2017-04-26 13:24:41 -050072
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050073
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050074Upload Host Image With Bad Manifest Via REST
Charles P. Hofer346c0452017-07-14 15:29:50 -050075 # Image File Name
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050076
Charles P. Hofer346c0452017-07-14 15:29:50 -050077 pnor_bad_manifest.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050078
Charles P. Hofer346c0452017-07-14 15:29:50 -050079 [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 Hofer9a5c7222017-08-03 18:21:08 -050082 [Tags] Upload_Host_Image_With_Bad_Manifest_Via_REST
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050083
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050084
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050085Upload Host Image With No Squashfs Via REST
Charles P. Hofer346c0452017-07-14 15:29:50 -050086 # Image File Name
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050087
Charles P. Hofer346c0452017-07-14 15:29:50 -050088 pnor_no_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050089
Charles P. Hofer346c0452017-07-14 15:29:50 -050090 [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 Hofer9a5c7222017-08-03 18:21:08 -050093 [Tags] Upload_Host_Image_With_No_Squashfs_Via_REST
Charles P. Hofer346c0452017-07-14 15:29:50 -050094
95
96Upload 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
107Upload 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 Hofer9a5c7222017-08-03 18:21:08 -0500118Upload Host Image With Bad Manifest Via TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500119 # 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 Hofer9a5c7222017-08-03 18:21:08 -0500126 [Tags] Upload_Host_Image_With_Bad_Manifest_Via_TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500127
128
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -0500129Upload Host Image With No Squashfs Via TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500130 # 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 Hofer9a5c7222017-08-03 18:21:08 -0500137 [Tags] Upload_Host_Image_With_No_Squashfs_Via_TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500138
139
140Upload 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
151Upload 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. Hofer1d20acd2017-07-05 15:24:40 -0500161
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500162*** Keywords ***
163
164Upload Image Teardown
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500165 [Documentation] Log FFDC if test fails for debugging purposes.
166
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500167 Close All Connections
168 FFDC On Test Case Fail
169
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500170
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500171Upload Post Request
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500172 [Documentation] Make POST request.
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500173 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
174
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500175 # Description of argument(s):
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500176 # uri URI for uploading image via REST.
177 # timeout Time allocated for the REST command to return status.
178 # quiet If enabled turns off logging to console.
179 # kwargs A dictionary that maps each keyword to a value.
180
181 Initialize OpenBMC ${timeout} quiet=${quiet}
182 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
183 ${headers}= Create Dictionary Content-Type=application/octet-stream
184 ... Accept=application/octet-stream
185 Set To Dictionary ${kwargs} headers ${headers}
186 Run Keyword If '${quiet}' == '${0}' Log Request method=Post
187 ... base_uri=${base_uri} args=&{kwargs}
188 ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
189 Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
190 Should Be Equal As Strings ${ret.status_code} ${HTTP_OK}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500191
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500192Get Image Version From TFTP Server
193 [Documentation] Get the version dfound in the MANIFEST file of
194 ... an image on the given TFTP server.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500195 [Arguments] ${tftp_image_file_path}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500196
197 # Description of argument(s):
Charles P. Hofer346c0452017-07-14 15:29:50 -0500198 # tftp_image_file_path The path to the image on the TFTP server.
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500199
Charles P. Hofer346c0452017-07-14 15:29:50 -0500200 ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500201 ${rc}= OperatingSystem.Run And Return RC
Charles P. Hofer346c0452017-07-14 15:29:50 -0500202 ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500203 Should Be Equal As Integers 0 ${rc}
204 ... msg=Could not download image to check version.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500205 ${version}= Get Version Tar tftp_image.tar
206 OperatingSystem.Remove File tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500207 [Return] ${version}
Charles P. Hofer346c0452017-07-14 15:29:50 -0500208
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500209Upload Image Via REST And Verify Success
210 [Documentation] Upload an image to the BMC and check that it is unpacked.
211
212 # Upload the given good image to the BMC via REST, and check that the
213 # BMC has unpacked the image and created a valid D-Bus entry for it.
214
215 [Arguments] ${image_file_path}
216
217 # Description of argument(s):
218 # image_file_path The path to the image file to upload.
219
220 OperatingSystem.File Should Exist ${image_file_path}
221 ${image_version}= Get Version Tar ${image_file_path}
222 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
223 Upload Image To BMC /upload/image data=${image_data}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500224 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500225 Should Be True ${ret}
226
227Upload Image Via TFTP And Verify Success
228 [Documentation] Upload an image to the BMC and check that it was unpacked.
229
230 # Upload the given good image to the BMC via TFTP, and check that the
231 # BMC has unpacked the image and created a valid D-Bus entry for it.
232
233 [Arguments] ${image_file_name}
234
235 # Description of argument(s):
236 # image_file_name The name of the image file on the TFTP server.
237
238 @{image}= Create List ${image_file_name} ${TFTP_SERVER}
239 ${data}= Create Dictionary data=@{image}
240 ${resp}= OpenBMC Post Request
241 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
242 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
243 Sleep 1 minute
244 ${image_version}= Get Image Version From TFTP Server ${image_file_name}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500245 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500246 Should Be True ${ret}
247
Charles P. Hofer346c0452017-07-14 15:29:50 -0500248Upload Bad Image Via REST And Verify Failure
249 [Documentation] Upload the given bad image to the BMC via REST and check
250 ... that the BMC did not unpack the invalid image.
251 [Arguments] ${bad_image_file_name}
252
253 # Description of argument(s):
254 # image_file_name The name of the bad image to upload via REST.
255
256 ${bad_image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH}
257 ... ${bad_image_file_name}
258 OperatingSystem.File Should Exist ${bad_image_file_path}
259 ... msg=Bad image file ${bad_image_file_name} not found.
260 ${bad_image_version}= Get Version Tar ${bad_image_file_path}
261 ${bad_image_data}= OperatingSystem.Get Binary File ${bad_image_file_path}
262 Upload Post Request /upload/image data=${bad_image_data}
263 Verify Image Not In BMC Uploads Dir ${bad_image_version}
264
265Upload Bad Image Via TFTP And Verify Failure
266 [Documentation] Upload the given bad image to the BMC via TFTP and check
267 ... that the BMC did not unpack the invalid image.
268 [Arguments] ${bad_image_file_name}
269
270 # Description of argument(s):
271 # image_file_name The name of the bad image to upload via TFTP.
272
273 @{image}= Create List ${bad_image_file_name} ${TFTP_SERVER}
274 ${data}= Create Dictionary data=@{image}
275 ${resp}= OpenBMC Post Request
276 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
277 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
278 ${bad_image_version}= Get Image Version From TFTP Server
279 ... ${bad_image_file_name}
280 Verify Image Not In BMC Uploads Dir ${bad_image_version}