blob: e050d23580ed5c76db59ff4c74af81ecbabe530b [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 Singhcdebdd52019-08-14 15:29:24 -050022Library ../../lib/gen_robot_valid.py
23Library ../../lib/tftp_update_utils.py
Sushil Singhf7674a52019-11-19 00:36:15 -060024Library ../../lib/gen_robot_keyword.py
Sushil Singhcdebdd52019-08-14 15:29:24 -050025
26Suite Setup Suite Setup Execution
27Suite Teardown Redfish.Logout
28Test Setup Printn
29Test Teardown FFDC On Test Case Fail
30
31Force Tags BMC_Code_Update
32
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060033*** Variables ***
34
35@{ADMIN} admin_user TestPwd123
36&{USERS} Administrator=${ADMIN}
Sushil Singhc915f5e2022-12-21 08:18:31 -060037${LOOP_COUNT} ${2}
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060038
Sushil Singhcdebdd52019-08-14 15:29:24 -050039*** Test Cases ***
40
41Redfish Code Update With ApplyTime OnReset
George Keishing16b3c7b2021-01-28 09:23:37 -060042 [Documentation] Update the firmware image with ApplyTime of OnReset.
Sushil Singhcdebdd52019-08-14 15:29:24 -050043 [Tags] Redfish_Code_Update_With_ApplyTime_OnReset
44 [Template] Redfish Update Firmware
45
46 # policy
47 OnReset
48
49
50Redfish Code Update With ApplyTime Immediate
George Keishing16b3c7b2021-01-28 09:23:37 -060051 [Documentation] Update the firmware image with ApplyTime of Immediate.
Sushil Singhcdebdd52019-08-14 15:29:24 -050052 [Tags] Redfish_Code_Update_With_ApplyTime_Immediate
53 [Template] Redfish Update Firmware
54
55 # policy
56 Immediate
57
58
Sushil Singhc915f5e2022-12-21 08:18:31 -060059Redfish Code Update Same Firmware Multiple Times
60 [Documentation] Multiple times update the firmware image for update service.
61 [Tags] Redfish_Code_Update_Same_Firmware_Multiple_Times
62
63 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1
64
65 FOR ${count} IN RANGE 1 ${temp_update_loop_count}
66 Print Timen **************************************
67 Print Timen * The Current Loop Count is ${count} of ${LOOP_COUNT} *
68 Print Timen **************************************
69
70 Redfish Update Firmware apply_time=OnReset
71 END
72
73
74
Sushil Singhffbfedf2019-10-17 15:58:25 -050075Redfish Code Update With Multiple Firmware
George Keishing16b3c7b2021-01-28 09:23:37 -060076 [Documentation] Update the firmware image with ApplyTime of Immediate.
Sushil Singhffbfedf2019-10-17 15:58:25 -050077 [Tags] Redfish_Code_Update_With_Multiple_Firmware
78 [Template] Redfish Multiple Upload Image And Check Progress State
79
80 # policy image_file_path alternate_image_file_path
81 Immediate ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
82
83
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060084Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup
Sushil Singh5166ebd2021-05-31 01:24:16 -050085 [Documentation] Verify updated admin credential remain same post switch to back up image.
George Keishing5236ec52022-01-31 12:07:58 -060086 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Image_Switched_To_Backup
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -060087 [Setup] Create Users With Different Roles users=${USERS} force=${True}
88 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
89
90 ${post_code_update_actions}= Get Post Boot Action
91 ${state}= Get Pre Reboot State
92 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
93
94 Redfish.Login
95 # change to backup image and reset the BMC.
96 Switch Backup Firmware Image To Functional
97 Wait For Reboot start_boot_seconds=${state['epoch_seconds']}
98
99 # verify modified admin password on backup image.
100 Redfish.Login admin_user 0penBmc123
101 Redfish.Logout
102
Sushil Singh5166ebd2021-05-31 01:24:16 -0500103
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600104Verify If The Modified Admin Credential Is Valid Post Update
Sushil Singh5166ebd2021-05-31 01:24:16 -0500105 [Documentation] Verify updated admin credential remain same post code update image.
George Keishing5236ec52022-01-31 12:07:58 -0600106 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Update
Anves Kumar rayankula7ed1ae82021-02-03 04:19:46 -0600107 [Setup] Create Users With Different Roles users=${USERS} force=${True}
108 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS}
109
110 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123
111
112 Redfish.Login
113 # Flash latest firmware using redfish.
114 Redfish Update Firmware OnReset
115
116 # verify modified admin credentails on latest image.
117 Redfish.Login admin_user 0penBmc123
118 Redfish.Logout
119
Sushil Singhcdebdd52019-08-14 15:29:24 -0500120*** Keywords ***
121
122Suite Setup Execution
123 [Documentation] Do the suite setup.
124
Sushil Singhcdebdd52019-08-14 15:29:24 -0500125 Valid File Path IMAGE_FILE_PATH
126 Redfish.Login
Tim Lee4aff2d02021-06-08 13:26:25 +0800127 Redfish Delete All BMC Dumps
Sushil Singhcdebdd52019-08-14 15:29:24 -0500128 Redfish Purge Event Log
129
130
131Redfish Update Firmware
132 [Documentation] Update the BMC firmware via redfish interface.
133 [Arguments] ${apply_time}
134
135 # Description of argument(s):
136 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
137
Sushil Singhb13fc362020-02-06 03:40:56 -0600138 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhcdebdd52019-08-14 15:29:24 -0500139 ${state}= Get Pre Reboot State
140 Rprint Vars state
Sushil Singh6f86f172019-10-30 11:36:25 -0500141 Set ApplyTime policy=${apply_Time}
Sushil Singh1560e652022-08-03 13:25:01 -0500142
143 ${task_inv_dict}= Get Task State from File
144
145 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path}
146
147 Log To Console Start uploading image to BMC.
148 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data}
149 Log To Console Completed image upload to BMC.
150
151 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService
152
153 Rprint Vars task_inv
154
155 Wait Until Keyword Succeeds 5 min 10 sec
156 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskCompleted']}
157
Sushil Singhb13fc362020-02-06 03:40:56 -0600158 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
Sushil Singhf7674a52019-11-19 00:36:15 -0600159 Redfish.Login
Sushil Singhb13fc362020-02-06 03:40:56 -0600160 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
Sushil Singh811ffae2019-10-23 05:16:22 -0500161 Verify Get ApplyTime ${apply_time}
Sushil Singhcdebdd52019-08-14 15:29:24 -0500162
Sushil Singhffbfedf2019-10-17 15:58:25 -0500163
164Redfish Multiple Upload Image And Check Progress State
165 [Documentation] Update multiple BMC firmware via redfish interface and check status.
166 [Arguments] ${apply_time} ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH}
167
168 # Description of argument(s):
169 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate").
170 # IMAGE_FILE_PATH The path to BMC image file.
171 # ALTERNATE_IMAGE_FILE_PATH The path to alternate BMC image file.
172
Sushil Singhb13fc362020-02-06 03:40:56 -0600173 ${post_code_update_actions}= Get Post Boot Action
Sushil Singhffbfedf2019-10-17 15:58:25 -0500174 Valid File Path ALTERNATE_IMAGE_FILE_PATH
175 ${state}= Get Pre Reboot State
176 Rprint Vars state
177
178 Set ApplyTime policy=${apply_time}
179 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH}
180
181 ${first_image_id}= Get Latest Image ID
182 Rprint Vars first_image_id
183 Sleep 5s
184 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${ALTERNATE_IMAGE_FILE_PATH}
185
186 ${second_image_id}= Get Latest Image ID
187 Rprint Vars second_image_id
188
189 Check Image Update Progress State
190 ... match_state='Updating', 'Disabled' image_id=${second_image_id}
191
192 Check Image Update Progress State
193 ... match_state='Updating' image_id=${first_image_id}
194
195 Wait Until Keyword Succeeds 8 min 20 sec
196 ... Check Image Update Progress State
197 ... match_state='Enabled' image_id=${first_image_id}
Sushil Singhb13fc362020-02-06 03:40:56 -0600198 Run Key ${post_code_update_actions['BMC image']['${apply_time}']}
199 Redfish.Login
200 Redfish Verify BMC Version ${IMAGE_FILE_PATH}