Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation 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 | |
| 12 | Resource ../../lib/resource.robot |
| 13 | Resource ../../lib/bmc_redfish_resource.robot |
| 14 | Resource ../../lib/openbmc_ffdc.robot |
| 15 | Resource ../../lib/common_utils.robot |
| 16 | Resource ../../lib/code_update_utils.robot |
| 17 | Resource ../../lib/dump_utils.robot |
| 18 | Resource ../../lib/logging_utils.robot |
| 19 | Resource ../../lib/redfish_code_update_utils.robot |
Sushil Singh | b13fc36 | 2020-02-06 03:40:56 -0600 | [diff] [blame] | 20 | Resource ../../lib/utils.robot |
Anves Kumar rayankula | 7ed1ae8 | 2021-02-03 04:19:46 -0600 | [diff] [blame] | 21 | Resource ../../lib/bmc_redfish_utils.robot |
Sushil Singh | c8526a2 | 2022-12-21 10:26:19 -0600 | [diff] [blame] | 22 | Resource ../../lib/external_intf/management_console_utils.robot |
Sushil Singh | 44bfc20 | 2023-02-08 09:53:36 -0600 | [diff] [blame] | 23 | Resource ../../lib/bmc_network_utils.robot |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 24 | Library ../../lib/gen_robot_valid.py |
| 25 | Library ../../lib/tftp_update_utils.py |
Sushil Singh | f7674a5 | 2019-11-19 00:36:15 -0600 | [diff] [blame] | 26 | Library ../../lib/gen_robot_keyword.py |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 27 | |
| 28 | Suite Setup Suite Setup Execution |
| 29 | Suite Teardown Redfish.Logout |
| 30 | Test Setup Printn |
| 31 | Test Teardown FFDC On Test Case Fail |
| 32 | |
| 33 | Force Tags BMC_Code_Update |
| 34 | |
Anves Kumar rayankula | 7ed1ae8 | 2021-02-03 04:19:46 -0600 | [diff] [blame] | 35 | *** Variables *** |
| 36 | |
| 37 | @{ADMIN} admin_user TestPwd123 |
| 38 | &{USERS} Administrator=${ADMIN} |
Sushil Singh | c915f5e | 2022-12-21 08:18:31 -0600 | [diff] [blame] | 39 | ${LOOP_COUNT} ${2} |
Sushil Singh | 44bfc20 | 2023-02-08 09:53:36 -0600 | [diff] [blame] | 40 | @{HOSTNAME} bmc_system01 bmc_system02 bmc_system03 bmc_system04 bmc_system05 |
Anves Kumar rayankula | 7ed1ae8 | 2021-02-03 04:19:46 -0600 | [diff] [blame] | 41 | |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 42 | *** Test Cases *** |
| 43 | |
| 44 | Redfish Code Update With ApplyTime OnReset |
George Keishing | 16b3c7b | 2021-01-28 09:23:37 -0600 | [diff] [blame] | 45 | [Documentation] Update the firmware image with ApplyTime of OnReset. |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 46 | [Tags] Redfish_Code_Update_With_ApplyTime_OnReset |
| 47 | [Template] Redfish Update Firmware |
| 48 | |
| 49 | # policy |
| 50 | OnReset |
| 51 | |
| 52 | |
| 53 | Redfish Code Update With ApplyTime Immediate |
George Keishing | 16b3c7b | 2021-01-28 09:23:37 -0600 | [diff] [blame] | 54 | [Documentation] Update the firmware image with ApplyTime of Immediate. |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 55 | [Tags] Redfish_Code_Update_With_ApplyTime_Immediate |
| 56 | [Template] Redfish Update Firmware |
| 57 | |
| 58 | # policy |
| 59 | Immediate |
| 60 | |
| 61 | |
Sushil Singh | c915f5e | 2022-12-21 08:18:31 -0600 | [diff] [blame] | 62 | Redfish 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 Singh | a83bba0 | 2023-01-18 08:43:45 -0600 | [diff] [blame] | 69 | Print Timen *************************************** |
Sushil Singh | c915f5e | 2022-12-21 08:18:31 -0600 | [diff] [blame] | 70 | Print Timen * The Current Loop Count is ${count} of ${LOOP_COUNT} * |
Sushil Singh | a83bba0 | 2023-01-18 08:43:45 -0600 | [diff] [blame] | 71 | Print Timen *************************************** |
Sushil Singh | c915f5e | 2022-12-21 08:18:31 -0600 | [diff] [blame] | 72 | |
| 73 | Redfish Update Firmware apply_time=OnReset |
| 74 | END |
| 75 | |
| 76 | |
| 77 | |
Sushil Singh | ffbfedf | 2019-10-17 15:58:25 -0500 | [diff] [blame] | 78 | Redfish Code Update With Multiple Firmware |
George Keishing | 16b3c7b | 2021-01-28 09:23:37 -0600 | [diff] [blame] | 79 | [Documentation] Update the firmware image with ApplyTime of Immediate. |
Sushil Singh | ffbfedf | 2019-10-17 15:58:25 -0500 | [diff] [blame] | 80 | [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 Singh | c8526a2 | 2022-12-21 10:26:19 -0600 | [diff] [blame] | 87 | Post 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 | |
| 105 | Post BMC Reset Perform Image Switched To Backup Multiple Times |
George Keishing | 0d930e9 | 2023-01-25 13:19:37 -0600 | [diff] [blame] | 106 | [Documentation] Test to reset BMC at standby and then perform switch |
| 107 | ... to backup image multiple times. |
Sushil Singh | c8526a2 | 2022-12-21 10:26:19 -0600 | [diff] [blame] | 108 | ... 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 rayankula | 7ed1ae8 | 2021-02-03 04:19:46 -0600 | [diff] [blame] | 131 | Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup |
Sushil Singh | 5166ebd | 2021-05-31 01:24:16 -0500 | [diff] [blame] | 132 | [Documentation] Verify updated admin credential remain same post switch to back up image. |
George Keishing | 5236ec5 | 2022-01-31 12:07:58 -0600 | [diff] [blame] | 133 | [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Image_Switched_To_Backup |
Anves Kumar rayankula | 7ed1ae8 | 2021-02-03 04:19:46 -0600 | [diff] [blame] | 134 | [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 Singh | 5166ebd | 2021-05-31 01:24:16 -0500 | [diff] [blame] | 150 | |
Anves Kumar rayankula | 7ed1ae8 | 2021-02-03 04:19:46 -0600 | [diff] [blame] | 151 | Verify If The Modified Admin Credential Is Valid Post Update |
Sushil Singh | 5166ebd | 2021-05-31 01:24:16 -0500 | [diff] [blame] | 152 | [Documentation] Verify updated admin credential remain same post code update image. |
George Keishing | 5236ec5 | 2022-01-31 12:07:58 -0600 | [diff] [blame] | 153 | [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Update |
Anves Kumar rayankula | 7ed1ae8 | 2021-02-03 04:19:46 -0600 | [diff] [blame] | 154 | [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 Singh | 44bfc20 | 2023-02-08 09:53:36 -0600 | [diff] [blame] | 167 | |
| 168 | Redfish 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 Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 178 | *** Keywords *** |
| 179 | |
| 180 | Suite Setup Execution |
| 181 | [Documentation] Do the suite setup. |
| 182 | |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 183 | Valid File Path IMAGE_FILE_PATH |
| 184 | Redfish.Login |
Sushil Singh | c8526a2 | 2022-12-21 10:26:19 -0600 | [diff] [blame] | 185 | |
Tim Lee | 4aff2d0 | 2021-06-08 13:26:25 +0800 | [diff] [blame] | 186 | Redfish Delete All BMC Dumps |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 187 | Redfish Purge Event Log |
| 188 | |
Sushil Singh | c8526a2 | 2022-12-21 10:26:19 -0600 | [diff] [blame] | 189 | Redfish Power Off stack_mode=skip |
| 190 | |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 191 | |
| 192 | Redfish 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 Singh | b13fc36 | 2020-02-06 03:40:56 -0600 | [diff] [blame] | 199 | ${post_code_update_actions}= Get Post Boot Action |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 200 | ${state}= Get Pre Reboot State |
| 201 | Rprint Vars state |
Sushil Singh | 6f86f17 | 2019-10-30 11:36:25 -0500 | [diff] [blame] | 202 | Set ApplyTime policy=${apply_Time} |
Sushil Singh | 1560e65 | 2022-08-03 13:25:01 -0500 | [diff] [blame] | 203 | |
| 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 Singh | b13fc36 | 2020-02-06 03:40:56 -0600 | [diff] [blame] | 219 | Run Key ${post_code_update_actions['BMC image']['${apply_time}']} |
Sushil Singh | f7674a5 | 2019-11-19 00:36:15 -0600 | [diff] [blame] | 220 | Redfish.Login |
Sushil Singh | b13fc36 | 2020-02-06 03:40:56 -0600 | [diff] [blame] | 221 | Redfish Verify BMC Version ${IMAGE_FILE_PATH} |
Sushil Singh | 811ffae | 2019-10-23 05:16:22 -0500 | [diff] [blame] | 222 | Verify Get ApplyTime ${apply_time} |
Sushil Singh | cdebdd5 | 2019-08-14 15:29:24 -0500 | [diff] [blame] | 223 | |
Sushil Singh | ffbfedf | 2019-10-17 15:58:25 -0500 | [diff] [blame] | 224 | |
| 225 | Redfish 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 Singh | b13fc36 | 2020-02-06 03:40:56 -0600 | [diff] [blame] | 234 | ${post_code_update_actions}= Get Post Boot Action |
Sushil Singh | ffbfedf | 2019-10-17 15:58:25 -0500 | [diff] [blame] | 235 | 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 Singh | b13fc36 | 2020-02-06 03:40:56 -0600 | [diff] [blame] | 259 | Run Key ${post_code_update_actions['BMC image']['${apply_time}']} |
| 260 | Redfish.Login |
| 261 | Redfish Verify BMC Version ${IMAGE_FILE_PATH} |
Sushil Singh | a83bba0 | 2023-01-18 08:43:45 -0600 | [diff] [blame] | 262 | |
| 263 | |
Sushil Singh | 44bfc20 | 2023-02-08 09:53:36 -0600 | [diff] [blame] | 264 | Run 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 | |
| 276 | Run 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 | |
| 290 | Get 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 | |
| 299 | Verify Redfish Code Update With Different Interrupted Operation |
George Keishing | 4611b81 | 2023-02-16 09:44:33 -0600 | [diff] [blame^] | 300 | [Documentation] Verify code update is successful when other operation |
| 301 | ... getting executed i.e. change the hostname. |
Sushil Singh | 44bfc20 | 2023-02-08 09:53:36 -0600 | [diff] [blame] | 302 | [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 | |