blob: f15c86bc9852cc67a4b81ecb9a0140edf09318dc [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
167 Open Connection And Log In
168 Execute Command On BMC rm -rf /tmp/images/*
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500169
170 Close All Connections
171 FFDC On Test Case Fail
172
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500173
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500174Upload Post Request
175 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
176
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500177 # Description of argument(s):
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500178 # uri URI for uploading image via REST.
179 # timeout Time allocated for the REST command to return status.
180 # quiet If enabled turns off logging to console.
181 # kwargs A dictionary that maps each keyword to a value.
182
183 Initialize OpenBMC ${timeout} quiet=${quiet}
184 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
185 ${headers}= Create Dictionary Content-Type=application/octet-stream
186 ... Accept=application/octet-stream
187 Set To Dictionary ${kwargs} headers ${headers}
188 Run Keyword If '${quiet}' == '${0}' Log Request method=Post
189 ... base_uri=${base_uri} args=&{kwargs}
190 ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
191 Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
192 Should Be Equal As Strings ${ret.status_code} ${HTTP_OK}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500193
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500194Get Image Version From TFTP Server
195 [Documentation] Get the version dfound in the MANIFEST file of
196 ... an image on the given TFTP server.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500197 [Arguments] ${tftp_image_file_path}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500198
199 # Description of argument(s):
Charles P. Hofer346c0452017-07-14 15:29:50 -0500200 # tftp_image_file_path The path to the image on the TFTP server.
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500201
Charles P. Hofer346c0452017-07-14 15:29:50 -0500202 ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500203 ${rc}= OperatingSystem.Run And Return RC
Charles P. Hofer346c0452017-07-14 15:29:50 -0500204 ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500205 Should Be Equal As Integers 0 ${rc}
206 ... msg=Could not download image to check version.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500207 ${version}= Get Version Tar tftp_image.tar
208 OperatingSystem.Remove File tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500209 [Return] ${version}
Charles P. Hofer346c0452017-07-14 15:29:50 -0500210
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500211Upload Image Via REST And Verify Success
212 [Documentation] Upload an image to the BMC and check that it is unpacked.
213
214 # Upload the given good image to the BMC via REST, and check that the
215 # BMC has unpacked the image and created a valid D-Bus entry for it.
216
217 [Arguments] ${image_file_path}
218
219 # Description of argument(s):
220 # image_file_path The path to the image file to upload.
221
222 OperatingSystem.File Should Exist ${image_file_path}
223 ${image_version}= Get Version Tar ${image_file_path}
224 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
225 Upload Image To BMC /upload/image data=${image_data}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500226 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500227 Should Be True ${ret}
228
229Upload Image Via TFTP And Verify Success
230 [Documentation] Upload an image to the BMC and check that it was unpacked.
231
232 # Upload the given good image to the BMC via TFTP, and check that the
233 # BMC has unpacked the image and created a valid D-Bus entry for it.
234
235 [Arguments] ${image_file_name}
236
237 # Description of argument(s):
238 # image_file_name The name of the image file on the TFTP server.
239
240 @{image}= Create List ${image_file_name} ${TFTP_SERVER}
241 ${data}= Create Dictionary data=@{image}
242 ${resp}= OpenBMC Post Request
243 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
244 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
245 Sleep 1 minute
246 ${image_version}= Get Image Version From TFTP Server ${image_file_name}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500247 ${ret} ${version_id}= Verify Image Upload ${image_version}
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500248 Should Be True ${ret}
249
Charles P. Hofer346c0452017-07-14 15:29:50 -0500250Upload Bad Image Via REST And Verify Failure
251 [Documentation] Upload the given bad image to the BMC via REST and check
252 ... that the BMC did not unpack the invalid image.
253 [Arguments] ${bad_image_file_name}
254
255 # Description of argument(s):
256 # image_file_name The name of the bad image to upload via REST.
257
258 ${bad_image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH}
259 ... ${bad_image_file_name}
260 OperatingSystem.File Should Exist ${bad_image_file_path}
261 ... msg=Bad image file ${bad_image_file_name} not found.
262 ${bad_image_version}= Get Version Tar ${bad_image_file_path}
263 ${bad_image_data}= OperatingSystem.Get Binary File ${bad_image_file_path}
264 Upload Post Request /upload/image data=${bad_image_data}
265 Verify Image Not In BMC Uploads Dir ${bad_image_version}
266
267Upload Bad Image Via TFTP And Verify Failure
268 [Documentation] Upload the given bad image to the BMC via TFTP and check
269 ... that the BMC did not unpack the invalid image.
270 [Arguments] ${bad_image_file_name}
271
272 # Description of argument(s):
273 # image_file_name The name of the bad image to upload via TFTP.
274
275 @{image}= Create List ${bad_image_file_name} ${TFTP_SERVER}
276 ${data}= Create Dictionary data=@{image}
277 ${resp}= OpenBMC Post Request
278 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
279 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
280 ${bad_image_version}= Get Image Version From TFTP Server
281 ... ${bad_image_file_name}
282 Verify Image Not In BMC Uploads Dir ${bad_image_version}