blob: a787cb89085f838cb36975cf38ac35727917f2cc [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 Keishing450a5282017-05-05 03:13:37 -050024Test Restore Policy LEAVE_OFF With Host Off
25 # Policy Initial Host State Expected Host State
George Keishing880f4e62017-04-20 01:10:17 -050026
George Keishing450a5282017-05-05 03:13:37 -050027 LEAVE_OFF Off Off
George Keishing880f4e62017-04-20 01:10:17 -050028
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 Keishing450a5282017-05-05 03:13:37 -050040 [Tags] Test_Restore_Policy_LEAVE_OFF_With_Host_Off
George Keishing880f4e62017-04-20 01:10:17 -050041
42
George Keishing450a5282017-05-05 03:13:37 -050043Test Restore Policy LEAVE_OFF With Host Running
44 # Policy Initial Host State Expected Host State
George Keishing880f4e62017-04-20 01:10:17 -050045
George Keishing450a5282017-05-05 03:13:37 -050046 LEAVE_OFF Running Off
47
48 [Template] Verify Restore Policy
49 [Tags] Test_Restore_Policy_LEAVE_OFF_With_Host_Running
50
51
52Test Restore Policy ALWAYS_POWER_ON With Host Off
53 # Policy Initial Host State Expected Host State
54
55 ALWAYS_POWER_ON Off Running
George Keishing880f4e62017-04-20 01:10:17 -050056
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 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 Keishing450a5282017-05-05 03:13:37 -050074 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 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
83 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
102 RESTORE_LAST_STATE Off Off
103
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
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
145Set 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
163Verify 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 Keishing0ef6ece2017-05-05 02:57:16 -0500171
172
173Post 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
182Post 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