blob: 1b536c6ecc7d951068771890fc10948e3f40c4b1 [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
22Library test_uploadimage.py
23
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 Khanbb8b63f2017-05-24 10:58:01 -050032${image_version} ${EMPTY}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050033
34*** Test Cases ***
35
Charles P. Hofer346c0452017-07-14 15:29:50 -050036Upload PNOR Image Via REST
Charles Paul Hofer6b972682017-07-20 11:36:56 -050037 # Image File Path
38
39 ${PNOR_IMAGE_FILE_PATH}
40
41 [Documentation] Upload a PNOR image via REST.
42 [Template] Upload Image Via REST And Verify Success
Charles P. Hofer346c0452017-07-14 15:29:50 -050043 [Tags] Upload_PNOR_Image_Via_REST
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050044
Charles Paul Hofer6b972682017-07-20 11:36:56 -050045
46Upload BMC Image Via REST
47 # Image File Path
48
49 ${BMC_IMAGE_FILE_PATH}
50
51 [Documentation] Upload a BMC image via REST.
52 [Template] Upload Image Via REST And Verify Success
53 [Tags] Upload_BMC_Image_Via_REST
54
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050055
Charles P. Hofer346c0452017-07-14 15:29:50 -050056Upload PNOR Image Via TFTP
Charles Paul Hofer6b972682017-07-20 11:36:56 -050057 # Image File Path
58
59 ${PNOR_TFTP_FILE_NAME}
60
61 [Documentation] Upload a PNOR image via TFTP.
62 [Template] Upload Image Via TFTP And Verify Success
Charles P. Hofer346c0452017-07-14 15:29:50 -050063 [Tags] Upload_PNOR_Image_Via_TFTP
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050064
Charles Paul Hofer6b972682017-07-20 11:36:56 -050065
66Upload BMC Image Via TFTP
67 # Image File Path
68
69 ${BMC_TFTP_FILE_NAME}
70
71 [Documentation] Upload a BMC image via TFTP
72 [Template] Upload Image Via TFTP And Verify Success
73 [Tags] Upload_BMC_Image_Via_TFTP
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050074
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050075
Charles P. Hofer346c0452017-07-14 15:29:50 -050076Upload PNOR Image With Bad Manifest Via REST
77 # Image File Name
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050078
Charles P. Hofer346c0452017-07-14 15:29:50 -050079 pnor_bad_manifest.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050080
Charles P. Hofer346c0452017-07-14 15:29:50 -050081 [Documentation] Upload a PNOR image with a bad MANIFEST via REST and
82 ... verify that the BMC does not unpack it.
83 [Template] Upload Bad Image Via REST And Verify Failure
84 [Tags] Upload_PNOR_Image_With_Bad_Manifest_Via_REST
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050085
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050086
Charles P. Hofer346c0452017-07-14 15:29:50 -050087Upload PNOR Image With No Squashfs Via REST
88 # Image File Name
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050089
Charles P. Hofer346c0452017-07-14 15:29:50 -050090 pnor_no_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050091
Charles P. Hofer346c0452017-07-14 15:29:50 -050092 [Documentation] Upload a PNOR image with just a MANIFEST file via REST
93 ... and verify that the BMC does not unpack it.
94 [Template] Upload Bad Image Via REST And Verify Failure
95 [Tags] Upload_PNOR_Image_With_No_Squashfs_Via_REST
96
97
98Upload BMC Image With Bad Manifest Via REST
99 # Image File Name
100
101 bmc_bad_manifest.tar
102
103 [Documentation] Upload a BMC image with a bad MANFIEST file via REST and
104 ... verify that the BMC does not unpack it.
105 [Template] Upload Bad Image Via REST And Verify Failure
106 [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_REST
107
108
109Upload BMC Image With No Image Via REST
110 # Image File Name
111
112 bmc_no_image.tar
113
114 [Documentation] Upload a BMC image with no just a MANIFEST file via REST
115 ... and verify that the BMC does not unpack it.
116 [Template] Upload Bad Image Via REST And Verify Failure
117 [Tags] Upload_BMC_Image_With_No_Image_Via_REST
118
119
120Upload PNOR Image With Bad Manifest Via TFTP
121 # Image File Name
122
123 pnor_bad_manifest.tar
124
125 [Documentation] Upload a PNOR image with a bad MANIFEST file via TFTP and
126 ... verify that the BMC does not unpack it.
127 [Template] Upload Bad Image Via TFTP And Verify Failure
128 [Tags] Upload_PNOR_Image_With_Bad_Manifest_Via_TFTP
129
130
131Upload PNOR Image With No Squashfs Via TFTP
132 # Image File Name
133
134 pnor_no_image.tar
135
136 [Documentation] Upload a PNOR image with just a MANIFEST file via TFTP and
137 ... verify that the BMC does not unpack it.
138 [Template] Upload Bad Image Via TFTP And Verify Failure
139 [Tags] Upload_PNOR_Image_With_No_Squashfs_Via_TFTP
140
141
142Upload BMC Image With Bad Manifest Via TFTP
143 # Image File Name
144
145 bmc_bad_manifest.tar
146
147 [Documentation] Upload a BMC image with a bad MANIFEST file via TFTP and
148 ... verify that the BMC does not unpack it.
149 [Template] Upload Bad Image Via TFTP And Verify Failure
150 [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_TFTP
151
152
153Upload BMC Image With No Image Via TFTP
154 # Image File Name
155
156 bmc_no_image.tar
157
158 [Documentation] Upload a BMC image with just a MANIFEST file via TFTP and
159 ... verify that the BMC does not unpack it.
160 [Template] Upload Bad Image Via TFTP And Verify Failure
161 [Tags] Upload_BMC_Image_With_No_Image_Via_TFTP
162
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500163
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500164*** Keywords ***
165
166Upload Image Teardown
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500167 [Documentation] Log FFDC if test fails for debugging purposes.
168
169 Open Connection And Log In
170 Execute Command On BMC rm -rf /tmp/images/*
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500171
172 Close All Connections
173 FFDC On Test Case Fail
174
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500175
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500176Upload Post Request
177 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
178
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500179 # Description of argument(s):
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500180 # uri URI for uploading image via REST.
181 # timeout Time allocated for the REST command to return status.
182 # quiet If enabled turns off logging to console.
183 # kwargs A dictionary that maps each keyword to a value.
184
185 Initialize OpenBMC ${timeout} quiet=${quiet}
186 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
187 ${headers}= Create Dictionary Content-Type=application/octet-stream
188 ... Accept=application/octet-stream
189 Set To Dictionary ${kwargs} headers ${headers}
190 Run Keyword If '${quiet}' == '${0}' Log Request method=Post
191 ... base_uri=${base_uri} args=&{kwargs}
192 ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
193 Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
194 Should Be Equal As Strings ${ret.status_code} ${HTTP_OK}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500195
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500196Get Image Version From TFTP Server
197 [Documentation] Get the version dfound in the MANIFEST file of
198 ... an image on the given TFTP server.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500199 [Arguments] ${tftp_image_file_path}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500200
201 # Description of argument(s):
Charles P. Hofer346c0452017-07-14 15:29:50 -0500202 # tftp_image_file_path The path to the image on the TFTP server.
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500203
Charles P. Hofer346c0452017-07-14 15:29:50 -0500204 ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500205 ${rc}= OperatingSystem.Run And Return RC
Charles P. Hofer346c0452017-07-14 15:29:50 -0500206 ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500207 Should Be Equal As Integers 0 ${rc}
208 ... msg=Could not download image to check version.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500209 ${version}= Get Version Tar tftp_image.tar
210 OperatingSystem.Remove File tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500211 [Return] ${version}
Charles P. Hofer346c0452017-07-14 15:29:50 -0500212
Charles Paul Hofer6b972682017-07-20 11:36:56 -0500213Upload Image Via REST And Verify Success
214 [Documentation] Upload an image to the BMC and check that it is unpacked.
215
216 # Upload the given good image to the BMC via REST, and check that the
217 # BMC has unpacked the image and created a valid D-Bus entry for it.
218
219 [Arguments] ${image_file_path}
220
221 # Description of argument(s):
222 # image_file_path The path to the image file to upload.
223
224 OperatingSystem.File Should Exist ${image_file_path}
225 ${image_version}= Get Version Tar ${image_file_path}
226 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
227 Upload Image To BMC /upload/image data=${image_data}
228 ${ret}= Verify Image Upload
229 Should Be True ${ret}
230
231Upload Image Via TFTP And Verify Success
232 [Documentation] Upload an image to the BMC and check that it was unpacked.
233
234 # Upload the given good image to the BMC via TFTP, and check that the
235 # BMC has unpacked the image and created a valid D-Bus entry for it.
236
237 [Arguments] ${image_file_name}
238
239 # Description of argument(s):
240 # image_file_name The name of the image file on the TFTP server.
241
242 @{image}= Create List ${image_file_name} ${TFTP_SERVER}
243 ${data}= Create Dictionary data=@{image}
244 ${resp}= OpenBMC Post Request
245 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
246 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
247 Sleep 1 minute
248 ${image_version}= Get Image Version From TFTP Server ${image_file_name}
249 ${ret}= Verify Image Upload
250 Should Be True ${ret}
251
Charles P. Hofer346c0452017-07-14 15:29:50 -0500252Upload Bad Image Via REST And Verify Failure
253 [Documentation] Upload the given bad image to the BMC via REST and check
254 ... that the BMC did not unpack the invalid image.
255 [Arguments] ${bad_image_file_name}
256
257 # Description of argument(s):
258 # image_file_name The name of the bad image to upload via REST.
259
260 ${bad_image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH}
261 ... ${bad_image_file_name}
262 OperatingSystem.File Should Exist ${bad_image_file_path}
263 ... msg=Bad image file ${bad_image_file_name} not found.
264 ${bad_image_version}= Get Version Tar ${bad_image_file_path}
265 ${bad_image_data}= OperatingSystem.Get Binary File ${bad_image_file_path}
266 Upload Post Request /upload/image data=${bad_image_data}
267 Verify Image Not In BMC Uploads Dir ${bad_image_version}
268
269Upload Bad Image Via TFTP And Verify Failure
270 [Documentation] Upload the given bad image to the BMC via TFTP and check
271 ... that the BMC did not unpack the invalid image.
272 [Arguments] ${bad_image_file_name}
273
274 # Description of argument(s):
275 # image_file_name The name of the bad image to upload via TFTP.
276
277 @{image}= Create List ${bad_image_file_name} ${TFTP_SERVER}
278 ${data}= Create Dictionary data=@{image}
279 ${resp}= OpenBMC Post Request
280 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
281 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
282 ${bad_image_version}= Get Image Version From TFTP Server
283 ... ${bad_image_file_name}
284 Verify Image Not In BMC Uploads Dir ${bad_image_version}