George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This suite verifies the power restore policy supported by |
| 3 | ... REST Interfaces. |
| 4 | ... Refer here for documentation on the REST interfaces |
| 5 | ... https://github.com/openbmc/docs/blob/master/rest-api.md |
| 6 | |
| 7 | Resource ../lib/rest_client.robot |
| 8 | Resource ../lib/utils.robot |
| 9 | Resource ../lib/openbmc_ffdc.robot |
| 10 | Resource ../lib/state_manager.robot |
| 11 | |
| 12 | |
| 13 | Library SSHLibrary |
| 14 | |
| 15 | Test Teardown FFDC On Test Case Fail |
| 16 | Suite Teardown Set BMC Power Policy RESTORE_LAST_STATE |
| 17 | |
| 18 | Force Tags power_restore |
| 19 | |
| 20 | *** Variables *** |
| 21 | |
| 22 | *** Test Cases *** |
| 23 | |
| 24 | Test Restore Policy LEAVE_OFF |
| 25 | #Policy Initial Host State Expected Host State |
| 26 | |
| 27 | LEAVE_OFF Off Off |
| 28 | LEAVE_OFF Running Off |
| 29 | |
| 30 | [Documentation] Validate LEAVE_OFF restore policy functionality. |
| 31 | ... Policy: |
| 32 | ... System policy set to LEAVE_OFF. |
| 33 | ... Initial Host State: |
| 34 | ... State where system should be before running the |
| 35 | ... test case. |
| 36 | ... Expected Host State: |
| 37 | ... After BMC reset, system should reach this |
| 38 | ... specific state. |
| 39 | |
| 40 | [Template] Verify Restore Policy |
| 41 | |
| 42 | |
| 43 | Test Restore Policy ALWAYS_POWER_ON |
| 44 | #Policy Initial Host State Expected Host State |
| 45 | |
| 46 | ALWAYS_POWER_ON Off Running |
| 47 | ALWAYS_POWER_ON Running Running |
| 48 | |
| 49 | [Documentation] Validate ALWAYS_POWER_ON restore policy functionality. |
| 50 | ... Policy: |
| 51 | ... System policy set to LEAVE_OFF. |
| 52 | ... Initial Host State: |
| 53 | ... State where system should be before running the |
| 54 | ... test case. |
| 55 | ... Expected Host State: |
| 56 | ... After BMC reset, system should reach this |
| 57 | ... specific state. |
| 58 | |
| 59 | [Template] Verify Restore Policy |
| 60 | |
| 61 | |
| 62 | Test Restore Policy RESTORE_LAST_STATE |
| 63 | #Policy Initial Host State Expected Host State |
| 64 | |
| 65 | RESTORE_LAST_STATE Running Running |
| 66 | RESTORE_LAST_STATE Off Off |
| 67 | |
| 68 | [Documentation] Validate RESTORE_LAST_STATE restore policy functionality. |
| 69 | ... Policy: |
| 70 | ... System policy set to RESTORE_LAST_STATE. |
| 71 | ... Initial Host State: |
| 72 | ... State where system should be before running the |
| 73 | ... test case. |
| 74 | ... Expected Host State: |
| 75 | ... After BMC reset, system should reach this |
| 76 | ... specific state. |
| 77 | |
| 78 | [Template] Verify Restore Policy |
| 79 | |
| 80 | *** Keywords *** |
| 81 | |
| 82 | Verify Restore Policy |
| 83 | [Documentation] Set given policy, reset BMC and expect specified end |
| 84 | ... state. |
| 85 | [Arguments] ${policy} ${expectedState} ${nextState} |
| 86 | |
| 87 | # Description of argument(s): |
| 88 | # policy System policy state string. |
| 89 | # expectedState Test initial host state. |
| 90 | # nextState Test end host state. |
| 91 | |
| 92 | Set BMC Power Policy ${policy} |
| 93 | |
| 94 | ${currentState}= Get Host State |
| 95 | |
| 96 | Log Current System State= ${currentState} |
| 97 | Log Initial Host State= ${expectedState} |
| 98 | Log Expected Host State= ${nextState} |
| 99 | |
| 100 | Run Keyword If |
| 101 | ... '${currentState}' != '${expectedState}' |
| 102 | ... Set Initial Test State ${expectedState} |
| 103 | |
| 104 | # TBD: Replace reboot with 'Initiate BMC Reboot' keyword |
| 105 | # Reference: openbmc/openbmc#1161 |
| 106 | Open Connection And Log In |
| 107 | Start Command /sbin/reboot |
| 108 | |
| 109 | Wait Until Keyword Succeeds |
| 110 | ... 5 min 10 sec Is BMC Ready |
| 111 | |
| 112 | Wait Until Keyword Succeeds |
| 113 | ... 10 min 10 sec Verify Host State ${nextState} |
| 114 | |
| 115 | |
| 116 | Set Initial Test State |
| 117 | [Documentation] Poweron if ON expected, Poweroff if OFF expected |
| 118 | ... to initial state of the test. |
| 119 | |
| 120 | [Arguments] ${expectedState} |
| 121 | # Description of argument(s): |
| 122 | # expectedState Test initial host state. |
| 123 | |
| 124 | Run Keyword If '${expectedState}' == 'Running' |
| 125 | ... Initiate Host Boot |
| 126 | |
| 127 | Run Keyword If '${expectedState}' == 'Off' |
| 128 | ... Initiate Host PowerOff |
| 129 | |
| 130 | |
| 131 | ${currentState}= Get Host State |
| 132 | |
| 133 | |
| 134 | Verify Host State |
| 135 | [Documentation] Verify expected host state. |
| 136 | [Arguments] ${expectedState} |
| 137 | |
| 138 | # Description of argument(s): |
| 139 | # expectedState Expected host state. |
| 140 | ${currentState}= Get Host State |
| 141 | Should Be Equal ${currentState} ${expectedState} |