Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Operational checks for fans. |
| 4 | |
| 5 | # Test Parameters: |
| 6 | # OPENBMC_HOST The BMC host name or IP address. |
| 7 | # OPENBMC_USERNAME The userID to login to the BMC as. |
| 8 | # OPENBMC_PASSWORD The password for OPENBMC_USERNAME. |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 9 | # |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 10 | # Approximate run time: 18 minutes. |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 11 | |
| 12 | Resource ../syslib/utils_os.robot |
| 13 | Resource ../lib/logging_utils.robot |
| 14 | Resource ../lib/utils.robot |
| 15 | Resource ../lib/fan_utils.robot |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 16 | Library ../syslib/utils_keywords.py |
| 17 | Library OperatingSystem |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 18 | |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 19 | Suite Setup Suite Setup Execution |
| 20 | Test Teardown Test Teardown Execution |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 21 | |
| 22 | |
| 23 | *** Variables *** |
| 24 | |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 25 | # Fan state values. |
| 26 | ${fan_functional} ${1} |
| 27 | ${fan_nonfunctional} ${0} |
| 28 | |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 29 | # Criteria for a fan to be considered to be at maximum speed. |
| 30 | ${max_speed}= ${10400} |
| 31 | |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 32 | |
| 33 | *** Test Cases *** |
| 34 | |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 35 | Check Number Of Fans With Power On |
| 36 | [Documentation] Verify system has the minimum number of fans. |
| 37 | [Tags] Check_Number_Of_Fans_With_Power_On |
| 38 | |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 39 | # Determine if system is water cooled. |
| 40 | ${water_coooled}= Is Water Cooled |
| 41 | |
| 42 | Verify Minimum Number Of Fans With Cooling Type ${number_of_fans} |
| 43 | ... ${water_coooled} |
| 44 | |
| 45 | |
| 46 | Check Number Of Fan Monitors With Power On |
| 47 | [Documentation] Verify monitors are present when power on. |
| 48 | [Tags] Check_Number_Of_Fan_Monitors_With_Power_On |
| 49 | |
| 50 | Verify Fan Monitors With State On |
| 51 | |
| 52 | |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 53 | Check Fan Speed |
| 54 | [Documentation] Verify fans are running at or near target speed. |
| 55 | [Tags] Check_Fan_Speed |
| 56 | |
| 57 | # Set the speed tolerance criteria. |
| 58 | # A tolerance value of .15 means that the fan's speed should be |
| 59 | # within 15% of its set target speed. Fans may be accelerating |
| 60 | # or decelerating to meet a new target, so allow .10 extra. |
| 61 | ${tolerance}= Set Variable .25 |
| 62 | Rpvars tolerance |
| 63 | |
| 64 | # Compare the fan's speed with its target speed. |
| 65 | :FOR ${fan_name} IN @{fan_names} |
| 66 | \ ${target_speed} ${fan_speed}= Get Fan Target And Speed ${fan_name} |
| 67 | \ Rpvars fan_name target_speed fan_speed |
| 68 | \ # Calculate tolerance, which is a % of the target speed. |
| 69 | \ ${tolerance_value}= Evaluate ${tolerance}*${target_speed} |
| 70 | \ # Calculate upper and lower speed limits. |
| 71 | \ ${max_limit}= Evaluate ${target_speed}+${tolerance_value} |
| 72 | \ ${min_limit}= Evaluate ${target_speed}-${tolerance_value} |
| 73 | \ Run Keyword If |
| 74 | ... ${fan_speed} < ${min_limit} or ${fan_speed} > ${max_limit} |
| 75 | ... Fail msg=${fan_name} speed of ${fan_speed} is out of range. |
| 76 | |
| 77 | |
| 78 | Check Fan Manual Control |
| 79 | [Documentation] Check direct control of fans. |
| 80 | [Tags] Check_Fan_Manual_Control |
| 81 | |
| 82 | # Test case overview: |
| 83 | # Turn off BMC's fan control daemon, then test to confirm |
| 84 | # that fans can be controlled manually. |
| 85 | # The app that takes data from sysfs and updates dbus is named hwmon. |
| 86 | # Verify hwmon functionality by comparing with what's on dbus |
| 87 | # (/xyz/openbmc_project/sensors/fan_tach/fan0_0, fan0_1, etc.) |
| 88 | # with what's in the BMC's file system at |
| 89 | # /sys/class/hwmon/hwmon9/fan*_input. |
| 90 | |
| 91 | # The maximum target speed that can be set. |
| 92 | ${max_fan_target_setting}= Set Variable ${10500} |
| 93 | |
| 94 | # Speed criteria for passing, which is 85% of max_fan_target_setting. |
| 95 | ${min_speed}= Set Variable ${8925} |
| 96 | |
| 97 | # Time allowed for the fan daemon to take control and return |
| 98 | # fans to normal speed. |
| 99 | ${minutes_to_stabilize}= Set Variable 4 |
| 100 | |
Gunnar Mills | 7732c7e | 2018-08-14 11:54:24 -0500 | [diff] [blame] | 101 | # Login to BMC and disable the fan daemon. Disabling the daemon sets |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 102 | # manual mode. |
| 103 | Open Connection And Log In |
| 104 | Set Fan Daemon State stop |
| 105 | |
| 106 | # For each fan, set a new target speed and wait for the fan to |
| 107 | # accelerate. Then check that the fan is running near that |
| 108 | # target speed. |
| 109 | :FOR ${fan_name} IN @{fan_names} |
| 110 | \ Set Fan Target Speed ${fan_name} ${max_fan_target_setting} |
| 111 | \ Run Key U Sleep \ 60s |
| 112 | \ ${target_speed} ${cw_speed} ${ccw_speed}= |
| 113 | ... Get Target And Blade Speeds ${fan_name} |
| 114 | \ Rpvars fan_name target_speed cw_speed ccw_speed |
| 115 | \ Run Keyword If |
| 116 | ... ${cw_speed} < ${min_speed} or ${ccw_speed} < ${min_speed} |
| 117 | ... Fail msg=${fan_name} failed manual speed test. |
| 118 | |
| 119 | # Check the fan speeds in the BMC file system. |
| 120 | |
| 121 | # Get the location of the fan hwmon. |
| 122 | ${controller_path} ${stderr} ${rc}= BMC Execute Command |
| 123 | ... grep -ir max31785a /sys/class/hwmon/hwmon* | grep name |
| 124 | # E.g., controller_path=/sys/class/hwmon/hwmon10/name:max31785a. |
| 125 | |
| 126 | ${hwmon_path} ${file_name}= Split Path ${controller_path} |
| 127 | # E.g., /sys/class/hwmon/hwmon10 or /sys/class/hwmon/hwmon9. |
| 128 | |
| 129 | Rpvars controller_path hwmon_path |
| 130 | |
| 131 | # Run the BMC command which gets fan speeds from the file system. |
| 132 | ${cmd}= Catenate cat ${hwmon_path}/fan*_input |
| 133 | ${stdout} ${stderr} ${rc}= |
| 134 | ... BMC Execute Command ${cmd} |
| 135 | |
| 136 | Rpvars fan_speeds_from_BMC_file_system |
| 137 | |
| 138 | # Convert output to integer values. |
| 139 | ${speeds}= Evaluate map(int, $stdout.split(${\n})) |
| 140 | Rpvars speeds |
| 141 | # Count the number of speeds > ${min_speed}. |
| 142 | ${count}= Set Variable ${0} |
| 143 | :FOR ${speed} IN @{speeds} |
| 144 | \ ${count}= Run Keyword If ${speed} > ${min_speed} |
| 145 | ... Evaluate ${count}+1 ELSE Set Variable ${count} |
| 146 | # Because each fan has two rotating fan blades, the count should be |
| 147 | # equual to 2*${number_of_fans}. On water-cooled systems some |
| 148 | # speeds may be reported by hwmon as 0. That is expected, |
| 149 | # and the number_of_fans reported in the system will be less. |
| 150 | ${fail_test}= Evaluate (2*${number_of_fans})-${count} |
| 151 | |
| 152 | # Re-enable the fan daemon |
| 153 | Set Fan Daemon State restart |
| 154 | |
| 155 | Run Keyword If ${fail_test} Fail |
| 156 | ... msg=hwmon did not properly report fan speeds. |
| 157 | |
| 158 | # Wait for the daemon to take control and gracefully set fan speeds |
| 159 | # back to normal. |
| 160 | ${msg}= Catenate Waiting ${minutes_to_stabilize} minutes |
| 161 | ... for fan daemon to stabilize fans. |
| 162 | Rprint Timen ${msg} |
| 163 | Run Key U Sleep \ ${minutes_to_stabilize}m |
| 164 | |
| 165 | |
| 166 | Verify Fan Speed Increase |
| 167 | [Documentation] Verify that the speed of working fans increase when |
| 168 | ... one fan is disabled. |
| 169 | [Tags] Verify_Fan_Speed_Increase |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 170 | # A non-functional fan should cause an error log and |
| 171 | # an enclosure LED will light. The other fans should speed up. |
| 172 | |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 173 | # Allow system_response_time before checking if there was a |
| 174 | # response by the system to an applied fault. |
| 175 | ${system_response_time}= Set Variable 60s |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 176 | |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 177 | # Choose a fan to test with, e.g., fan0. |
| 178 | ${test_fan_name}= Get From List ${fan_names} 0 |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 179 | |
| 180 | ${initial_speed}= Get Target Speed Of Fans |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 181 | Rpvars test_fan_name initial_speed |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 182 | |
| 183 | # If initial speed is not already at maximum, set expect_increase. |
| 184 | # This flag is used later to determine if speed checking is |
| 185 | # to be done or not. |
| 186 | ${expect_increase}= Run Keyword If |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 187 | ... ${initial_speed} < ${max_speed} |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 188 | ... Set Variable 1 ELSE Set Variable 0 |
| 189 | |
| 190 | Set Fan State ${test_fan_name} ${fan_nonfunctional} |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 191 | |
| 192 | # Wait for error to be asserted. |
| 193 | |
| 194 | :FOR ${n} IN RANGE 30 |
| 195 | \ ${front_fault}= Get System LED State front_fault |
| 196 | \ ${rear_fault}= Get System LED State rear_fault |
| 197 | \ Run Key U Sleep \ 1s |
| 198 | \ Exit For Loop If '${front_fault}' == 'On' and '${rear_fault}' == 'On' |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 199 | |
| 200 | Verify System Error Indication Due To Fans |
| 201 | |
| 202 | # Verify the error log is for test_fan_name. |
| 203 | ${elog_entries}= Get Logging Entry List |
| 204 | :FOR ${elog_entry} IN @{elog_entries} |
| 205 | \ ${elog_entry_callout}= Set Variable ${elog_entry}/callout |
| 206 | \ ${endpoint}= Read Attribute ${elog_entry_callout} endpoints |
| 207 | \ ${endpoint_name}= Get From List ${endpoint} 0 |
| 208 | \ Should Contain ${endpoint_name} ${test_fan_name} |
| 209 | ... msg=Error log present but not for ${test_fan_name}. |
| 210 | |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 211 | Run Key U Sleep \ ${system_response_time} |
| 212 | |
| 213 | # A heavily loaded system may have powered-off. |
| 214 | ${host_state}= Get Host State |
| 215 | Rpvars host_state |
| 216 | Run Keyword If 'Running' != '${host_state}' Pass Execution |
| 217 | ... msg=System shutdown so skipping remainder of test. |
| 218 | |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 219 | ${new_fan_speed}= Get Target Speed Of Fans |
| 220 | Rpvars expect_increase initial_speed new_fan_speed |
| 221 | |
| 222 | # Fail if current fan speed did not increase past the initial |
| 223 | # speed, but do this check only if not at maximum speed to begin with. |
| 224 | Run Keyword If |
| 225 | ... ${expect_increase} == 1 and ${new_fan_speed} < ${initial_speed} |
| 226 | ... Fail msg=Remaining fans did not increase speed with loss of one fan. |
| 227 | |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 228 | |
| 229 | Verify System Shutdown Due To Fans |
| 230 | [Documentation] Shut down when not enough fans. |
| 231 | [Tags] Verify_System_Shutdown_Due_To_Fans |
| 232 | |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 233 | ${wait_after_poweroff}= Set Variable 15s |
| 234 | |
| 235 | # The previous test may have shutdown the system. |
| 236 | REST Power On stack_mode=skip |
| 237 | |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 238 | # Set fans to be non-functional. |
| 239 | :FOR ${fan_name} IN @{fan_names} |
| 240 | \ Set Fan State ${fan_name} ${fan_nonfunctional} |
| 241 | |
| 242 | # System should notice the non-functional fans and power-off the |
| 243 | # system. The Wait For PowerOff keyword will time-out and report |
| 244 | # an error if power off does not happen within a reasonable time. |
| 245 | Wait For PowerOff |
| 246 | |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 247 | Run Key U Sleep \ ${wait_after_poweroff} |
| 248 | |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 249 | Verify System Error Indication Due To Fans |
| 250 | |
| 251 | # Verify there is an error log because of the shutdown. |
| 252 | ${expect}= Catenate |
| 253 | ... xyz.openbmc_project.State.Shutdown.Inventory.Error.Fan |
| 254 | ${elog_entries}= Get Logging Entry List |
| 255 | :FOR ${elog_entry} IN @{elog_entries} |
| 256 | \ ${elog_message}= Read Attribute ${elog_entry} Message |
| 257 | \ ${found}= Set Variable 1 |
| 258 | \ Run Keyword If '${elog_message}' == '${expect}' Exit For Loop |
| 259 | \ ${found}= Set Variable 0 |
| 260 | Run Keyword If not ${found} Fail |
| 261 | ... msg=No error log for event Shutdown.Inventory.Error.Fan. |
| 262 | |
| 263 | |
| 264 | *** Keywords *** |
| 265 | |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 266 | Reset Fans |
| 267 | [Documentation] Set the fans to functional state. |
| 268 | # Set state of fans to functional by writing 1 to the Functional |
| 269 | # attribute of each fan in the @{fan_names} list. If @{fan_names} |
| 270 | # is empty nothing is done. |
| 271 | |
| 272 | # Description of Argument(s): |
| 273 | # fans Suite Variable which is a list containing the |
| 274 | # names of the fans (e.g., fan0 fan2 fan3). |
| 275 | |
| 276 | :FOR ${fan_name} IN @{fan_names} |
| 277 | \ Set Fan State ${fan_name} ${fan_functional} |
| 278 | |
| 279 | |
| 280 | Suite Setup Execution |
| 281 | [Documentation] Do the pre-test setup. |
| 282 | |
| 283 | REST Power On stack_mode=skip |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 284 | |
| 285 | # The @{fan_names} list holds the names of the fans in the system. |
| 286 | @{fan_names} Create List |
| 287 | ${fan_names}= Get Fan Names ${fan_names} |
| 288 | Set Suite Variable ${fan_names} children=true |
| 289 | |
| 290 | ${number_of_fans}= Get Length ${fan_names} |
| 291 | Set Suite Variable ${number_of_fans} children=true |
| 292 | |
| 293 | Reset Fans |
| 294 | Run Key U Sleep \ 15s |
George Keishing | 32fe4e1 | 2018-07-13 05:06:47 -0500 | [diff] [blame] | 295 | Delete All Error Logs |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 296 | Set System LED State front_fault Off |
| 297 | Set System LED State rear_fault Off |
| 298 | |
| 299 | |
| 300 | Test Teardown Execution |
| 301 | [Documentation] Do the post-test teardown. |
| 302 | |
| 303 | FFDC On Test Case Fail |
| 304 | Reset Fans |
Steven Sombar | 1508aff | 2018-04-06 12:53:42 -0500 | [diff] [blame] | 305 | Run Key U Sleep \ 15s |
George Keishing | 32fe4e1 | 2018-07-13 05:06:47 -0500 | [diff] [blame] | 306 | Delete All Error Logs |
Steven Sombar | 43d6ba3 | 2018-02-16 11:25:09 -0600 | [diff] [blame] | 307 | Set System LED State front_fault Off |
| 308 | Set System LED State rear_fault Off |