blob: 9a6412e53f88eac4dc8c3a61b7627d0ecb1aa3aa [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
George Keishing56114212019-07-22 02:27:42 -05007Resource ../../lib/rest_client.robot
8Resource ../../lib/utils.robot
9Resource ../../lib/openbmc_ffdc.robot
10Resource ../../lib/state_manager.robot
11Resource ../../lib/boot_utils.robot
George Keishing69436a32019-08-09 01:53:08 -050012Resource ../../lib/bmc_redfish_resource.robot
13Resource ../../lib/bmc_redfish_utils.robot
aravinth051067b409b2022-07-13 10:41:26 +000014Resource ../../lib/pdu/pdu.robot
George Keishing56114212019-07-22 02:27:42 -050015Library ../../lib/state_map.py
George Keishing880f4e62017-04-20 01:10:17 -050016
George Keishing62c82672017-12-06 04:39:46 -060017Test Teardown Test Teardown Execution
18Suite Teardown Suite Teardown Execution
George Keishing880f4e62017-04-20 01:10:17 -050019
Matt Fischer6fb70d92023-10-24 19:06:33 -060020Test Tags Power_Restore
George Keishing880f4e62017-04-20 01:10:17 -050021
George Keishing880f4e62017-04-20 01:10:17 -050022
23*** Test Cases ***
24
George Keishing1c3a9662017-08-11 10:16:36 -050025Test Restore Policy ALWAYS_POWER_OFF With Host Off
George Keishing1c3a9662017-08-11 10:16:36 -050026 [Documentation] Validate ALWAYS_POWER_OFF restore policy functionality.
George Keishing880f4e62017-04-20 01:10:17 -050027 ... Policy:
George Keishing1c3a9662017-08-11 10:16:36 -050028 ... System policy set to ALWAYS_POWER_OFF.
George Keishing880f4e62017-04-20 01:10:17 -050029 ... Initial Host State:
30 ... State where system should be before running the
31 ... test case.
32 ... Expected Host State:
33 ... After BMC reset, system should reach this
34 ... specific state.
George Keishing1c3a9662017-08-11 10:16:36 -050035 [Tags] Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Off
George Keishing5abfe602018-07-05 11:54:37 -050036 [Template] Verify Restore Policy
37
38 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050039 AlwaysOff Off Off
George Keishing5abfe602018-07-05 11:54:37 -050040
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
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050044 [Documentation] Verify that the BMC restore policy is ALWAYS_POWER_OFF while the Host is running.
George Keishing1c3a9662017-08-11 10:16:36 -050045 [Tags] Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Running
George Keishing5abfe602018-07-05 11:54:37 -050046 [Template] Verify Restore Policy
47
48 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050049 AlwaysOff Running Running
George Keishing450a5282017-05-05 03:13:37 -050050
51
52Test Restore Policy ALWAYS_POWER_ON With Host Off
George Keishing880f4e62017-04-20 01:10:17 -050053 [Documentation] Validate ALWAYS_POWER_ON restore policy functionality.
54 ... Policy:
George Keishing1c3a9662017-08-11 10:16:36 -050055 ... System policy set to ALWAYS_POWER_OFF.
George Keishing880f4e62017-04-20 01:10:17 -050056 ... Initial Host State:
57 ... State where system should be before running the
58 ... test case.
59 ... Expected Host State:
60 ... After BMC reset, system should reach this
61 ... specific state.
George Keishing450a5282017-05-05 03:13:37 -050062 [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Off
George Keishing5abfe602018-07-05 11:54:37 -050063 [Template] Verify Restore Policy
64
65 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050066 AlwaysOn Off Running
George Keishing5abfe602018-07-05 11:54:37 -050067
George Keishing880f4e62017-04-20 01:10:17 -050068
69
George Keishing450a5282017-05-05 03:13:37 -050070Test Restore Policy ALWAYS_POWER_ON With Host Running
George Keishing5abfe602018-07-05 11:54:37 -050071 [Documentation] Verify the BMC restore policy is ALWAYS_POWER_ON while the Host is running.
72 [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Running
73 [Template] Verify Restore Policy
George Keishing880f4e62017-04-20 01:10:17 -050074
George Keishing5abfe602018-07-05 11:54:37 -050075 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050076 AlwaysOn Running Running
George Keishing450a5282017-05-05 03:13:37 -050077
George Keishing450a5282017-05-05 03:13:37 -050078
79
Rahul Maheshwarif0499592017-05-10 01:55:59 -050080Test Restore Policy Restore Last State With Host Running
George Keishing880f4e62017-04-20 01:10:17 -050081 [Documentation] Validate RESTORE_LAST_STATE restore policy functionality.
82 ... Policy:
83 ... System policy set to RESTORE_LAST_STATE.
84 ... Initial Host State:
85 ... State where system should be before running the
86 ... test case.
87 ... Expected Host State:
88 ... After BMC reset, system should reach this
89 ... specific state.
Rahul Maheshwarif0499592017-05-10 01:55:59 -050090 [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Running
George Keishing5abfe602018-07-05 11:54:37 -050091 [Template] Verify Restore Policy
92
93 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050094 LastState Running Running
George Keishing5abfe602018-07-05 11:54:37 -050095
George Keishing450a5282017-05-05 03:13:37 -050096
97
Rahul Maheshwarif0499592017-05-10 01:55:59 -050098Test Restore Policy Restore Last State With Host Off
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050099 [Documentation] Verify the RESTORE_LAST_STATE restore policy functionality while the Host is off.
Rahul Maheshwarif0499592017-05-10 01:55:59 -0500100 [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Off
George Keishing5abfe602018-07-05 11:54:37 -0500101 [Template] Verify Restore Policy
102
103 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -0500104 LastState Off Off
George Keishing450a5282017-05-05 03:13:37 -0500105
George Keishing880f4e62017-04-20 01:10:17 -0500106
107*** Keywords ***
108
109Verify Restore Policy
110 [Documentation] Set given policy, reset BMC and expect specified end
111 ... state.
112 [Arguments] ${policy} ${expectedState} ${nextState}
113
114 # Description of argument(s):
115 # policy System policy state string.
116 # expectedState Test initial host state.
117 # nextState Test end host state.
118
George Keishingd45aae52017-12-11 09:38:37 -0600119 Set Initial Test State ${expectedState}
George Keishing880f4e62017-04-20 01:10:17 -0500120
George Keishing90b555a2021-05-20 11:54:16 -0500121 Redfish Set Power Restore Policy ${policy}
George Keishing69436a32019-08-09 01:53:08 -0500122
aravinth051067b409b2022-07-13 10:41:26 +0000123 PDU Power Cycle
George Keishing90b555a2021-05-20 11:54:16 -0500124 Sleep 20s
125 Wait For BMC Online
George Keishing880f4e62017-04-20 01:10:17 -0500126
127 Wait Until Keyword Succeeds
George Keishing69436a32019-08-09 01:53:08 -0500128 ... 10 min 20 sec Valid Boot States ${nextState}
George Keishingd45aae52017-12-11 09:38:37 -0600129
130
131Valid Boot States
132 [Documentation] Verify boot states for a given system state.
133 [Arguments] ${sys_state}
134
135 # Description of argument(s):
136 # sys_state system state list
George Keishingb95aba22017-12-13 07:59:23 -0600137 # (e.g. "Off", "On", "Reboot", etc.).
George Keishingd45aae52017-12-11 09:38:37 -0600138
George Keishing90b555a2021-05-20 11:54:16 -0500139 ${current_state}= Redfish Get States
140 Redfish Valid Boot State ${sys_state} ${current_state}
George Keishing880f4e62017-04-20 01:10:17 -0500141
142
143Set Initial Test State
144 [Documentation] Poweron if ON expected, Poweroff if OFF expected
145 ... to initial state of the test.
146
147 [Arguments] ${expectedState}
148 # Description of argument(s):
149 # expectedState Test initial host state.
150
George Keishing9e1a30e2021-05-25 23:15:41 -0500151 Redfish.Login
152
George Keishing7dc48472025-05-07 20:23:47 +0530153 IF '${expectedState}' == 'Running'
154 Redfish Power On stack_mode=skip
155 END
George Keishing880f4e62017-04-20 01:10:17 -0500156
George Keishing7dc48472025-05-07 20:23:47 +0530157 IF '${expectedState}' == 'Off'
158 Redfish Power Off stack_mode=skip
159 END
George Keishing69436a32019-08-09 01:53:08 -0500160
George Keishing880f4e62017-04-20 01:10:17 -0500161
George Keishing62c82672017-12-06 04:39:46 -0600162Test Teardown Execution
George Keishing0ef6ece2017-05-05 02:57:16 -0500163 [Documentation] Do the post test teardown.
164 # 1. Capture FFDC on test failure.
165 # 2. Close all open SSH connections.
166
167 FFDC On Test Case Fail
168 Close All Connections
169
170
George Keishing62c82672017-12-06 04:39:46 -0600171Suite Teardown Execution
George Keishing0ef6ece2017-05-05 02:57:16 -0500172 [Documentation] Do the post suite teardown.
173 # 1. Set policy to default.
174
George Keishing90b555a2021-05-20 11:54:16 -0500175 Run Keyword And Ignore Error Redfish Set Power Restore Policy AlwaysOff
George Keishing69436a32019-08-09 01:53:08 -0500176 Redfish.Logout
George Keishing0ef6ece2017-05-05 02:57:16 -0500177
George Keishing90b555a2021-05-20 11:54:16 -0500178
179Wait For BMC Online
180 [Documentation] Wait for Host to be online. Checks every X seconds
181 ... interval for Y minutes and fails if timed out.
182 ... Default MAX timedout is 10 min, interval 10 seconds.
183 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
184 ... ${interval}=10 sec
185
186 # Description of argument(s):
187 # max_timeout Maximum time to wait.
188 # This should be expressed in Robot Framework's time format
189 # (e.g. "10 minutes").
190 # interval Interval to wait between status checks.
191 # This should be expressed in Robot Framework's time format
192 # (e.g. "5 seconds").
193
194 Wait Until Keyword Succeeds
195 ... ${max_timeout} ${interval} Verify Ping SSH And Redfish Authentication