xref: /openbmc/openbmc-test-automation/redfish/extended/test_power_restore.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
15611421fSGeorge Keishing*** Settings ***
25611421fSGeorge KeishingDocumentation   This suite verifies the power restore policy supported by
35611421fSGeorge Keishing...             REST Interfaces.
45611421fSGeorge Keishing...             Refer here for documentation on the REST interfaces
55611421fSGeorge Keishing...             https://github.com/openbmc/docs/blob/master/rest-api.md
65611421fSGeorge Keishing
75611421fSGeorge KeishingResource        ../../lib/rest_client.robot
85611421fSGeorge KeishingResource        ../../lib/utils.robot
95611421fSGeorge KeishingResource        ../../lib/openbmc_ffdc.robot
105611421fSGeorge KeishingResource        ../../lib/state_manager.robot
115611421fSGeorge KeishingResource        ../../lib/boot_utils.robot
1269436a31SGeorge KeishingResource        ../../lib/bmc_redfish_resource.robot
1369436a31SGeorge KeishingResource        ../../lib/bmc_redfish_utils.robot
1467b409b2Saravinth0510Resource        ../../lib/pdu/pdu.robot
155611421fSGeorge KeishingLibrary         ../../lib/state_map.py
165611421fSGeorge Keishing
175611421fSGeorge KeishingTest Teardown   Test Teardown Execution
185611421fSGeorge KeishingSuite Teardown  Suite Teardown Execution
195611421fSGeorge Keishing
20*6fb70d98SMatt FischerTest Tags      Power_Restore
215611421fSGeorge Keishing
225611421fSGeorge Keishing*** Variables ***
235611421fSGeorge Keishing
245611421fSGeorge Keishing*** Test Cases ***
255611421fSGeorge Keishing
265611421fSGeorge KeishingTest Restore Policy ALWAYS_POWER_OFF With Host Off
275611421fSGeorge Keishing    [Documentation]  Validate ALWAYS_POWER_OFF restore policy functionality.
285611421fSGeorge Keishing    ...              Policy:
295611421fSGeorge Keishing    ...                    System policy set to ALWAYS_POWER_OFF.
305611421fSGeorge Keishing    ...              Initial Host State:
315611421fSGeorge Keishing    ...                    State where system should be before running the
325611421fSGeorge Keishing    ...                    test case.
335611421fSGeorge Keishing    ...              Expected Host State:
345611421fSGeorge Keishing    ...                    After BMC reset, system should reach this
355611421fSGeorge Keishing    ...                    specific state.
365611421fSGeorge Keishing    [Tags]  Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Off
375611421fSGeorge Keishing    [Template]  Verify Restore Policy
385611421fSGeorge Keishing
395611421fSGeorge Keishing    # Policy                Initial Host State     Expected Host State
4090b555aaSGeorge Keishing    AlwaysOff               Off                    Off
415611421fSGeorge Keishing
425611421fSGeorge Keishing
435611421fSGeorge Keishing
445611421fSGeorge KeishingTest Restore Policy ALWAYS_POWER_OFF With Host Running
455611421fSGeorge Keishing    [Documentation]  Verify that the BMC restore policy is ALWAYS_POWER_OFF while the Host is running.
465611421fSGeorge Keishing    [Tags]  Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Running
475611421fSGeorge Keishing    [Template]  Verify Restore Policy
485611421fSGeorge Keishing
495611421fSGeorge Keishing    # Policy                Initial Host State     Expected Host State
5090b555aaSGeorge Keishing    AlwaysOff               Running                Running
515611421fSGeorge Keishing
525611421fSGeorge Keishing
535611421fSGeorge KeishingTest Restore Policy ALWAYS_POWER_ON With Host Off
545611421fSGeorge Keishing    [Documentation]  Validate ALWAYS_POWER_ON restore policy functionality.
555611421fSGeorge Keishing    ...              Policy:
565611421fSGeorge Keishing    ...                    System policy set to ALWAYS_POWER_OFF.
575611421fSGeorge Keishing    ...              Initial Host State:
585611421fSGeorge Keishing    ...                    State where system should be before running the
595611421fSGeorge Keishing    ...                    test case.
605611421fSGeorge Keishing    ...              Expected Host State:
615611421fSGeorge Keishing    ...                    After BMC reset, system should reach this
625611421fSGeorge Keishing    ...                    specific state.
635611421fSGeorge Keishing    [Tags]  Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Off
645611421fSGeorge Keishing    [Template]  Verify Restore Policy
655611421fSGeorge Keishing
665611421fSGeorge Keishing    # Policy                Initial Host State     Expected Host State
6790b555aaSGeorge Keishing    AlwaysOn                Off                    Running
685611421fSGeorge Keishing
695611421fSGeorge Keishing
705611421fSGeorge Keishing
715611421fSGeorge KeishingTest Restore Policy ALWAYS_POWER_ON With Host Running
725611421fSGeorge Keishing    [Documentation]  Verify the BMC restore policy is ALWAYS_POWER_ON while the Host is running.
735611421fSGeorge Keishing    [Tags]  Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Running
745611421fSGeorge Keishing    [Template]  Verify Restore Policy
755611421fSGeorge Keishing
765611421fSGeorge Keishing    # Policy                Initial Host State     Expected Host State
7790b555aaSGeorge Keishing    AlwaysOn                Running                Running
785611421fSGeorge Keishing
795611421fSGeorge Keishing
805611421fSGeorge Keishing
815611421fSGeorge KeishingTest Restore Policy Restore Last State With Host Running
825611421fSGeorge Keishing    [Documentation]  Validate RESTORE_LAST_STATE restore policy functionality.
835611421fSGeorge Keishing    ...              Policy:
845611421fSGeorge Keishing    ...                    System policy set to RESTORE_LAST_STATE.
855611421fSGeorge Keishing    ...              Initial Host State:
865611421fSGeorge Keishing    ...                    State where system should be before running the
875611421fSGeorge Keishing    ...                    test case.
885611421fSGeorge Keishing    ...              Expected Host State:
895611421fSGeorge Keishing    ...                    After BMC reset, system should reach this
905611421fSGeorge Keishing    ...                    specific state.
915611421fSGeorge Keishing    [Tags]  Test_Restore_Policy_Restore_Last_State_With_Host_Running
925611421fSGeorge Keishing    [Template]  Verify Restore Policy
935611421fSGeorge Keishing
945611421fSGeorge Keishing    # Policy                Initial Host State     Expected Host State
9590b555aaSGeorge Keishing    LastState               Running                Running
965611421fSGeorge Keishing
975611421fSGeorge Keishing
985611421fSGeorge Keishing
995611421fSGeorge KeishingTest Restore Policy Restore Last State With Host Off
1005611421fSGeorge Keishing    [Documentation]  Verify the RESTORE_LAST_STATE restore policy functionality while the Host is off.
1015611421fSGeorge Keishing    [Tags]  Test_Restore_Policy_Restore_Last_State_With_Host_Off
1025611421fSGeorge Keishing    [Template]  Verify Restore Policy
1035611421fSGeorge Keishing
1045611421fSGeorge Keishing    # Policy                Initial Host State     Expected Host State
10590b555aaSGeorge Keishing    LastState               Off                    Off
1065611421fSGeorge Keishing
1075611421fSGeorge Keishing
1085611421fSGeorge Keishing*** Keywords ***
1095611421fSGeorge Keishing
1105611421fSGeorge KeishingVerify Restore Policy
1115611421fSGeorge Keishing    [Documentation]  Set given policy, reset BMC and expect specified end
1125611421fSGeorge Keishing    ...              state.
1135611421fSGeorge Keishing    [Arguments]  ${policy}  ${expectedState}  ${nextState}
1145611421fSGeorge Keishing
1155611421fSGeorge Keishing    # Description of argument(s):
1165611421fSGeorge Keishing    # policy           System policy state string.
1175611421fSGeorge Keishing    # expectedState    Test initial host state.
1185611421fSGeorge Keishing    # nextState        Test end host state.
1195611421fSGeorge Keishing
1205611421fSGeorge Keishing    Set Initial Test State  ${expectedState}
1215611421fSGeorge Keishing
12290b555aaSGeorge Keishing    Redfish Set Power Restore Policy  ${policy}
12369436a31SGeorge Keishing
12467b409b2Saravinth0510    PDU Power Cycle
12590b555aaSGeorge Keishing    Sleep  20s
12690b555aaSGeorge Keishing    Wait For BMC Online
1275611421fSGeorge Keishing
1285611421fSGeorge Keishing    Wait Until Keyword Succeeds
12969436a31SGeorge Keishing    ...  10 min  20 sec  Valid Boot States  ${nextState}
1305611421fSGeorge Keishing
1315611421fSGeorge Keishing
1325611421fSGeorge KeishingValid Boot States
1335611421fSGeorge Keishing    [Documentation]  Verify boot states for a given system state.
1345611421fSGeorge Keishing    [Arguments]  ${sys_state}
1355611421fSGeorge Keishing
1365611421fSGeorge Keishing    # Description of argument(s):
1375611421fSGeorge Keishing    # sys_state    system state list
1385611421fSGeorge Keishing    #              (e.g. "Off", "On", "Reboot", etc.).
1395611421fSGeorge Keishing
14090b555aaSGeorge Keishing    ${current_state}=  Redfish Get States
14190b555aaSGeorge Keishing    Redfish Valid Boot State  ${sys_state}  ${current_state}
1425611421fSGeorge Keishing
1435611421fSGeorge Keishing
1445611421fSGeorge KeishingSet Initial Test State
1455611421fSGeorge Keishing    [Documentation]  Poweron if ON expected, Poweroff if OFF expected
1465611421fSGeorge Keishing    ...              to initial state of the test.
1475611421fSGeorge Keishing
1485611421fSGeorge Keishing    [Arguments]  ${expectedState}
1495611421fSGeorge Keishing    # Description of argument(s):
1505611421fSGeorge Keishing    # expectedState    Test initial host state.
1515611421fSGeorge Keishing
1529e1a30e9SGeorge Keishing    Redfish.Login
1539e1a30e9SGeorge Keishing
1545611421fSGeorge Keishing    Run Keyword If  '${expectedState}' == 'Running'
15569436a31SGeorge Keishing    ...  Redfish Power On  stack_mode=skip
1565611421fSGeorge Keishing
1575611421fSGeorge Keishing    Run Keyword If  '${expectedState}' == 'Off'
15869436a31SGeorge Keishing    ...  Redfish Power Off  stack_mode=skip
15969436a31SGeorge Keishing
1605611421fSGeorge Keishing
1615611421fSGeorge KeishingTest Teardown Execution
1625611421fSGeorge Keishing    [Documentation]  Do the post test teardown.
1635611421fSGeorge Keishing    # 1. Capture FFDC on test failure.
1645611421fSGeorge Keishing    # 2. Close all open SSH connections.
1655611421fSGeorge Keishing
1665611421fSGeorge Keishing    FFDC On Test Case Fail
1675611421fSGeorge Keishing    Close All Connections
1685611421fSGeorge Keishing
1695611421fSGeorge Keishing
1705611421fSGeorge KeishingSuite Teardown Execution
1715611421fSGeorge Keishing    [Documentation]  Do the post suite teardown.
1725611421fSGeorge Keishing    # 1. Set policy to default.
1735611421fSGeorge Keishing
17490b555aaSGeorge Keishing    Run Keyword And Ignore Error  Redfish Set Power Restore Policy  AlwaysOff
17569436a31SGeorge Keishing    Redfish.Logout
1765611421fSGeorge Keishing
17790b555aaSGeorge Keishing
17890b555aaSGeorge KeishingWait For BMC Online
17990b555aaSGeorge Keishing    [Documentation]  Wait for Host to be online. Checks every X seconds
18090b555aaSGeorge Keishing    ...              interval for Y minutes and fails if timed out.
18190b555aaSGeorge Keishing    ...              Default MAX timedout is 10 min, interval 10 seconds.
18290b555aaSGeorge Keishing    [Arguments]      ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
18390b555aaSGeorge Keishing    ...              ${interval}=10 sec
18490b555aaSGeorge Keishing
18590b555aaSGeorge Keishing    # Description of argument(s):
18690b555aaSGeorge Keishing    # max_timeout   Maximum time to wait.
18790b555aaSGeorge Keishing    #               This should be expressed in Robot Framework's time format
18890b555aaSGeorge Keishing    #               (e.g. "10 minutes").
18990b555aaSGeorge Keishing    # interval      Interval to wait between status checks.
19090b555aaSGeorge Keishing    #               This should be expressed in Robot Framework's time format
19190b555aaSGeorge Keishing    #               (e.g. "5 seconds").
19290b555aaSGeorge Keishing
19390b555aaSGeorge Keishing    Wait Until Keyword Succeeds
19490b555aaSGeorge Keishing    ...   ${max_timeout}  ${interval}  Verify Ping SSH And Redfish Authentication
195