xref: /openbmc/openbmc-test-automation/systest/collection/bmc_collect_sensors.robot (revision feb79d60e26d78a6e91521ee41b1af5b8ba71f4c)
1*** Settings ***
2Documentation       BMC server health, collect sensors.
3
4# Test Parameters:
5# OPENBMC_HOST      The BMC host name or IP address.
6
7Resource            ../../lib/bmc_redfish_resource.robot
8Resource            ../../lib/openbmc_ffdc.robot
9Library             Collections
10Library             ../lib/os_utils_keywords.py
11
12Suite Setup         Suite Setup Execution
13Suite Teardown      Suite Teardown Execution
14Test Setup          Printn
15
16Test Tags           BMC_Collect_Sensors
17
18*** Variables ***
19${QUIET}                     ${1}
20${sensors_values_rest}       Rest sensors collection excluded
21${sensors_values_redfish}    Redfish sensors collection excluded
22${sensors_flagged_rest}      Rest sensors collection excluded
23${sensors_flagged_redfish}   Redfish sensors collection excluded
24
25
26*** Test Cases ***
27
28Rest Collect Sensors
29    [Documentation]  Collect the sensors values using the OpenBMC Rest API.
30    [Tags]  Rest_Collect_Sensors  rest
31    [Teardown]  FFDC On Test Case Fail
32
33    ${sensors}=  OpenBMC Get Request  ${SENSORS_URI}enumerate
34    ${sensors}=  Evaluate  $sensors.json()['data']
35    ${sensors_collected_via_rest}=  gen_robot_print.Sprint Vars  sensors
36    Log To Console  ${sensors_collected_via_rest}
37    ${fans}=  Filter Struct  ${sensors}  [('Unit', '\.RPMS$')]  regex=1
38    ${no_fans}=  Filter Struct  ${sensors}  [('WarningAlarmHigh', None),('WarningAlarmLow', None)]
39    ...  invert=${True}
40    Log  sensor values raw:${\n}${sensors}${\n}sensors no fans:${\n}${no_fans}${\n}fans:${\n}${fans}
41    ...  level=DEBUG
42
43    ${fans_flagged}=  Filter Struct  ${fans}
44    ...  [('CriticalAlarmHigh', False),('CriticalAlarmLow', False)]  invert=${True}
45    ${filter_str}=  Catenate  [('CriticalAlarmHigh', False),('CriticalAlarmLow', False),
46    ...  ('WarningAlarmHigh', False),('WarningAlarmLow', False)]
47    ${other_sensors_flagged}=  Filter Struct  ${no_fans}  ${filter_str}  invert=${True}
48    ${sensors_flagged_rest}=  gen_robot_print.Sprint Vars  fans_flagged  other_sensors_flagged
49    Set Suite Variable  ${sensors_flagged_rest}
50
51
52Redfish Collect Sensors
53    [Documentation]  Collect the sensor values using Redfish.
54    [Tags]  Redfish_Collect_Sensors  redfish
55    [Setup]  Redfish.Login
56    [Teardown]  Redfish Test Teardown Execution
57
58    ${redfish_chassis_power}=  Redfish_Utils.Enumerate Request  ${REDFISH_CHASSIS_POWER_URI}  ${0}
59    ${redfish_chassis_thermal}=  Redfish_Utils.Enumerate Request  ${REDFISH_CHASSIS_THERMAL_URI}  ${0}
60    ${redfish_chassis_sensors}=  Redfish_Utils.Enumerate Request  ${REDFISH_CHASSIS_SENSORS_URI}  ${0}
61    ${sensors_values_redfish}=  gen_robot_print.Sprint Vars
62    ...  redfish_chassis_power  redfish_chassis_thermal  redfish_chassis_sensors
63    Set Suite Variable  ${sensors_values_redfish}
64    Log To Console  ${sensors_values_redfish}
65
66    ${health_check_filter_dict}=  Create Dictionary  Health=OK
67    ${merged_dicts}=  Evaluate  {**$redfish_chassis_power, **$redfish_chassis_thermal}
68    Log  ${merged_dicts}  level=DEBUG
69    ${sensors_flagged_redfish}=  Filter Struct  ${merged_dicts}  ${health_check_filter_dict}  invert=${TRUE}
70    ${sensors_flagged_redfish}=  gen_robot_print.Sprint Vars  sensors_flagged_redfish
71    Set Suite Variable  ${sensors_flagged_redfish}
72
73
74*** Keywords ***
75
76Suite Setup Execution
77    [Documentation]  Do suite setup tasks.
78
79    Set Log Level  DEBUG
80    REST Power On  stack_mode=skip
81
82
83Suite Teardown Execution
84    [Documentation]  Do suite teardown tasks. Log sensor values collected.
85
86    Log Many  ${sensors_values_rest}  ${sensors_values_redfish}
87    Log  Sensors detected out of bounds via Rest:${\n}${sensors_flagged_rest}  console=true
88    Log  Sensors detected out of bounds via Redfish:${\n}${sensors_flagged_redfish}  console=true
89
90
91Redfish Test Teardown Execution
92    [Documentation]  Do the post test teardown for redfish.
93
94    Redfish.Logout
95    FFDC On Test Case Fail
96