1*** Settings ***
2Documentation       Getting the systems thermal records for temperature.
3
4Resource            ../../lib/bmc_redfish_resource.robot
5Resource            ../../lib/bmc_redfish_utils.robot
6Resource            ../../lib/logging_utils.robot
7Resource            ../../lib/boot_utils.robot
8Resource            ../../lib/openbmc_ffdc.robot
9Library             ../../lib/gen_robot_valid.py
10Library             ../../lib/logging_utils.py
11
12Suite Setup         Suite Setup Execution
13Suite Teardown      Suite Teardown Execution
14Test Setup          Redfish Purge Event Log
15Test Teardown       Test Teardown Execution
16
17
18*** Test Cases ***
19
20Get Ambient Temperature Records
21    [Documentation]  Get the ambient temperature records.
22    [Tags]  Get_Ambient_Temperature_Records
23    [Template]  Get Thermal Records and Verify
24
25    # record_type   reading_type
26    Temperatures    ReadingCelsius
27
28
29Reboot And Check Ambient Temperature Records Are Valid
30    [Documentation]  Check the ambient temperature records are valid after a reboot.
31    [Tags]  Reboot_And_Check_Ambient_Temperature_Records_Are_Valid
32
33    Redfish OBMC Reboot (run)
34
35    # Clear errors if there are any.
36    Redfish.Login
37    Redfish Purge Event Log
38
39    Get Thermal Records and Verify  Temperatures  ReadingCelsius
40
41
42*** Keywords ***
43
44Get Thermal Records and Verify
45    [Documentation]  Get the thermal records for temperatures.
46    [Arguments]  ${record_type}  ${reading_type}
47
48    # Description of Arguments(s):
49    # record_type    The thermal record type (e.g. "Temperatures")
50    # reading_type   The thermal temperature readings (e.g. "ReadingCelsius")
51
52    ${records}=  Verify Valid Records  ${record_type}
53    ...  ${REDFISH_CHASSIS_URI}/${CHASSIS_ID}/Thermal  ${reading_type}
54
55    ${num_records}=  Get Length  ${records}
56    Rprint Vars  num_records  records
57
58    ${cmd}  Catenate  [x for x in ${records}
59    ...  if not x['LowerThresholdNonCritical'] <= x['${reading_type}'] <= x['UpperThresholdNonCritical']]
60    ${invalid_records}=  Evaluate  ${cmd}
61
62    ${num_invalid_records}=  Get Length  ${invalid_records}
63    Run Keyword If  ${num_invalid_records} > ${0}
64    ...  Rprint Vars  num_invalid_records  invalid_records
65    Valid Value   num_invalid_records  valid_values=[0]
66
67    Event Log Should Not Exist
68
69
70Suite Teardown Execution
71    [Documentation]  Do the post suite teardown.
72
73    Redfish.Logout
74
75
76Suite Setup Execution
77    [Documentation]  Do test case setup tasks.
78
79    Printn
80    Redfish.Login
81    Redfish Purge Event Log
82
83
84Test Teardown Execution
85    [Documentation]  Do the post test teardown.
86
87    FFDC On Test Case Fail
88