blob: ccfde94ecea05f7a0a8fea143bbc41751ead3c8f [file] [log] [blame]
Sushil Singhcdebdd52019-08-14 15:29:24 -05001*** Settings ***
2Documentation Update firmware on a target BMC via Redifsh.
3
4# Test Parameters:
5# IMAGE_FILE_PATH The path to the BMC image file.
6#
7# Firmware update states:
8# Enabled Image is installed and either functional or active.
9# Disabled Image installation failed or ready for activation.
10# Updating Image installation currently in progress.
11
12Resource ../../lib/resource.robot
13Resource ../../lib/bmc_redfish_resource.robot
14Resource ../../lib/openbmc_ffdc.robot
15Resource ../../lib/common_utils.robot
16Resource ../../lib/code_update_utils.robot
17Resource ../../lib/dump_utils.robot
18Resource ../../lib/logging_utils.robot
19Resource ../../lib/redfish_code_update_utils.robot
Sushil Singhb13fc362020-02-06 03:40:56 -060020Resource ../../lib/utils.robot
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060021Resource ../../lib/bmc_redfish_utils.robot
Sushil Singhc8526a22022-12-21 10:26:19 -060022Resource ../../lib/external_intf/management_console_utils.robot
Sushil Singh44bfc202023-02-08 09:53:36 -060023Resource ../../lib/bmc_network_utils.robot
Sushil Singh1ee3c932023-02-24 01:58:09 -060024Resource ../../lib/certificate_utils.robot
Sushil Singhcdebdd52019-08-14 15:29:24 -050025Library ../../lib/gen_robot_valid.py
26Library ../../lib/tftp_update_utils.py
Sushil Singhf7674a52019-11-19 00:36:15 -060027Library ../../lib/gen_robot_keyword.py
Sushil Singhcdebdd52019-08-14 15:29:24 -050028
29Suite Setup Suite Setup Execution
30Suite Teardown Redfish.Logout
31Test Setup Printn
32Test Teardown FFDC On Test Case Fail
33
34Force Tags BMC_Code_Update
35
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060036*** Variables ***
37
Sushil Singh759f1482023-02-28 01:29:52 -060038@{ADMIN} admin_user TestPwd123
39&{USERS} Administrator=${ADMIN}
40${LOOP_COUNT} ${2}
41@{HOSTNAME} bmc_system01 bmc_system02 bmc_system03 bmc_system04 bmc_system05
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060042
Sushil Singhcdebdd52019-08-14 15:29:24 -050043*** Test Cases ***
44
45Redfish Code Update With ApplyTime OnReset
George Keishing16b3c7b2021-01-28 09:23:37 -060046 [Documentation] Update the firmware image with ApplyTime of OnReset.
Sushil Singhcdebdd52019-08-14 15:29:24 -050047 [Tags] Redfish_Code_Update_With_ApplyTime_OnReset
48 [Template] Redfish Update Firmware
49
50 # policy
51 OnReset
52
53
54Redfish Code Update With ApplyTime Immediate
George Keishing16b3c7b2021-01-28 09:23:37 -060055 [Documentation] Update the firmware image with ApplyTime of Immediate.
Sushil Singhcdebdd52019-08-14 15:29:24 -050056 [Tags] Redfish_Code_Update_With_ApplyTime_Immediate
57 [Template] Redfish Update Firmware
58
59 # policy
60 Immediate
61
62
Sushil Singhc915f5e2022-12-21 08:18:31 -060063Redfish Code Update Same Firmware Multiple Times
64 [Documentation] Multiple times update the firmware image for update service.
65 [Tags] Redfish_Code_Update_Same_Firmware_Multiple_Times
66
67 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1
68
69 FOR ${count} IN RANGE 1 ${temp_update_loop_count}
Sushil Singha83bba02023-01-18 08:43:45 -060070 Print Timen ***************************************
Sushil Singhc915f5e2022-12-21 08:18:31 -060071 Print Timen * The Current Loop Count is ${count} of ${LOOP_COUNT} *
Sushil Singha83bba02023-01-18 08:43:45 -060072 Print Timen ***************************************
Sushil Singhc915f5e2022-12-21 08:18:31 -060073
74 Redfish Update Firmware apply_time=OnReset
75 END
76
77
78
Sushil Singhffbfedf2019-10-17 15:58:25 -050079Redfish Code Update With Multiple Firmware
George Keishing16b3c7b2021-01-28 09:23:37 -060080 [Documentation] Update the firmware image with ApplyTime of Immediate.
Sushil Singhffbfedf2019-10-17 15:58:25 -050081 [Tags] Redfish_Code_Update_With_Multiple_Firmware
82 [Template] Redfish Multiple Upload Image And Check Progress State
83
84 # policy image_file_path alternate_image_file_path
85 Immediate ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
86
87
Sushil Singhc8526a22022-12-21 10:26:19 -060088Post BMC Reset Perform Redfish Code Update
89 [Documentation] Test to reset BMC at standby and then perform BMC firmware update and
90 ... ensure there is not error or dump logs post update.
91 [Tags] Post_BMC_Reset_Perform_Redfish_Code_Update
92
93 Redfish Delete All BMC Dumps
94 Redfish Purge Event Log
95
96 Redfish OBMC Reboot (off)
97
98 Redfish Update Firmware apply_time=OnReset
99
100 Event Log Should Not Exist
101 Redfish BMC Dump Should Not Exist
102
103 Redfish Power Off
104
105
106Post BMC Reset Perform Image Switched To Backup Multiple Times
George Keishing0d930e92023-01-25 13:19:37 -0600107 [Documentation] Test to reset BMC at standby and then perform switch
108 ... to backup image multiple times.
Sushil Singhc8526a22022-12-21 10:26:19 -0600109 ... Then ensure no event and dump logs exist.
110 [Tags] Post_BMC_Reset_Perform_Image_Switched_To_Backup_Multiple_Times
111
112 Redfish Delete All BMC Dumps
113 Redfish Purge Event Log
114
115 Redfish OBMC Reboot (off)
116
117 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1
118
119 FOR ${count} IN RANGE 1 ${temp_update_loop_count}
120 ${state}= Get Pre Reboot State
121
122 # change to backup image and reset the BMC.
123 Switch Backup Firmware Image To Functional
124
125 Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
126 END
127
128 Event Log Should Not Exist
129 Redfish BMC Dump Should Not Exist
130
131
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600132Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup
Sushil Singh5166ebd2021-05-31 01:24:16 -0500133 [Documentation] Verify updated admin credential remain same post switch to back up image.
George Keishing5236ec52022-01-31 12:07:58 -0600134 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Image_Switched_To_Backup
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600135 [Setup] Create Users With Different Roles users=${USERS} force=${True}
136 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
137
138 ${post_code_update_actions}= Get Post Boot Action
139 ${state}= Get Pre Reboot State
140 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
141
142 Redfish.Login
143 # change to backup image and reset the BMC.
144 Switch Backup Firmware Image To Functional
145 Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
146
147 # verify modified admin password on backup image.
148 Redfish.Login admin_user 0penBmc123
149 Redfish.Logout
150
Sushil Singh5166ebd2021-05-31 01:24:16 -0500151
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600152Verify If The Modified Admin Credential Is Valid Post Update
Sushil Singh5166ebd2021-05-31 01:24:16 -0500153 [Documentation] Verify updated admin credential remain same post code update image.
George Keishing5236ec52022-01-31 12:07:58 -0600154 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Update
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600155 [Setup] Create Users With Different Roles users=${USERS} force=${True}
156 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
157
158 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
159
160 Redfish.Login
161 # Flash latest firmware using redfish.
162 Redfish Update Firmware OnReset
163
164 # verify modified admin credentails on latest image.
165 Redfish.Login admin_user 0penBmc123
166 Redfish.Logout
167
Sushil Singh44bfc202023-02-08 09:53:36 -0600168
169Redfish Code Update With Different Interrupted Operation
170 [Documentation] Ensure firmware update is successful when different interrupted operation executed
Sushil Singh1ee3c932023-02-24 01:58:09 -0600171 ... i.e. change the hostname, updating https certificate and firmware update fail
172 ... when kernel panic.
Sushil Singh44bfc202023-02-08 09:53:36 -0600173 [Tags] Redfish_Code_Update_With_Different_Interrupted_Operation
174 [Template] Verify Redfish Code Update With Different Interrupted Operation
175
Sushil Singh1ee3c932023-02-24 01:58:09 -0600176 # operation count
177 host_name 1
178 kernel_panic 1
179 https_certificate 1
Sushil Singh44bfc202023-02-08 09:53:36 -0600180
Sushil Singhcdebdd52019-08-14 15:29:24 -0500181*** Keywords ***
182
183Suite Setup Execution
184 [Documentation] Do the suite setup.
185
Sushil Singhcdebdd52019-08-14 15:29:24 -0500186 Valid File Path IMAGE_FILE_PATH
187 Redfish.Login
Sushil Singhc8526a22022-12-21 10:26:19 -0600188
Tim Lee4aff2d02021-06-08 13:26:25 +0800189 Redfish Delete All BMC Dumps
Sushil Singhcdebdd52019-08-14 15:29:24 -0500190 Redfish Purge Event Log
191
Sushil Singhc8526a22022-12-21 10:26:19 -0600192 Redfish Power Off stack_mode=skip
193
Sushil Singh759f1482023-02-28 01:29:52 -0600194 # Check and set the update path.
195 # Old - /redfish/v1/UpdateService/
196 # New - /redfish/v1/UpdateService/update
197
198 ${resp}= Redfish.Get /redfish/v1/UpdateService/update
199 ... valid_status_codes=[${HTTP_OK},${HTTP_NOT_FOUND}]
200
201 # If the method is not found, set update URI to old method.
202 Run Keyword If ${resp.status} == ${HTTP_NOT_FOUND}
203 ... Set Suite Variable ${REDFISH_UPDATE_URI} /redfish/v1/UpdateService
204
205 Log To Console Update URI: ${REDFISH_UPDATE_URI}
206
Sushil Singhcdebdd52019-08-14 15:29:24 -0500207
208Redfish Update Firmware
209 [Documentation] Update the BMC firmware via redfish interface.
210 [Arguments] ${apply_time}
211
212 # Description of argument(s):
213 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
214
Sushil Singhb13fc362020-02-06 03:40:56 -0600215 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhcdebdd52019-08-14 15:29:24 -0500216 ${state}= Get Pre Reboot State
217 Rprint Vars state
Sushil Singh6f86f172019-10-30 11:36:25 -0500218 Set ApplyTime policy=${apply_Time}
Sushil Singh1560e652022-08-03 13:25:01 -0500219
220 ${task_inv_dict}= Get Task State from File
221
222 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path}
223
224 Log To Console Start uploading image to BMC.
Sushil Singh759f1482023-02-28 01:29:52 -0600225 Upload Image To BMC ${REDFISH_UPDATE_URI} timeout=${600} data=${file_bin_data}
Sushil Singh1560e652022-08-03 13:25:01 -0500226 Log To Console Completed image upload to BMC.
227
Sushil Singh759f1482023-02-28 01:29:52 -0600228 ${task_inv}= Check Task With Match TargetUri ${REDFISH_UPDATE_URI}
Sushil Singh1560e652022-08-03 13:25:01 -0500229
230 Rprint Vars task_inv
231
232 Wait Until Keyword Succeeds 5 min 10 sec
233 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskCompleted']}
234
Sushil Singhb13fc362020-02-06 03:40:56 -0600235 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
Sushil Singhf7674a52019-11-19 00:36:15 -0600236 Redfish.Login
Sushil Singhb13fc362020-02-06 03:40:56 -0600237 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
Sushil Singh811ffae2019-10-23 05:16:22 -0500238 Verify Get ApplyTime ${apply_time}
Sushil Singhcdebdd52019-08-14 15:29:24 -0500239
Sushil Singhffbfedf2019-10-17 15:58:25 -0500240
241Redfish Multiple Upload Image And Check Progress State
242 [Documentation] Update multiple BMC firmware via redfish interface and check status.
243 [Arguments] ${apply_time} ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
244
245 # Description of argument(s):
246 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate").
247 # IMAGE_FILE_PATH The path to BMC image file.
248 # ALTERNATE_IMAGE_FILE_PATH The path to alternate BMC image file.
249
Sushil Singhb13fc362020-02-06 03:40:56 -0600250 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhffbfedf2019-10-17 15:58:25 -0500251 Valid File Path ALTERNATE_IMAGE_FILE_PATH
252 ${state}= Get Pre Reboot State
253 Rprint Vars state
254
255 Set ApplyTime policy=${apply_time}
256 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH}
257
258 ${first_image_id}= Get Latest Image ID
259 Rprint Vars first_image_id
260 Sleep 5s
261 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${ALTERNATE_IMAGE_FILE_PATH}
262
263 ${second_image_id}= Get Latest Image ID
264 Rprint Vars second_image_id
265
266 Check Image Update Progress State
267 ... match_state='Updating', 'Disabled' image_id=${second_image_id}
268
269 Check Image Update Progress State
270 ... match_state='Updating' image_id=${first_image_id}
271
272 Wait Until Keyword Succeeds 8 min 20 sec
273 ... Check Image Update Progress State
274 ... match_state='Enabled' image_id=${first_image_id}
Sushil Singhb13fc362020-02-06 03:40:56 -0600275 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
276 Redfish.Login
277 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
Sushil Singha83bba02023-01-18 08:43:45 -0600278
279
Sushil Singh44bfc202023-02-08 09:53:36 -0600280Run Configure BMC Hostname In Loop
281 [Documentation] Update hostname in loop.
282 [Arguments] ${count}
283
284 # Description of argument(s):
285 # count Loop count.
286
287 FOR ${index} IN RANGE ${count}
288 Configure Hostname  hostname=${HOSTNAME}[${index}] status_code=[${HTTP_INTERNAL_SERVER_ERROR}]
289 END
290
291
Sushil Singh1ee3c932023-02-24 01:58:09 -0600292Redfish Update Certificate Upload In Loop
293 [Documentation] Upload HTTPS server certificate via Redfish and verify using OpenSSL.
294 [Arguments] ${count}
295
296 # Description of argument(s):
297 # count Loop count.
298
299 FOR ${index} IN RANGE ${count}
300 ${resp}= Run Keyword And Return Status Redfish.Get ${REDFISH_HTTPS_CERTIFICATE_URI}/1 valid_status_codes=[${HTTP_OK}]
301 Should Be Equal As Strings ${resp} ${True}
302
303 ${cert_file_path}= Generate Certificate File Via Openssl Valid Certificate Valid Privatekey
304 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path}
305 ${file_data}= Decode Bytes To String ${bytes} UTF-8
306
307 ${certificate_dict}= Create Dictionary
308 ... @odata.id=${REDFISH_HTTPS_CERTIFICATE_URI}/1
309 ${payload}= Create Dictionary CertificateString=${file_data}
310 ... CertificateType=PEM CertificateUri=${certificate_dict}
311
312 ${resp}= Redfish.Post /redfish/v1/CertificateService/Actions/CertificateService.ReplaceCertificate
313 ... body=${payload}
314
315 Verify Certificate Visible Via OpenSSL ${cert_file_path}
316 END
317
318
Sushil Singh44bfc202023-02-08 09:53:36 -0600319Run Operation On BMC
320 [Documentation] Run operation on BMC.
321 [Arguments] ${operation} ${count}
322
323 # Description of argument(s):
324 # operation If host_name then change hostname.
325 # count Loop count.
326
Sushil Singh1ee3c932023-02-24 01:58:09 -0600327 Run Keyword If '${operation}' == 'host_name'
328 ... Run Configure BMC Hostname In Loop count=${count}
329 ... ELSE IF '${operation}' == 'kernel_panic'
330 ... Run Keywords Kernel Panic BMC Reset Operation AND
331 ... Is BMC Unpingable
332 ... ELSE IF '${operation}' == 'https_certificate'
333 ... Redfish Update Certificate Upload In Loop count=${count}
334 ... ELSE
335 ... Fail msg=Operation not handled.
Sushil Singh44bfc202023-02-08 09:53:36 -0600336
337
338Get Active Firmware Image
339 [Documentation] Return get active firmware image.
340
ganesanb4d430282023-04-27 14:33:23 +0000341 ${active_image}= Redfish.Get Attribute /redfish/v1/Managers/${MANAGER_ID} Links
Sushil Singh44bfc202023-02-08 09:53:36 -0600342 Rprint Vars active_image
343
344 [Return] ${active_image}
345
346
Sushil Singh1ee3c932023-02-24 01:58:09 -0600347Get New Image ID
348 [Documentation] Return the ID of the most recently extracted image.
349
350 ${image_id}= Get Image Id Updating
351
352 [Return] ${image_id}
353
354
Sushil Singh44bfc202023-02-08 09:53:36 -0600355Verify Redfish Code Update With Different Interrupted Operation
George Keishing4611b812023-02-16 09:44:33 -0600356 [Documentation] Verify code update is successful when other operation
Sushil Singh1ee3c932023-02-24 01:58:09 -0600357 ... getting executed i.e. change the hostname, updating http certificate
358 ... and code update will fail for kernel panic.
Sushil Singh44bfc202023-02-08 09:53:36 -0600359 [Arguments] ${operation} ${count}
360
361 # Description of argument(s):
362 # operation host_name to change Hostname, kernel_panic to perform kernel panic.
363 # count Number of times loop will get executed.
364
365 ${before_update_activeswimage}= Get Active Firmware Image
366
367 ${post_code_update_actions}= Get Post Boot Action
368
369 Set ApplyTime policy=OnReset
370
371 ${task_inv_dict}= Get Task State from File
372
373 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path}
374
375 Log To Console Start uploading image to BMC.
376 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data}
377 Log To Console Completed image upload to BMC.
378
Sushil Singh1ee3c932023-02-24 01:58:09 -0600379 Sleep 5
380
381 ${image_id}= Get New Image ID
382 Rprint Vars image_id
383
Sushil Singh44bfc202023-02-08 09:53:36 -0600384 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService
385 Rprint Vars task_inv
386
387 Wait Until Keyword Succeeds 1 min 10 sec
388 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskStarting']}
389
390 Run Operation On BMC ${operation} ${count}
391
Sushil Singh1ee3c932023-02-24 01:58:09 -0600392 IF '${operation}' == 'kernel_panic'
393 Wait Until Keyword Succeeds 10 min 10 sec Is BMC Standby
394 ELSE IF '${operation}' == 'host_name'
395 Wait Until Keyword Succeeds 5 min 10 sec
396 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskCompleted']}
397 Run Key ${post_code_update_actions['BMC image']['OnReset']}
398 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
399 ELSE IF '${operation}' == 'https_certificate'
400 Check Image Update Progress State
401 ... match_state='Updating' image_id=${image_id}
402 Wait Until Keyword Succeeds 8 min 20 sec
403 ... Check Image Update Progress State
404 ... match_state='Enabled' image_id=${image_id}
405 Run Key ${post_code_update_actions['BMC image']['OnReset']}
406 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
407 ELSE
408 Fail msg=Operation not handled.
409 END
Sushil Singh44bfc202023-02-08 09:53:36 -0600410
411 ${after_update_activeswimage}= Get Active Firmware Image
412
413 ${status}= Run Keyword And Return Status Should Be Equal As Strings
414 ... ${before_update_activeswimage['ActiveSoftwareImage']['@odata.id']}
415 ... ${after_update_activeswimage['ActiveSoftwareImage']['@odata.id']}
416
417 Run Keyword If '${operation}' == 'kernel_panic'
418 ... Should Be True ${status}
419 ... ELSE
420 ... Should Not Be True ${status}
421
422 Verify Get ApplyTime OnReset
423