blob: f1a1050f5e696ee27ff90473b9f810a3ad60e943 [file] [log] [blame]
George Keishing78ea2dc2016-11-18 04:33:45 -06001*** Settings ***
2Documentation This module will take whatever action is necessary
3... to bring the BMC to a stable, standby state. For our
4... purposes, a stable state is defined as:
5... - BMC is communicating
6... (pinging, sshing and REST commands working)
7... - Power state is 0 (off)
Rahul Maheshwari2c725042017-01-29 22:55:28 -06008... - BMC state is "Ready"
9... - HOST state is "Off"
George Keishingefc3ff22017-12-12 11:49:25 -060010... - Boot policy is "ALWAYS_POWER_OFF"
George Keishing34d4b8d2016-12-07 08:35:29 -060011... Power cycle system via PDU if specified
George Keishing0bd59f12016-12-14 10:39:21 -060012... Prune archived journal logs
George Keishing78ea2dc2016-11-18 04:33:45 -060013
George Keishing78ea2dc2016-11-18 04:33:45 -060014Resource ../lib/utils.robot
George Keishing34d4b8d2016-12-07 08:35:29 -060015Resource ../lib/pdu/pdu.robot
Rahul Maheshwari9bd3abc2017-02-07 00:51:30 -060016Resource ../lib/state_manager.robot
Michael Walsh1b0ceb22017-05-31 16:03:01 -050017Resource ../lib/bmc_network_utils.robot
Sunil Mec6fe312017-06-19 04:21:25 -050018Resource ../lib/bmc_cleanup.robot
George Keishing27a1f202017-08-30 22:40:26 -050019Resource ../lib/dump_utils.robot
George Keishingcaa718b2019-03-10 00:08:33 -060020Resource ../lib/bmc_redfish_resource.robot
21Resource ../lib/bmc_redfish_utils.robot
George Keishingc7748be2018-07-12 05:40:37 -050022Library ../lib/gen_misc.py
George Keishing78ea2dc2016-11-18 04:33:45 -060023
George Keishing8dd04af2021-03-23 10:36:40 -050024# Force the test to timedout to prevent test hanging.
25Test Timeout 10 minutes
26
Igor Kanyukafeb79d62025-10-20 21:24:03 +010027Test Tags Standby_BMC
George Keishing8dd04af2021-03-23 10:36:40 -050028
George Keishing78ea2dc2016-11-18 04:33:45 -060029*** Variables ***
30${HOST_SETTING} /org/openbmc/settings/host0
31
George Keishingc7748be2018-07-12 05:40:37 -050032${ERROR_REGEX} xyz.openbmc_project.Software.BMC.Updater.service: Failed with result 'core-dump'
33
Gunnar Mills7c8923f2016-12-12 21:19:52 -060034*** Test Cases ***
George Keishing78ea2dc2016-11-18 04:33:45 -060035
George Keishing62f94302017-01-31 07:00:52 -060036Get To Stable State
Rahul Maheshwari2c725042017-01-29 22:55:28 -060037 [Documentation] BMC cleanup drive to stable state
38 ... 1. PDU powercycle if specified
39 ... 1. Ping Test
40 ... 2. SSH Connection session Test
41 ... 3. REST Connection session Test
42 ... 4. Reboot BMC if REST Test failed
43 ... 5. Get BMC in Ready state if its not in this state
44 ... 6. Get Host in Off state if its not in this state
45 ... 7. Update restore policy
Sunil M89fb0f52017-05-26 05:25:33 -050046 ... 8. Verify and Update MAC address.
George Keishing62f94302017-01-31 07:00:52 -060047 [Tags] Get_To_Stable_State
George Keishing78ea2dc2016-11-18 04:33:45 -060048
Rahul Maheshwari2c725042017-01-29 22:55:28 -060049 Run Keyword And Ignore Error Powercycle System Via PDU
George Keishing34d4b8d2016-12-07 08:35:29 -060050
George Keishing13497eb2018-11-07 06:35:14 -060051 ${ping_status}= Run Keyword And Return Status
52 ... Wait For Host To Ping ${OPENBMC_HOST} 2 mins
53
54 # Check if the ping works using 1400 MTU.
George Keishingd5e8d862025-05-13 21:59:19 +053055 #IF ${ping_status} == ${True} MTU Ping Test
George Keishing13497eb2018-11-07 06:35:14 -060056
George Keishingd5e8d862025-05-13 21:59:19 +053057 IF ${ping_status} == ${False} Fail ${OPENBMC_HOST} ping test failed.
George Keishing13497eb2018-11-07 06:35:14 -060058
59 Open Connection And Log In host=${OPENBMC_HOST}
George Keishing78ea2dc2016-11-18 04:33:45 -060060
George Keishingd5e8d862025-05-13 21:59:19 +053061 IF ${REDFISH_SUPPORTED}
62 Redfish Clean Up
63 ELSE
64 REST Clean Up
65 END
George Keishing8dd04af2021-03-23 10:36:40 -050066
George Keishing78ea2dc2016-11-18 04:33:45 -060067
George Keishing0bd59f12016-12-14 10:39:21 -060068 Prune Journal Log
Charles Paul Hofer7cdb8b42018-09-10 12:12:04 -050069 Check For Current Boot Application Failures
George Keishing78ea2dc2016-11-18 04:33:45 -060070
71*** Keywords ***
72
George Keishing8dd04af2021-03-23 10:36:40 -050073
74REST Clean Up
75 [Documentation] Check states, reboot if needed and poweroff.
76
77 Wait Until Keyword Succeeds 1 min 30 sec Initialize OpenBMC
78
79 ${ready_status}= Run Keyword And Return Status Is BMC Ready
George Keishingd5e8d862025-05-13 21:59:19 +053080 IF '${ready_status}' == '${False}'
81 Put BMC State Ready
82 ELSE
83 REST Power Off stack_mode=skip
84 END
George Keishing8dd04af2021-03-23 10:36:40 -050085
86 Run Keyword And Ignore Error Set BMC Power Policy ${ALWAYS_POWER_OFF}
87 Run Keyword And Ignore Error Delete All Error Logs
88 Run Keyword And Ignore Error Delete All Dumps
89
90
91Redfish Clean Up
92 [Documentation] Check states, reboot if needed and poweroff.
93
94 Wait Until Keyword Succeeds 1 min 30 sec Redfish.Login
95
96 Redfish Power Off stack_mode=skip
97
98 Run Keyword And Ignore Error Redfish Set Power Restore Policy AlwaysOff
99 Run Keyword And Ignore Error Redfish Purge Event Log
100 Run Keyword And Ignore Error Redfish Delete All BMC Dumps
George Keishing2ef6a7d2021-05-19 09:05:32 -0500101 Run Keyword And Ignore Error Redfish Delete All System Dumps
Anusha Dathatri34298bf2021-06-17 00:00:01 -0500102 Run Keyword And Ignore Error Clear All Subscriptions
George Keishing8dd04af2021-03-23 10:36:40 -0500103 Run Keyword And Ignore Error Delete All Redfish Sessions
104
105
George Keishing78ea2dc2016-11-18 04:33:45 -0600106BMC Online Test
107 [Documentation] BMC ping, SSH, REST connection Test
108
Gunnar Mills597ffa02016-12-06 11:26:53 -0600109 ${l_status}= Run Keyword and Return Status
George Keishing78ea2dc2016-11-18 04:33:45 -0600110 ... Verify Ping and REST Authentication
George Keishingd5e8d862025-05-13 21:59:19 +0530111 IF '${l_status}' == '${False}'
112 Fail msg=System not in ideal state to continue [ERROR]
113 END
George Keishing78ea2dc2016-11-18 04:33:45 -0600114
115
George Keishing78ea2dc2016-11-18 04:33:45 -0600116Update Policy Setting
117 [Documentation] Update the given restore policy
Gunnar Mills38032802016-12-12 13:43:40 -0600118 [Arguments] ${policy}
George Keishing78ea2dc2016-11-18 04:33:45 -0600119
Sridevi Ramesh34f0bf02025-07-24 09:31:26 -0500120 # Description of argument(s):
121 # policy Restore policy.
122
Gunnar Mills597ffa02016-12-06 11:26:53 -0600123 ${valueDict}= create dictionary data=${policy}
George Keishing78ea2dc2016-11-18 04:33:45 -0600124 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
125 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
126 Should Be Equal ${currentPolicy} ${policy}
127
George Keishingd5123f72016-12-07 09:54:51 -0600128
129Trigger Warm Reset via Reboot
130 [Documentation] Execute reboot command on the remote BMC and
131 ... returns immediately. This keyword "Start Command"
132 ... returns nothing and does not wait for the command
133 ... execution to be finished.
134 Open Connection And Log In
135
136 Start Command /sbin/reboot
George Keishing34d4b8d2016-12-07 08:35:29 -0600137
138
139Powercycle System Via PDU
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500140 [Documentation] AC cycle the system via PDU.
George Keishing34d4b8d2016-12-07 08:35:29 -0600141
142 Validate Parameters
143 PDU Power Cycle
144 Check If BMC is Up 5 min 10 sec
145
146
Charles Paul Hofer7cdb8b42018-09-10 12:12:04 -0500147Check For Current Boot Application Failures
George Keishingc7748be2018-07-12 05:40:37 -0500148 [Documentation] Parse the journal log and check for failures.
149 [Arguments] ${error_regex}=${ERROR_REGEX}
150
Sridevi Ramesh34f0bf02025-07-24 09:31:26 -0500151 # Description of argument(s):
152 # error_regex Regex error pattern to be checked in the journal log.
153
George Keishingc7748be2018-07-12 05:40:37 -0500154 ${error_regex}= Escape Bash Quotes ${error_regex}
155 ${journal_log} ${stderr} ${rc}= BMC Execute Command
Charles Paul Hoferbcae08b2018-08-09 11:33:33 -0500156 ... journalctl -b --no-pager | egrep '${error_regex}' ignore_err=1
George Keishingc7748be2018-07-12 05:40:37 -0500157
158 Should Be Empty ${journal_log}
159
160
George Keishing34d4b8d2016-12-07 08:35:29 -0600161Validate Parameters
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500162 [Documentation] Validate PDU parameters.
Sridevi Ramesh34f0bf02025-07-24 09:31:26 -0500163
George Keishing34d4b8d2016-12-07 08:35:29 -0600164 Should Not Be Empty ${PDU_IP}
165 Should Not Be Empty ${PDU_TYPE}
166 Should Not Be Empty ${PDU_SLOT_NO}
167 Should Not Be Empty ${PDU_USERNAME}
168 Should Not Be Empty ${PDU_PASSWORD}
George Keishing13497eb2018-11-07 06:35:14 -0600169
170
171MTU Ping Test
172 [Documentation] Ping test using MTU.
173 [Arguments] ${mtu}=${1400}
174
175 # Description of argument(s):
176 # mtu The maximum transmission unit (MTU) of a network interface.
177
178 ${rc} ${output}= Run And Return RC And Output
179 ... ping -M do -s ${mtu} -c 10 ${OPENBMC_HOST}
180 Should Be Equal As Integers ${rc} 0
181 Should Not Contain ${output} 100% packet loss
Anusha Dathatri34298bf2021-06-17 00:00:01 -0500182
183
184Clear All Subscriptions
185 [Documentation] Delete all subscriptions.
186
187 ${subscriptions}= Redfish.Get Attribute /redfish/v1/EventService/Subscriptions Members
188 FOR ${subscription} IN @{subscriptions}
189 Redfish.Delete ${subscription['@odata.id']}
190 END