Power restore test policy
Changes:
- Moved extended/test_power_restore.robot to
CT directory tests/test_power_restore.robot
- Replaced PDU reset with BMC reboot
- Grouped policy test cases by functionality
- Minor documentation changes and spacing fixes.
Resolves openbmc/openbmc-test-automation#518
Change-Id: If06f4ee6b4389da96776b10bf83cf90feff88210
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/extended/test_power_restore.robot b/extended/test_power_restore.robot
deleted file mode 100644
index 6066f55..0000000
--- a/extended/test_power_restore.robot
+++ /dev/null
@@ -1,82 +0,0 @@
-*** Settings ***
-Documentation This suite verifies the power restore policy supported by
-... REST Interfaces.
-... Refer here for documentation on the REST interfaces
-... https://github.com/openbmc/docs/blob/master/rest-api.md
-
-Resource ../lib/rest_client.robot
-Resource ../lib/pdu/pdu.robot
-Resource ../lib/utils.robot
-Resource ../lib/openbmc_ffdc.robot
-Resource ../lib/state_manager.robot
-
-
-Library SSHLibrary
-
-Test Teardown FFDC On Test Case Fail
-Force Tags chassisboot bmcreboot
-
-*** Variables ***
-
-*** Test Cases ***
-
-Set the power restore policy
- #Policy Expected System State Next System State
-
- LEAVE_OFF Off Off
- LEAVE_OFF Running Off
- ALWAYS_POWER_ON Off Running
- ALWAYS_POWER_ON Running Running
- RESTORE_LAST_STATE Running Running
- RESTORE_LAST_STATE Off Off
-
- [Documentation] Test to validate restore policy attribute functionality.
- ... Policy:
- ... System policy to restore on power cycle
- ... Expected System State:
- ... State where system should be before running the
- ... test case
- ... Next System State:
- ... After power cycle, system should reach this
- ... specific state
-
- [Template] Set Restore Policy
-
-*** Keywords ***
-
-Set Restore Policy
- [Arguments] ${policy} ${expectedState} ${nextState}
-
- Set BMC Power Policy ${policy}
-
- ${currentState}= Get Host State
-
- Log Current System State= ${currentState}
- Log Expected System State= ${expectedState}
- Log Next System State= ${nextState}
-
- Run Keyword If
- ... '${currentState}' != '${expectedState}'
- ... Set Initial Test State ${expectedState}
-
- Log "Doing power cycle"
- PDU Power Cycle
- Check If BMC is Up 5 min 10 sec
- Log "BMC is Online now"
-
- Wait Until Keyword Succeeds
- ... 5 min 10 sec Is BMC Ready
-
-
-Set Initial Test State
- [Documentation] Poweron if ON expected, Poweroff if OFF expected
- ... to initial state of the test.
- [Arguments] ${expectedState}
-
- Run Keyword If
- ... '${expectedState}' == 'Running'
- ... Initiate Host Boot
-
- Run Keyword If
- ... '${expectedState}' == 'Off'
- ... Initiate Host PowerOff
diff --git a/tests/test_power_restore.robot b/tests/test_power_restore.robot
new file mode 100644
index 0000000..137fea1
--- /dev/null
+++ b/tests/test_power_restore.robot
@@ -0,0 +1,141 @@
+*** Settings ***
+Documentation This suite verifies the power restore policy supported by
+... REST Interfaces.
+... Refer here for documentation on the REST interfaces
+... https://github.com/openbmc/docs/blob/master/rest-api.md
+
+Resource ../lib/rest_client.robot
+Resource ../lib/utils.robot
+Resource ../lib/openbmc_ffdc.robot
+Resource ../lib/state_manager.robot
+
+
+Library SSHLibrary
+
+Test Teardown FFDC On Test Case Fail
+Suite Teardown Set BMC Power Policy RESTORE_LAST_STATE
+
+Force Tags power_restore
+
+*** Variables ***
+
+*** Test Cases ***
+
+Test Restore Policy LEAVE_OFF
+ #Policy Initial Host State Expected Host State
+
+ LEAVE_OFF Off Off
+ LEAVE_OFF Running Off
+
+ [Documentation] Validate LEAVE_OFF restore policy functionality.
+ ... Policy:
+ ... System policy set to LEAVE_OFF.
+ ... Initial Host State:
+ ... State where system should be before running the
+ ... test case.
+ ... Expected Host State:
+ ... After BMC reset, system should reach this
+ ... specific state.
+
+ [Template] Verify Restore Policy
+
+
+Test Restore Policy ALWAYS_POWER_ON
+ #Policy Initial Host State Expected Host State
+
+ ALWAYS_POWER_ON Off Running
+ ALWAYS_POWER_ON Running Running
+
+ [Documentation] Validate ALWAYS_POWER_ON restore policy functionality.
+ ... Policy:
+ ... System policy set to LEAVE_OFF.
+ ... Initial Host State:
+ ... State where system should be before running the
+ ... test case.
+ ... Expected Host State:
+ ... After BMC reset, system should reach this
+ ... specific state.
+
+ [Template] Verify Restore Policy
+
+
+Test Restore Policy RESTORE_LAST_STATE
+ #Policy Initial Host State Expected Host State
+
+ RESTORE_LAST_STATE Running Running
+ RESTORE_LAST_STATE Off Off
+
+ [Documentation] Validate RESTORE_LAST_STATE restore policy functionality.
+ ... Policy:
+ ... System policy set to RESTORE_LAST_STATE.
+ ... Initial Host State:
+ ... State where system should be before running the
+ ... test case.
+ ... Expected Host State:
+ ... After BMC reset, system should reach this
+ ... specific state.
+
+ [Template] Verify Restore Policy
+
+*** Keywords ***
+
+Verify Restore Policy
+ [Documentation] Set given policy, reset BMC and expect specified end
+ ... state.
+ [Arguments] ${policy} ${expectedState} ${nextState}
+
+ # Description of argument(s):
+ # policy System policy state string.
+ # expectedState Test initial host state.
+ # nextState Test end host state.
+
+ Set BMC Power Policy ${policy}
+
+ ${currentState}= Get Host State
+
+ Log Current System State= ${currentState}
+ Log Initial Host State= ${expectedState}
+ Log Expected Host State= ${nextState}
+
+ Run Keyword If
+ ... '${currentState}' != '${expectedState}'
+ ... Set Initial Test State ${expectedState}
+
+ # TBD: Replace reboot with 'Initiate BMC Reboot' keyword
+ # Reference: openbmc/openbmc#1161
+ Open Connection And Log In
+ Start Command /sbin/reboot
+
+ Wait Until Keyword Succeeds
+ ... 5 min 10 sec Is BMC Ready
+
+ Wait Until Keyword Succeeds
+ ... 10 min 10 sec Verify Host State ${nextState}
+
+
+Set Initial Test State
+ [Documentation] Poweron if ON expected, Poweroff if OFF expected
+ ... to initial state of the test.
+
+ [Arguments] ${expectedState}
+ # Description of argument(s):
+ # expectedState Test initial host state.
+
+ Run Keyword If '${expectedState}' == 'Running'
+ ... Initiate Host Boot
+
+ Run Keyword If '${expectedState}' == 'Off'
+ ... Initiate Host PowerOff
+
+
+ ${currentState}= Get Host State
+
+
+Verify Host State
+ [Documentation] Verify expected host state.
+ [Arguments] ${expectedState}
+
+ # Description of argument(s):
+ # expectedState Expected host state.
+ ${currentState}= Get Host State
+ Should Be Equal ${currentState} ${expectedState}