blob: a362e5cc62b48c185af3c30d29c06430cc11adfc [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>
10... -v TFTP_FILE_NAME:<filename.tar>
Charles P. Hofer346c0452017-07-14 15:29:50 -050011... -v IMAGE_FILE_PATH:<path/*.tar>
12... -v BAD_IMAGES_DIR_PATH:<path> test_uploadimage.robot
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050013
14Resource ../lib/connection_client.robot
15Resource ../lib/rest_client.robot
16Resource ../lib/openbmc_ffdc.robot
17Library Collections
18Library String
19Library OperatingSystem
20Library test_uploadimage.py
21
22Test Teardown Upload Image Teardown
23
Sweta Potthuri5db43e42017-06-15 05:36:44 -050024Force Tags Upload_Test
25
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050026*** Variables ***
27${timeout} 10
Saqib Khanbb8b63f2017-05-24 10:58:01 -050028${upload_dir_path} /tmp/images/
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050029${QUIET} ${1}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050030${image_version} ${EMPTY}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050031
32*** Test Cases ***
33
Charles P. Hofer346c0452017-07-14 15:29:50 -050034Upload PNOR Image Via REST
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050035 [Documentation] Upload an image via REST.
Charles P. Hofer346c0452017-07-14 15:29:50 -050036 [Tags] Upload_PNOR_Image_Via_REST
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050037
38 OperatingSystem.File Should Exist ${IMAGE_FILE_PATH}
39 ${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH}
40 ${image_data}= OperatingSystem.Get Binary File ${IMAGE_FILE_PATH}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050041 Upload Image To BMC /upload/image data=${image_data}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050042 ${ret}= Verify Image Upload
43 Should Be True True == ${ret}
44
Charles P. Hofer346c0452017-07-14 15:29:50 -050045Upload PNOR Image Via TFTP
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050046 [Documentation] Upload an image via TFTP.
Charles P. Hofer346c0452017-07-14 15:29:50 -050047 [Tags] Upload_PNOR_Image_Via_TFTP
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050048
49 @{image}= Create List ${TFTP_FILE_NAME} ${TFTP_SERVER}
50 ${data}= Create Dictionary data=@{image}
51 ${resp}= OpenBMC Post Request
George Keishingff1e3ec2017-07-20 01:58:21 -050052 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050053 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
54 Sleep 1 minute
Charles P. Hofer346c0452017-07-14 15:29:50 -050055 ${image_version}= Get Image Version From TFTP Server ${TFTP_FILE_NAME}
Saqib Khanfb1f6ae2017-04-26 13:24:41 -050056 ${ret}= Verify Image Upload
57 Should Be True True == ${ret}
58
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050059
Charles P. Hofer346c0452017-07-14 15:29:50 -050060Upload PNOR Image With Bad Manifest Via REST
61 # Image File Name
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050062
Charles P. Hofer346c0452017-07-14 15:29:50 -050063 pnor_bad_manifest.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050064
Charles P. Hofer346c0452017-07-14 15:29:50 -050065 [Documentation] Upload a PNOR image with a bad MANIFEST via REST and
66 ... verify that the BMC does not unpack it.
67 [Template] Upload Bad Image Via REST And Verify Failure
68 [Tags] Upload_PNOR_Image_With_Bad_Manifest_Via_REST
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050069
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050070
Charles P. Hofer346c0452017-07-14 15:29:50 -050071Upload PNOR Image With No Squashfs Via REST
72 # Image File Name
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050073
Charles P. Hofer346c0452017-07-14 15:29:50 -050074 pnor_no_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -050075
Charles P. Hofer346c0452017-07-14 15:29:50 -050076 [Documentation] Upload a PNOR image with just a MANIFEST file via REST
77 ... and verify that the BMC does not unpack it.
78 [Template] Upload Bad Image Via REST And Verify Failure
79 [Tags] Upload_PNOR_Image_With_No_Squashfs_Via_REST
80
81
82Upload BMC Image With Bad Manifest Via REST
83 # Image File Name
84
85 bmc_bad_manifest.tar
86
87 [Documentation] Upload a BMC image with a bad MANFIEST file via REST and
88 ... verify that the BMC does not unpack it.
89 [Template] Upload Bad Image Via REST And Verify Failure
90 [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_REST
91
92
93Upload BMC Image With No Image Via REST
94 # Image File Name
95
96 bmc_no_image.tar
97
98 [Documentation] Upload a BMC image with no just a MANIFEST file via REST
99 ... and verify that the BMC does not unpack it.
100 [Template] Upload Bad Image Via REST And Verify Failure
101 [Tags] Upload_BMC_Image_With_No_Image_Via_REST
102
103
104Upload PNOR Image With Bad Manifest Via TFTP
105 # Image File Name
106
107 pnor_bad_manifest.tar
108
109 [Documentation] Upload a PNOR image with a bad MANIFEST file via TFTP and
110 ... verify that the BMC does not unpack it.
111 [Template] Upload Bad Image Via TFTP And Verify Failure
112 [Tags] Upload_PNOR_Image_With_Bad_Manifest_Via_TFTP
113
114
115Upload PNOR Image With No Squashfs Via TFTP
116 # Image File Name
117
118 pnor_no_image.tar
119
120 [Documentation] Upload a PNOR image with just a MANIFEST file via TFTP and
121 ... verify that the BMC does not unpack it.
122 [Template] Upload Bad Image Via TFTP And Verify Failure
123 [Tags] Upload_PNOR_Image_With_No_Squashfs_Via_TFTP
124
125
126Upload BMC Image With Bad Manifest Via TFTP
127 # Image File Name
128
129 bmc_bad_manifest.tar
130
131 [Documentation] Upload a BMC image with a bad MANIFEST file via TFTP and
132 ... verify that the BMC does not unpack it.
133 [Template] Upload Bad Image Via TFTP And Verify Failure
134 [Tags] Upload_BMC_Image_With_Bad_Manifest_Via_TFTP
135
136
137Upload BMC Image With No Image Via TFTP
138 # Image File Name
139
140 bmc_no_image.tar
141
142 [Documentation] Upload a BMC image with just a MANIFEST file via TFTP and
143 ... verify that the BMC does not unpack it.
144 [Template] Upload Bad Image Via TFTP And Verify Failure
145 [Tags] Upload_BMC_Image_With_No_Image_Via_TFTP
146
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500147
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500148*** Keywords ***
149
150Upload Image Teardown
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500151 [Documentation] Log FFDC if test fails for debugging purposes.
152
153 Open Connection And Log In
154 Execute Command On BMC rm -rf /tmp/images/*
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500155
156 Close All Connections
157 FFDC On Test Case Fail
158
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500159
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500160Upload Post Request
161 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
162
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500163 # Description of argument(s):
Saqib Khanfb1f6ae2017-04-26 13:24:41 -0500164 # uri URI for uploading image via REST.
165 # timeout Time allocated for the REST command to return status.
166 # quiet If enabled turns off logging to console.
167 # kwargs A dictionary that maps each keyword to a value.
168
169 Initialize OpenBMC ${timeout} quiet=${quiet}
170 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
171 ${headers}= Create Dictionary Content-Type=application/octet-stream
172 ... Accept=application/octet-stream
173 Set To Dictionary ${kwargs} headers ${headers}
174 Run Keyword If '${quiet}' == '${0}' Log Request method=Post
175 ... base_uri=${base_uri} args=&{kwargs}
176 ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
177 Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
178 Should Be Equal As Strings ${ret.status_code} ${HTTP_OK}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500179
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500180Get Image Version From TFTP Server
181 [Documentation] Get the version dfound in the MANIFEST file of
182 ... an image on the given TFTP server.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500183 [Arguments] ${tftp_image_file_path}
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500184
185 # Description of argument(s):
Charles P. Hofer346c0452017-07-14 15:29:50 -0500186 # tftp_image_file_path The path to the image on the TFTP server.
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500187
Charles P. Hofer346c0452017-07-14 15:29:50 -0500188 ${stripped_file_path}= Strip String ${tftp_image_file_path} characters=/
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500189 ${rc}= OperatingSystem.Run And Return RC
Charles P. Hofer346c0452017-07-14 15:29:50 -0500190 ... curl -s tftp://${TFTP_SERVER}/${stripped_file_path} > tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500191 Should Be Equal As Integers 0 ${rc}
192 ... msg=Could not download image to check version.
Charles P. Hofer346c0452017-07-14 15:29:50 -0500193 ${version}= Get Version Tar tftp_image.tar
194 OperatingSystem.Remove File tftp_image.tar
Charles P. Hofer1d20acd2017-07-05 15:24:40 -0500195 [Return] ${version}
Charles P. Hofer346c0452017-07-14 15:29:50 -0500196
197Upload Bad Image Via REST And Verify Failure
198 [Documentation] Upload the given bad image to the BMC via REST and check
199 ... that the BMC did not unpack the invalid image.
200 [Arguments] ${bad_image_file_name}
201
202 # Description of argument(s):
203 # image_file_name The name of the bad image to upload via REST.
204
205 ${bad_image_file_path}= OperatingSystem.Join Path ${BAD_IMAGES_DIR_PATH}
206 ... ${bad_image_file_name}
207 OperatingSystem.File Should Exist ${bad_image_file_path}
208 ... msg=Bad image file ${bad_image_file_name} not found.
209 ${bad_image_version}= Get Version Tar ${bad_image_file_path}
210 ${bad_image_data}= OperatingSystem.Get Binary File ${bad_image_file_path}
211 Upload Post Request /upload/image data=${bad_image_data}
212 Verify Image Not In BMC Uploads Dir ${bad_image_version}
213
214Upload Bad Image Via TFTP And Verify Failure
215 [Documentation] Upload the given bad image to the BMC via TFTP and check
216 ... that the BMC did not unpack the invalid image.
217 [Arguments] ${bad_image_file_name}
218
219 # Description of argument(s):
220 # image_file_name The name of the bad image to upload via TFTP.
221
222 @{image}= Create List ${bad_image_file_name} ${TFTP_SERVER}
223 ${data}= Create Dictionary data=@{image}
224 ${resp}= OpenBMC Post Request
225 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
226 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
227 ${bad_image_version}= Get Image Version From TFTP Server
228 ... ${bad_image_file_name}
229 Verify Image Not In BMC Uploads Dir ${bad_image_version}