blob: 523a05faaf9811872f3da72186fafbfbe2e793e1 [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
22*** Variables ***
23
24*** Test Cases ***
25
George Keishing1c3a9662017-08-11 10:16:36 -050026Test Restore Policy ALWAYS_POWER_OFF With Host Off
George Keishing1c3a9662017-08-11 10:16:36 -050027 [Documentation] Validate ALWAYS_POWER_OFF restore policy functionality.
George Keishing880f4e62017-04-20 01:10:17 -050028 ... Policy:
George Keishing1c3a9662017-08-11 10:16:36 -050029 ... System policy set to ALWAYS_POWER_OFF.
George Keishing880f4e62017-04-20 01:10:17 -050030 ... Initial Host State:
31 ... State where system should be before running the
32 ... test case.
33 ... Expected Host State:
34 ... After BMC reset, system should reach this
35 ... specific state.
George Keishing1c3a9662017-08-11 10:16:36 -050036 [Tags] Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Off
George Keishing5abfe602018-07-05 11:54:37 -050037 [Template] Verify Restore Policy
38
39 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050040 AlwaysOff Off Off
George Keishing5abfe602018-07-05 11:54:37 -050041
George Keishing880f4e62017-04-20 01:10:17 -050042
43
George Keishing1c3a9662017-08-11 10:16:36 -050044Test Restore Policy ALWAYS_POWER_OFF With Host Running
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050045 [Documentation] Verify that the BMC restore policy is ALWAYS_POWER_OFF while the Host is running.
George Keishing1c3a9662017-08-11 10:16:36 -050046 [Tags] Test_Restore_Policy_ALWAYS_POWER_OFF_With_Host_Running
George Keishing5abfe602018-07-05 11:54:37 -050047 [Template] Verify Restore Policy
48
49 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050050 AlwaysOff Running Running
George Keishing450a5282017-05-05 03:13:37 -050051
52
53Test Restore Policy ALWAYS_POWER_ON With Host Off
George Keishing880f4e62017-04-20 01:10:17 -050054 [Documentation] Validate ALWAYS_POWER_ON restore policy functionality.
55 ... Policy:
George Keishing1c3a9662017-08-11 10:16:36 -050056 ... System policy set to ALWAYS_POWER_OFF.
George Keishing880f4e62017-04-20 01:10:17 -050057 ... Initial Host State:
58 ... State where system should be before running the
59 ... test case.
60 ... Expected Host State:
61 ... After BMC reset, system should reach this
62 ... specific state.
George Keishing450a5282017-05-05 03:13:37 -050063 [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Off
George Keishing5abfe602018-07-05 11:54:37 -050064 [Template] Verify Restore Policy
65
66 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050067 AlwaysOn Off Running
George Keishing5abfe602018-07-05 11:54:37 -050068
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
George Keishing5abfe602018-07-05 11:54:37 -050072 [Documentation] Verify the BMC restore policy is ALWAYS_POWER_ON while the Host is running.
73 [Tags] Test_Restore_Policy_ALWAYS_POWER_ON_With_Host_Running
74 [Template] Verify Restore Policy
George Keishing880f4e62017-04-20 01:10:17 -050075
George Keishing5abfe602018-07-05 11:54:37 -050076 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050077 AlwaysOn Running Running
George Keishing450a5282017-05-05 03:13:37 -050078
George Keishing450a5282017-05-05 03:13:37 -050079
80
Rahul Maheshwarif0499592017-05-10 01:55:59 -050081Test Restore Policy Restore Last State With Host Running
George Keishing880f4e62017-04-20 01:10:17 -050082 [Documentation] Validate RESTORE_LAST_STATE restore policy functionality.
83 ... Policy:
84 ... System policy set to RESTORE_LAST_STATE.
85 ... Initial Host State:
86 ... State where system should be before running the
87 ... test case.
88 ... Expected Host State:
89 ... After BMC reset, system should reach this
90 ... specific state.
Rahul Maheshwarif0499592017-05-10 01:55:59 -050091 [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Running
George Keishing5abfe602018-07-05 11:54:37 -050092 [Template] Verify Restore Policy
93
94 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -050095 LastState Running Running
George Keishing5abfe602018-07-05 11:54:37 -050096
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
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500100 [Documentation] Verify the RESTORE_LAST_STATE restore policy functionality while the Host is off.
Rahul Maheshwarif0499592017-05-10 01:55:59 -0500101 [Tags] Test_Restore_Policy_Restore_Last_State_With_Host_Off
George Keishing5abfe602018-07-05 11:54:37 -0500102 [Template] Verify Restore Policy
103
104 # Policy Initial Host State Expected Host State
George Keishing90b555a2021-05-20 11:54:16 -0500105 LastState Off Off
George Keishing450a5282017-05-05 03:13:37 -0500106
George Keishing880f4e62017-04-20 01:10:17 -0500107
108*** Keywords ***
109
110Verify Restore Policy
111 [Documentation] Set given policy, reset BMC and expect specified end
112 ... state.
113 [Arguments] ${policy} ${expectedState} ${nextState}
114
115 # Description of argument(s):
116 # policy System policy state string.
117 # expectedState Test initial host state.
118 # nextState Test end host state.
119
George Keishingd45aae52017-12-11 09:38:37 -0600120 Set Initial Test State ${expectedState}
George Keishing880f4e62017-04-20 01:10:17 -0500121
George Keishing90b555a2021-05-20 11:54:16 -0500122 Redfish Set Power Restore Policy ${policy}
George Keishing69436a32019-08-09 01:53:08 -0500123
aravinth051067b409b2022-07-13 10:41:26 +0000124 PDU Power Cycle
George Keishing90b555a2021-05-20 11:54:16 -0500125 Sleep 20s
126 Wait For BMC Online
George Keishing880f4e62017-04-20 01:10:17 -0500127
128 Wait Until Keyword Succeeds
George Keishing69436a32019-08-09 01:53:08 -0500129 ... 10 min 20 sec Valid Boot States ${nextState}
George Keishingd45aae52017-12-11 09:38:37 -0600130
131
132Valid Boot States
133 [Documentation] Verify boot states for a given system state.
134 [Arguments] ${sys_state}
135
136 # Description of argument(s):
137 # sys_state system state list
George Keishingb95aba22017-12-13 07:59:23 -0600138 # (e.g. "Off", "On", "Reboot", etc.).
George Keishingd45aae52017-12-11 09:38:37 -0600139
George Keishing90b555a2021-05-20 11:54:16 -0500140 ${current_state}= Redfish Get States
141 Redfish Valid Boot State ${sys_state} ${current_state}
George Keishing880f4e62017-04-20 01:10:17 -0500142
143
144Set Initial Test State
145 [Documentation] Poweron if ON expected, Poweroff if OFF expected
146 ... to initial state of the test.
147
148 [Arguments] ${expectedState}
149 # Description of argument(s):
150 # expectedState Test initial host state.
151
George Keishing9e1a30e2021-05-25 23:15:41 -0500152 Redfish.Login
153
George Keishing880f4e62017-04-20 01:10:17 -0500154 Run Keyword If '${expectedState}' == 'Running'
George Keishing69436a32019-08-09 01:53:08 -0500155 ... Redfish Power On stack_mode=skip
George Keishing880f4e62017-04-20 01:10:17 -0500156
157 Run Keyword If '${expectedState}' == 'Off'
George Keishing69436a32019-08-09 01:53:08 -0500158 ... Redfish Power Off stack_mode=skip
159
George Keishing880f4e62017-04-20 01:10:17 -0500160
George Keishing62c82672017-12-06 04:39:46 -0600161Test Teardown Execution
George Keishing0ef6ece2017-05-05 02:57:16 -0500162 [Documentation] Do the post test teardown.
163 # 1. Capture FFDC on test failure.
164 # 2. Close all open SSH connections.
165
166 FFDC On Test Case Fail
167 Close All Connections
168
169
George Keishing62c82672017-12-06 04:39:46 -0600170Suite Teardown Execution
George Keishing0ef6ece2017-05-05 02:57:16 -0500171 [Documentation] Do the post suite teardown.
172 # 1. Set policy to default.
173
George Keishing90b555a2021-05-20 11:54:16 -0500174 Run Keyword And Ignore Error Redfish Set Power Restore Policy AlwaysOff
George Keishing69436a32019-08-09 01:53:08 -0500175 Redfish.Logout
George Keishing0ef6ece2017-05-05 02:57:16 -0500176
George Keishing90b555a2021-05-20 11:54:16 -0500177
178Wait For BMC Online
179 [Documentation] Wait for Host to be online. Checks every X seconds
180 ... interval for Y minutes and fails if timed out.
181 ... Default MAX timedout is 10 min, interval 10 seconds.
182 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
183 ... ${interval}=10 sec
184
185 # Description of argument(s):
186 # max_timeout Maximum time to wait.
187 # This should be expressed in Robot Framework's time format
188 # (e.g. "10 minutes").
189 # interval Interval to wait between status checks.
190 # This should be expressed in Robot Framework's time format
191 # (e.g. "5 seconds").
192
193 Wait Until Keyword Succeeds
194 ... ${max_timeout} ${interval} Verify Ping SSH And Redfish Authentication