blob: ade0b0b213b53928a8321f4119c97664677691d0 [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>
Charles P. Hofer346c0452017-07-14 15:29:50 -050014... -v BAD_IMAGES_DIR_PATH:<path> test_uploadimage.robot
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050015
16Resource ../lib/connection_client.robot
17Resource ../lib/rest_client.robot
18Resource ../lib/openbmc_ffdc.robot
19Library Collections
20Library String
21Library OperatingSystem
Charles Paul Hoferde7d4082017-08-08 14:41:01 -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 Khanbb8b63f2017-05-24 10:58:01 -050030${upload_dir_path} /tmp/images/
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050031${QUIET} ${1}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050032
33*** Test Cases ***
34
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050035Upload Host Image Via REST
Charles Paul Hofer6b972682017-07-20 11:36:56 -050036 # 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 Hofer9a5c7222017-08-03 18:21:08 -050042 [Tags] Upload_Host_Image_Via_REST
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050043
Charles Paul Hofer6b972682017-07-20 11:36:56 -050044
45Upload 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 Khanfb1f6ae2017-04-26 13:24:41 -050054
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050055Upload Host Image Via TFTP
Charles Paul Hofer6b972682017-07-20 11:36:56 -050056 # 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 Hofer9a5c7222017-08-03 18:21:08 -050062 [Tags] Upload_Host_Image_Via_TFTP
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050063
Charles Paul Hofer6b972682017-07-20 11:36:56 -050064
65Upload 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 Khanfb1f6ae2017-04-26 13:24:41 -050073
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050074
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050075Upload Host Image With Bad Manifest Via REST
Charles P. Hofer346c0452017-07-14 15:29:50 -050076 # Image File Name
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050077
Charles P. Hofer346c0452017-07-14 15:29:50 -050078 pnor_bad_manifest.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050079
Charles P. Hofer346c0452017-07-14 15:29:50 -050080 [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 Hofer9a5c7222017-08-03 18:21:08 -050083 [Tags] Upload_Host_Image_With_Bad_Manifest_Via_REST
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050084
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050085
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050086Upload Host Image With No Squashfs Via REST
Charles P. Hofer346c0452017-07-14 15:29:50 -050087 # Image File Name
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050088
Charles P. Hofer346c0452017-07-14 15:29:50 -050089 pnor_no_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050090
Charles P. Hofer346c0452017-07-14 15:29:50 -050091 [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 Hofer9a5c7222017-08-03 18:21:08 -050094 [Tags] Upload_Host_Image_With_No_Squashfs_Via_REST
Charles P. Hofer346c0452017-07-14 15:29:50 -050095
96
97Upload 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
108Upload 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 Hofer9a5c7222017-08-03 18:21:08 -0500119Upload Host Image With Bad Manifest Via TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500120 # 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 Hofer9a5c7222017-08-03 18:21:08 -0500127 [Tags] Upload_Host_Image_With_Bad_Manifest_Via_TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500128
129
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -0500130Upload Host Image With No Squashfs Via TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500131 # 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 Hofer9a5c7222017-08-03 18:21:08 -0500138 [Tags] Upload_Host_Image_With_No_Squashfs_Via_TFTP
Charles P. Hofer346c0452017-07-14 15:29:50 -0500139
140
141Upload 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
152Upload 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. Hofer1d20acd2017-07-05 15:24:40 -0500162
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500163*** Keywords ***
164
165Upload Image Teardown
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500166 [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 Khanfb1f6ae2017-04-26 13:24:41 -0500170
171 Close All Connections
172 FFDC On Test Case Fail
173
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500174
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500175Upload Post Request
176 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
177
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500178 # Description of argument(s):
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500179 # 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. Hofer1d20acd2017-07-05 15:24:40 -0500194
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500195Get 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. Hofer346c0452017-07-14 15:29:50 -0500198 [Arguments] ${tftp_image_file_path}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500199
200 # Description of argument(s):
Charles P. Hofer346c0452017-07-14 15:29:50 -0500201 # tftp_image_file_path The path to the image on the TFTP server.
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500202
Charles P. Hofer346c0452017-07-14 15:29:50 -0500203 ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500204 ${rc}= OperatingSystem.Run And Return RC
Charles P. Hofer346c0452017-07-14 15:29:50 -0500205 ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500206 Should Be Equal As Integers 0 ${rc}
207 ... msg=Could not download image to check version.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500208 ${version}= Get Version Tar tftp_image.tar
209 OperatingSystem.Remove File tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500210 [Return] ${version}
Charles P. Hofer346c0452017-07-14 15:29:50 -0500211
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500212Upload 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 Hofercef61992017-08-18 10:14:18 -0500227 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500228 Should Be True ${ret}
229
230Upload 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 Hofercef61992017-08-18 10:14:18 -0500248 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500249 Should Be True ${ret}
250
Charles P. Hofer346c0452017-07-14 15:29:50 -0500251Upload 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
268Upload 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}