Add indicator led asserted tests for system and power supply units
Resolves openbmc/openbmc-test-automation#1610
Signed-off-by: Marissa Garza <garzam@us.ibm.com>
Change-Id: I947b4feefe336aa93a0fb1ec205f015cdd3b2fce
diff --git a/data/variables.py b/data/variables.py
index 245c3dd..00cbace 100755
--- a/data/variables.py
+++ b/data/variables.py
@@ -74,6 +74,9 @@
# Led URI variable
LED_GROUPS_URI = OPENBMC_BASE_URI + 'led/groups/'
LED_PHYSICAL_URI = OPENBMC_BASE_URI + 'led/physical/'
+LED_LAMP_TEST_ASSERTED_URI = LED_GROUPS_URI + 'lamp_test/'
+LED_PHYSICAL_PS0_URI = LED_PHYSICAL_URI + 'cffps1_69/'
+LED_PHYSICAL_PS1_URI = LED_PHYSICAL_URI + 'cffps1_68/'
# Host control URI variables.
CONTROL_HOST_URI = OPENBMC_BASE_URI + 'control/host0/'
diff --git a/redfish/systems/test_led_indicator_asserted.robot b/redfish/systems/test_led_indicator_asserted.robot
new file mode 100755
index 0000000..f0bfa8a
--- /dev/null
+++ b/redfish/systems/test_led_indicator_asserted.robot
@@ -0,0 +1,159 @@
+*** Settings ***
+Documentation Check the indicator LEDs on the system can set the assert
+... property to the correct state.
+
+Resource ../../lib/rest_client.robot
+Resource ../../lib/bmc_redfish_resource.robot
+Resource ../../lib/bmc_redfish_utils.robot
+Resource ../../lib/openbmc_ffdc.robot
+Resource ../../lib/resource.robot
+Resource ../../lib/boot_utils.robot
+Library ../../lib/gen_robot_valid.py
+Library ../../lib/gen_robot_keyword.py
+
+Suite Setup Suite Setup Execution
+Suite Teardown Suite Teardown Execution
+Test Setup Printn
+Test Teardown Test Teardown Execution
+
+
+*** Test Cases ***
+
+Verify LED Lamp Test Asserted At Standby
+ [Documentation] Verify the LED asserted at standby is set to off or blinking.
+ [Tags] Verify_LED_Lamp_Test_Asserted_At_Standby
+ [Template] Set and Verify Lamp LED Indicator
+
+ # pre_req_state asserted expected_indicator_led
+ Off 1 Blinking
+ Off 0 Off
+
+
+Verify LED Lamp Test Asserted At Runtime
+ [Documentation] Verify the LED asserted at runtime is set to off or blinking.
+ [Tags] Verify_LED_Lamp_Test_Asserted_At_Runtime
+ [Template] Set and Verify Lamp LED Indicator
+
+ # pre_req_state asserted expected_indicator_led
+ On 1 Blinking
+ On 0 Off
+
+
+Verify LED Power Supply Units Asserted At Standby
+ [Documentation] Verify the power supply units are asserted at standby to lit or off.
+ [Tags] Verify_LED_Power_Supply_Units_Asserted_At_Standby
+ [Template] Set and Verify LED Indicator
+
+ # pre_req_state asserted expected_indicator_led
+ Off "xyz.openbmc_project.Led.Physical.Action.On" Lit
+ Off "xyz.openbmc_project.Led.Physical.Action.Off" Off
+
+
+Verify LED Power Supply Units Asserted At Runtime
+ [Documentation] Verify the power supply units are asserted at runtime to lit or off.
+ [Tags] Verify_LED_Power_Supply_Units_Asserted_At_Runtime
+ [Template] Set and Verify LED Indicator
+
+ # pre_req_state asserted expected_indicator_led
+ On "xyz.openbmc_project.Led.Physical.Action.On" Lit
+ On "xyz.openbmc_project.Led.Physical.Action.Off" Off
+
+
+*** Keywords ***
+
+Set and Verify Lamp LED Indicator
+ [Documentation] Verify the indicator LED for the group lamp test is asserted.
+ [Arguments] ${pre_req_state} ${asserted} ${expected_indicator_led}
+
+ # Description of Arguments(s):
+ # pre_req_state The pre-requisite state of the host to perform the test (e.g. "On")
+ # asserted The assert property that sets the value to 0 - Off or 1 - Blinking (e.g. "1")
+ # expected_indicator_led The expected value of the IndicatorLED attribute for all the
+ # LEDs after the lamp test is initiated (e.g. "Blinking")
+
+ Run Key U Redfish Power ${pre_req_state} \ stack_mode=skip \ quiet=1
+ Redfish.Login
+
+ Redfish.Put ${LED_LAMP_TEST_ASSERTED_URI}attr/Asserted body={"data":${asserted}}
+
+ # Example result:
+ # power_supplies:
+ # [0]:
+ # [MemberId]: powersupply0
+ # [PartNumber]: 02CL396
+ # [IndicatorLED]: Blinking
+ # [EfficiencyPercent]: 90
+ # [Status]:
+ # [Health]: OK
+ # [State]: Enabled
+
+ Verify Indicator LEDs ${expected_indicator_led}
+
+
+Set and Verify LED Indicator
+ [Documentation] Verify the indicator LED for the power supply units are asserted.
+ [Arguments] ${pre_req_state} ${asserted} ${expected_indicator_led}
+
+ # Description of Arguments(s):
+ # pre_req_state The pre-requisite state of the host to perform the test (e.g. "On")
+ # asserted The assert property that sets the value (e.g. "xyz.openbmc_project.Led.Physical.Action.On")
+ # expected_indicator_led The expected value of the IndicatorLED attribute for all the
+ # power supplies units are initiated (e.g. "Lit")
+
+ Run Key U Redfish Power ${pre_req_state} \ stack_mode=skip \ quiet=1
+ Redfish.Login
+
+ # Put both power supply LEDs On/Off to check all units are asserted
+ Redfish.Put ${LED_PHYSICAL_PS0_URI}attr/State body={"data":${asserted}}
+ Redfish.Put ${LED_PHYSICAL_PS1_URI}attr/State body={"data":${asserted}}
+
+ # Example output:
+ # power_supplies:
+ # [0]:
+ # [MemberId]: powersupply0
+ # [IndicatorLED]: Lit
+ # [Status]:
+ # [Health]: OK
+ # [State]: Enabled
+ # [1]:
+ # [MemberId]: powersupply1
+ # [IndicatorLED]: Lit
+ # [Status]:
+ # [Health]: OK
+ # [State]: Enabled
+
+ Verify Indicator LEDs ${expected_indicator_led}
+
+
+Verify Indicator LEDs
+ [Documentation] Verify the LEDs on the power supply units are set according to caller's expectation.
+ [Arguments] ${expected_indicator_led}
+
+ # Description of Arguments(s):
+ # expected_indicator_led The expected value of the IndicatorLED attribute for all the
+ # LEDs after the lamp test is initiated (e.g. "Blinking")
+
+ ${power_supplies}= Redfish.Get Attribute ${REDFISH_CHASSIS_POWER_URI} PowerSupplies
+ Rprint Vars power_supplies
+ FOR ${power_supply_leds} IN @{power_supplies}
+ Valid Value power_supply_leds['IndicatorLED'] [${expected_indicator_led}]
+ END
+
+
+Suite Teardown Execution
+ [Documentation] Do the post suite teardown.
+
+ Redfish.Logout
+
+
+Suite Setup Execution
+ [Documentation] Do test case setup tasks.
+
+ Printn
+ Redfish.Login
+
+
+Test Teardown Execution
+ [Documentation] Do the post test teardown.
+
+ FFDC On Test Case Fail