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/openbmc_ffdc.robot
7Library             ../../lib/gen_robot_valid.py
8
9Suite Setup         Suite Setup Execution
10Suite Teardown      Suite Teardown Execution
11Test Setup          Printn
12Test Teardown       Test Teardown Execution
13
14
15*** Test Cases ***
16
17Get Ambient Temperature Records
18    [Documentation]  Get the ambient temperature records.
19    [Tags]  Get_Ambient_Temperature_Records
20    [Template]  Get Thermal Records and Verify
21
22    # record_type   reading_type
23    Temperatures    ReadingCelsius
24
25
26*** Keywords ***
27
28Get Thermal Records and Verify
29    [Documentation]  Get the thermal records for temperatures.
30    [Arguments]  ${record_type}  ${reading_type}
31
32    # Description of Arguments(s):
33    # record_type    The thermal record type (e.g. "Temperatures")
34    # reading_type   The thermal temperature readings (e.g. "ReadingCelsius")
35
36    # A valid record will have "State" key "Enabled" and "Health" key "OK"
37    ${records}=  Redfish.Get Attribute
38    ...  ${REDFISH_CHASSIS_THERMAL_URI}  ${record_type}
39
40    ${num_records}=  Get Length  ${records}
41    Rprint Vars  num_records  records
42
43    ${invalid_records}=  Filter Struct  ${records}
44    ...  [('Health', '^OK$'), ('State', '^Enabled$'), ('${reading_type}', '')]  regex=1  invert=1
45    ${num_invalid_records}=  Get Length  ${invalid_records}
46
47    Run Keyword If  ${num_invalid_records} > ${0}
48    ...  Rprint Vars  num_invalid_records  invalid_records
49    Valid Value  num_invalid_records  valid_values=[0]
50
51    ${invalid_records}=  Evaluate
52    ...  [x for x in ${records} if not x['LowerThresholdNonCritical'] <= x['ReadingCelsius'] <= x['UpperThresholdNonCritical']]
53
54    ${num_invalid_records}=  Get Length  ${invalid_records}
55    Run Keyword If  ${num_invalid_records} > ${0}
56    ...  Rprint Vars  num_invalid_records  invalid_records
57    Valid Value   num_invalid_records  valid_values=[0]
58
59Suite Teardown Execution
60    [Documentation]  Do the post suite teardown.
61
62    Redfish.Logout
63
64Suite Setup Execution
65    [Documentation]  Do test case setup tasks.
66
67    Printn
68    Redfish.Login
69
70Test Teardown Execution
71    [Documentation]  Do the post test teardown.
72
73    FFDC On Test Case Fail
74