1*** Settings ***
2Documentation       Getting the systems power sensor readings for voltages.
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 Power Sensor Voltage Records
18    [Documentation]  Get the power voltage records.
19    [Tags]  Get_Power_Sensor_Voltage_Records
20    [Template]  Get Voltage Records and Verify
21
22    # record_type   reading_type
23    Voltages        ReadingVolts
24
25
26*** Keywords ***
27
28Get Voltage Records and Verify
29    [Documentation]  Get the power records for voltages.
30    [Arguments]  ${record_type}  ${reading_type}
31
32    # Description of Arguments(s):
33    # record_type    The sensor record type (e.g. "Voltages")
34    # reading_type   The power voltage readings (e.g. "ReadingVolts")
35
36    # A valid record will have "State" key "Enabled" and "Health" key "OK"
37    ${records}=  Redfish.Get Attribute
38    ...  ${REDFISH_CHASSIS_POWER_URI}  ${record_type}
39
40    ${num_records}=  Get Length  ${records}
41    Rprint Vars  num_records  records  fmt=terse
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  fmt=terse
49    Valid Value  num_invalid_records  valid_values=[0]
50
51    ${cmd}  Catenate  [x for x in ${records}
52    ...  if not x['LowerThresholdNonCritical'] <= x['ReadingVolts'] <= x['UpperThresholdNonCritical']]
53    ${invalid_records}=  Evaluate  ${cmd}
54
55    ${num_invalid_records}=  Get Length  ${invalid_records}
56    Run Keyword If  ${num_invalid_records} > ${0}
57    ...  Rprint Vars  num_invalid_records  invalid_records  fmt=terse
58    Valid Value  num_invalid_records  valid_values=[0]
59
60
61Suite Teardown Execution
62    [Documentation]  Do the post suite teardown.
63
64    Redfish.Logout
65
66
67Suite Setup Execution
68    [Documentation]  Do test case setup tasks.
69
70    Printn
71    Redfish Power On  stack_mode=skip
72    Redfish.Login
73
74
75Test Teardown Execution
76    [Documentation]  Do the post test teardown.
77
78    FFDC On Test Case Fail
79