Rahul Maheshwari | 07d91d2 | 2019-07-31 01:12:05 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Module to test IPMI chassis functionality. |
| 4 | Resource ../lib/ipmi_client.robot |
| 5 | Resource ../lib/openbmc_ffdc.robot |
George Keishing | 6f395fd | 2021-08-18 02:18:53 -0500 | [diff] [blame] | 6 | Resource ../lib/boot_utils.robot |
Nagarjun B | 1499c91 | 2023-05-27 22:13:20 +0530 | [diff] [blame] | 7 | Resource ../lib/bmc_dbus.robot |
Rahul Maheshwari | f724a00 | 2020-02-21 05:17:02 -0600 | [diff] [blame] | 8 | Library ../lib/ipmi_utils.py |
chithrag | f459540 | 2022-03-30 16:35:03 +0000 | [diff] [blame] | 9 | Variables ../data/ipmi_raw_cmd_table.py |
Rahul Maheshwari | 07d91d2 | 2019-07-31 01:12:05 -0500 | [diff] [blame] | 10 | |
George Keishing | 2d0edad | 2021-08-18 11:44:10 -0500 | [diff] [blame] | 11 | Suite Setup Redfish.Login |
| 12 | Suite Teardown Redfish.Logout |
chithrag | f459540 | 2022-03-30 16:35:03 +0000 | [diff] [blame] | 13 | Test Teardown Test Teardown Execution |
| 14 | |
George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 15 | Force Tags IPMI_Chassis |
Nagarjun B | 1499c91 | 2023-05-27 22:13:20 +0530 | [diff] [blame] | 16 | |
George Keishing | f628017 | 2022-07-08 01:51:27 -0500 | [diff] [blame] | 17 | *** Variables *** |
| 18 | |
| 19 | # Timeout value in minutes. Default 3 minutes. |
Nagarjun B | 1499c91 | 2023-05-27 22:13:20 +0530 | [diff] [blame] | 20 | ${IPMI_POWEROFF_WAIT_TIMEOUT} 3 |
| 21 | ${busctl_settings} xyz.openbmc_project.Settings |
| 22 | ${chassis_capabilities_dbus_URL} /xyz/openbmc_project/Control/ChassisCapabilities |
| 23 | |
Rahul Maheshwari | 07d91d2 | 2019-07-31 01:12:05 -0500 | [diff] [blame] | 24 | |
| 25 | *** Test Cases *** |
| 26 | |
| 27 | IPMI Chassis Status On |
George Keishing | e16f158 | 2022-12-15 07:32:21 -0600 | [diff] [blame] | 28 | [Documentation] This test case verifies system power on status |
Rahul Maheshwari | 07d91d2 | 2019-07-31 01:12:05 -0500 | [diff] [blame] | 29 | ... using IPMI Get Chassis status command. |
| 30 | [Tags] IPMI_Chassis_Status_On |
| 31 | |
| 32 | Redfish Power On stack_mode=skip quiet=1 |
| 33 | ${resp}= Run IPMI Standard Command chassis status |
| 34 | ${power_status}= Get Lines Containing String ${resp} System Power |
| 35 | Should Contain ${power_status} on |
| 36 | |
| 37 | IPMI Chassis Status Off |
George Keishing | e16f158 | 2022-12-15 07:32:21 -0600 | [diff] [blame] | 38 | [Documentation] This test case verifies system power off status |
Rahul Maheshwari | 07d91d2 | 2019-07-31 01:12:05 -0500 | [diff] [blame] | 39 | ... using IPMI Get Chassis status command. |
| 40 | [Tags] IPMI_Chassis_Status_Off |
| 41 | |
| 42 | Redfish Power Off stack_mode=skip quiet=1 |
| 43 | ${resp}= Run IPMI Standard Command chassis status |
| 44 | ${power_status}= Get Lines Containing String ${resp} System Power |
| 45 | Should Contain ${power_status} off |
Sushma M M | 1cc2127 | 2020-01-05 23:47:46 -0600 | [diff] [blame] | 46 | |
| 47 | Verify Host PowerOff Via IPMI |
| 48 | [Documentation] Verify host power off operation using external IPMI command. |
| 49 | [Tags] Verify_Host_PowerOff_Via_IPMI |
| 50 | |
| 51 | IPMI Power Off |
| 52 | ${ipmi_state}= Get Host State Via External IPMI |
| 53 | Valid Value ipmi_state ['off'] |
| 54 | |
| 55 | Verify Host PowerOn Via IPMI |
| 56 | [Documentation] Verify host power on operation using external IPMI command. |
| 57 | [Tags] Verify_Host_PowerOn_Via_IPMI |
| 58 | |
| 59 | IPMI Power On |
| 60 | ${ipmi_state}= Get Host State Via External IPMI |
Rahul Maheshwari | 460778d | 2020-02-23 22:37:22 -0600 | [diff] [blame] | 61 | Valid Value ipmi_state ['on'] |
| 62 | |
| 63 | |
| 64 | Verify Soft Shutdown |
| 65 | [Documentation] Verify host OS shutdown softly via IPMI command. |
George Keishing | fba5ad9 | 2021-11-08 02:52:35 -0600 | [diff] [blame] | 66 | [Tags] Verify_Soft_Shutdown |
Rahul Maheshwari | 460778d | 2020-02-23 22:37:22 -0600 | [diff] [blame] | 67 | |
| 68 | Redfish Power On stack_mode=skip |
| 69 | Run IPMI Standard Command chassis power soft |
George Keishing | f628017 | 2022-07-08 01:51:27 -0500 | [diff] [blame] | 70 | Wait Until Keyword Succeeds ${IPMI_POWEROFF_WAIT_TIMEOUT} min 10 sec Is Host Off Via IPMI |
Rahul Maheshwari | 460778d | 2020-02-23 22:37:22 -0600 | [diff] [blame] | 71 | |
Rahul Maheshwari | f724a00 | 2020-02-21 05:17:02 -0600 | [diff] [blame] | 72 | |
chithrag | f459540 | 2022-03-30 16:35:03 +0000 | [diff] [blame] | 73 | Verify Chassis Power Cycle And Check Chassis Status Via IPMI |
George Keishing | 6e64126 | 2022-05-05 10:46:22 -0500 | [diff] [blame] | 74 | [Documentation] Verify chassis power Cycle operation and check the Chassis |
| 75 | ... Power Status using external IPMI command. |
chithrag | f459540 | 2022-03-30 16:35:03 +0000 | [diff] [blame] | 76 | [Tags] Verify_Chassis_Power_Cycle_And_Check_Chassis_Status_Via_IPMI |
| 77 | |
| 78 | # Chassis power cycle command via IPMI |
| 79 | IPMI Power Cycle |
| 80 | ${ipmi_state}= Get Host State Via External IPMI |
| 81 | Valid Value ipmi_state ['on'] |
| 82 | |
| 83 | |
| 84 | Verify Chassis Power Reset And Check Chassis Status Via IPMI |
George Keishing | 6e64126 | 2022-05-05 10:46:22 -0500 | [diff] [blame] | 85 | [Documentation] Verify chassis power Reset operation and check the Chassis |
| 86 | ... Power Status using external IPMI command. |
chithrag | f459540 | 2022-03-30 16:35:03 +0000 | [diff] [blame] | 87 | [Tags] Verify_Chassis_Power_Reset_And_Check_Chassis_Status_Via_IPMI |
| 88 | |
| 89 | # Chassis power reset command via IPMI |
| 90 | IPMI Power Reset |
| 91 | ${ipmi_state}= Get Host State Via External IPMI |
| 92 | Valid Value ipmi_state ['on'] |
| 93 | |
| 94 | |
Rahul Maheshwari | f724a00 | 2020-02-21 05:17:02 -0600 | [diff] [blame] | 95 | Verify Chassis Power Policy |
| 96 | [Documentation] Verify setting chassis power policy via IPMI command. |
| 97 | [Tags] Verify_Chassis_Power_Policy |
| 98 | [Setup] Test Setup Execution |
| 99 | [Teardown] Run Keywords FFDC On Test Case Fail AND |
| 100 | ... Run IPMI Standard Command chassis policy ${initial_power_policy} |
| 101 | [Template] Set Chassis Power Policy Via IPMI And Verify |
| 102 | |
| 103 | # power_policy |
| 104 | always-off |
| 105 | always-on |
| 106 | previous |
| 107 | |
| 108 | |
chithrag | f459540 | 2022-03-30 16:35:03 +0000 | [diff] [blame] | 109 | Verify Chassis Status Via IPMI |
| 110 | [Documentation] Verify Chassis Status via IPMI command. |
| 111 | [Tags] Verify_Chassis_Status_Via_IPMI |
| 112 | [Setup] Test Setup Execution |
| 113 | [Teardown] Run Keywords FFDC On Test Case Fail AND |
| 114 | ... Run IPMI Standard Command chassis policy ${initial_power_policy} |
| 115 | [Template] Check Chassis Status Via IPMI |
| 116 | |
| 117 | # power_policy |
| 118 | always-off |
| 119 | always-on |
| 120 | previous |
| 121 | |
| 122 | |
Nagarjun B | 1499c91 | 2023-05-27 22:13:20 +0530 | [diff] [blame] | 123 | Verify Get Chassis Capabilities |
| 124 | [Documentation] Verify get chassis capabilities IPMI cmd with valid data length and verify |
| 125 | ... its response comparing with busctl command. |
| 126 | [Tags] Verify_Get_Chassis_Capabilities |
| 127 | [Teardown] FFDC On Test Case Fail |
| 128 | |
| 129 | ${ipmi_resp}= Run External IPMI Raw Command |
| 130 | ... ${IPMI_RAW_CMD['Chassis Capabilities']['Get'][0]} |
| 131 | |
| 132 | ${ipmi_resp}= Split String ${ipmi_resp} |
| 133 | ${busctl_cmd}= Catenate ${BUSCTL_INTROSPECT_COMMAND} ${busctl_settings} |
| 134 | ... ${chassis_capabilities_dbus_URL} |
| 135 | |
| 136 | ${busctl_resp}= BMC Execute Command sh --login -c "${busctl_cmd}" |
| 137 | |
| 138 | Verify Chassis Capabilities Response ${ipmi_resp[0]} ${busctl_resp[0]} CapabilitiesFlags |
| 139 | Verify Chassis Capabilities Response ${ipmi_resp[1]} ${busctl_resp[0]} FRUDeviceAddress |
| 140 | Verify Chassis Capabilities Response ${ipmi_resp[2]} ${busctl_resp[0]} SDRDeviceAddress |
| 141 | Verify Chassis Capabilities Response ${ipmi_resp[3]} ${busctl_resp[0]} SELDeviceAddress |
| 142 | Verify Chassis Capabilities Response ${ipmi_resp[4]} ${busctl_resp[0]} SMDeviceAddress |
| 143 | Verify Chassis Capabilities Response ${ipmi_resp[5]} ${busctl_resp[0]} BridgeDeviceAddress |
| 144 | |
| 145 | |
| 146 | Verify Get Chassis Capabilities With Invalid Data Length |
| 147 | [Documentation] Verify get chassis capabilities IPMI command with invalid data length |
| 148 | [Tags] Verify_Get_Chassis_Capabilities_With_Invalid_Data_Length |
| 149 | [Teardown] FFDC On Test Case Fail |
| 150 | |
| 151 | Verify Invalid IPMI Command ${IPMI_RAW_CMD['Chassis Capabilities']['Get'][1]} 0xc7 |
| 152 | |
| 153 | |
Rahul Maheshwari | f724a00 | 2020-02-21 05:17:02 -0600 | [diff] [blame] | 154 | *** Keywords *** |
| 155 | |
| 156 | Set Chassis Power Policy Via IPMI And Verify |
| 157 | [Documentation] Set chasiss power policy via IPMI and verify. |
| 158 | [Arguments] ${power_policy} |
| 159 | |
| 160 | # Description of argument(s): |
| 161 | # power_policy Chassis power policy to be set(e.g. "always-off", "always-on"). |
| 162 | |
| 163 | Run IPMI Standard Command chassis policy ${power_policy} |
| 164 | ${resp}= Get Chassis Status |
| 165 | Valid Value resp['power_restore_policy'] ['${power_policy}'] |
| 166 | |
| 167 | |
chithrag | f459540 | 2022-03-30 16:35:03 +0000 | [diff] [blame] | 168 | Check Chassis Status Via IPMI |
| 169 | [Documentation] Set Chassis Status via IPMI and verify and verify chassis status. |
| 170 | [Arguments] ${power_policy} |
| 171 | |
| 172 | # Sets power policy according to requested policy |
| 173 | Set Chassis Power Policy Via IPMI And Verify ${power_policy} |
| 174 | |
| 175 | # Gets chassis status via IPMI raw command and validate byte 1 |
| 176 | ${status}= Run External IPMI Raw Command ${IPMI_RAW_CMD['Chassis_status']['get'][0]} |
| 177 | ${status}= Split String ${status} |
| 178 | ${state}= Convert To Binary ${status[0]} base=16 |
| 179 | ${state}= Zfill Data ${state} 8 |
| 180 | |
| 181 | # Last bit corresponds whether Power is on |
| 182 | Should Be Equal As Strings ${state[-1]} 1 |
| 183 | # bit 1-2 corresponds to power restore policy |
| 184 | ${policy}= Set Variable ${state[1:3]} |
| 185 | |
| 186 | # condition to verify each power policy |
| 187 | IF '${power_policy}' == 'always-off' |
| 188 | Should Be Equal As Strings ${policy} 00 |
| 189 | ELSE IF '${power_policy}' == 'always-on' |
| 190 | Should Be Equal As Strings ${policy} 10 |
| 191 | ELSE IF '${power_policy}' == 'previous' |
| 192 | Should Be Equal As Strings ${policy} 01 |
| 193 | ELSE |
| 194 | Log Power Restore Policy is Unknown |
| 195 | Should Be Equal As Strings ${policy} 11 |
| 196 | END |
| 197 | |
| 198 | # Last Power Event - 4th bit should be 1b i.e, last ‘Power is on’ state was entered via IPMI command |
| 199 | ${last_power_event}= Convert To Binary ${status[1]} base=16 |
| 200 | ${last_power_event}= Zfill Data ${last_power_event} 8 |
| 201 | Should Be Equal As Strings ${last_power_event[3]} 1 |
| 202 | |
| 203 | |
Nagarjun B | 1499c91 | 2023-05-27 22:13:20 +0530 | [diff] [blame] | 204 | Verify Chassis Capabilities Response |
| 205 | [Documentation] Will compare the ipmi response with thh busctl response for given property. |
| 206 | [Arguments] ${ipmi_response} ${busctl_response} ${property} |
| 207 | |
| 208 | ${ipmi_response}= Convert To Integer ${ipmi_response} 16 |
| 209 | |
| 210 | ${busctl_value}= Get Regexp Matches ${busctl_response} |
| 211 | ... \\.${property}\\s+property\\s+\\w\\s+(\\d+)\\s+ 1 |
| 212 | |
| 213 | Should Be Equal As Integers ${ipmi_response} ${busctl_value[0]} |
| 214 | |
| 215 | |
Rahul Maheshwari | f724a00 | 2020-02-21 05:17:02 -0600 | [diff] [blame] | 216 | Test Setup Execution |
| 217 | [Documentation] Do test setup tasks. |
| 218 | |
| 219 | ${chassis_status}= Get Chassis Status |
| 220 | Set Test Variable ${initial_power_policy} ${chassis_status['power_restore_policy']} |
| 221 | |
chithrag | f459540 | 2022-03-30 16:35:03 +0000 | [diff] [blame] | 222 | |
| 223 | Test Teardown Execution |
| 224 | [Documentation] Do Test Teardown tasks. |
| 225 | |
| 226 | ${resp}= Run IPMI Standard Command chassis status |
| 227 | ${power_status}= Get Lines Containing String ${resp} System Power |
| 228 | @{powertolist}= Split String ${power_status} : |
| 229 | ${status}= Get From List ${powertolist} 1 |
| 230 | # Chassis Power ON if status is off |
| 231 | Run Keyword If '${status.strip()}' != 'on' |
| 232 | ... Redfish Power On |
| 233 | FFDC On Test Case Fail |