*** Settings ***
Documentation  Test power on for HW CI.

Resource            ../lib/openbmc_ffdc.robot
Resource            ../lib/utils.robot
Resource            ../lib/state_manager.robot

Test Setup          Start SOL Console Logging
Test Teardown       Test Exit Logs

Force Tags  chassisboot

*** Variables ***

# User may pass LOOP_COUNT.
# By default 2 cycle for CI/CT.
${LOOP_COUNT}  ${2}

*** Test Cases ***

Power On Test
    [Documentation]  Power off and on.
    [Tags]  Power_On_Test

    Repeat Keyword  ${LOOP_COUNT} times  Host Off And On

*** Keywords ***

Test Exit Logs
    [Documentation]  Collect FFDC and SOL log.
    FFDC On Test Case Fail
    ${sol_log}=    Stop SOL Console Logging
    Log   ${sol_log}

Host Off And On
    [Documentation]  Verify power off and on.

    Initiate Host PowerOff
    Wait Until Keyword Succeeds  5 min  10 sec  Is OS Off

    # Add delay to wait for mailbox to reset before powering on
    # to minimize the watchdog reset error.
    # TODO: openbmc/openbmc#1045
    Sleep  30s

    Initiate Host Boot
    Wait Until Keyword Succeeds  10 min  10 sec  Is OS Starting

    Flush REST Sessions

*** Settings ***
Documentation  Test power on for HW CI.

Resource            ../lib/openbmc_ffdc.robot
Resource            ../lib/utils.robot
Resource            ../lib/state_manager.robot

Test Setup          Start SOL Console Logging
Test Teardown       Test Exit Logs

Force Tags  chassisboot

*** Variables ***

# User may pass LOOP_COUNT.
# By default 2 cycle for CI/CT.
${LOOP_COUNT}  ${2}

*** Test Cases ***

Power On Test
    [Documentation]  Power off and on.
    [Tags]  Power_On_Test

    Repeat Keyword  ${LOOP_COUNT} times  Host Off And On

*** Keywords ***

Test Exit Logs
    [Documentation]  Collect FFDC and SOL log.
    FFDC On Test Case Fail
    ${sol_log}=    Stop SOL Console Logging
    Log   ${sol_log}

Host Off And On
    [Documentation]  Verify power off and on.

    Initiate Host PowerOff
    Wait Until Keyword Succeeds  5 min  10 sec  Is OS Off

    Initiate Host Boot
    Wait Until Keyword Succeeds  10 min  10 sec  Is OS Starting

    Flush REST Sessions

Remove workaround sleep delay for poweroff
Remove workaround sleep delay for poweroff

Once openbmc/openbmc#1045 is merged, we would no longer need to
wait post power off.

Resolves openbmc/openbmc-test-automation#475

Change-Id: I80f44b31d0c9cd10e6ccff83c98055635ebcfa0d
Signed-off-by: George Keishing <bef0a9ecac45fb57611777c8270153994e13fd2e@in.ibm.com>

openbmc/openbmc-test-automation,openbmc/openbmc-test-automation