1*** Settings ***
2
3Documentation  Test Suite for Supported Fan Modules.
4
5Resource         ../../lib/rest_client.robot
6Resource         ../../lib/bmc_redfish_resource.robot
7Resource         ../../lib/bmc_redfish_utils.robot
8Resource         ../../lib/openbmc_ffdc.robot
9Resource         ../../lib/resource.robot
10Resource         ../../lib/boot_utils.robot
11Library          ../../lib/gen_robot_valid.py
12Library          ../../lib/gen_robot_keyword.py
13
14Suite Setup      Suite Setup Execution
15Suite Teardown   Suite Teardown Execution
16Test Setup       Printn
17Test Teardown    Test Teardown Execution
18
19
20*** Variables ***
21
22@{VALID_MODE_VALUES}   DEFAULT  CUSTOM  HEAVY_IO  MAX_BASE_FAN_FLOOR
23
24
25*** Test Cases ***
26
27Verify Current Fan Thermal Mode
28    [Documentation]  Check current thermal fan mode is a valid mode value.
29    [Tags]  Verify_Current_Fan_Thermal_Mode
30
31    # Example:
32    #  /xyz/openbmc_project/control/thermal/0
33    #
34    # Response code:200, Content: {
35    # "data": {
36    #         "Current": "DEFAULT",
37    #         "Supported": [
38    #           "DEFAULT",
39    #           "CUSTOM",
40    #           "HEAVY_IO",
41    #           "MAX_BASE_FAN_FLOOR"
42    #         },
43    #         },
44    # "message": "200 OK",
45    # "status": "ok"
46    # }
47
48    ${current}=  Read Attribute  ${THERMAL_CONTROL_URI}  Current
49    Rprint Vars  current
50
51    Valid Value  current  valid_values=${VALID_MODE_VALUES}
52
53
54Verify Supported Fan Thermal Modes Available
55    [Documentation]  Check supported fan thermal modes are valid mode values.
56    [Tags]  Verify_Supported_Fan_Thermal_Modes_Available
57
58    ${supported}=  Read Attribute  ${THERMAL_CONTROL_URI}  Supported
59    Rprint Vars  supported
60
61    Valid List  supported  valid_values=${VALID_MODE_VALUES}
62
63
64Verify Supported Fan Thermal Modes Switch At Standby
65    [Documentation]  Check that supported modes are set successfully at standby.
66    [Tags]  Verify_Supported_Fan_Thermal_Modes_Switch_At_Standby
67    [Template]  Set and Verify Thermal Mode Switches
68
69    # pre_req_state      thermal_mode_type
70    Off                  DEFAULT
71    Off                  CUSTOM
72    Off                  HEAVY_IO
73    Off                  MAX_BASE_FAN_FLOOR
74
75
76Verify Supported Fan Thermal Modes Switch At Runtime
77    [Documentation]  Check that supported modes are set successfully at runtime.
78    [Tags]  Verify_Supported_Fan_Thermal_Modes_Switch_At_Runtime
79    [Template]  Set and Verify Thermal Mode Switches
80
81    # pre_req_state      thermal_mode
82    On                   DEFAULT
83    On                   CUSTOM
84    On                   HEAVY_IO
85    On                   MAX_BASE_FAN_FLOOR
86
87
88Verify Supported Fan Thermal Mode Remains Set After IPL
89    [Documentation]  Check that supported modes remain set at runtime.
90    [Tags]  Verify_Supported_Fan_Thermal_Mode_Remains_Set_After_IPL
91    [Template]  Set and Verify Thermal Mode After IPL
92
93    # pre_req_state      thermal_mode_type
94    Off                  DEFAULT
95    Off                  CUSTOM
96    Off                  HEAVY_IO
97    Off                  MAX_BASE_FAN_FLOOR
98
99
100*** Keywords ***
101
102Set and Verify Thermal Mode Switches
103    [Documentation]  Verify the thermal mode switches successfully at standby or runtime.
104    [Arguments]  ${pre_req_state}  ${thermal_mode}
105
106    # Description of Arguments(s):
107    # thermal_mode       Read the supported thermal mode (e.g. "CUSTOM")
108    # pre_req_state      Set the state of the host to Standby or Runtime (e.g. "Running")
109
110    Run Key U  Redfish Power ${pre_req_state} \ stack_mode=skip \ quiet=1
111    Redfish.Login
112
113    ${mode}=  Redfish.Put  ${THERMAL_CONTROL_URI}/attr/Current  body={"data": "${thermal_mode}"}
114
115    ${current}=  Read Attribute  ${THERMAL_CONTROL_URI}  Current
116    Should Be Equal As Strings  ${thermal_mode}  ${current}
117    ...  msg=The thermal mode does not match the current fan mode.
118    Rprint Vars  current
119
120
121Set and Verify Thermal Mode After IPL
122    [Documentation]  Verify the thermal mode remains set at runtime.
123    [Arguments]  ${pre_req_state}  ${thermal_mode}
124
125    Set and Verify Thermal Mode Switches  ${pre_req_state}  ${thermal_mode}
126
127    Run Key U  Redfish Power On \ stack_mode=normal \ quiet=1
128    Redfish.Login
129
130    ${current}=  Read Attribute  ${THERMAL_CONTROL_URI}  Current
131    Should Be Equal As Strings  ${thermal_mode}  ${current}
132    ...  msg=The current thermal fan mode switched successfully.
133    Rprint Vars  current
134
135
136Suite Teardown Execution
137    [Documentation]  Do the post suite teardown.
138
139    Redfish.Logout
140
141
142Suite Setup Execution
143    [Documentation]  Do test case setup tasks.
144
145    Printn
146    Redfish.Login
147
148
149Test Teardown Execution
150    [Documentation]  Do the post test teardown.
151
152    FFDC On Test Case Fail
153