blob: 8636e96e22fbe1d528748571fd213bd0c815ddb3 [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}
67 Print Timen **************************************
68 Print Timen * The Current Loop Count is ${count} of ${LOOP_COUNT} *
69 Print Timen **************************************
70
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
104 [Documentation] Test to reset BMC at standby and then perfrom switch to backup image multiple times.
105 ... Then ensure no event and dump logs exist.
106 [Tags] Post_BMC_Reset_Perform_Image_Switched_To_Backup_Multiple_Times
107
108 Redfish Delete All BMC Dumps
109 Redfish Purge Event Log
110
111 Redfish OBMC Reboot (off)
112
113 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1
114
115 FOR ${count} IN RANGE 1 ${temp_update_loop_count}
116 ${state}= Get Pre Reboot State
117
118 # change to backup image and reset the BMC.
119 Switch Backup Firmware Image To Functional
120
121 Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
122 END
123
124 Event Log Should Not Exist
125 Redfish BMC Dump Should Not Exist
126
127
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600128Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup
Sushil Singh5166ebd2021-05-31 01:24:16 -0500129 [Documentation] Verify updated admin credential remain same post switch to back up image.
George Keishing5236ec52022-01-31 12:07:58 -0600130 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Image_Switched_To_Backup
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600131 [Setup] Create Users With Different Roles users=${USERS} force=${True}
132 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
133
134 ${post_code_update_actions}= Get Post Boot Action
135 ${state}= Get Pre Reboot State
136 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
137
138 Redfish.Login
139 # change to backup image and reset the BMC.
140 Switch Backup Firmware Image To Functional
141 Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
142
143 # verify modified admin password on backup image.
144 Redfish.Login admin_user 0penBmc123
145 Redfish.Logout
146
Sushil Singh5166ebd2021-05-31 01:24:16 -0500147
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600148Verify If The Modified Admin Credential Is Valid Post Update
Sushil Singh5166ebd2021-05-31 01:24:16 -0500149 [Documentation] Verify updated admin credential remain same post code update image.
George Keishing5236ec52022-01-31 12:07:58 -0600150 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Update
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600151 [Setup] Create Users With Different Roles users=${USERS} force=${True}
152 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
153
154 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
155
156 Redfish.Login
157 # Flash latest firmware using redfish.
158 Redfish Update Firmware OnReset
159
160 # verify modified admin credentails on latest image.
161 Redfish.Login admin_user 0penBmc123
162 Redfish.Logout
163
Sushil Singhcdebdd52019-08-14 15:29:24 -0500164*** Keywords ***
165
166Suite Setup Execution
167 [Documentation] Do the suite setup.
168
Sushil Singhcdebdd52019-08-14 15:29:24 -0500169 Valid File Path IMAGE_FILE_PATH
170 Redfish.Login
Sushil Singhc8526a22022-12-21 10:26:19 -0600171
Tim Lee4aff2d02021-06-08 13:26:25 +0800172 Redfish Delete All BMC Dumps
Sushil Singhcdebdd52019-08-14 15:29:24 -0500173 Redfish Purge Event Log
174
Sushil Singhc8526a22022-12-21 10:26:19 -0600175 Redfish Power Off stack_mode=skip
176
Sushil Singhcdebdd52019-08-14 15:29:24 -0500177
178Redfish Update Firmware
179 [Documentation] Update the BMC firmware via redfish interface.
180 [Arguments] ${apply_time}
181
182 # Description of argument(s):
183 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
184
Sushil Singhb13fc362020-02-06 03:40:56 -0600185 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhcdebdd52019-08-14 15:29:24 -0500186 ${state}= Get Pre Reboot State
187 Rprint Vars state
Sushil Singh6f86f172019-10-30 11:36:25 -0500188 Set ApplyTime policy=${apply_Time}
Sushil Singh1560e652022-08-03 13:25:01 -0500189
190 ${task_inv_dict}= Get Task State from File
191
192 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path}
193
194 Log To Console Start uploading image to BMC.
195 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data}
196 Log To Console Completed image upload to BMC.
197
198 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService
199
200 Rprint Vars task_inv
201
202 Wait Until Keyword Succeeds 5 min 10 sec
203 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskCompleted']}
204
Sushil Singhb13fc362020-02-06 03:40:56 -0600205 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
Sushil Singhf7674a52019-11-19 00:36:15 -0600206 Redfish.Login
Sushil Singhb13fc362020-02-06 03:40:56 -0600207 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
Sushil Singh811ffae2019-10-23 05:16:22 -0500208 Verify Get ApplyTime ${apply_time}
Sushil Singhcdebdd52019-08-14 15:29:24 -0500209
Sushil Singhffbfedf2019-10-17 15:58:25 -0500210
211Redfish Multiple Upload Image And Check Progress State
212 [Documentation] Update multiple BMC firmware via redfish interface and check status.
213 [Arguments] ${apply_time} ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
214
215 # Description of argument(s):
216 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate").
217 # IMAGE_FILE_PATH The path to BMC image file.
218 # ALTERNATE_IMAGE_FILE_PATH The path to alternate BMC image file.
219
Sushil Singhb13fc362020-02-06 03:40:56 -0600220 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhffbfedf2019-10-17 15:58:25 -0500221 Valid File Path ALTERNATE_IMAGE_FILE_PATH
222 ${state}= Get Pre Reboot State
223 Rprint Vars state
224
225 Set ApplyTime policy=${apply_time}
226 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH}
227
228 ${first_image_id}= Get Latest Image ID
229 Rprint Vars first_image_id
230 Sleep 5s
231 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${ALTERNATE_IMAGE_FILE_PATH}
232
233 ${second_image_id}= Get Latest Image ID
234 Rprint Vars second_image_id
235
236 Check Image Update Progress State
237 ... match_state='Updating', 'Disabled' image_id=${second_image_id}
238
239 Check Image Update Progress State
240 ... match_state='Updating' image_id=${first_image_id}
241
242 Wait Until Keyword Succeeds 8 min 20 sec
243 ... Check Image Update Progress State
244 ... match_state='Enabled' image_id=${first_image_id}
Sushil Singhb13fc362020-02-06 03:40:56 -0600245 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
246 Redfish.Login
247 Redfish Verify BMC Version ${IMAGE_FILE_PATH}