blob: e0233ad6f70423fbb873b7901a819cbf774aca11 [file] [log] [blame]
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -05001*** Settings ***
2Documentation Update the BMC code on a target BMC.
3... Execution Method:
4... python -m robot -v OPENBMC_HOST:<hostname>
5... -v IMAGE_FILE_PATH:<path/*.tar> bmc_code_update.robot
6
7Library ../../lib/code_update_utils.py
Michael Walshe78a4432018-03-29 16:36:04 -05008Library ../../lib/gen_robot_keyword.py
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -05009Variables ../../data/variables.py
Sivas SRR77c69192017-11-02 23:56:39 -050010Resource ../../lib/utils.robot
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050011Resource ../../lib/boot_utils.robot
12Resource code_update_utils.robot
13Resource ../../lib/code_update_utils.robot
George Keishing1eb85f52017-08-30 22:55:13 -050014Resource ../../lib/openbmc_ffdc.robot
15Resource ../../lib/dump_utils.robot
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -050016Resource ../../lib/certificate_utils.robot
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050017
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -050018Suite Setup Suite Setup Execution
19
20Test Teardown Test Teardown Execution
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050021
George Keishing7e854712021-03-17 13:18:10 -050022# Force the test to timedout to prevent test hanging.
23Test Timeout 30 minutes
24
George Keishing09712a12017-10-16 12:52:42 -050025Force Tags BMC_Code_Update
26
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050027*** Variables ***
28
29${QUIET} ${1}
30${IMAGE_FILE_PATH} ${EMPTY}
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -050031${ALTERNATE_IMAGE_FILE_PATH} ${EMPTY}
Charles Paul Hoferb7842a52017-09-22 10:11:33 -050032${SKIP_UPDATE_IF_ACTIVE} false
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -050033${dump_id} ${EMPTY}
34${running_persistence_test} ${FALSE}
35${test_errlog_text} AutoTestSimple
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050036
37*** Test Cases ***
38
Sivas SRR77c69192017-11-02 23:56:39 -050039Test Basic BMC Performance Before BMC Code Update
40 [Documentation] Check performance of memory, CPU & file system of BMC.
41 [Tags] Test_Basic_BMC_Performance_Before_BMC_Code_Update
42
43 Open Connection And Log In
44 Check BMC Performance
45
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -050046Prepare Persistent Data
47 [Documentation] Set data that should persist across the code update.
48 [Tags] Prepare_Persistent_Data
49
50 # Install the debug tarball.
51 BMC Execute Command rm -rf /tmp/tarball
52 Install Debug Tarball On BMC tarball_file_path=${DEBUG_TARBALL_PATH}
53
54 # Create a dummy error log and dump.
55 BMC Execute Command /tmp/tarball/bin/logging-test -c ${test_errlog_text}
56 ${dump_id}= Create User Initiated Dump
57 Check Dump Existence ${dump_id}
58 Set Suite Variable ${dump_id}
59
60 # Set persistent settings.
61 ${autoreboot_dict}= Create Dictionary data=${0}
62 Write Attribute ${CONTROL_HOST_URI}auto_reboot AutoReboot
63 ... data=${autoreboot_dict}
64 ${onetime_dict}= Create Dictionary data=${0}
65 Write Attribute ${CONTROL_HOST_URI}boot/one_time Enabled
66 ... data=${onetime_dict}
67
68 # Let the remaining test cases know we are doing a persistence test so we
69 # do not delete logs.
70 Set Suite Variable ${running_persistence_test} ${TRUE}
71
72
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050073REST BMC Code Update
74 [Documentation] Do a BMC code update by uploading image on BMC via REST.
75 [Tags] REST_BMC_Code_Update
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -050076 [Teardown] REST BMC Code Update Teardown
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050077
Sweta Potthuri8c7ada42018-01-15 05:05:59 -060078 Run Keyword And Ignore Error List Installed Images BMC
George Keishingfe96e642021-01-25 08:45:24 -060079 Run Keyword And Ignore Error Set ApplyTime policy=OnReset
Sweta Potthuri8c7ada42018-01-15 05:05:59 -060080
George Keishing8010d862019-12-03 09:46:27 -060081 ${image_version}= Get Version Tar ${IMAGE_FILE_PATH}
Michael Walshc81c6ae2020-05-08 10:19:36 -050082 ${bmc_release_info}= Get BMC Release Info
83 ${functional_version}= Set Variable ${bmc_release_info['version_id']}
84 Rprint Vars image_version functional_version
George Keishing8010d862019-12-03 09:46:27 -060085
86 # Check if the existing firmware is functional.
Michael Walshc81c6ae2020-05-08 10:19:36 -050087 Pass Execution If '${functional_version}' == '${image_version}'
88 ... The existing ${image_version} firmware is already functional.
George Keishing8010d862019-12-03 09:46:27 -060089
susilsi773cae6e2021-03-04 02:03:23 -060090 Run Keyword And Ignore Error Delete Only BMC Image
91
Charles Paul Hofer21845462017-09-27 12:40:33 -050092 Upload And Activate Image ${IMAGE_FILE_PATH}
93 ... skip_if_active=${SKIP_UPDATE_IF_ACTIVE}
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050094 OBMC Reboot (off)
Charles Paul Hofere43fb2f2017-09-26 15:36:18 -050095 Verify Running BMC Image ${IMAGE_FILE_PATH}
Sivas SRRda339e62019-10-10 01:04:14 -050096 BMC Execute Command cd /etc ; cat host.conf hosts hostname print_out=1
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050097
98
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -050099Verify Error Log Persistency
100 [Documentation] Check that the error log is still present after a
101 ... code update.
102 [Tags] Verify_Error_Log_Persistency
103
Steven Sombara8800da2018-12-18 16:19:05 -0600104 ${error_log_paths}= Read Properties ${BMC_LOGGING_ENTRY}list
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -0500105 Log To Console ${error_log_paths}
106 ${test_error_message}= Read Attribute @{error_log_paths}[-1] Message
107 Should Be Equal ${test_error_message}
108 ... example.xyz.openbmc_project.Example.Elog.${test_errlog_text}
109 Delete Error Log Entry @{error_log_paths}[-1]
110
111
112Verify BMC Dump Persistency
113 [Documentation] Check that the BMC dump present after a code update.
114 [Tags] Verify_BMC_Dump_Persistency
115 [Teardown] Set Suite Variable ${running_persistence_test} ${FALSE}
116
117 Check Dump Existence ${dump_id}
118 Delete BMC Dump ${dump_id}
119
120
121Verify Settings Persistency
122 [Documentation] Verify that the settings from 'Prepare Persistent Data'
123 ... are still set correctly after the code update.
124 [Tags] Verify_Settings_Persistency
125
126 ${autoreboot_enabled}= Read Attribute ${CONTROL_HOST_URI}auto_reboot
127 ... AutoReboot
128 Should Be Equal ${autoreboot_enabled} ${0}
129 ${onetime_enabled}= Read Attribute ${CONTROL_HOST_URI}boot/one_time
130 ... Enabled
131 Should Be Equal ${onetime_enabled} ${0}
132
133 # Set values back to their defaults
134 ${autoreboot_dict}= Create Dictionary data=${1}
135 Write Attribute ${CONTROL_HOST_URI}auto_reboot AutoReboot
136 ... data=${autoreboot_dict}
137 ${onetime_dict}= Create Dictionary data=${1}
138 Write Attribute ${CONTROL_HOST_URI}boot/one_time Enabled
139 ... data=${onetime_dict}
140
141
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500142Upload And Activate Multiple BMC Images
143 [Documentation] Upload another BMC image and verify that its state is
144 ... different from all others.
145 [Tags] Upload_And_Activate_Multiple_BMC_Images
146 [Template] Activate Image And Verify No Duplicate Priorities
147 [Setup] Upload And Activate Multiple BMC Images Setup
148
149 # Image File Path Image Purpose
150 ${ALTERNATE_IMAGE_FILE_PATH} ${VERSION_PURPOSE_BMC}
151
152
Charles Paul Hofer42f17462017-09-12 14:09:32 -0500153BMC Set Priority To Invalid Values
154 [Documentation] Attempt to set the priority of an image to an invalid
155 ... value and expect an error.
156 [Tags] BMC_Set_Priority_To_Invalid_Values
157 [Template] Set Priority To Invalid Value And Expect Error
158
159 # Version Type Priority
160 ${VERSION_PURPOSE_BMC} ${-1}
161 ${VERSION_PURPOSE_BMC} ${256}
162
163
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500164Delete BMC Image
165 [Documentation] Delete a BMC image from the BMC flash chip.
166 [Tags] Delete_BMC_Image
167
168 ${software_object}= Get Non Running BMC Software Object
169 Delete Image And Verify ${software_object} ${VERSION_PURPOSE_BMC}
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500170
171
George Keishing97ecb272017-09-12 04:30:20 -0500172BMC Image Priority Attribute Test
173 [Documentation] Set "Priority" attribute.
174 [Tags] BMC_Image_Priority_Attribute_Test
175 [Template] Temporarily Set BMC Attribute
176
177 # Property Value
George Keishing872d69f2019-10-18 12:35:02 -0500178 Priority ${False}
179 Priority ${True}
George Keishing97ecb272017-09-12 04:30:20 -0500180 Priority ${0}
181 Priority ${1}
182 Priority ${127}
183 Priority ${255}
184
185
Charles Paul Hofere8dc5252017-10-10 13:50:18 -0500186Delete All Non Running BMC Images
187 [Documentation] Delete all non running BMC images.
188 [Tags] Delete_All_Non_Running_BMC_Images
189
190 ${version_id}= Upload And Activate Image ${ALTERNATE_IMAGE_FILE_PATH}
George Keishing0889d432017-11-27 11:53:06 -0600191 ... skip_if_active=true
Charles Paul Hofere8dc5252017-10-10 13:50:18 -0500192 Delete All Non Running BMC Images
193
194 ${software_ids}= Get Software Objects Id
195 ... version_type=${VERSION_PURPOSE_BMC}
196 Should Not Contain ${software_ids} ${version_id}
197
George Keishing1659f592018-10-03 08:33:41 -0500198
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500199Test Certificate Persistency After BMC Code Update
200 [Documentation] Test certificate persistency after BMC update.
201 [Tags] Test_Certificate_Persistency_After_BMC_Code_Update
202
Rahul Maheshwarifa146c42018-11-05 00:38:52 -0600203 # Create certificate sub-directory in current working directory.
204 Create Directory certificate_dir
205 OperatingSystem.Directory Should Exist ${EXECDIR}${/}certificate_dir
206
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500207 ${cert_file_path}= Generate Certificate File Via Openssl
208 ... Valid Certificate Valid Privatekey
209 ${file_data}= OperatingSystem.Get Binary File ${cert_file_path}
210 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
211
Rahul Maheshwari6a849ad2020-02-26 03:31:19 -0600212 Redfish.Login
213 ${cert_id}= Install Certificate File On BMC ${REDFISH_CA_CERTIFICATE_URI} ok data=${file_data}
214 Logging Installed certificate id: ${cert_id}
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500215
Rahul Maheshwari6a849ad2020-02-26 03:31:19 -0600216 # Adding delay after certificate installation.
217 Sleep 30s
218
219 ${bmc_cert_content}= redfish_utils.Get Attribute
220 ... /redfish/v1/Managers/bmc/Truststore/Certificates/${cert_id} CertificateString
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500221 Should Contain ${cert_file_content} ${bmc_cert_content}
222
223 Upload And Activate Image ${IMAGE_FILE_PATH}
224 ... skip_if_active=${SKIP_UPDATE_IF_ACTIVE}
225 OBMC Reboot (off)
226 Verify Running BMC Image ${IMAGE_FILE_PATH}
227
Rahul Maheshwari6a849ad2020-02-26 03:31:19 -0600228 Redfish.Login
229 ${bmc_cert_content}= redfish_utils.Get Attribute
230 ... ${REDFISH_CA_CERTIFICATE_URI}/${cert_id} CertificateString
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500231 Should Contain ${cert_file_content} ${bmc_cert_content}
232
Rahul Maheshwari6a849ad2020-02-26 03:31:19 -0600233 Redfish.Logout
234
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500235
Sivas SRR77c69192017-11-02 23:56:39 -0500236Test Basic BMC Performance After Code Update
237 [Documentation] Check performance of memory, CPU & file system of BMC.
238 [Tags] Test_Basic_BMC_Performance_After_Code_Update
239
240 Open Connection And Log In
241 Check BMC Performance
242
Charles Paul Hofere8dc5252017-10-10 13:50:18 -0500243
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500244*** Keywords ***
245
George Keishing97ecb272017-09-12 04:30:20 -0500246Temporarily Set BMC Attribute
247 [Documentation] Update the BMC attribute value.
248 [Arguments] ${attribute_name} ${attribute_value}
249
250 # Description of argument(s):
251 # attribute_name BMC software attribute name (e.g. "Priority").
252 # attribute_value Value to be written.
253
254 ${image_ids}= Get Software Objects ${VERSION_PURPOSE_BMC}
255 ${init_bmc_properties}= Get Host Software Property ${image_ids[0]}
256 ${initial_priority}= Set Variable ${init_bmc_properties["Priority"]}
257
258 Set Host Software Property ${image_ids[0]} ${attribute_name}
259 ... ${attribute_value}
260
261 ${cur_bmc_properties}= Get Host Software Property ${image_ids[0]}
262 Should Be Equal As Integers ${cur_bmc_properties["Priority"]}
263 ... ${attribute_value}
264
265 # Revert to to initial value.
266 Set Host Software Property
267 ... ${image_ids[0]} ${attribute_name} ${initial_priority}
268
269
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500270Upload And Activate Multiple BMC Images Setup
271 [Documentation] Check that the ALTERNATE_FILE_PATH variable is set.
272
George Keishing1eb85f52017-08-30 22:55:13 -0500273 Should Not Be Empty ${ALTERNATE_IMAGE_FILE_PATH}
274
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -0500275
susilsi773cae6e2021-03-04 02:03:23 -0600276Delete Only BMC Image
277 [Documentation] Delete a BMC image from the BMC flash chip.
278
279 ${software_object}= Get Non Running BMC Software Object
280 Delete Image And Verify ${software_object} ${VERSION_PURPOSE_BMC}
281
282
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -0500283REST BMC Code Update Teardown
284 [Documentation] Do code update test teardown.
285
286 FFDC On Test Case Fail
287 Run Keyword If Test Failed Fatal Error msg=Code update failed.
288
289
290Suite Setup Execution
George Keishing1eb85f52017-08-30 22:55:13 -0500291 [Documentation] Do code update test case setup.
292 # - Clean up all existing BMC dumps.
293
Michael Walshe78a4432018-03-29 16:36:04 -0500294 Run Key Delete All Dumps ignore=1
Charles Paul Hoferb9264082017-09-29 15:00:19 -0500295 Run Keyword And Ignore Error Smart Power Off
George Keishing00715492017-08-18 11:46:37 -0500296
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -0500297Test Teardown Execution
George Keishing00715492017-08-18 11:46:37 -0500298 [Documentation] Do code update test case teardown.
299 # 1. Collect FFDC if test case failed.
300 # 2. Collect FFDC if test PASS but error log exists.
301
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -0500302 # Don't delete our logs if we want to persist them for tests.
303 Return From Keyword If ${running_persistence_test}
304
George Keishing00715492017-08-18 11:46:37 -0500305 FFDC On Test Case Fail
306 Run Keyword If '${TEST_STATUS}' == 'PASS' Check Error And Collect FFDC
Sivas SRR77c69192017-11-02 23:56:39 -0500307 Close All Connections