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 | |
George Keishing | 0ef6ece | 2017-05-05 02:57:16 -0500 | [diff] [blame] | 15 | Test Teardown Post Test Case Execution |
| 16 | Suite Teardown Post Test Suite Execution |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 17 | |
| 18 | Force Tags power_restore |
| 19 | |
| 20 | *** Variables *** |
| 21 | |
| 22 | *** Test Cases *** |
| 23 | |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 24 | Test Restore Policy LEAVE_OFF With Host Off |
| 25 | # Policy Initial Host State Expected Host State |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 26 | |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 27 | LEAVE_OFF Off Off |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 28 | |
| 29 | [Documentation] Validate LEAVE_OFF restore policy functionality. |
| 30 | ... Policy: |
| 31 | ... System policy set to LEAVE_OFF. |
| 32 | ... Initial Host State: |
| 33 | ... State where system should be before running the |
| 34 | ... test case. |
| 35 | ... Expected Host State: |
| 36 | ... After BMC reset, system should reach this |
| 37 | ... specific state. |
| 38 | |
| 39 | [Template] Verify Restore Policy |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 40 | [Tags] Test_Restore_Policy_LEAVE_OFF_With_Host_Off |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 41 | |
| 42 | |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 43 | Test Restore Policy LEAVE_OFF With Host Running |
| 44 | # Policy Initial Host State Expected Host State |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 45 | |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 46 | LEAVE_OFF Running Off |
| 47 | |
| 48 | [Template] Verify Restore Policy |
| 49 | [Tags] Test_Restore_Policy_LEAVE_OFF_With_Host_Running |
| 50 | |
| 51 | |
| 52 | Test Restore Policy ALWAYS_POWER_ON With Host Off |
| 53 | # Policy Initial Host State Expected Host State |
| 54 | |
| 55 | ALWAYS_POWER_ON Off Running |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 56 | |
| 57 | [Documentation] Validate ALWAYS_POWER_ON restore policy functionality. |
| 58 | ... Policy: |
| 59 | ... System policy set to LEAVE_OFF. |
| 60 | ... Initial Host State: |
| 61 | ... State where system should be before running the |
| 62 | ... test case. |
| 63 | ... Expected Host State: |
| 64 | ... After BMC reset, system should reach this |
| 65 | ... specific state. |
| 66 | |
| 67 | [Template] Verify Restore Policy |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 68 | [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Off |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 69 | |
| 70 | |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 71 | Test Restore Policy ALWAYS_POWER_ON With Host Running |
| 72 | # Policy Initial Host State Expected Host State |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 73 | |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 74 | ALWAYS_POWER_ON Running Running |
| 75 | |
| 76 | [Template] Verify Restore Policy |
| 77 | [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Running |
| 78 | |
| 79 | |
Rahul Maheshwari | f049959 | 2017-05-10 01:55:59 -0500 | [diff] [blame] | 80 | Test Restore Policy Restore Last State With Host Running |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 81 | # Policy Initial Host State Expected Host State |
| 82 | |
| 83 | RESTORE_LAST_STATE Running Running |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 84 | |
| 85 | [Documentation] Validate RESTORE_LAST_STATE restore policy functionality. |
| 86 | ... Policy: |
| 87 | ... System policy set to RESTORE_LAST_STATE. |
| 88 | ... Initial Host State: |
| 89 | ... State where system should be before running the |
| 90 | ... test case. |
| 91 | ... Expected Host State: |
| 92 | ... After BMC reset, system should reach this |
| 93 | ... specific state. |
| 94 | |
| 95 | [Template] Verify Restore Policy |
Rahul Maheshwari | f049959 | 2017-05-10 01:55:59 -0500 | [diff] [blame] | 96 | [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Running |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 97 | |
| 98 | |
Rahul Maheshwari | f049959 | 2017-05-10 01:55:59 -0500 | [diff] [blame] | 99 | Test Restore Policy Restore Last State With Host Off |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 100 | # Policy Initial Host State Expected Host State |
| 101 | |
| 102 | RESTORE_LAST_STATE Off Off |
| 103 | |
| 104 | |
| 105 | [Template] Verify Restore Policy |
Rahul Maheshwari | f049959 | 2017-05-10 01:55:59 -0500 | [diff] [blame] | 106 | [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Off |
George Keishing | 450a528 | 2017-05-05 03:13:37 -0500 | [diff] [blame] | 107 | |
George Keishing | 880f4e6 | 2017-04-20 01:10:17 -0500 | [diff] [blame] | 108 | |
| 109 | *** Keywords *** |
| 110 | |
| 111 | Verify Restore Policy |
| 112 | [Documentation] Set given policy, reset BMC and expect specified end |
| 113 | ... state. |
| 114 | [Arguments] ${policy} ${expectedState} ${nextState} |
| 115 | |
| 116 | # Description of argument(s): |
| 117 | # policy System policy state string. |
| 118 | # expectedState Test initial host state. |
| 119 | # nextState Test end host state. |
| 120 | |
| 121 | Set BMC Power Policy ${policy} |
| 122 | |
| 123 | ${currentState}= Get Host State |
| 124 | |
| 125 | Log Current System State= ${currentState} |
| 126 | Log Initial Host State= ${expectedState} |
| 127 | Log Expected Host State= ${nextState} |
| 128 | |
| 129 | Run Keyword If |
| 130 | ... '${currentState}' != '${expectedState}' |
| 131 | ... Set Initial Test State ${expectedState} |
| 132 | |
| 133 | # TBD: Replace reboot with 'Initiate BMC Reboot' keyword |
| 134 | # Reference: openbmc/openbmc#1161 |
| 135 | Open Connection And Log In |
| 136 | Start Command /sbin/reboot |
| 137 | |
| 138 | Wait Until Keyword Succeeds |
| 139 | ... 5 min 10 sec Is BMC Ready |
| 140 | |
| 141 | Wait Until Keyword Succeeds |
| 142 | ... 10 min 10 sec Verify Host State ${nextState} |
| 143 | |
| 144 | |
| 145 | Set Initial Test State |
| 146 | [Documentation] Poweron if ON expected, Poweroff if OFF expected |
| 147 | ... to initial state of the test. |
| 148 | |
| 149 | [Arguments] ${expectedState} |
| 150 | # Description of argument(s): |
| 151 | # expectedState Test initial host state. |
| 152 | |
| 153 | Run Keyword If '${expectedState}' == 'Running' |
| 154 | ... Initiate Host Boot |
| 155 | |
| 156 | Run Keyword If '${expectedState}' == 'Off' |
| 157 | ... Initiate Host PowerOff |
| 158 | |
| 159 | |
| 160 | ${currentState}= Get Host State |
| 161 | |
| 162 | |
| 163 | Verify Host State |
| 164 | [Documentation] Verify expected host state. |
| 165 | [Arguments] ${expectedState} |
| 166 | |
| 167 | # Description of argument(s): |
| 168 | # expectedState Expected host state. |
| 169 | ${currentState}= Get Host State |
| 170 | Should Be Equal ${currentState} ${expectedState} |
George Keishing | 0ef6ece | 2017-05-05 02:57:16 -0500 | [diff] [blame] | 171 | |
| 172 | |
| 173 | Post Test Case Execution |
| 174 | [Documentation] Do the post test teardown. |
| 175 | # 1. Capture FFDC on test failure. |
| 176 | # 2. Close all open SSH connections. |
| 177 | |
| 178 | FFDC On Test Case Fail |
| 179 | Close All Connections |
| 180 | |
| 181 | |
| 182 | Post Test Suite Execution |
| 183 | [Documentation] Do the post suite teardown. |
| 184 | # 1. Set policy to default. |
| 185 | |
| 186 | Run Keyword And Ignore Error Set BMC Power Policy RESTORE_LAST_STATE |
| 187 | |