1*** Settings *** 2Documentation Test Redfish sensor monitoring. 3 4Resource ../../lib/resource.robot 5Resource ../../lib/bmc_redfish_resource.robot 6Resource ../../lib/bmc_redfish_utils.robot 7Library ../../lib/gen_robot_print.py 8 9Test Setup Test Setup Execution 10Test Teardown Test Teardown Execution 11 12*** Variables *** 13 14@{INVALID_SENSORS} 15${OPENBMC_CONN_METHOD} ssh 16${IPMI_COMMAND} Inband 17 18** Test Cases ** 19 20Verify Sensor Monitoring 21 [Documentation] Verify the redfish sensor monitoring according to the BMC 22 ... expected SDR table. 23 [Tags] Verify_Sensor_Monitoring 24 25 # Check whether the expected sensors are present in the Redfish request. 26 # Check whether the sensors's 'Health' is 'OK' and the 'State' is 'Enabled'. 27 # Check sensor reading is not equal to null. 28 29 ${resp}= Redfish.Get /redfish/v1/Chassis/${CHASSIS_ID} 30 ... valid_status_codes=[${HTTP_OK}] 31 32 Should Be Equal As Strings ${resp.dict['Sensors']['@odata.id']} 33 ... /redfish/v1/Chassis/${CHASSIS_ID}/Sensors 34 Should Be Equal As Strings ${resp.dict['Thermal']['@odata.id']} 35 ... /redfish/v1/Chassis/${CHASSIS_ID}/Thermal 36 Should Be Equal As Strings ${resp.dict['Power']['@odata.id']} 37 ... /redfish/v1/Chassis/${CHASSIS_ID}/Power 38 39 # Check sensors in /redfish/v1/Chassis/{ChassisId}/Power 40 ${resp}= Redfish.Get /redfish/v1/Chassis/${CHASSIS_ID}/Power 41 ... valid_status_codes=[${HTTP_OK}] 42 43 Check Sensors Present ${resp.dict['Voltages']} Voltage 44 Check Sensor Status And Reading Via Sensor Info 45 ... ${resp.dict['Voltages']} ReadingVolts 46 47 # Check sensors in /redfish/v1/Chassis/{ChassisId}/Thermal 48 ${resp}= Redfish.Get /redfish/v1/Chassis/${CHASSIS_ID}/Thermal 49 ... valid_status_codes=[${HTTP_OK}] 50 51 Check Sensors Present ${resp.dict['Temperatures']} Temperature 52 Check Sensors Present ${resp.dict['Fans']} Fans 53 54 Check Sensor Status And Reading Via Sensor Info 55 ... ${resp.dict['Temperatures']} ReadingCelsius 56 Check Sensor Status And Reading Via Sensor Info 57 ... ${resp.dict['Fans']} Reading 58 59 # Check sensors in 60 # /redfish/v1/Chassis/{ChassisId}/Sensors/{Sensor Name} 61 ${expected_current_power_sensor_name_list}= Set Variable 62 ... ${redfish_sensor_info_map['${OPENBMC_MODEL}']['Current_Power']} 63 64 FOR ${sensor_name} IN @{expected_current_power_sensor_name_list} 65 Check Sensor Status And Reading Via Sensor Name ${sensor_name} 66 END 67 68 Rprint Vars INVALID_SENSORS 69 70 ${error_msg}= Evaluate ", ".join(${INVALID_SENSORS}) 71 Should Be Empty ${INVALID_SENSORS} 72 ... msg=Test fail, invalid sensors are ${error_msg}. 73 74 75*** Keywords *** 76 77Test Teardown Execution 78 [Documentation] Do the post test teardown. 79 80 Run Keyword And Ignore Error Redfish.Logout 81 82 83Test Setup Execution 84 [Documentation] Do the test setup. 85 86 Required Parameters For Sensor Monitoring 87 Redfish.Login 88 89 90Required Parameters For Sensor Monitoring 91 [Documentation] Check if required parameters are provided via command line. 92 93 Should Not Be Empty ${OS_HOST} 94 Should Not Be Empty ${OS_USERNAME} 95 Should Not Be Empty ${OS_PASSWORD} 96 97 IF '${OPENBMC_CONN_METHOD}' == 'ssh' 98 Should Not Be Empty ${OPENBMC_HOST} 99 ELSE IF '${OPENBMC_CONN_METHOD}' == 'telnet' 100 Should Not Be Empty ${OPENBMC_SERIAL_HOST} 101 END 102 103 Should Not Be Empty ${OPENBMC_MODEL} 104 105 106Get Sensors Name List From Redfish 107 [Documentation] Get sensors name list from redfish. 108 [Arguments] ${sensor_info_list} 109 # Description of arguments: 110 # sensor_info_list A list of a specified sensor info return by a redfish 111 # request. 112 113 # An example of a sensor redfish request: 114 # /redfish/v1/Chassis/${CHASSIS_ID}/Power 115 # { 116 # ... 117 # "Voltages": [ 118 # { 119 # "@odata.id": "/redfish/v1/Chassis/${CHASSIS_ID}/Power#/Voltages/0", 120 # "@odata.type": "#Power.v1_0_0.Voltage", 121 # "LowerThresholdCritical": 1.14, 122 # "LowerThresholdNonCritical": 1.14, 123 # "MaxReadingRange": 2.0, 124 # "MemberId": "Output_Voltage", 125 # "MinReadingRange": 0.0, 126 # "Name": "Output Voltage", 127 # "ReadingVolts": 1.176, 128 # "Status": { 129 # "Health": "OK", 130 # "State": "Enabled" 131 # }, 132 # "UpperThresholdCritical": 1.21, 133 # "UpperThresholdNonCritical": 1.21 134 # } 135 # ... 136 # } 137 138 @{sensor_name_list}= Create List 139 FOR ${sensor_info} IN @{sensor_info_list} 140 Append To List ${sensor_name_list} ${sensor_info['MemberId']} 141 END 142 143 RETURN ${sensor_name_list} 144 145 146Check Sensor Status And Reading Via Sensor Name 147 [Documentation] Check Sensor Status And Reading Via Sensor Name. 148 [Arguments] ${sensor_name} 149 # Description of arguments: 150 # sensor_name Sensor that should be present. 151 152 ${resp}= Redfish.Get 153 ... /redfish/v1/Chassis/${CHASSIS_ID}/Sensors/${sensor_name} 154 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] 155 156 Run Keyword And Return If '${resp.status}' == '${HTTP_NOT_FOUND}' 157 ... Append To List ${INVALID_SENSORS} ${sensor_name} 158 159 ${condition_str}= Catenate 160 ... '${resp.dict['Status']['Health']}' != 'OK' 161 ... or '${resp.dict['Status']['State']}' != 'Enabled' 162 ... or ${resp.dict['Reading']} == ${null} 163 164 IF ${condition_str} 165 Append To List ${INVALID_SENSORS} ${sensor_name} 166 END 167 168 169Check Sensor Status And Reading Via Sensor Info 170 [Documentation] Check Sensor Status And Reading Via Sensor Info. 171 [Arguments] ${sensor_info_list} ${reading_unit} 172 # Description of arguments: 173 # sensor_info_list A list of a specified sensor info return by a redfish 174 # request. 175 # reading_unit A string represents the reading value in sensor info 176 # return by a redfish request. It different between 177 # different sensor unit of sensor info. 178 179 FOR ${sensor_info} IN @{sensor_info_list} 180 ${sensor}= Set Variable ${sensor_info['MemberId']} 181 ${condition_str}= Catenate 182 ... '${sensor_info['Status']['Health']}' != 'OK' 183 ... or '${sensor_info['Status']['State']}' != 'Enabled' 184 ... or ${sensor_info['${reading_unit}']} == ${null} 185 186 IF ${condition_str} 187 Append To List ${INVALID_SENSORS} ${sensor_info['MemberId']} 188 END 189 END 190 191 192Check Sensors Present 193 [Documentation] Check that sensors are present as expected. 194 [Arguments] ${sensor_info_list} ${sensor_type} 195 # Description of arguments: 196 # sensor_info_list A list of a specified sensor info return by a redfish 197 # request. 198 # sensor_type A string represents the sensor category to be verified. 199 200 # An example table of expected sensors: 201 # redfish_sensor_info_map = { 202 # ${OPENBMC_MODEL}:{ 203 # "Voltage":{ 204 # "Voltage0", 205 # ... 206 # }, 207 # "Temperature":{ 208 # "DIMM0", 209 # ... 210 # } 211 # "Fans":{ 212 # "Fan0", 213 # ... 214 # }... 215 # } 216 #} 217 218 ${curr_sensor_name_list}= Get Sensors Name List From Redfish 219 ... ${sensor_info_list} 220 221 ${expected_sensor_name_list}= Set Variable 222 ... ${redfish_sensor_info_map['${OPENBMC_MODEL}']['${sensor_type}']} 223 224 FOR ${sensor_name} IN @{expected_sensor_name_list} 225 ${exist}= Evaluate '${sensor_name}' in ${curr_sensor_name_list} 226 IF '${exist}' == '${False}' 227 Append To List ${INVALID_SENSORS} ${sensor_name} 228 END 229 END 230