1*** Settings *** 2Documentation Utilities for fan tests. 3 4Library ../lib/bmc_ssh_utils.py 5Resource ../lib/openbmc_ffdc_utils.robot 6Variables ../data/variables.py 7 8*** Keywords *** 9 10Is Water Cooled 11 [Documentation] Return 1 if system is water cooled, 0 othersise. 12 13 ${water_cooled}= Read Attribute 14 ... ${HOST_INVENTORY_URI}/system/chassis WaterCooled 15 [Return] ${water_cooled} 16 17 18Get Fan Names 19 [Documentation] Get the names of fans marked present in inventory. 20 [Arguments] ${fan_names} 21 # This keyword populates the fan_names list with the names of 22 # fans present in inventory e.g. fan0, fan2, fan3. 23 24 # Description of Argument(s): 25 # fan_names The list of fan names to which new fan names are to be 26 # added to. This list is returned to the caller. 27 28 ${fan_uris}= Get Endpoint Paths ${HOST_INVENTORY_URI}/system fan 29 : FOR ${fan_uri} IN @{fan_uris} 30 \ ${fan_properties}= Read Properties ${fan_uri} 31 \ Continue For Loop If ${fan_properties['Present']} != 1 32 \ ${remaining_uri} ${fan_name}= Split Path ${fan_uri} 33 \ Append To List ${fan_names} ${fan_name} 34 35 [Return] ${fan_names} 36 37 38Verify System Error Indication Due To Fans 39 [Documentation] Verify enclosure LEDs are on and there's an error log. 40 41 # Both enclosure LEDs should now be On. 42 Verify Front And Rear LED State On 43 44 # An error log should now exist. 45 Error Logs Should Exist 46 47 48Verify Front And Rear LED State 49 [Documentation] Check state of the front and rear enclsure fault LEDs. 50 [Arguments] ${state} 51 # Both LEDs should be in the specified state. If not fail the test case. 52 53 # Description of Argument(s): 54 # state The state to check for, either 'Off' or 'On'. 55 56 ${front_fault}= Get System LED State front_fault 57 ${rear_fault}= Get System LED State rear_fault 58 Run Keyword If 59 ... '${front_fault}' != '${state}' or '${rear_fault}' != '${state}' 60 ... Fail msg=Expecting both enclosure LEDs to be ${state}. 61 62 63Set Fan State 64 [Documentation] Set the fan state, either functional or non-functional. 65 [Arguments] ${fan_name} ${fan_state} 66 67 # Description of Argument(s): 68 # fan_name The name of the fan, e.g. "fan2". 69 # fan_state The state to set, 1 for functional, 2 for non-functional. 70 71 ${valueDict}= Create Dictionary data=${fan_state} 72 Write Attribute 73 ... ${HOST_INVENTORY_URI}system/chassis/motherboard/${fan_name} 74 ... Functional data=${valueDict} 75 76 77Get Target Speed Of Fans 78 [Documentation] Return the maximum target RPM speed of the system fans. 79 80 ${max_target}= Set Variable 0 81 ${paths}= Get Endpoint Paths ${SENSORS_URI}fan_tach/ 0 82 :FOR ${path} IN @{paths} 83 \ ${response}= OpenBMC Get Request ${path} 84 \ ${json}= To JSON ${response.content} 85 \ ${target_speed}= Set Variable ${json["data"]["Target"]} 86 \ ${max_target}= Run Keyword If ${target_speed} > ${max_target} 87 ... Set Variable ${target_speed} ELSE Set Variable ${max_target} 88 [Return] ${max_target} 89 90 91Verify Minimum Number Of Fans With Cooling Type 92 [Documentation] Verify minimum number of fans. 93 [Arguments] ${num_fans} ${water_cooled} 94 95 # Description of argument(s): 96 # num_fans The number of fans present in the system. 97 # water_cooled The value 1 if the system is water cooled, 98 # 0 if air cooled. 99 100 # For a water cooled system. 101 ${min_fans_water}= Set Variable 2 102 103 # For an air cooled system. 104 ${min_fans_air}= Set Variable 3 105 106 Rprintn 107 Rpvars num_fans water_cooled 108 109 # If water cooled must have at least min_fans_water fans, otherwise 110 # issue Fatal Error and terminate testing. 111 Run Keyword If ${water_cooled} == 1 and ${num_fans} < ${min_fans_water} 112 ... Fatal Error 113 ... msg=Water cooled but less than ${min_fans_water} fans present. 114 115 # If air cooled must have at least min_fans_air fans. 116 Run Keyword If ${water_cooled} == 0 and ${num_fans} < ${min_fans_air} 117 ... Fatal Error 118 ... msg=Air cooled but less than ${min_fans_air} fans present. 119 120 121Verify Fan Monitors With State 122 [Documentation] Verify fan monitor daemons in the system state. 123 [Arguments] ${power_state} 124 # The number of monitoring daemons is dependent upon the system 125 # power state. If power is off there should be 0, if power 126 # is on there should be several. 127 128 # Description of argument(s): 129 # power_state Power staet of the system, either "On" or "Off" 130 131 ${cmd}= Catenate systemctl list-units | grep phosphor-fan | wc -l 132 ${num_fan_daemons} ${stderr} ${rc}= BMC Execute Command ${cmd} 133 134 Rpvars power_state num_fan_daemons 135 136 # Fail if system is On and there are no fan monitors. 137 Run Keyword If '${power_state}' == 'On' and ${num_fan_daemons} == 0 138 ... Fail msg=No phosphor-fan monitors found at power on. 139 140 # Fail if system is Off and the fan monitors are present. 141 Run Keyword If '${power_state}' == 'Off' and ${num_fan_daemons} != 0 142 ... Fail msg=Phosphor-fan monitors found at power off. 143