blob: 8ced81defaccaac875d20bae635f553da0bc484e [file] [log] [blame]
George Keishing880f4e62017-04-20 01:10:17 -05001*** Settings ***
2Documentation 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
7Resource ../lib/rest_client.robot
8Resource ../lib/utils.robot
9Resource ../lib/openbmc_ffdc.robot
10Resource ../lib/state_manager.robot
11
12
13Library SSHLibrary
14
George Keishing0ef6ece2017-05-05 02:57:16 -050015Test Teardown Post Test Case Execution
16Suite Teardown Post Test Suite Execution
George Keishing880f4e62017-04-20 01:10:17 -050017
18Force Tags power_restore
19
20*** Variables ***
21
22*** Test Cases ***
23
George Keishing1c3a9662017-08-11 10:16:36 -050024Test Restore Policy ALWAYS_POWER_OFF With Host Off
George Keishing450a5282017-05-05 03:13:37 -050025 # Policy Initial Host State Expected Host State
George Keishing880f4e62017-04-20 01:10:17 -050026
George Keishing1c3a9662017-08-11 10:16:36 -050027 ${ALWAYS_POWER_OFF} Off Off
George Keishing880f4e62017-04-20 01:10:17 -050028
George Keishing1c3a9662017-08-11 10:16:36 -050029 [Documentation] Validate ALWAYS_POWER_OFF restore policy functionality.
George Keishing880f4e62017-04-20 01:10:17 -050030 ... Policy:
George Keishing1c3a9662017-08-11 10:16:36 -050031 ... System policy set to ALWAYS_POWER_OFF.
George Keishing880f4e62017-04-20 01:10:17 -050032 ... 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 Keishing1c3a9662017-08-11 10:16:36 -050040 [Tags] Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Off
George Keishing880f4e62017-04-20 01:10:17 -050041
42
George Keishing1c3a9662017-08-11 10:16:36 -050043Test Restore Policy ALWAYS_POWER_OFF With Host Running
George Keishing450a5282017-05-05 03:13:37 -050044 # Policy Initial Host State Expected Host State
George Keishing880f4e62017-04-20 01:10:17 -050045
George Keishing1c3a9662017-08-11 10:16:36 -050046 ${ALWAYS_POWER_OFF} Running Off
George Keishing450a5282017-05-05 03:13:37 -050047
48 [Template] Verify Restore Policy
George Keishing1c3a9662017-08-11 10:16:36 -050049 [Tags] Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Running
George Keishing450a5282017-05-05 03:13:37 -050050
51
52Test Restore Policy ALWAYS_POWER_ON With Host Off
53 # Policy Initial Host State Expected Host State
54
George Keishing1c3a9662017-08-11 10:16:36 -050055 ${ALWAYS_POWER_ON} Off Running
George Keishing880f4e62017-04-20 01:10:17 -050056
57 [Documentation] Validate ALWAYS_POWER_ON restore policy functionality.
58 ... Policy:
George Keishing1c3a9662017-08-11 10:16:36 -050059 ... System policy set to ALWAYS_POWER_OFF.
George Keishing880f4e62017-04-20 01:10:17 -050060 ... 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 Keishing450a5282017-05-05 03:13:37 -050068 [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Off
George Keishing880f4e62017-04-20 01:10:17 -050069
70
George Keishing450a5282017-05-05 03:13:37 -050071Test Restore Policy ALWAYS_POWER_ON With Host Running
72 # Policy Initial Host State Expected Host State
George Keishing880f4e62017-04-20 01:10:17 -050073
George Keishing1c3a9662017-08-11 10:16:36 -050074 ${ALWAYS_POWER_ON} Running Running
George Keishing450a5282017-05-05 03:13:37 -050075
76 [Template] Verify Restore Policy
77 [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Running
78
79
Rahul Maheshwarif0499592017-05-10 01:55:59 -050080Test Restore Policy Restore Last State With Host Running
George Keishing450a5282017-05-05 03:13:37 -050081 # Policy Initial Host State Expected Host State
82
George Keishing1c3a9662017-08-11 10:16:36 -050083 ${RESTORE_LAST_STATE} Running Running
George Keishing880f4e62017-04-20 01:10:17 -050084
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 Maheshwarif0499592017-05-10 01:55:59 -050096 [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Running
George Keishing450a5282017-05-05 03:13:37 -050097
98
Rahul Maheshwarif0499592017-05-10 01:55:59 -050099Test Restore Policy Restore Last State With Host Off
George Keishing450a5282017-05-05 03:13:37 -0500100 # Policy Initial Host State Expected Host State
101
George Keishing1c3a9662017-08-11 10:16:36 -0500102 ${RESTORE_LAST_STATE} Off Off
George Keishing450a5282017-05-05 03:13:37 -0500103
104
105 [Template] Verify Restore Policy
Rahul Maheshwarif0499592017-05-10 01:55:59 -0500106 [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Off
George Keishing450a5282017-05-05 03:13:37 -0500107
George Keishing880f4e62017-04-20 01:10:17 -0500108
109*** Keywords ***
110
111Verify 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
George Keishing1c3a9662017-08-11 10:16:36 -0500133 Initiate BMC Reboot
George Keishing880f4e62017-04-20 01:10:17 -0500134
135 Wait Until Keyword Succeeds
136 ... 10 min 10 sec Verify Host State ${nextState}
137
138
139Set Initial Test State
140 [Documentation] Poweron if ON expected, Poweroff if OFF expected
141 ... to initial state of the test.
142
143 [Arguments] ${expectedState}
144 # Description of argument(s):
145 # expectedState Test initial host state.
146
147 Run Keyword If '${expectedState}' == 'Running'
148 ... Initiate Host Boot
149
150 Run Keyword If '${expectedState}' == 'Off'
151 ... Initiate Host PowerOff
152
153
154 ${currentState}= Get Host State
155
156
157Verify Host State
158 [Documentation] Verify expected host state.
159 [Arguments] ${expectedState}
160
161 # Description of argument(s):
162 # expectedState Expected host state.
163 ${currentState}= Get Host State
164 Should Be Equal ${currentState} ${expectedState}
George Keishing0ef6ece2017-05-05 02:57:16 -0500165
166
167Post Test Case Execution
168 [Documentation] Do the post test teardown.
169 # 1. Capture FFDC on test failure.
170 # 2. Close all open SSH connections.
171
172 FFDC On Test Case Fail
173 Close All Connections
174
175
176Post Test Suite Execution
177 [Documentation] Do the post suite teardown.
178 # 1. Set policy to default.
179
George Keishing1c3a9662017-08-11 10:16:36 -0500180 Run Keyword And Ignore Error Set BMC Power Policy ${RESTORE_LAST_STATE}
George Keishing0ef6ece2017-05-05 02:57:16 -0500181