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