blob: 54a277d3a21c8bf2defc3af6dfe16870859ef4e4 [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 Singhcdebdd52019-08-14 15:29:24 -050024Library ../../lib/gen_robot_valid.py
25Library ../../lib/tftp_update_utils.py
Sushil Singhf7674a52019-11-19 00:36:15 -060026Library ../../lib/gen_robot_keyword.py
Sushil Singhcdebdd52019-08-14 15:29:24 -050027
28Suite Setup Suite Setup Execution
29Suite Teardown Redfish.Logout
30Test Setup Printn
31Test Teardown FFDC On Test Case Fail
32
33Force Tags BMC_Code_Update
34
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060035*** Variables ***
36
37@{ADMIN} admin_user TestPwd123
38&{USERS} Administrator=${ADMIN}
Sushil Singhc915f5e2022-12-21 08:18:31 -060039${LOOP_COUNT} ${2}
Sushil Singh44bfc202023-02-08 09:53:36 -060040@{HOSTNAME} bmc_system01 bmc_system02 bmc_system03 bmc_system04 bmc_system05
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060041
Sushil Singhcdebdd52019-08-14 15:29:24 -050042*** Test Cases ***
43
44Redfish Code Update With ApplyTime OnReset
George Keishing16b3c7b2021-01-28 09:23:37 -060045 [Documentation] Update the firmware image with ApplyTime of OnReset.
Sushil Singhcdebdd52019-08-14 15:29:24 -050046 [Tags] Redfish_Code_Update_With_ApplyTime_OnReset
47 [Template] Redfish Update Firmware
48
49 # policy
50 OnReset
51
52
53Redfish Code Update With ApplyTime Immediate
George Keishing16b3c7b2021-01-28 09:23:37 -060054 [Documentation] Update the firmware image with ApplyTime of Immediate.
Sushil Singhcdebdd52019-08-14 15:29:24 -050055 [Tags] Redfish_Code_Update_With_ApplyTime_Immediate
56 [Template] Redfish Update Firmware
57
58 # policy
59 Immediate
60
61
Sushil Singhc915f5e2022-12-21 08:18:31 -060062Redfish Code Update Same Firmware Multiple Times
63 [Documentation] Multiple times update the firmware image for update service.
64 [Tags] Redfish_Code_Update_Same_Firmware_Multiple_Times
65
66 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1
67
68 FOR ${count} IN RANGE 1 ${temp_update_loop_count}
Sushil Singha83bba02023-01-18 08:43:45 -060069 Print Timen ***************************************
Sushil Singhc915f5e2022-12-21 08:18:31 -060070 Print Timen * The Current Loop Count is ${count} of ${LOOP_COUNT} *
Sushil Singha83bba02023-01-18 08:43:45 -060071 Print Timen ***************************************
Sushil Singhc915f5e2022-12-21 08:18:31 -060072
73 Redfish Update Firmware apply_time=OnReset
74 END
75
76
77
Sushil Singhffbfedf2019-10-17 15:58:25 -050078Redfish Code Update With Multiple Firmware
George Keishing16b3c7b2021-01-28 09:23:37 -060079 [Documentation] Update the firmware image with ApplyTime of Immediate.
Sushil Singhffbfedf2019-10-17 15:58:25 -050080 [Tags] Redfish_Code_Update_With_Multiple_Firmware
81 [Template] Redfish Multiple Upload Image And Check Progress State
82
83 # policy image_file_path alternate_image_file_path
84 Immediate ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
85
86
Sushil Singhc8526a22022-12-21 10:26:19 -060087Post BMC Reset Perform Redfish Code Update
88 [Documentation] Test to reset BMC at standby and then perform BMC firmware update and
89 ... ensure there is not error or dump logs post update.
90 [Tags] Post_BMC_Reset_Perform_Redfish_Code_Update
91
92 Redfish Delete All BMC Dumps
93 Redfish Purge Event Log
94
95 Redfish OBMC Reboot (off)
96
97 Redfish Update Firmware apply_time=OnReset
98
99 Event Log Should Not Exist
100 Redfish BMC Dump Should Not Exist
101
102 Redfish Power Off
103
104
105Post BMC Reset Perform Image Switched To Backup Multiple Times
George Keishing0d930e92023-01-25 13:19:37 -0600106 [Documentation] Test to reset BMC at standby and then perform switch
107 ... to backup image multiple times.
Sushil Singhc8526a22022-12-21 10:26:19 -0600108 ... Then ensure no event and dump logs exist.
109 [Tags] Post_BMC_Reset_Perform_Image_Switched_To_Backup_Multiple_Times
110
111 Redfish Delete All BMC Dumps
112 Redfish Purge Event Log
113
114 Redfish OBMC Reboot (off)
115
116 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1
117
118 FOR ${count} IN RANGE 1 ${temp_update_loop_count}
119 ${state}= Get Pre Reboot State
120
121 # change to backup image and reset the BMC.
122 Switch Backup Firmware Image To Functional
123
124 Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
125 END
126
127 Event Log Should Not Exist
128 Redfish BMC Dump Should Not Exist
129
130
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600131Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup
Sushil Singh5166ebd2021-05-31 01:24:16 -0500132 [Documentation] Verify updated admin credential remain same post switch to back up image.
George Keishing5236ec52022-01-31 12:07:58 -0600133 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Image_Switched_To_Backup
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600134 [Setup] Create Users With Different Roles users=${USERS} force=${True}
135 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
136
137 ${post_code_update_actions}= Get Post Boot Action
138 ${state}= Get Pre Reboot State
139 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
140
141 Redfish.Login
142 # change to backup image and reset the BMC.
143 Switch Backup Firmware Image To Functional
144 Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
145
146 # verify modified admin password on backup image.
147 Redfish.Login admin_user 0penBmc123
148 Redfish.Logout
149
Sushil Singh5166ebd2021-05-31 01:24:16 -0500150
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600151Verify If The Modified Admin Credential Is Valid Post Update
Sushil Singh5166ebd2021-05-31 01:24:16 -0500152 [Documentation] Verify updated admin credential remain same post code update image.
George Keishing5236ec52022-01-31 12:07:58 -0600153 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Update
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600154 [Setup] Create Users With Different Roles users=${USERS} force=${True}
155 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
156
157 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
158
159 Redfish.Login
160 # Flash latest firmware using redfish.
161 Redfish Update Firmware OnReset
162
163 # verify modified admin credentails on latest image.
164 Redfish.Login admin_user 0penBmc123
165 Redfish.Logout
166
Sushil Singh44bfc202023-02-08 09:53:36 -0600167
168Redfish Code Update With Different Interrupted Operation
169 [Documentation] Ensure firmware update is successful when different interrupted operation executed
170 ... i.e. change the hostname.
171 [Tags] Redfish_Code_Update_With_Different_Interrupted_Operation
172 [Template] Verify Redfish Code Update With Different Interrupted Operation
173
174 # operation count
175 host_name 1
176 kernel_panic 1
177
Sushil Singhcdebdd52019-08-14 15:29:24 -0500178*** Keywords ***
179
180Suite Setup Execution
181 [Documentation] Do the suite setup.
182
Sushil Singhcdebdd52019-08-14 15:29:24 -0500183 Valid File Path IMAGE_FILE_PATH
184 Redfish.Login
Sushil Singhc8526a22022-12-21 10:26:19 -0600185
Tim Lee4aff2d02021-06-08 13:26:25 +0800186 Redfish Delete All BMC Dumps
Sushil Singhcdebdd52019-08-14 15:29:24 -0500187 Redfish Purge Event Log
188
Sushil Singhc8526a22022-12-21 10:26:19 -0600189 Redfish Power Off stack_mode=skip
190
Sushil Singhcdebdd52019-08-14 15:29:24 -0500191
192Redfish Update Firmware
193 [Documentation] Update the BMC firmware via redfish interface.
194 [Arguments] ${apply_time}
195
196 # Description of argument(s):
197 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
198
Sushil Singhb13fc362020-02-06 03:40:56 -0600199 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhcdebdd52019-08-14 15:29:24 -0500200 ${state}= Get Pre Reboot State
201 Rprint Vars state
Sushil Singh6f86f172019-10-30 11:36:25 -0500202 Set ApplyTime policy=${apply_Time}
Sushil Singh1560e652022-08-03 13:25:01 -0500203
204 ${task_inv_dict}= Get Task State from File
205
206 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path}
207
208 Log To Console Start uploading image to BMC.
209 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data}
210 Log To Console Completed image upload to BMC.
211
212 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService
213
214 Rprint Vars task_inv
215
216 Wait Until Keyword Succeeds 5 min 10 sec
217 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskCompleted']}
218
Sushil Singhb13fc362020-02-06 03:40:56 -0600219 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
Sushil Singhf7674a52019-11-19 00:36:15 -0600220 Redfish.Login
Sushil Singhb13fc362020-02-06 03:40:56 -0600221 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
Sushil Singh811ffae2019-10-23 05:16:22 -0500222 Verify Get ApplyTime ${apply_time}
Sushil Singhcdebdd52019-08-14 15:29:24 -0500223
Sushil Singhffbfedf2019-10-17 15:58:25 -0500224
225Redfish Multiple Upload Image And Check Progress State
226 [Documentation] Update multiple BMC firmware via redfish interface and check status.
227 [Arguments] ${apply_time} ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
228
229 # Description of argument(s):
230 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate").
231 # IMAGE_FILE_PATH The path to BMC image file.
232 # ALTERNATE_IMAGE_FILE_PATH The path to alternate BMC image file.
233
Sushil Singhb13fc362020-02-06 03:40:56 -0600234 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhffbfedf2019-10-17 15:58:25 -0500235 Valid File Path ALTERNATE_IMAGE_FILE_PATH
236 ${state}= Get Pre Reboot State
237 Rprint Vars state
238
239 Set ApplyTime policy=${apply_time}
240 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH}
241
242 ${first_image_id}= Get Latest Image ID
243 Rprint Vars first_image_id
244 Sleep 5s
245 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${ALTERNATE_IMAGE_FILE_PATH}
246
247 ${second_image_id}= Get Latest Image ID
248 Rprint Vars second_image_id
249
250 Check Image Update Progress State
251 ... match_state='Updating', 'Disabled' image_id=${second_image_id}
252
253 Check Image Update Progress State
254 ... match_state='Updating' image_id=${first_image_id}
255
256 Wait Until Keyword Succeeds 8 min 20 sec
257 ... Check Image Update Progress State
258 ... match_state='Enabled' image_id=${first_image_id}
Sushil Singhb13fc362020-02-06 03:40:56 -0600259 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
260 Redfish.Login
261 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
Sushil Singha83bba02023-01-18 08:43:45 -0600262
263
Sushil Singh44bfc202023-02-08 09:53:36 -0600264Run Configure BMC Hostname In Loop
265 [Documentation] Update hostname in loop.
266 [Arguments] ${count}
267
268 # Description of argument(s):
269 # count Loop count.
270
271 FOR ${index} IN RANGE ${count}
272 Configure Hostname  hostname=${HOSTNAME}[${index}] status_code=[${HTTP_INTERNAL_SERVER_ERROR}]
273 END
274
275
276Run Operation On BMC
277 [Documentation] Run operation on BMC.
278 [Arguments] ${operation} ${count}
279
280 # Description of argument(s):
281 # operation If host_name then change hostname.
282 # count Loop count.
283
284 Run Keyword If '${operation}' == 'host_name' Run Configure BMC Hostname In Loop count=${count}
285 Run Keyword If '${operation}' == 'kernel_panic'
286 ... Run Keywords Kernel Panic BMC Reset Operation AND
287 ... Is BMC Unpingable
288
289
290Get Active Firmware Image
291 [Documentation] Return get active firmware image.
292
293 ${active_image}= Redfish.Get Attribute /redfish/v1/Managers/bmc Links
294 Rprint Vars active_image
295
296 [Return] ${active_image}
297
298
299Verify Redfish Code Update With Different Interrupted Operation
George Keishing4611b812023-02-16 09:44:33 -0600300 [Documentation] Verify code update is successful when other operation
301 ... getting executed i.e. change the hostname.
Sushil Singh44bfc202023-02-08 09:53:36 -0600302 [Arguments] ${operation} ${count}
303
304 # Description of argument(s):
305 # operation host_name to change Hostname, kernel_panic to perform kernel panic.
306 # count Number of times loop will get executed.
307
308 ${before_update_activeswimage}= Get Active Firmware Image
309
310 ${post_code_update_actions}= Get Post Boot Action
311
312 Set ApplyTime policy=OnReset
313
314 ${task_inv_dict}= Get Task State from File
315
316 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path}
317
318 Log To Console Start uploading image to BMC.
319 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data}
320 Log To Console Completed image upload to BMC.
321
322 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService
323 Rprint Vars task_inv
324
325 Wait Until Keyword Succeeds 1 min 10 sec
326 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskStarting']}
327
328 Run Operation On BMC ${operation} ${count}
329
330 Run Keyword If '${operation}' == 'kernel_panic'
331 ... Wait Until Keyword Succeeds 10 min 10 sec Is BMC Standby
332
333 Run Keyword If '${operation}' == 'host_name'
334 ... Run Keywords Wait Until Keyword Succeeds 5 min 10 sec
335 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskCompleted']} AND
336 ... Run Key ${post_code_update_actions['BMC image']['OnReset']} AND
337 ... Redfish.Login AND
338 ... Redfish Verify BMC Version ${IMAGE_FILE_PATH}
339
340 ${after_update_activeswimage}= Get Active Firmware Image
341
342 ${status}= Run Keyword And Return Status Should Be Equal As Strings
343 ... ${before_update_activeswimage['ActiveSoftwareImage']['@odata.id']}
344 ... ${after_update_activeswimage['ActiveSoftwareImage']['@odata.id']}
345
346 Run Keyword If '${operation}' == 'kernel_panic'
347 ... Should Be True ${status}
348 ... ELSE
349 ... Should Not Be True ${status}
350
351 Verify Get ApplyTime OnReset
352