1*** Settings *** 2Documentation Energy scale power capping tests. 3 4 5# Acronyms 6# PL Power Limit 7# OCC On Chip Controller 8 9 10Resource ../../lib/energy_scale_utils.robot 11Resource ../../lib/rest_client.robot 12Resource ../../lib/openbmc_ffdc.robot 13Resource ../../lib/boot_utils.robot 14Resource ../../lib/ipmi_client.robot 15Resource ../../syslib/utils_os.robot 16 17 18Suite Setup Suite Setup Execution 19Test Teardown Test Teardown Execution 20 21 22 23*** Variables **** 24 25${max_power} 3050 26${near_max_power_50} 3000 27${near_max_power_100} 2950 28 29 30 31*** Test Cases *** 32 33 34Escale System On And PL Enabled 35 [Documentation] Change active power limit with system power on and 36 ... Power limit active. 37 [Tags] Escale_System_On_And_PL_Enabled 38 39 Set DCMI Power Limit And Verify ${max_power} 40 41 Redfish Power On stack_mode=skip 42 43 Tool Exist opal-prd 44 OCC Tool Upload Setup 45 46 # Get OCC data from OS. 47 ${cmd}= Set Variable /tmp/occtoolp9 -p | grep -e State: -e Sensor: 48 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} 49 50 # Check for expected responses. 51 Should Contain ${output} ACTIVE 52 Should Contain ${output} Sensor: TEMP 53 Should Contain ${output} Sensor: FREQ 54 Should Contain ${output} Sensor: POWR 55 56 # Disable OCC. 57 ${output} ${stderr} ${rc}= OS Execute Command opal-prd occ disable 58 # With OCC disabled we should have OBSERVATION in output. 59 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} 60 Should Contain ${output} OBSERVATION 61 62 # Re-enable OCC for remaining tests. 63 ${output} ${stderr} ${rc}= OS Execute Command opal-prd occ enable 64 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} 65 Should Contain ${output} ACTIVE 66 67 ${power}= Get DCMI Power Limit 68 Should Be True ${power} == ${max_power} 69 ... msg=DCMI power limit should be ${max_power}. 70 71 Activate DCMI Power And Verify 72 73 Set DCMI Power Limit And Verify ${near_max_power_50} 74 75 76Escale System On And PL Disabled 77 [Documentation] Change active power limit with system power on and 78 ... deactivate power limit prior to change. 79 [Tags] Escale_System_On_And_PL_Disabled 80 81 ${power_setting}= Set Variable ${near_max_power_100} 82 83 Redfish Power On stack_mode=skip 84 85 Set DCMI Power Limit And Verify ${power_setting} 86 87 # Deactivate and check limit 88 Deactivate DCMI Power And Verify 89 90 ${cmd}= Catenate dcmi power set_limit limit ${near_max_power_50} 91 Run External IPMI Standard Command ${cmd} 92 ${power}= Get DCMI Power Limit 93 94 Should Be True ${power} == ${near_max_power_50} 95 ... msg=Could not set power limit when power limiting deactivated. 96 97 98Escale Check Settings System On Then Off 99 [Documentation] Set power limit and activate power limit before 100 ... BMC state is power on. 101 [Tags] Escale_Check_Settings_System_On_Then_Off 102 103 ${power_setting}= Set Variable ${near_max_power_100} 104 105 Redfish Power On stack_mode=skip 106 107 Set DCMI Power Limit And Verify ${power_setting} 108 Deactivate DCMI Power And Verify 109 110 ${power}= Get DCMI Power Limit 111 Should Be True ${power} == ${power_setting} 112 ... msg=dcmi power limit not set to ${power_setting} as expected. 113 114 Smart Power Off 115 116 Activate DCMI Power And Verify 117 118 Redfish Power On 119 120 ${power}= Get DCMI Power Limit 121 Should Be True ${power} == ${power_setting} 122 ... msg=Power limit setting of watts not retained at Runtime. 123 124 Deactivate DCMI Power And Verify 125 126 127Escale Check Settings System Off Then On 128 [Documentation] Set and activate power limit with system power off. 129 [Tags] Escale_Check_Settings_System_Off_Then_On 130 131 ${power_setting}= Set Variable ${near_max_power_50} 132 133 Set DCMI Power Limit And Verify ${power_setting} 134 Deactivate DCMI Power and Verify 135 136 Smart Power Off 137 138 # Check deactivated and the power limit. 139 Fail If DCMI Power Is Not Deactivated 140 ${power}= Get DCMI Power Limit 141 Should Be True ${power} == ${power_setting} 142 ... msg=DCMI power not set at ${power_setting} as expected 143 144 Activate DCMI Power And Verify 145 Set DCMI Power Limit And Verify ${power_setting} 146 147 Redfish Power On 148 149 Fail If DCMI Power Is Not Activated 150 151 ${power}= Get DCMI Power Limit 152 Should Be True ${power} == ${power_setting} 153 ... msg=Power limit setting not retained at Runtime. 154 155 156Escale Change Limit At Runtime 157 [Documentation] Change power limit at runtime. 158 [Tags] Escale_Change_Limit_At_Runtime 159 160 ${power_setting}= Set Variable ${near_max_power_100} 161 162 Set DCMI Power Limit And Verify ${near_max_power_50} 163 164 Smart Power Off 165 166 Redfish Power On stack_mode=skip 167 168 Set DCMI Power Limit And Verify ${power_setting} 169 170 # Check that DCMI power limit setting = ${power_setting}. 171 ${power}= Get DCMI Power Limit 172 Should Be True ${power} == ${power_setting} 173 ... msg=DCMI power limit not set to ${power_setting} watts as expected. 174 175 Set DCMI Power Limit And Verify ${max_power} 176 177 178Escale Disable And Enable At Runtime 179 [Documentation] Disable/enable power limit at runtime. 180 [Tags] Escale_Disable_And_Enable_At_Runtime 181 182 ${power_setting}= Set Variable ${near_max_power_50} 183 184 Smart Power Off 185 186 Set DCMI Power Limit And Verify ${power_setting} 187 Activate DCMI Power And Verify 188 189 # Power on the system. 190 Redfish Power On 191 192 # Check that DCMI power limit setting = ${power_setting}. 193 ${power}= Get DCMI Power Limit 194 Should Be True ${power} == ${power_setting} 195 ... msg=DCMI power limit not set to ${power_setting} watts as expected. 196 197 Deactivate DCMI Power And Verify 198 199 Activate DCMI Power And Verify 200 201 ${power}= Get DCMI Power Limit 202 Should Be True ${power} == ${power_setting} 203 ... msg=DCMI power limit not set to ${power_setting} watts as expected. 204 205 206*** Keywords *** 207 208 209Suite Setup Execution 210 [Documentation] Do test setup initialization. 211 # Power Off if system if not already off. 212 # Save initial settings. 213 # Deactivate power and set limit. 214 215 Smart Power Off 216 217 # Save the deactivation/activation setting. 218 ${cmd}= Catenate dcmi power get_limit | grep State 219 ${resp}= Run External IPMI Standard Command ${cmd} 220 # Response is either "Power Limit Active" or "No Active Power Limit". 221 ${initial_deactivation}= Get Count ${resp} No 222 # If deactivated: initial_deactivation = 1, 0 otherwise. 223 Set Suite Variable ${initial_deactivation} children=true 224 225 # Save the power limit setting. 226 ${initial_power_setting}= Get DCMI Power Limit 227 Set Suite Variable ${initial_power_setting} children=true 228 229 # Set power limiting deactivated. 230 Deactivate DCMI Power And Verify 231 232 # Set initial power setting value. 233 Set DCMI Power Limit And Verify ${max_power} 234 235 236Test Teardown Execution 237 [Documentation] Do the post test teardown. 238 # FFDC on test case fail. 239 # Power off the OS and wait for power off state. 240 # Return the system's initial deactivation/activation setting. 241 # Return the system's initial power limit setting. 242 243 FFDC On Test Case Fail 244 245 Smart Power Off 246 247 Run Keyword If '${initial_power_setting}' != '${0}' 248 ... Set DCMI Power Limit And Verify ${initial_power_setting} 249 250 Run Keyword If '${initial_deactivation}' == '${1}' 251 ... Deactivate DCMI Power And Verify ELSE Activate DCMI Power And Verify 252