blob: 5a3e81b8d22659cc64257b99dfde6ac208970df8 [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 Singhcdebdd52019-08-14 15:29:24 -050023Library ../../lib/gen_robot_valid.py
24Library ../../lib/tftp_update_utils.py
Sushil Singhf7674a52019-11-19 00:36:15 -060025Library ../../lib/gen_robot_keyword.py
Sushil Singhcdebdd52019-08-14 15:29:24 -050026
27Suite Setup Suite Setup Execution
28Suite Teardown Redfish.Logout
29Test Setup Printn
30Test Teardown FFDC On Test Case Fail
31
32Force Tags BMC_Code_Update
33
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060034*** Variables ***
35
36@{ADMIN} admin_user TestPwd123
37&{USERS} Administrator=${ADMIN}
Sushil Singhc915f5e2022-12-21 08:18:31 -060038${LOOP_COUNT} ${2}
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060039
Sushil Singhcdebdd52019-08-14 15:29:24 -050040*** Test Cases ***
41
42Redfish Code Update With ApplyTime OnReset
George Keishing16b3c7b2021-01-28 09:23:37 -060043 [Documentation] Update the firmware image with ApplyTime of OnReset.
Sushil Singhcdebdd52019-08-14 15:29:24 -050044 [Tags] Redfish_Code_Update_With_ApplyTime_OnReset
45 [Template] Redfish Update Firmware
46
47 # policy
48 OnReset
49
50
51Redfish Code Update With ApplyTime Immediate
George Keishing16b3c7b2021-01-28 09:23:37 -060052 [Documentation] Update the firmware image with ApplyTime of Immediate.
Sushil Singhcdebdd52019-08-14 15:29:24 -050053 [Tags] Redfish_Code_Update_With_ApplyTime_Immediate
54 [Template] Redfish Update Firmware
55
56 # policy
57 Immediate
58
59
Sushil Singhc915f5e2022-12-21 08:18:31 -060060Redfish Code Update Same Firmware Multiple Times
61 [Documentation] Multiple times update the firmware image for update service.
62 [Tags] Redfish_Code_Update_Same_Firmware_Multiple_Times
63
64 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1
65
66 FOR ${count} IN RANGE 1 ${temp_update_loop_count}
Sushil Singha83bba02023-01-18 08:43:45 -060067 Print Timen ***************************************
Sushil Singhc915f5e2022-12-21 08:18:31 -060068 Print Timen * The Current Loop Count is ${count} of ${LOOP_COUNT} *
Sushil Singha83bba02023-01-18 08:43:45 -060069 Print Timen ***************************************
Sushil Singhc915f5e2022-12-21 08:18:31 -060070
71 Redfish Update Firmware apply_time=OnReset
72 END
73
74
75
Sushil Singhffbfedf2019-10-17 15:58:25 -050076Redfish Code Update With Multiple Firmware
George Keishing16b3c7b2021-01-28 09:23:37 -060077 [Documentation] Update the firmware image with ApplyTime of Immediate.
Sushil Singhffbfedf2019-10-17 15:58:25 -050078 [Tags] Redfish_Code_Update_With_Multiple_Firmware
79 [Template] Redfish Multiple Upload Image And Check Progress State
80
81 # policy image_file_path alternate_image_file_path
82 Immediate ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
83
84
Sushil Singhc8526a22022-12-21 10:26:19 -060085Post BMC Reset Perform Redfish Code Update
86 [Documentation] Test to reset BMC at standby and then perform BMC firmware update and
87 ... ensure there is not error or dump logs post update.
88 [Tags] Post_BMC_Reset_Perform_Redfish_Code_Update
89
90 Redfish Delete All BMC Dumps
91 Redfish Purge Event Log
92
93 Redfish OBMC Reboot (off)
94
95 Redfish Update Firmware apply_time=OnReset
96
97 Event Log Should Not Exist
98 Redfish BMC Dump Should Not Exist
99
100 Redfish Power Off
101
102
103Post BMC Reset Perform Image Switched To Backup Multiple Times
George Keishing0d930e92023-01-25 13:19:37 -0600104 [Documentation] Test to reset BMC at standby and then perform switch
105 ... to backup image multiple times.
Sushil Singhc8526a22022-12-21 10:26:19 -0600106 ... Then ensure no event and dump logs exist.
107 [Tags] Post_BMC_Reset_Perform_Image_Switched_To_Backup_Multiple_Times
108
109 Redfish Delete All BMC Dumps
110 Redfish Purge Event Log
111
112 Redfish OBMC Reboot (off)
113
114 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1
115
116 FOR ${count} IN RANGE 1 ${temp_update_loop_count}
117 ${state}= Get Pre Reboot State
118
119 # change to backup image and reset the BMC.
120 Switch Backup Firmware Image To Functional
121
122 Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
123 END
124
125 Event Log Should Not Exist
126 Redfish BMC Dump Should Not Exist
127
128
Sushil Singha83bba02023-01-18 08:43:45 -0600129Verify Code Update Fails When Kernel Panic Occur
130 [Documentation] Ensure firmware update is un-successful when kernel panic
131 ... occur during ongoing firmware update.
132 [Tags] Verify_Code_Update_Fails_When_Kernel_Panic_Occur
133
134 ${before_update_activeswimage}= Redfish.Get Attribute /redfish/v1/Managers/bmc Links
135 Rprint Vars before_update_activeswimage
136
137 Set ApplyTime policy=OnReset
138
139 ${task_inv_dict}= Get Task State from File
140
141 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path}
142
143 Log To Console Start uploading image to BMC.
144 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data}
145 Log To Console Completed image upload to BMC.
146
147 Sleep 5
148
149 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService
150 Rprint Vars task_inv
151
152 Run Keyword Kernel Panic BMC Reset Operation
153
154 Is BMC Unpingable
155
156 Wait Until Keyword Succeeds 10 min 10 sec Is BMC Standby
157
158 Redfish.Login
159
160 ${after_update_activeswimage}= Redfish.Get Attribute /redfish/v1/Managers/bmc Links
161 Rprint Vars after_update_activeswimage
162
163 Should Be Equal As Strings
164 ... ${before_update_activeswimage['ActiveSoftwareImage']['@odata.id']}
165 ... ${after_update_activeswimage['ActiveSoftwareImage']['@odata.id']}
166
167 Verify Get ApplyTime OnReset
168
169
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600170Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup
Sushil Singh5166ebd2021-05-31 01:24:16 -0500171 [Documentation] Verify updated admin credential remain same post switch to back up image.
George Keishing5236ec52022-01-31 12:07:58 -0600172 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Image_Switched_To_Backup
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600173 [Setup] Create Users With Different Roles users=${USERS} force=${True}
174 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
175
176 ${post_code_update_actions}= Get Post Boot Action
177 ${state}= Get Pre Reboot State
178 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
179
180 Redfish.Login
181 # change to backup image and reset the BMC.
182 Switch Backup Firmware Image To Functional
183 Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
184
185 # verify modified admin password on backup image.
186 Redfish.Login admin_user 0penBmc123
187 Redfish.Logout
188
Sushil Singh5166ebd2021-05-31 01:24:16 -0500189
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600190Verify If The Modified Admin Credential Is Valid Post Update
Sushil Singh5166ebd2021-05-31 01:24:16 -0500191 [Documentation] Verify updated admin credential remain same post code update image.
George Keishing5236ec52022-01-31 12:07:58 -0600192 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Update
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600193 [Setup] Create Users With Different Roles users=${USERS} force=${True}
194 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
195
196 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
197
198 Redfish.Login
199 # Flash latest firmware using redfish.
200 Redfish Update Firmware OnReset
201
202 # verify modified admin credentails on latest image.
203 Redfish.Login admin_user 0penBmc123
204 Redfish.Logout
205
Sushil Singhcdebdd52019-08-14 15:29:24 -0500206*** Keywords ***
207
208Suite Setup Execution
209 [Documentation] Do the suite setup.
210
Sushil Singhcdebdd52019-08-14 15:29:24 -0500211 Valid File Path IMAGE_FILE_PATH
212 Redfish.Login
Sushil Singhc8526a22022-12-21 10:26:19 -0600213
Tim Lee4aff2d02021-06-08 13:26:25 +0800214 Redfish Delete All BMC Dumps
Sushil Singhcdebdd52019-08-14 15:29:24 -0500215 Redfish Purge Event Log
216
Sushil Singhc8526a22022-12-21 10:26:19 -0600217 Redfish Power Off stack_mode=skip
218
Sushil Singhcdebdd52019-08-14 15:29:24 -0500219
220Redfish Update Firmware
221 [Documentation] Update the BMC firmware via redfish interface.
222 [Arguments] ${apply_time}
223
224 # Description of argument(s):
225 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
226
Sushil Singhb13fc362020-02-06 03:40:56 -0600227 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhcdebdd52019-08-14 15:29:24 -0500228 ${state}= Get Pre Reboot State
229 Rprint Vars state
Sushil Singh6f86f172019-10-30 11:36:25 -0500230 Set ApplyTime policy=${apply_Time}
Sushil Singh1560e652022-08-03 13:25:01 -0500231
232 ${task_inv_dict}= Get Task State from File
233
234 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path}
235
236 Log To Console Start uploading image to BMC.
237 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data}
238 Log To Console Completed image upload to BMC.
239
240 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService
241
242 Rprint Vars task_inv
243
244 Wait Until Keyword Succeeds 5 min 10 sec
245 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskCompleted']}
246
Sushil Singhb13fc362020-02-06 03:40:56 -0600247 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
Sushil Singhf7674a52019-11-19 00:36:15 -0600248 Redfish.Login
Sushil Singhb13fc362020-02-06 03:40:56 -0600249 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
Sushil Singh811ffae2019-10-23 05:16:22 -0500250 Verify Get ApplyTime ${apply_time}
Sushil Singhcdebdd52019-08-14 15:29:24 -0500251
Sushil Singhffbfedf2019-10-17 15:58:25 -0500252
253Redfish Multiple Upload Image And Check Progress State
254 [Documentation] Update multiple BMC firmware via redfish interface and check status.
255 [Arguments] ${apply_time} ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
256
257 # Description of argument(s):
258 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate").
259 # IMAGE_FILE_PATH The path to BMC image file.
260 # ALTERNATE_IMAGE_FILE_PATH The path to alternate BMC image file.
261
Sushil Singhb13fc362020-02-06 03:40:56 -0600262 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhffbfedf2019-10-17 15:58:25 -0500263 Valid File Path ALTERNATE_IMAGE_FILE_PATH
264 ${state}= Get Pre Reboot State
265 Rprint Vars state
266
267 Set ApplyTime policy=${apply_time}
268 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH}
269
270 ${first_image_id}= Get Latest Image ID
271 Rprint Vars first_image_id
272 Sleep 5s
273 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${ALTERNATE_IMAGE_FILE_PATH}
274
275 ${second_image_id}= Get Latest Image ID
276 Rprint Vars second_image_id
277
278 Check Image Update Progress State
279 ... match_state='Updating', 'Disabled' image_id=${second_image_id}
280
281 Check Image Update Progress State
282 ... match_state='Updating' image_id=${first_image_id}
283
284 Wait Until Keyword Succeeds 8 min 20 sec
285 ... Check Image Update Progress State
286 ... match_state='Enabled' image_id=${first_image_id}
Sushil Singhb13fc362020-02-06 03:40:56 -0600287 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
288 Redfish.Login
289 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
Sushil Singha83bba02023-01-18 08:43:45 -0600290
291