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