Test system LEDs.
This change includes:
- Added test cases to turn on/off heartbeat, beep and
identify LEDs.
- Added keywords to get and set physical LED state.
- Skipped these test case for Witherspoon system.
Resolves openbmc/openbmc-test-automation#404
Change-Id: I64c939d50852e4b627ad8bf559b75da4f95237a1
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/data/variables.py b/data/variables.py
index 2070c51..8d86e6f 100644
--- a/data/variables.py
+++ b/data/variables.py
@@ -49,6 +49,7 @@
# Led URI variable
LED_GROUPS_URI = '/xyz/openbmc_project/led/groups/'
+LED_PHYSICAL_URI = '/xyz/openbmc_project/led/physical/'
'''
diff --git a/test_lists/skip_test_witherspoon b/test_lists/skip_test_witherspoon
index 474715b..3072f20 100644
--- a/test_lists/skip_test_witherspoon
+++ b/test_lists/skip_test_witherspoon
@@ -43,3 +43,5 @@
-e eSEL_Logging
#openbmc/openbmc-test-automation/issues/396
-e NetworkManager
+# System LED test are NA for Witherspoon system.
+-e System_LED
diff --git a/tests/test_led.robot b/tests/test_led.robot
index b31c384..24a2a24 100644
--- a/tests/test_led.robot
+++ b/tests/test_led.robot
@@ -1,238 +1,78 @@
*** Settings ***
-Documentation This testsuite is for testing the functions of Heartbeat,
-... Identify and Power LED's
+Documentation Test the functions of system LEDs.
Resource ../lib/rest_client.robot
+Resource ../lib/state_manager.robot
Resource ../lib/resource.txt
Resource ../lib/openbmc_ffdc.robot
+
Test Teardown FFDC On Test Case Fail
+Force Tags System_LED
+
*** Variables ***
-${MIN_TOGGLE_VALUE} 0
-${SAMPLING_FREQUENCY} 6
-
-${LED_CONTROL} ${CONTROL_URI}led/
*** Test Cases ***
-Validate Heartbeat LEDs Test Cases
- [Documentation] If heartbeat LED exist then execute the test set.
- [Tags] Validate_Heartbeat_LEDs_Test_Cases
- ${resp}= OpenBMC Get Request ${LED_CONTROL}heartbeat
- Run keyword If ${resp.status_code} == ${HTTP_OK} Execute Heartbeat LEDs Test Cases
+Test Heartbeat LED And Verify Via REST
+ [Documentation] Turn On Off heartbeat LED and verify via REST.
+ #LED Name LED State
+ heartbeat On
+ heartbeat Off
-Validate Identify LEDs Test Cases
- [Documentation] If identify LED exist then execute the test set.
- [Tags] Validate_Identify_LEDs_Test_Cases
- ${resp}= OpenBMC Get Request ${LED_CONTROL}identify
- Run keyword If ${resp.status_code} == ${HTTP_OK} Execute Identify LEDs Test Cases
+ [Tags] Test_Heartbeat_LED_And_Verify_Via_REST
+ [Template] Set System LED State
-Validate Beep LEDs Test Cases
- [Documentation] If beep LED exist then execute the test set.
- [Tags] Validate_Beep_LEDs_Test_Cases
- ${resp}= OpenBMC Get Request ${LED_CONTROL}beep
- Run keyword If ${resp.status_code} == ${HTTP_OK} Execute Beep LEDs Test Cases
+Test Beep LED And Verify Via REST
+ [Documentation] Turn On Off beep LED and verify via REST.
+ #LED Name LED State
+ beep On
+ beep Off
+
+ [Tags] Test_Beep_LED_And_Verify_Via_REST
+ [Template] Set System LED State
+
+Test Identify LED And Verify Via REST
+ [Documentation] Turn On Off identify LED and verify via REST.
+ #LED Name LED State
+ identify On
+ identify Off
+
+ [Tags] Test_Identify_LED_And_Verify_Via_REST
+ [Template] Set System LED State
+
*** Keywords ***
-Execute Heartbeat LEDs Test Cases
- [Documentation] Executing ON/OFF/Fast/Slow Heartbeat LED test cases.
- Turn ON the Heartbeat LED
- Turn OFF the Heartbeat LED
- Blink Fast the Heartbeat LED
- Blink Slow the Heartbeat LED
+Get System LED State
+ [Documentation] Returns the state of given system LED.
+ [Arguments] ${led_name}
+ # Description of arguments:
+ # led_name System LED name (e.g. heartbeat, identify, beep).
-Execute Identify LEDs Test Cases
- [Documentation] Executing ON/OFF/Fast/Slow Identify LED test cases.
- Turn ON the Identify LED
- Turn OFF the Identify LED
- Blink Fast the Identify LED
- Blink Slow the Identify LED
+ ${state}= Read Attribute ${LED_PHYSICAL_URI}${led_name} State
+ [Return] ${state.rsplit('.', 1)[1]}
-Execute Beep LEDs Test Cases
- [Documentation] Executing ON/OFF/Fast/Slow Beep LED test cases.
- Turn ON the Beep LED
- Turn OFF the Beep LED
- Blink Fast the Beep LED
- Blink Slow the Beep LED
+Set System LED State
+ [Documentation] Set given system LED via REST.
+ [Arguments] ${led_name} ${led_state}
+ # Description of arguments:
+ # led_name System LED name (e.g. heartbeat, identify, beep).
+ # led_state LED state to be set (e.g. On, Off).
-Turn ON the Heartbeat LED
- [Documentation] This testcase is to test the setOn functionality of the
- ... Heartbeat LED. The LED state is read again to check if
- ... the LED is in ON state.
- Set On heartbeat
- ${ledstate}= Get LED State heartbeat
- should be equal as strings ${ledstate} On
+ ${args}= Create Dictionary data=xyz.openbmc_project.Led.Physical.Action.${led_state}
+ Write Attribute ${LED_PHYSICAL_URI}${led_name} State data=${args}
-Turn OFF the Heartbeat LED
- [Documentation] This testcase is to test the setOff functionality of the
- ... Heartbeat LED. The LED state is read again to check if
- ... the LED is in OFF state.
- Set Off heartbeat
- ${ledstate}= Get LED State heartbeat
- should be equal as strings ${ledstate} Off
+ Verify LED State ${led_name} ${led_state}
-Blink Fast the Heartbeat LED
- [Documentation] This testcase is to test the setBlinkFast functionality of the
- ... Heartbeat LED. The LED state is sampled to figure out
- ... whether the LED is blinking. There is no distinguishing
- ... between whether the LED is blinking fast or slow for
- ... this testcase to pass.
- ${OFF_VALUE}= Set Variable ${0}
- ${ON_VALUE}= Set Variable ${0}
- Set Blink Fast heartbeat
- : FOR ${INDEX} IN RANGE 1 ${SAMPLING_FREQUENCY}
- \ ${ledstate}= Get LED State heartbeat
- \ ${ON_VALUE}= Set Variable If '${ledstate}'=='On' ${ON_VALUE + 1} ${ON_VALUE}
- \ ${OFF_VALUE}= Set Variable If '${ledstate}'=='Off' ${OFF_VALUE + 1} ${OFF_VALUE}
- should be true ${ON_VALUE} > ${MIN_TOGGLE_VALUE} and ${OFF_VALUE} > ${MIN_TOGGLE_VALUE}
+Verify LED State
+ [Documentation] Checks if LED is in given state.
+ [Arguments] ${led_name} ${led_state}
+ # Description of arguments:
+ # led_name System LED name (e.g. heartbeat, identify, beep).
+ # led_state LED state to be verified (e.g. On, Off).
-Blink Slow the Heartbeat LED
- [Documentation] This testcase is to test the setBlinkSlow functionality of the
- ... Heartbeat LED. The LED state is sampled to figure out
- ... whether the LED is blinking. There is no distinguishing
- ... between whether the LED is blinking fast or slow for
- ... this testcase to pass.
- ${OFF_VALUE}= Set Variable ${0}
- ${ON_VALUE}= Set Variable ${0}
- Set Blink Slow heartbeat
- : FOR ${INDEX} IN RANGE 1 ${SAMPLING_FREQUENCY}
- \ ${ledstate}= Get LED State heartbeat
- \ ${ON_VALUE}= Set Variable If '${ledstate}'=='On' ${ON_VALUE + 1} ${ON_VALUE}
- \ ${OFF_VALUE}= Set Variable If '${ledstate}'=='Off' ${OFF_VALUE + 1} ${OFF_VALUE}
- should be true ${ON_VALUE} > ${MIN_TOGGLE_VALUE} and ${OFF_VALUE} > ${MIN_TOGGLE_VALUE}
-
-Turn ON the Identify LED
- [Documentation] This testcase is to test the setOn functionality of the
- ... Identify LED. The LED state is read again to check if
- ... the LED is in ON state.
- Set On identify
- ${ledstate}= Get LED State identify
- should be equal as strings ${ledstate} On
-
-Turn OFF the Identify LED
- [Documentation] This testcase is to test the setOff functionality of the
- ... Identify LED. The LED state is read again to check if
- ... the LED is in OFF state.
- Set Off identify
- ${ledstate}= Get LED State identify
- should be equal as strings ${ledstate} Off
-
-Blink Fast the Identify LED
- [Documentation] This testcase is to test the setBlinkFast functionality of the
- ... Identify LED. The LED state is sampled to figure out
- ... whether the LED is blinking. There is no distinguishing
- ... between whether the LED is blinking fast or slow for
- ... this testcase to pass.
- ${OFF_VALUE}= Set Variable ${0}
- ${ON_VALUE}= Set Variable ${0}
- Set Blink Fast identify
- : FOR ${INDEX} IN RANGE 1 ${SAMPLING_FREQUENCY}
- \ ${ledstate}= Get LED State identify
- \ ${ON_VALUE}= Set Variable If '${ledstate}'=='On' ${ON_VALUE + 1} ${ON_VALUE}
- \ ${OFF_VALUE}= Set Variable If '${ledstate}'=='Off' ${OFF_VALUE + 1} ${OFF_VALUE}
- should be true ${ON_VALUE} > ${MIN_TOGGLE_VALUE} and ${OFF_VALUE} > ${MIN_TOGGLE_VALUE}
-
-Blink Slow the Identify LED
- [Documentation] This testcase is to test the setBlinkSlow functionality of the
- ... Identify LED. The LED state is sampled to figure out
- ... whether the LED is blinking. There is no distinguishing
- ... between whether the LED is blinking fast or slow for
- ... this testcase to pass.
- ${OFF_VALUE}= Set Variable ${0}
- ${ON_VALUE}= Set Variable ${0}
- Set Blink Slow identify
- : FOR ${INDEX} IN RANGE 1 ${SAMPLING_FREQUENCY}
- \ ${ledstate}= Get LED State identify
- \ ${ON_VALUE}= Set Variable If '${ledstate}'=='On' ${ON_VALUE + 1} ${ON_VALUE}
- \ ${OFF_VALUE}= Set Variable If '${ledstate}'=='Off' ${OFF_VALUE + 1} ${OFF_VALUE}
- should be true ${ON_VALUE} > ${MIN_TOGGLE_VALUE} and ${OFF_VALUE} > ${MIN_TOGGLE_VALUE}
-
-Turn ON the Beep LED
- [Documentation] This testcase is to test the setOn functionality of the
- ... Beep LED. The LED state is read again to check if
- ... the LED is in ON state.
- Set On beep
- ${ledstate}= Get LED State beep
- should be equal as strings ${ledstate} On
-
-Turn OFF the Beep LED
- [Documentation] This testcase is to test the setOff functionality of the
- ... Beep LED. The LED state is read again to check if
- ... the LED is in OFF state.
- Set Off beep
- ${ledstate}= Get LED State beep
- should be equal as strings ${ledstate} Off
-
-Blink Fast the Beep LED
- [Documentation] This testcase is to test the setBlinkFast functionality of the
- ... Beep LED. The LED state is sampled to figure out
- ... whether the LED is blinking. There is no distinguishing
- ... between whether the LED is blinking fast or slow for
- ... this testcase to pass.
- ${OFF_VALUE}= Set Variable ${0}
- ${ON_VALUE}= Set Variable ${0}
- ${data}= create dictionary data=@{EMPTY}
- Set Blink Fast beep
- : FOR ${INDEX} IN RANGE 1 ${SAMPLING_FREQUENCY}
- \ ${ledstate}= Get LED State beep
- \ ${ON_VALUE}= Set Variable If '${ledstate}'=='On' ${ON_VALUE + 1} ${ON_VALUE}
- \ ${OFF_VALUE}= Set Variable If '${ledstate}'=='Off' ${OFF_VALUE + 1} ${OFF_VALUE}
- should be true ${ON_VALUE} > ${MIN_TOGGLE_VALUE} and ${OFF_VALUE} > ${MIN_TOGGLE_VALUE}
-
-Blink Slow the Beep LED
- [Documentation] This testcase is to test the setBlinkSlow functionality of the
- ... Beep LED. The LED state is sampled to figure out
- ... whether the LED is blinking. There is no distinguishing
- ... between whether the LED is blinking fast or slow for
- ... this testcase to pass.
- ${OFF_VALUE}= Set Variable ${0}
- ${ON_VALUE}= Set Variable ${0}
- Set Blink Slow beep
- : FOR ${INDEX} IN RANGE 1 ${SAMPLING_FREQUENCY}
- \ ${ledstate}= Get LED State beep
- \ ${ON_VALUE}= Set Variable If '${ledstate}'=='On' ${ON_VALUE + 1} ${ON_VALUE}
- \ ${OFF_VALUE}= Set Variable If '${ledstate}'=='Off' ${OFF_VALUE + 1} ${OFF_VALUE}
- should be true ${ON_VALUE} > ${MIN_TOGGLE_VALUE} and ${OFF_VALUE} > ${MIN_TOGGLE_VALUE}
-
-Get LED State
- [Arguments] ${args}
- ${data}= create dictionary data=@{EMPTY}
- ${resp}= OpenBMC Post Request ${LED_CONTROL}${args}/action/GetLedState data=${data}
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- [Return] ${json['data'][1]}
-
-Set On
- [Arguments] ${args}
- ${data}= create dictionary data=@{EMPTY}
- ${resp}= OpenBMC Post Request ${LED_CONTROL}${args}/action/setOn data=${data}
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- should be equal as integers ${json['data']} 0
-
-Set Off
- [Arguments] ${args}
- ${data}= create dictionary data=@{EMPTY}
- ${resp}= OpenBMC Post Request ${LED_CONTROL}${args}/action/setOff data=${data}
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- should be equal as integers ${json['data']} 0
-
-Set Blink Fast
- [Arguments] ${args}
- ${data}= create dictionary data=@{EMPTY}
- ${resp}= OpenBMC Post Request ${LED_CONTROL}${args}/action/setBlinkFast data=${data}
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- should be equal as integers ${json['data']} 0
-
-Set Blink Slow
- [Arguments] ${args}
- ${data}= create dictionary data=@{EMPTY}
- ${resp}= OpenBMC Post Request ${LED_CONTROL}${args}/action/setBlinkSlow data=${data}
- should be equal as strings ${resp.status_code} ${HTTP_OK}
- ${json}= to json ${resp.content}
- should be equal as integers ${json['data']} 0
+ ${state}= Get System LED State ${led_name}
+ Should Be Equal ${state} ${led_state}