blob: 28c903f225375f9ba312a40625f24484288d9951 [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
172 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
173
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500174 # Description of argument(s):
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500175 # uri URI for uploading image via REST.
176 # timeout Time allocated for the REST command to return status.
177 # quiet If enabled turns off logging to console.
178 # kwargs A dictionary that maps each keyword to a value.
179
180 Initialize OpenBMC ${timeout} quiet=${quiet}
181 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
182 ${headers}= Create Dictionary Content-Type=application/octet-stream
183 ... Accept=application/octet-stream
184 Set To Dictionary ${kwargs} headers ${headers}
185 Run Keyword If '${quiet}' == '${0}' Log Request method=Post
186 ... base_uri=${base_uri} args=&{kwargs}
187 ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
188 Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
189 Should Be Equal As Strings ${ret.status_code} ${HTTP_OK}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500190
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500191Get Image Version From TFTP Server
192 [Documentation] Get the version dfound in the MANIFEST file of
193 ... an image on the given TFTP server.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500194 [Arguments] ${tftp_image_file_path}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500195
196 # Description of argument(s):
Charles P. Hofer346c0452017-07-14 15:29:50 -0500197 # tftp_image_file_path The path to the image on the TFTP server.
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500198
Charles P. Hofer346c0452017-07-14 15:29:50 -0500199 ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500200 ${rc}= OperatingSystem.Run And Return RC
Charles P. Hofer346c0452017-07-14 15:29:50 -0500201 ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500202 Should Be Equal As Integers 0 ${rc}
203 ... msg=Could not download image to check version.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500204 ${version}= Get Version Tar tftp_image.tar
205 OperatingSystem.Remove File tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500206 [Return] ${version}
Charles P. Hofer346c0452017-07-14 15:29:50 -0500207
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500208Upload Image Via REST And Verify Success
209 [Documentation] Upload an image to the BMC and check that it is unpacked.
210
211 # Upload the given good image to the BMC via REST, and check that the
212 # BMC has unpacked the image and created a valid D-Bus entry for it.
213
214 [Arguments] ${image_file_path}
215
216 # Description of argument(s):
217 # image_file_path The path to the image file to upload.
218
219 OperatingSystem.File Should Exist ${image_file_path}
220 ${image_version}= Get Version Tar ${image_file_path}
221 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
222 Upload Image To BMC /upload/image data=${image_data}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500223 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500224 Should Be True ${ret}
225
226Upload Image Via TFTP And Verify Success
227 [Documentation] Upload an image to the BMC and check that it was unpacked.
228
229 # Upload the given good image to the BMC via TFTP, and check that the
230 # BMC has unpacked the image and created a valid D-Bus entry for it.
231
232 [Arguments] ${image_file_name}
233
234 # Description of argument(s):
235 # image_file_name The name of the image file on the TFTP server.
236
237 @{image}= Create List ${image_file_name} ${TFTP_SERVER}
238 ${data}= Create Dictionary data=@{image}
239 ${resp}= OpenBMC Post Request
240 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
241 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
242 Sleep 1 minute
243 ${image_version}= Get Image Version From TFTP Server ${image_file_name}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500244 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500245 Should Be True ${ret}
246
Charles P. Hofer346c0452017-07-14 15:29:50 -0500247Upload Bad Image Via REST And Verify Failure
248 [Documentation] Upload the given bad image to the BMC via REST and check
249 ... that the BMC did not unpack the invalid image.
250 [Arguments] ${bad_image_file_name}
251
252 # Description of argument(s):
253 # image_file_name The name of the bad image to upload via REST.
254
255 ${bad_image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH}
256 ... ${bad_image_file_name}
257 OperatingSystem.File Should Exist ${bad_image_file_path}
258 ... msg=Bad image file ${bad_image_file_name} not found.
259 ${bad_image_version}= Get Version Tar ${bad_image_file_path}
260 ${bad_image_data}= OperatingSystem.Get Binary File ${bad_image_file_path}
261 Upload Post Request /upload/image data=${bad_image_data}
262 Verify Image Not In BMC Uploads Dir ${bad_image_version}
263
264Upload Bad Image Via TFTP And Verify Failure
265 [Documentation] Upload the given bad image to the BMC via TFTP and check
266 ... that the BMC did not unpack the invalid image.
267 [Arguments] ${bad_image_file_name}
268
269 # Description of argument(s):
270 # image_file_name The name of the bad image to upload via TFTP.
271
272 @{image}= Create List ${bad_image_file_name} ${TFTP_SERVER}
273 ${data}= Create Dictionary data=@{image}
274 ${resp}= OpenBMC Post Request
275 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
276 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
277 ${bad_image_version}= Get Image Version From TFTP Server
278 ... ${bad_image_file_name}
279 Verify Image Not In BMC Uploads Dir ${bad_image_version}