1*** Settings ***
2Documentation       Check the indicator LEDs on the system can set the assert
3...                 property to the correct state.
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*** Test Cases ***
21
22Verify LED Lamp Test Asserted At Standby
23    [Documentation]  Verify the LED asserted at standby is set to off or blinking.
24    [Tags]  Verify_LED_Lamp_Test_Asserted_At_Standby
25    [Template]  Set and Verify Lamp LED Indicator
26
27    # pre_req_state     asserted     expected_indicator_led
28    Off                 1            Blinking
29    Off                 0            Off
30
31
32Verify LED Lamp Test Asserted At Runtime
33    [Documentation]  Verify the LED asserted at runtime is set to off or blinking.
34    [Tags]  Verify_LED_Lamp_Test_Asserted_At_Runtime
35    [Template]  Set and Verify Lamp LED Indicator
36
37    # pre_req_state     asserted     expected_indicator_led
38    On                  1            Blinking
39    On                  0            Off
40
41
42Verify LED Power Supply Units Asserted At Standby
43    [Documentation]  Verify the power supply units are asserted at standby to lit or off.
44    [Tags]  Verify_LED_Power_Supply_Units_Asserted_At_Standby
45    [Template]  Set and Verify LED Indicator
46
47    # pre_req_state     asserted                                        expected_indicator_led
48    Off                 "xyz.openbmc_project.Led.Physical.Action.On"    Lit
49    Off                 "xyz.openbmc_project.Led.Physical.Action.Off"   Off
50
51
52Verify LED Power Supply Units Asserted At Runtime
53    [Documentation]  Verify the power supply units are asserted at runtime to lit or off.
54    [Tags]  Verify_LED_Power_Supply_Units_Asserted_At_Runtime
55    [Template]  Set and Verify LED Indicator
56
57    # pre_req_state     asserted                                        expected_indicator_led
58    On                  "xyz.openbmc_project.Led.Physical.Action.On"    Lit
59    On                  "xyz.openbmc_project.Led.Physical.Action.Off"   Off
60
61
62Verify LED Fans Asserted At Standby
63    [Documentation]  Verify the fans are asserted at standby to lit or off.
64    [Tags]  Verify_LED_Fans_Asserted_At_Standby
65    [Template]  Set and Verify Fan LED Indicators
66
67    # pre_req_state     asserted                                        expected_indicator_led
68    Off                 "xyz.openbmc_project.Led.Physical.Action.On"    Lit
69    Off                 "xyz.openbmc_project.Led.Physical.Action.Off"   Off
70
71
72Verify LED Fans Asserted At Runtime
73    [Documentation]  Verify the fans are asserted at runtime to lit or off.
74    [Tags]  Verify_LED_Fans_Asserted_At_Runtime
75    [Template]  Set and Verify Fan LED Indicators
76
77    # pre_req_state     asserted                                        expected_indicator_led
78    On                  "xyz.openbmc_project.Led.Physical.Action.On"    Lit
79    On                  "xyz.openbmc_project.Led.Physical.Action.Off"   Off
80
81
82Verify Location Indicator Active status
83    [Documentation]  Verify the Location Indicator Active status to true or false.
84    [Tags]  Verify_Location_Indicator_Active_status
85    [setup]     Set Suite LED Indicator Initial Value
86    [Teardown]  Set Initial Value  ${value}
87
88
89   Set And Verify LED Location Indicator Active  ${set_value}
90
91
92*** Keywords ***
93
94Set and Verify Lamp LED Indicator
95    [Documentation]  Verify the indicator LED for the group lamp test is asserted.
96    [Arguments]  ${pre_req_state}  ${asserted}  ${expected_indicator_led}
97
98    # Description of Arguments(s):
99    # pre_req_state           The pre-requisite state of the host to perform the test (e.g. "On")
100    # asserted                The assert property that sets the value to 0 - Off or 1 - Blinking (e.g. "1")
101    # expected_indicator_led  The expected value of the IndicatorLED attribute for all the
102    #                         LEDs after the lamp test is initiated (e.g. "Blinking")
103
104    Run Key U  Redfish Power ${pre_req_state} \ stack_mode=skip \ quiet=1
105    Redfish.Login
106
107    Redfish.Put  ${LED_LAMP_TEST_ASSERTED_URI}attr/Asserted  body={"data":${asserted}}
108
109    # Example result:
110    # power_supplies:
111    #   [0]:
112    #     [MemberId]:                                   powersupply0
113    #     [PartNumber]:                                 02CL396
114    #     [IndicatorLED]:                               Blinking
115    #     [EfficiencyPercent]:                          90
116    #     [Status]:
117    #       [Health]:                                   OK
118    #       [State]:                                    Enabled
119
120    Verify Indicator LEDs  ${expected_indicator_led}
121
122
123Set and Verify LED Indicator
124    [Documentation]  Verify the indicator LED for the power supply units are asserted.
125    [Arguments]  ${pre_req_state}  ${asserted}  ${expected_indicator_led}
126
127    # Description of Arguments(s):
128    # pre_req_state           The pre-requisite state of the host to perform the test (e.g. "On")
129    # asserted                The assert property that sets the value
130    #                         (e.g. "xyz.openbmc_project.Led.Physical.Action.On")
131    # expected_indicator_led  The expected value of the IndicatorLED attribute for all the
132    #                         power supplies units are initiated (e.g. "Lit")
133
134    Run Key U  Redfish Power ${pre_req_state} \ stack_mode=skip \ quiet=1
135    Redfish.Login
136
137    # Put both power supply LEDs On/Off to check all units are asserted
138    Redfish.Put  ${LED_PHYSICAL_PS0_URI}attr/State  body={"data":${asserted}}
139    Redfish.Put  ${LED_PHYSICAL_PS1_URI}attr/State  body={"data":${asserted}}
140
141    # Example output:
142    # power_supplies:
143    #   [0]:
144    #     [MemberId]:                                   powersupply0
145    #     [IndicatorLED]:                               Lit
146    #     [Status]:
147    #       [Health]:                                   OK
148    #       [State]:                                    Enabled
149    #   [1]:
150    #     [MemberId]:                                   powersupply1
151    #     [IndicatorLED]:                               Lit
152    #     [Status]:
153    #       [Health]:                                   OK
154    #       [State]:                                    Enabled
155
156    Verify Indicator LEDs  ${expected_indicator_led}
157
158
159Verify Indicator LEDs
160    [Documentation]  Verify the LEDs on the power supply units are set according to caller's expectation.
161    [Arguments]  ${expected_indicator_led}
162
163    # Description of Arguments(s):
164    # expected_indicator_led  The expected value of the IndicatorLED attribute for all the
165    #                         LEDs after the lamp test is initiated (e.g. "Blinking")
166
167    ${power_supplies}=  Redfish.Get Attribute  ${REDFISH_CHASSIS_POWER_URI}  PowerSupplies
168    Rprint Vars  power_supplies
169    FOR  ${power_supply_leds}  IN  @{power_supplies}
170        Valid Value  power_supply_leds['IndicatorLED']  ['${expected_indicator_led}']
171    END
172
173
174Set and Verify Fan LED Indicators
175    [Documentation]  Verify the indicator LED for the fans are asserted.
176    [Arguments]  ${pre_req_state}  ${asserted}  ${expected_indicator_led}
177
178    # Description of Arguments(s):
179    # pre_req_state           The pre-requisite state of the host to perform the test (e.g. "On")
180    # asserted                The assert property that sets the value
181    #                         (e.g. "xyz.openbmc_project.Led.Physical.Action.On")
182    # expected_indicator_led  The expected value of the IndicatorLED attribute for all the fans
183    #                         are initiated (e.g. "Lit")
184
185    Run Key U  Redfish Power ${pre_req_state} \ stack_mode=skip \ quiet=1
186    Redfish.Login
187
188    # Put all the fan LEDs On/Off to check all are asserted
189    Redfish.Put  ${LED_PHYSICAL_FAN0_URI}attr/State  body={"data":${asserted}}
190    Redfish.Put  ${LED_PHYSICAL_FAN2_URI}attr/State  body={"data":${asserted}}
191    Redfish.Put  ${LED_PHYSICAL_FAN3_URI}attr/State  body={"data":${asserted}}
192
193    # Example output:
194    # fans:
195    #   [0]:
196    #     [@odata.id]:                                  /redfish/v1/Chassis/chassis/Thermal#/Fans/0
197    #     [@odata.type]:                                #Thermal.v1_3_0.Fan
198    #     [IndicatorLED]:                               Lit
199    #     [MemberId]:                                   fan0_0
200    #     [Name]:                                       fan0 0
201    #     [Status]:
202    #       [Health]:                                   OK
203    #       [State]:                                    Enabled
204
205    ${fans}=  Redfish.Get Attribute  ${REDFISH_CHASSIS_THERMAL_URI}  Fans
206    Rprint Vars  fans
207    FOR  ${fan_leds}  IN  @{fans}
208        Valid Value  fan_leds['IndicatorLED']  ['${expected_indicator_led}']
209    END
210
211
212Suite Teardown Execution
213    [Documentation]  Do the post suite teardown.
214
215    Redfish.Logout
216
217
218Suite Setup Execution
219    [Documentation]  Do test case setup tasks.
220
221    Printn
222    Redfish.Login
223
224
225Test Teardown Execution
226    [Documentation]  Do the post test teardown.
227
228    FFDC On Test Case Fail
229
230
231Set Suite LED Indicator Initial Value
232    [Documentation]  set suite For LED Initial value.
233
234    ${value}=  Redfish.Get Attribute      /redfish/v1/Systems/system  LocationIndicatorActive
235    Set Suite Variable  ${value}
236
237    IF  ${value} == False
238        Set Suite Variable  ${set_value}  ${True}
239    ELSE
240        Set Suite Variable  ${set_value}  ${False}
241    END
242
243
244Set And Verify LED Location Indicator Active
245    [Documentation]  Set And Verify LED Location Indicator State.
246    [Arguments]  ${set_value}
247
248    ${payload}=  Create Dictionary    LocationIndicatorActive=${set_value}
249    Redfish.Patch      /redfish/v1/Systems/system    body=&{payload}
250    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
251
252    ${value}=  Redfish.Get Attribute      /redfish/v1/Systems/system  LocationIndicatorActive
253
254    Should Be Equal As Strings  ${value}    ${set_value}
255
256
257Set Initial Value
258    [Documentation]  setting back Initial value.
259    [Arguments]  ${value}
260
261    ${payload}=  Create Dictionary    LocationIndicatorActive=${value}
262    Redfish.Patch      /redfish/v1/Systems/system    body=&{payload}
263    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
264
265    ${intial_value}=  Redfish.Get Attribute      /redfish/v1/Systems/system  LocationIndicatorActive
266    Should Be Equal As Strings  ${intial_value}  ${value}
267