xref: /openbmc/openbmc-test-automation/redfish/systems/test_powersubsystem_settings.robot (revision b2a2d948d555cb6e5169b9f21d489a3b089b4387)
1*** Settings ***
2Documentation       Get the system power supply readings and power mode settings.
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
14Test Tags           Powersubsystem_Settings
15
16*** Variables ***
17
18# Power Mode Settings
19@{VALID_POWER_MODES}    Static  PowerSaving  MaximumPerformance
20
21
22*** Test Cases ***
23
24Verify Current Power Mode Setting
25    [Documentation]  Verify the current power mode setting.
26    [Tags]  Verify_Current_Power_Mode_Setting
27
28    # Example:
29    # /redfish/v1/Systems/system
30    #
31    # "PartNumber": "",
32    # "PowerMode": "MaximumPerformance",
33    # "PowerMode@Redfish.AllowableValues": [
34    #    "Static",
35    #    "MaximumPerformance",
36    #    "PowerSaving"
37    # ],
38
39    ${current_power_mode}=  Redfish.Get Attribute  ${SYSTEM_BASE_URI}  PowerMode
40    Rprint Vars  current_power_mode
41
42    Valid Value  current_power_mode  valid_values=${VALID_POWER_MODES}
43
44
45Verify Allowable Power Mode Settings
46    [Documentation]  Verify the allowable power mode settings.
47    [Tags]  Verify_Allowable_Power_Mode_Settings
48
49    ${allowed_power_modes}=  Redfish.Get Attribute  ${SYSTEM_BASE_URI}  PowerMode@Redfish.AllowableValues
50    Rprint Vars  allowed_power_modes
51
52    Valid List  allowed_power_modes  valid_values=${VALID_POWER_MODES}
53
54
55Verify Allowable Power Mode Settings Switch At Runtime
56    [Documentation]  Check the allowable power modes are set successfully at runtime.
57    [Tags]  Verify_Allowable_Power_Mode_Settings_Switch_At_Runtime
58    [Template]  Set and Verify Power Mode Switches
59
60    # power_mode_type
61    Static
62    PowerSaving
63    MaximumPerformance
64
65
66Verify State Of PowerSubsystem PowerSupplies
67    [Documentation]  Verify the state of the system's powersupplies is ok and enabled.
68    [Tags]  Verify_State_Of_PowerSubsystem_PowerSupplies
69
70    ${total_num_supplies}=  Get Total Number Of PowerSupplies
71    Rprint Vars  total_num_supplies
72
73    ${resp}=  Redfish.Get  ${REDFISH_CHASSIS_URI}/${CHASSIS_ID}/PowerSubsystem/PowerSupplies
74    FOR  ${entry}  IN RANGE  0  ${total_num_supplies}
75         ${resp_resource}=  Redfish.Get  ${resp.dict["Members"][${entry}]["@odata.id"]}
76         # Example:
77         # "Status": {
78         #     "Health": "OK",
79         #     "State": "Enabled"
80         # },
81         Should Be Equal As Strings  ${resp_resource.dict["Status"]["Health"]}  OK
82         Should Be Equal As Strings  ${resp_resource.dict["Status"]["State"]}  Enabled
83    END
84
85
86Verify PowerSubsystem Efficiency Percent For All PowerSupplies
87    [Documentation]  Verify the efficiency percent for all powersupplies.
88    [Tags]  Verify_PowerSubsystem_Efficiency_Percent_For_All_PowerSupplies
89
90    ${total_num_supplies}=  Get Total Number Of PowerSupplies
91    Rprint Vars  total_num_supplies
92
93    # Example output:
94    # - Executing: get('/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply0')
95    # resp_resource:
96    #   [0]:
97    #     [EfficiencyPercent]:                          90
98    # - Executing: get('/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply1')
99    # resp_resource:
100    #   [0]:
101    #     [EfficiencyPercent]:                          90
102
103    ${resp}=  Redfish.Get  ${REDFISH_CHASSIS_URI}/${CHASSIS_ID}/PowerSubsystem/PowerSupplies
104    FOR  ${entry}  IN RANGE  0  ${total_num_supplies}
105        ${resp_resource}=  Redfish.Get Attribute
106        ...  ${resp.dict["Members"][${entry}]["@odata.id"]}  EfficiencyRatings
107        Rprint Vars  resp_resource
108        ${efficiency_percentages}=  Nested Get  EfficiencyPercent  ${resp_resource}
109        Valid List  efficiency_percentages  [90]
110    END
111
112
113
114*** Keywords ***
115
116Get Total Number Of PowerSupplies
117    [Documentation]  Return total number of powersupplies.
118    ${total_num_powersupplies}=  Redfish.Get Attribute
119    ...  ${REDFISH_CHASSIS_URI}/${CHASSIS_ID}/PowerSubsystem/PowerSupplies  Members@odata.count
120
121    # Entries "Members@odata.count": 4,
122    # {'@odata.id': '/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply0'}
123    # {'@odata.id': '/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply1'}
124    # {'@odata.id': '/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply2'}
125    # {'@odata.id': '/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply3'}
126    RETURN  ${total_num_powersupplies}
127
128
129Set and Verify Power Mode Switches
130    [Documentation]  Verify the power mode switches successfully at standby or runtime.
131    [Arguments]  ${power_mode}
132
133    # Description of Arguments(s):
134    # power_mode       Read the allowable power modes (e.g. "Static")
135
136    Redfish.Login
137
138    Redfish.patch  ${SYSTEM_BASE_URI}
139    ...  body={"PowerMode":"${power_mode}"}  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
140    ${current_power_mode}=  Redfish.Get Attribute  ${SYSTEM_BASE_URI}  PowerMode
141    Should Be Equal As Strings  ${power_mode}  ${current_power_mode}
142    ...  msg=The thermal mode does not match the current fan mode.
143    Rprint Vars  current_power_mode
144
145
146Suite Teardown Execution
147    [Documentation]  Do the post suite teardown.
148
149    Redfish.Logout
150
151
152Suite Setup Execution
153    [Documentation]  Do test case setup tasks.
154
155    Printn
156    Redfish.Login
157
158
159Test Teardown Execution
160    [Documentation]  Do the post test teardown.
161
162    FFDC On Test Case Fail
163