blob: 630c54127a78dea193ee8cd06179d64c7b780e71 [file] [log] [blame]
Vijayfcdadc52020-01-21 01:48:19 -06001*** Settings ***
2
3Documentation Test Save Area feature of Management Console on BMC.
4
5Resource ../../lib/rest_client.robot
6Resource ../../lib/openbmc_ffdc.robot
7Resource ../../lib/resource.robot
Vijay09839e22020-02-05 02:54:44 -06008Resource ../../lib/bmc_redfish_utils.robot
Vijayfcdadc52020-01-21 01:48:19 -06009Resource ../../lib/utils.robot
10
Vijay39373152020-02-14 08:08:20 -060011Suite Setup Suite Setup Execution
12Test Teardown Test Teardown Execution
13Suite Teardown Suite Teardown Execution
Vijayfcdadc52020-01-21 01:48:19 -060014
15
16*** Variables ***
17
Sushil Singh7c075e92020-06-11 02:57:48 -050018${MAX_SIZE_MSG} File size exceeds maximum allowed size[500KB]
Vijay09839e22020-02-05 02:54:44 -060019${UPLOADED_MSG} File Created
Sushil Singh4b399ea2020-08-26 02:18:11 -050020${FILE_UPDATED} File Updated
Vijay09839e22020-02-05 02:54:44 -060021${FORBIDDEN_MSG} Forbidden
22${FILE_CREATE_ERROR_MSG} Error while creating the file
Vijayfcdadc52020-01-21 01:48:19 -060023
Vijay09839e22020-02-05 02:54:44 -060024@{ADMIN} admin_user TestPwd123
25@{OPERATOR} operator_user TestPwd123
26&{USERS} Administrator=${ADMIN} Operator=${OPERATOR}
Vijayfcdadc52020-01-21 01:48:19 -060027
28*** Test Cases ***
29
30Verify Small Partition File Upload And Delete
31 [Documentation] Verify small partition file upload and delete.
32 [Tags] Verify_Small_Partition_File_Upload_And_Delete
33 [Template] Upload File To Create Partition Then Delete Partition
34
Vijay09839e22020-02-05 02:54:44 -060035 # partition delete
36 # file_name size_kb name expect_resp_code expected_msg partition username
Sushil Singh7c075e92020-06-11 02:57:48 -050037 501KB_file 501 501KB ${HTTP_BAD_REQUEST} ${MAX_SIZE_MSG} ${True} ${OPENBMC_USERNAME}
Vijay09839e22020-02-05 02:54:44 -060038 15KB_file 15 15KB ${HTTP_OK} ${UPLOADED_MSG} ${True} ${OPENBMC_USERNAME}
Sushil Singh7c075e92020-06-11 02:57:48 -050039 500KB_file 500 500KB ${HTTP_OK} ${UPLOADED_MSG} ${True} ${OPENBMC_USERNAME}
Vijayfcdadc52020-01-21 01:48:19 -060040
41
42Verify Multiple Files Upload
43 [Documentation] Verify multiple files upload.
44 [Tags] Verify_Multiple_Files_Upload
45 [Template] Upload File To Create Partition Then Delete Partition
46
Vijay09839e22020-02-05 02:54:44 -060047 # partition delete
48 # file_name size_kb name expect_resp_code expected_msg partition username
49 0KB_file 0 0KB ${HTTP_OK} ${UPLOADED_MSG} ${False} ${OPENBMC_USERNAME}
50 10KB_file 10 10KB ${HTTP_OK} ${UPLOADED_MSG} ${False} ${OPENBMC_USERNAME}
51 50KB_file 50 50KB ${HTTP_OK} ${UPLOADED_MSG} ${False} ${OPENBMC_USERNAME}
Sushil Singh7c075e92020-06-11 02:57:48 -050052 550KB_file 550 550KB ${HTTP_BAD_REQUEST} ${MAX_SIZE_MSG} ${False} ${OPENBMC_USERNAME}
Vijay09839e22020-02-05 02:54:44 -060053 19KB_file 19 19KB ${HTTP_OK} ${UPLOADED_MSG} ${False} ${OPENBMC_USERNAME}
Sushil Singh7c075e92020-06-11 02:57:48 -050054 499KB_file 199 499KB ${HTTP_OK} ${UPLOADED_MSG} ${False} ${OPENBMC_USERNAME}
Vijayfcdadc52020-01-21 01:48:19 -060055
56
57Verify Read Partition
58 [Documentation] Verify read partition.
59 [Tags] Verify_Read_Partition
60
61 Set Test Variable ${file_name} testfile
62 Set Test Variable ${partition_name} part_read
63 Set Test Variable ${content} Sample Content to test partition file upload
64
65 Run echo "${content}" > ${file_name}
66 OperatingSystem.File Should Exist ${file_name}
67
68 Upload File To Create Partition Then Delete Partition ${file_name} 1 ${partition_name}
69 ... delete_partition=${False}
70
71 Read Partition And Verify Content ${partition_name} ${content}
72
73
Vijay09839e22020-02-05 02:54:44 -060074Verify Non-Admin User Is Forbidden To Upload Partition File
75 [Documentation] Verify non-admin user is forbidden to upload partition file.
76 [Tags] Verify_Non-Admin_User_Is_Forbidden_To_Upload_Partition_File
77 [Template] Upload File To Create Partition Then Delete Partition
78
79 # partition delete
80 # file_name size_kb name expect_resp_code expected_msg partition username
81 12KB_file 12 12KB ${HTTP_FORBIDDEN} ${FORBIDDEN_MSG} ${False} operator_user
82
83
84Verify Partition Update On BMC
85 [Documentation] Verify partition update on BMC.
86 [Tags] Verify_Partition_Update_On_BMC
87
88 Set Test Variable ${file_name} testfile
89 Set Test Variable ${partition_name} part_read
90 Set Test Variable ${content1} Sample Content to test partition file upload
91 Set Test Variable ${content2} Sample Content to test partition file update
92
Sushil Singh4b399ea2020-08-26 02:18:11 -050093 Upload Partition File With Some Known Contents
94 ... ${file_name} ${partition_name} ${content1} ${UPLOADED_MSG}
Vijay09839e22020-02-05 02:54:44 -060095 Read Partition And Verify Content ${partition_name} ${content1}
96
97 # Upload the same partition with modified contents to verify update partition feature.
Sushil Singh4b399ea2020-08-26 02:18:11 -050098 Upload Partition File With Some Known Contents
99 ... ${file_name} ${partition_name} ${content2} ${FILE_UPDATED}
Vijay09839e22020-02-05 02:54:44 -0600100 Read Partition And Verify Content ${partition_name} ${content2}
101
102
103Verify Delete Partition When Partition Does Not Exist
104 [Documentation] Verify delete partition when partition does not exist.
105 [Tags] Verify_Delete_Partition_When_Partition_Does_Not_Exist
106 [Template] Delete Partition And Verify On BMC
107
108 # partition_name expect_resp_code username
109 Does_not_exist ${HTTP_NOT_FOUND} ${OPENBMC_USERNAME}
110 Does_not_exist ${HTTP_FORBIDDEN} operator_user
111
112
113Verify Partition Files Persistency And Re-upload After BMC Reboot
114 [Documentation] Verify partition files persistency and re-upload after BMC reboot.
115 [Tags] Verify_Partition_Files_Persistency_And_Re-upload_After_BMC_Reboot
116
117 Set Test Variable ${file_name} testfile
118 Set Test Variable ${partition_name} part_read
119 Set Test Variable ${content} Sample Content to test partition file upload
120
121 Upload Partition File With Some Known Contents
122 ... ${file_name}_1 ${partition_name}_1 ${content}_${file_name}_1
123 Upload Partition File With Some Known Contents
124 ... ${file_name}_2 ${partition_name}_2 ${content}_${file_name}_2
125
126 OBMC Reboot (off)
127
128 # Get REST session to BMC.
129 Initialize OpenBMC
130
131 # Checking for the content of uploaded partitions after BMC reboot.
132 Read Partition And Verify Content ${partition_name}_1 ${content}_${file_name}_1
133 Read Partition And Verify Content ${partition_name}_2 ${content}_${file_name}_2
134
135 # Upload same partition with different content to test partition update after BMC reboot.
136 Upload Partition File With Some Known Contents
Sushil Singh4b399ea2020-08-26 02:18:11 -0500137 ... ${file_name}_1 ${partition_name}_1 ${content}_${file_name}_2 ${FILE_UPDATED}
Vijay09839e22020-02-05 02:54:44 -0600138
139 # Upload different partition.
Sushil Singh4b399ea2020-08-26 02:18:11 -0500140 Upload Partition File With Some Known Contents
141 ... ${file_name} ${partition_name} ${content} ${UPLOADED_MSG}
Vijay09839e22020-02-05 02:54:44 -0600142
143
144Verify One Thousand Partitions File Upload
145 [Documentation] Verify One Thousand Partitions File Upload.
146 [Tags] Verify_One_Thousand_Partitions_File_Upload
147
148 # Note: 1000 Partitions file upload would take 15-20 minutes.
149 FOR ${INDEX} IN RANGE 1 1000
150 ${status}= Run Keyword And Return Status Upload File To Create Partition Then Delete Partition
151 ... 200KB 200 p${INDEX} delete_partition=${False}
152 Run Keyword If ${status} == ${True} Continue For Loop
153
154 # Check if /var is full on BMC.
155 ${status} ${stderr} ${rc}= BMC Execute Command df -k | grep \' /var\' | grep -v /var/
156 ${var_size}= Set Variable ${status.split('%')[0].split()[1]}
157
158 # Should be a problem if partition file upload request has failed when /var is not full.
159 Exit For Loop If ${var_size} != ${100}
160
161 # Expect HTTP_INTERNAL_SERVER_ERROR and FILE_CREATE_ERROR_MSG when /var is full.
162 Upload File To Create Partition Then Delete Partition
163 ... 200KB 200 p${INDEX} ${HTTP_INTERNAL_SERVER_ERROR} ${FILE_CREATE_ERROR_MSG} ${False}
164 END
165
166
Vijayfcdadc52020-01-21 01:48:19 -0600167*** Keywords ***
168
169Create Partition File
170 [Documentation] Create partition file.
171 [Arguments] ${file_name}=dummyfile ${size_kb}=15
172
173 # Description of argument(s):
174 # file_name Name of the test file to be created. Examples: p1.log, part1.txt etc.
George Keishing879f0842020-02-05 11:00:47 -0600175 # size_kb Size of the test file to be created in KB, default is 15KB.
Vijayfcdadc52020-01-21 01:48:19 -0600176 # Example : 15, 200 etc.
177
178 ${file_exist}= Run Keyword And Return Status OperatingSystem.File Should Exist ${file_name}
179 Return From Keyword If ${file_exist} ${True}
180
181 # Create a partition file if it does not exist locally.
182 Run dd if=/dev/zero of=${file_name} bs=1 count=0 seek=${size_kb}KB
183 OperatingSystem.File Should Exist ${file_name}
184
185
Vijay09839e22020-02-05 02:54:44 -0600186Delete All Sessions And Login Using Given User
187 [Documentation] Delete all sessions and login using given user.
188 [Arguments] ${username}=${OPENBMC_USERNAME}
189
190 # Description of argument(s):
191 # username Username to login. Default is OPENBMC_USERNAME.
192 # Ex: root, operator_user, admin_user, readonly_user etc.
193
194 Delete All Sessions
195 ${password}= Set Variable If '${username}' == '${OPENBMC_USERNAME}' ${OPENBMC_PASSWORD} TestPwd123
196 Initialize OpenBMC rest_username=${username} rest_password=${password}
197
198
Vijayfcdadc52020-01-21 01:48:19 -0600199Upload File To Create Partition Then Delete Partition
200 [Documentation] Upload file to create partition the delete partition.
201 [Arguments] ${file_name}=dummyfile ${size_kb}=15 ${partition_name}=p1 ${expect_resp_code}=${HTTP_OK}
Vijay09839e22020-02-05 02:54:44 -0600202 ... ${expected_msg}=File Created ${delete_partition}=${True} ${username}=${OPENBMC_USERNAME}
Vijayfcdadc52020-01-21 01:48:19 -0600203
204 # Description of argument(s):
205 # file_name Name of the test file to be created.
206 # partition_name Name of the partition on BMC.
207 # expect_resp_code Expected REST response code, default is ${HTTP_OK}.
208 # expected_msg Expected message from file upload, default is 'File Created'.
209 # delete_partition Partition will be deleted if this is True.
Vijay09839e22020-02-05 02:54:44 -0600210 # username Login username
211
212 # Create a session with given user to test upload partition file.
213 Run Keyword If '${username}' != '${OPENBMC_USERNAME}'
214 ... Delete All Sessions And Login Using Given User ${username}
Vijayfcdadc52020-01-21 01:48:19 -0600215
216 # Create a partition file.
217 Create Partition File ${file_name} ${size_kb}
218
219 # Get the content of the file and upload to BMC.
220 ${image_data}= OperatingSystem.Get Binary File ${file_name}
221 ${data}= Create Dictionary data ${image_data}
222 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN}
223
224 Set To Dictionary ${data} headers ${headers}
225 ${resp}= Put Request openbmc /ibm/v1/Host/ConfigFiles/${partition_name} &{data}
226 Should Be Equal As Strings ${resp.status_code} ${expect_resp_code}
227
Vijay09839e22020-02-05 02:54:44 -0600228 ${description}= Run Keyword If ${expect_resp_code} != ${HTTP_FORBIDDEN}
229 ... Return Description Of REST Response ${resp.text}
230 ... ELSE Set Variable ${FORBIDDEN_MSG}
231
232 Should Be Equal As Strings ${description} ${expected_msg}
Vijayfcdadc52020-01-21 01:48:19 -0600233
234 # Cleanup local space after upload attempt.
235 Run Keyword And Ignore Error Delete Local File Created To Upload ${file_name}
236
237 ${upload_success}= Set Variable If ${expect_resp_code} != ${HTTP_OK} ${False} ${True}
Vijay09839e22020-02-05 02:54:44 -0600238 Verify Partition Available On BMC ${partition_name} ${upload_success} ${username}
Vijayfcdadc52020-01-21 01:48:19 -0600239
240 # Delete partition and verify on BMC.
Vijay09839e22020-02-05 02:54:44 -0600241 ${expect_resp_code}= Set Variable If ${expect_resp_code} != ${HTTP_OK} ${HTTP_NOT_FOUND} ${HTTP_OK}
242 Run Keyword If ${delete_partition} == ${True} Delete Partition And Verify On BMC
243 ... ${partition_name} ${expect_resp_code} ${username}
244
245
246Return Description Of REST Response
247 [Documentation] Return description of REST response.
248 [Arguments] ${resp_text}
249
250 # Description of argument(s):
251 # resp_text REST response body.
252
253 # resp_text after successful partition file upload looks like:
254 # {
255 # "Description": "File Created"
256 # }
257
258 ${message}= Evaluate json.loads('''${resp_text}''') json
259
260 [Return] ${message["Description"]}
261
262
263Delete Partition And Verify On BMC
264 [Documentation] Delete partition and verify on BMC.
265 [Arguments] ${partition_name} ${expect_resp_code}=${HTTP_OK} ${username}=${OPENBMC_USERNAME}
266
267 # Description of argument(s):
268 # partition_name Name of the partition on BMC.
269 # expect_resp_code Expected REST response code from DELETE request, default is ${HTTP_OK}.
270 # username Username to login, if other than OPENBMC_USERNAME user.
271
272 # Create a session with given user to test delete operation.
273 # If user is a non-admin user then DELETE request is forbidden for the user.
274 Run Keyword If '${username}' != '${OPENBMC_USERNAME}'
275 ... Delete All Sessions And Login Using Given User ${username}
276
277 Delete Partition ${partition_name} ${expect_resp_code}
278 Verify Partition Available On BMC ${partition_name} ${False} ${username}
Vijayfcdadc52020-01-21 01:48:19 -0600279
280
281Get List Of Partitions
282 [Documentation] Get list of partitions.
283 [Arguments] ${expect_resp_code}=${HTTP_OK}
284
285 # Description of argument(s):
286 # expect_resp_code Expected REST response code, default is ${HTTP_OK}.
287
288 ${resp}= Get Request openbmc /ibm/v1/Host/ConfigFiles
289 Should Be Equal As Strings ${resp.status_code} ${expect_resp_code}
290 Return From Keyword If ${expect_resp_code} != ${HTTP_OK}
291
292 ${resp_json}= To JSON ${resp.content}
293 ${partitions_cnt}= Get Length ${resp_json['Members']}
294
295 [Return] ${resp_json['Members']} ${partitions_cnt}
296
297
298Verify Partition Available On BMC
299 [Documentation] Verify partition available on BMC.
Vijay09839e22020-02-05 02:54:44 -0600300 [Arguments] ${partition_name}=${EMPTY} ${operation_status}=${True} ${username}=${OPENBMC_USERNAME}
Vijayfcdadc52020-01-21 01:48:19 -0600301
302 # Description of argument(s):
Vijay09839e22020-02-05 02:54:44 -0600303 # partition_name Name of the partition on BMC.
304 # operation_success Status of the previous operation like upload/delete success or failure.
305 # True if operation was a success else False.
306 # username Username used to upload/delete. Default is ${OPENBMC_USERNAME}.
Vijayfcdadc52020-01-21 01:48:19 -0600307
Vijay09839e22020-02-05 02:54:44 -0600308 # Non admin users will not have an access to do GET list
309 Run Keyword If '${username}' != '${OPENBMC_USERNAME}'
310 ... Delete All Sessions And Login Using Given User
Vijayfcdadc52020-01-21 01:48:19 -0600311
312 ${partitions} ${partitions_cnt}= Get List Of Partitions
313 ${rest_response}= Run Keyword And Return Status List Should Contain Value ${partitions}
314 ... /ibm/v1/Host/ConfigFiles/${partition_name}
315
316 ${status} ${stderr} ${rc}= BMC Execute Command
317 ... ls -l /var/lib/obmc/bmc-console-mgmt/save-area/${partition_name} | wc -l
318 ${bmc_response}= Run Keyword And Return Status Should Be True ${status} == ${1}
319
320 Run Keyword If '${partition_name}' == '${EMPTY}' Run Keywords
321 ... Should Be Equal ${rest_response} ${False} AND Should Be Equal ${bmc_response} ${False}
322
323 Run Keyword And Return If '${partition_name}' != '${EMPTY}' Run Keywords
324 ... Should Be True ${rest_response} == ${operation_status} AND
325 ... Should Be True ${bmc_response} == ${operation_status}
326
327
328Delete Partition
329 [Documentation] Delete partition.
330 [Arguments] ${partition_name}='${EMPTY}' ${expect_resp_code}=${HTTP_OK}
331
332 # Description of argument(s):
333 # partition_name Name of the partition on BMC.
334 # expect_resp_code Expected REST response code, default is ${HTTP_OK}.
335
336 ${data}= Create Dictionary
337 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN}
338 Set To Dictionary ${data} headers ${headers}
339
340 ${resp}= Delete Request openbmc /ibm/v1/Host/ConfigFiles/${partition_name} &{data}
341 ${expect_resp_code}= Set Variable If '${partition_name}' == '${EMPTY}'
342 ... ${HTTP_NOT_FOUND} ${expect_resp_code}
343 Should Be Equal As Strings ${resp.status_code} ${expect_resp_code}
344
345
346Delete And Verify All Partitions on BMC
347 [Documentation] Delete and verify all partitions on BMC.
348 [Arguments] ${expect_resp_code}=${HTTP_OK}
349
350 # Description of argument(s):
351 # expect_resp_code Expected REST response code, default is ${HTTP_OK}.
352
353 ${data}= Create Dictionary
354 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN}
355 Set To Dictionary ${data} headers ${headers}
356
Sushil Singhfa562972020-08-05 08:01:27 -0500357 ${resp}= Post Request openbmc /ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll &{data}
Vijayfcdadc52020-01-21 01:48:19 -0600358 Should Be Equal As Strings ${resp.status_code} ${expect_resp_code}
359
360 Return From Keyword If ${expect_resp_code} != ${HTTP_OK}
361 Verify Partition Available On BMC operation_status=${False}
362
363
364Read Partition And Verify Content
365 [Documentation] Read partition and verify content.
366 [Arguments] ${partition_name}=p1 ${content}=${EMPTY} ${expect_resp_code}=${HTTP_OK}
367
368 # Description of argument(s):
369 # partition_name Name of the partition on BMC.
370 # content Content of the partition file uploaded.
371 # expect_resp_code Expected REST response code, default is ${HTTP_OK}.
372
373 ${resp}= Get Request openbmc /ibm/v1/Host/ConfigFiles/${partition_name}
374 Should Be Equal As Strings ${resp.status_code} ${expect_resp_code}
375
376 ${partition_data}= Remove String ${resp.text} \\n
377 ${partition_data}= Evaluate json.loads('''${partition_data}''') json
378 Should Be Equal As Strings ${partition_data["Data"]} ${content}
379
380
381Delete Local File Created To Upload
382 [Documentation] Delete local file created to upload.
383 [Arguments] ${file_name}
384
385 # Description of argument(s):
386 # file_name Name of the local file to be deleted.
387
388 Run Keyword And Ignore Error Run rm -f ${file_name}
389
390
Vijay09839e22020-02-05 02:54:44 -0600391Upload Partition File With Some Known Contents
392 [Documentation] Upload partition file with some known contents.
Sushil Singh4b399ea2020-08-26 02:18:11 -0500393 [Arguments] ${file_name} ${partition_name} ${content} ${expected_msg}=${UPLOADED_MSG}
Vijay09839e22020-02-05 02:54:44 -0600394
395 # Description of argument(s):
396 # file_name Name of the partition file to be uploaded.
397 # partition_name Name of the partition on BMC.
398 # content Content of the partition file to be uploaded.
399
400 Run echo "${content}" > ${file_name}
401 OperatingSystem.File Should Exist ${file_name}
402
403 Upload File To Create Partition Then Delete Partition ${file_name} 1 ${partition_name}
Sushil Singh4b399ea2020-08-26 02:18:11 -0500404 ... expected_msg=${expected_msg} delete_partition=${False}
Vijay09839e22020-02-05 02:54:44 -0600405
406
Vijayfcdadc52020-01-21 01:48:19 -0600407Suite Setup Execution
408 [Documentation] Suite setup execution.
409
Vijay09839e22020-02-05 02:54:44 -0600410 # Create different user accounts.
411 Redfish.Login
George Keishing82068512020-02-27 08:46:34 -0600412 Create Users With Different Roles users=${USERS} force=${True}
Vijayfcdadc52020-01-21 01:48:19 -0600413 # Get REST session to BMC.
414 Initialize OpenBMC
415
416
417Test Teardown Execution
418 [Documentation] Test teardown execution.
419
420 Delete And Verify All Partitions on BMC
George Keishingbe27e922020-02-04 11:27:34 -0600421 FFDC On Test Case Fail
Vijayfcdadc52020-01-21 01:48:19 -0600422
Vijay39373152020-02-14 08:08:20 -0600423
424Suite Teardown Execution
425 [Documentation] Suite teardown execution.
426
427 Delete BMC Users Via Redfish users=${USERS}
428 Delete All Sessions