blob: d68eaa830ce8314bb53df5d51655e5257f3baa11 [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 Keishing09712a12017-10-16 12:52:42 -050022Force Tags BMC_Code_Update
23
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050024*** Variables ***
25
26${QUIET} ${1}
27${IMAGE_FILE_PATH} ${EMPTY}
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -050028${ALTERNATE_IMAGE_FILE_PATH} ${EMPTY}
Charles Paul Hoferb7842a52017-09-22 10:11:33 -050029${SKIP_UPDATE_IF_ACTIVE} false
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -050030${dump_id} ${EMPTY}
31${running_persistence_test} ${FALSE}
32${test_errlog_text} AutoTestSimple
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050033
34*** Test Cases ***
35
Sivas SRR77c69192017-11-02 23:56:39 -050036Test Basic BMC Performance Before BMC Code Update
37 [Documentation] Check performance of memory, CPU & file system of BMC.
38 [Tags] Test_Basic_BMC_Performance_Before_BMC_Code_Update
39
40 Open Connection And Log In
41 Check BMC Performance
42
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -050043Prepare Persistent Data
44 [Documentation] Set data that should persist across the code update.
45 [Tags] Prepare_Persistent_Data
46
47 # Install the debug tarball.
48 BMC Execute Command rm -rf /tmp/tarball
49 Install Debug Tarball On BMC tarball_file_path=${DEBUG_TARBALL_PATH}
50
51 # Create a dummy error log and dump.
52 BMC Execute Command /tmp/tarball/bin/logging-test -c ${test_errlog_text}
53 ${dump_id}= Create User Initiated Dump
54 Check Dump Existence ${dump_id}
55 Set Suite Variable ${dump_id}
56
57 # Set persistent settings.
58 ${autoreboot_dict}= Create Dictionary data=${0}
59 Write Attribute ${CONTROL_HOST_URI}auto_reboot AutoReboot
60 ... data=${autoreboot_dict}
61 ${onetime_dict}= Create Dictionary data=${0}
62 Write Attribute ${CONTROL_HOST_URI}boot/one_time Enabled
63 ... data=${onetime_dict}
64
65 # Let the remaining test cases know we are doing a persistence test so we
66 # do not delete logs.
67 Set Suite Variable ${running_persistence_test} ${TRUE}
68
69
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050070REST BMC Code Update
71 [Documentation] Do a BMC code update by uploading image on BMC via REST.
72 [Tags] REST_BMC_Code_Update
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -050073 [Teardown] REST BMC Code Update Teardown
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050074
Sweta Potthuri8c7ada42018-01-15 05:05:59 -060075 Run Keyword And Ignore Error List Installed Images BMC
76
George Keishing8010d862019-12-03 09:46:27 -060077 ${image_version}= Get Version Tar ${IMAGE_FILE_PATH}
Michael Walshc81c6ae2020-05-08 10:19:36 -050078 ${bmc_release_info}= Get BMC Release Info
79 ${functional_version}= Set Variable ${bmc_release_info['version_id']}
80 Rprint Vars image_version functional_version
George Keishing8010d862019-12-03 09:46:27 -060081
George Keishingc23d4242020-05-07 01:36:51 -050082 # TODO: openbmc/phosphor-bmc-code-mgmt/issues/4
George Keishing8010d862019-12-03 09:46:27 -060083 # Check if the existing firmware is functional.
Michael Walshc81c6ae2020-05-08 10:19:36 -050084 Pass Execution If '${functional_version}' == '${image_version}'
85 ... The existing ${image_version} firmware is already functional.
George Keishing8010d862019-12-03 09:46:27 -060086
Charles Paul Hofer21845462017-09-27 12:40:33 -050087 Upload And Activate Image ${IMAGE_FILE_PATH}
88 ... skip_if_active=${SKIP_UPDATE_IF_ACTIVE}
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050089 OBMC Reboot (off)
Charles Paul Hofere43fb2f2017-09-26 15:36:18 -050090 Verify Running BMC Image ${IMAGE_FILE_PATH}
Sivas SRRda339e62019-10-10 01:04:14 -050091 BMC Execute Command cd /etc ; cat host.conf hosts hostname print_out=1
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050092
93
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -050094Verify Error Log Persistency
95 [Documentation] Check that the error log is still present after a
96 ... code update.
97 [Tags] Verify_Error_Log_Persistency
98
Steven Sombara8800da2018-12-18 16:19:05 -060099 ${error_log_paths}= Read Properties ${BMC_LOGGING_ENTRY}list
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -0500100 Log To Console ${error_log_paths}
101 ${test_error_message}= Read Attribute @{error_log_paths}[-1] Message
102 Should Be Equal ${test_error_message}
103 ... example.xyz.openbmc_project.Example.Elog.${test_errlog_text}
104 Delete Error Log Entry @{error_log_paths}[-1]
105
106
107Verify BMC Dump Persistency
108 [Documentation] Check that the BMC dump present after a code update.
109 [Tags] Verify_BMC_Dump_Persistency
110 [Teardown] Set Suite Variable ${running_persistence_test} ${FALSE}
111
112 Check Dump Existence ${dump_id}
113 Delete BMC Dump ${dump_id}
114
115
116Verify Settings Persistency
117 [Documentation] Verify that the settings from 'Prepare Persistent Data'
118 ... are still set correctly after the code update.
119 [Tags] Verify_Settings_Persistency
120
121 ${autoreboot_enabled}= Read Attribute ${CONTROL_HOST_URI}auto_reboot
122 ... AutoReboot
123 Should Be Equal ${autoreboot_enabled} ${0}
124 ${onetime_enabled}= Read Attribute ${CONTROL_HOST_URI}boot/one_time
125 ... Enabled
126 Should Be Equal ${onetime_enabled} ${0}
127
128 # Set values back to their defaults
129 ${autoreboot_dict}= Create Dictionary data=${1}
130 Write Attribute ${CONTROL_HOST_URI}auto_reboot AutoReboot
131 ... data=${autoreboot_dict}
132 ${onetime_dict}= Create Dictionary data=${1}
133 Write Attribute ${CONTROL_HOST_URI}boot/one_time Enabled
134 ... data=${onetime_dict}
135
136
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500137Upload And Activate Multiple BMC Images
138 [Documentation] Upload another BMC image and verify that its state is
139 ... different from all others.
140 [Tags] Upload_And_Activate_Multiple_BMC_Images
141 [Template] Activate Image And Verify No Duplicate Priorities
142 [Setup] Upload And Activate Multiple BMC Images Setup
143
144 # Image File Path Image Purpose
145 ${ALTERNATE_IMAGE_FILE_PATH} ${VERSION_PURPOSE_BMC}
146
147
Charles Paul Hofer42f17462017-09-12 14:09:32 -0500148BMC Set Priority To Invalid Values
149 [Documentation] Attempt to set the priority of an image to an invalid
150 ... value and expect an error.
151 [Tags] BMC_Set_Priority_To_Invalid_Values
152 [Template] Set Priority To Invalid Value And Expect Error
153
154 # Version Type Priority
155 ${VERSION_PURPOSE_BMC} ${-1}
156 ${VERSION_PURPOSE_BMC} ${256}
157
158
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500159Delete BMC Image
160 [Documentation] Delete a BMC image from the BMC flash chip.
161 [Tags] Delete_BMC_Image
162
163 ${software_object}= Get Non Running BMC Software Object
164 Delete Image And Verify ${software_object} ${VERSION_PURPOSE_BMC}
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500165
166
George Keishing97ecb272017-09-12 04:30:20 -0500167BMC Image Priority Attribute Test
168 [Documentation] Set "Priority" attribute.
169 [Tags] BMC_Image_Priority_Attribute_Test
170 [Template] Temporarily Set BMC Attribute
171
172 # Property Value
George Keishing872d69f2019-10-18 12:35:02 -0500173 Priority ${False}
174 Priority ${True}
George Keishing97ecb272017-09-12 04:30:20 -0500175 Priority ${0}
176 Priority ${1}
177 Priority ${127}
178 Priority ${255}
179
180
Charles Paul Hofere8dc5252017-10-10 13:50:18 -0500181Delete All Non Running BMC Images
182 [Documentation] Delete all non running BMC images.
183 [Tags] Delete_All_Non_Running_BMC_Images
184
185 ${version_id}= Upload And Activate Image ${ALTERNATE_IMAGE_FILE_PATH}
George Keishing0889d432017-11-27 11:53:06 -0600186 ... skip_if_active=true
Charles Paul Hofere8dc5252017-10-10 13:50:18 -0500187 Delete All Non Running BMC Images
188
189 ${software_ids}= Get Software Objects Id
190 ... version_type=${VERSION_PURPOSE_BMC}
191 Should Not Contain ${software_ids} ${version_id}
192
George Keishing1659f592018-10-03 08:33:41 -0500193
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500194Test Certificate Persistency After BMC Code Update
195 [Documentation] Test certificate persistency after BMC update.
196 [Tags] Test_Certificate_Persistency_After_BMC_Code_Update
197
Rahul Maheshwarifa146c42018-11-05 00:38:52 -0600198 # Create certificate sub-directory in current working directory.
199 Create Directory certificate_dir
200 OperatingSystem.Directory Should Exist ${EXECDIR}${/}certificate_dir
201
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500202 ${cert_file_path}= Generate Certificate File Via Openssl
203 ... Valid Certificate Valid Privatekey
204 ${file_data}= OperatingSystem.Get Binary File ${cert_file_path}
205 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
206
Rahul Maheshwari6a849ad2020-02-26 03:31:19 -0600207 Redfish.Login
208 ${cert_id}= Install Certificate File On BMC ${REDFISH_CA_CERTIFICATE_URI} ok data=${file_data}
209 Logging Installed certificate id: ${cert_id}
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500210
Rahul Maheshwari6a849ad2020-02-26 03:31:19 -0600211 # Adding delay after certificate installation.
212 Sleep 30s
213
214 ${bmc_cert_content}= redfish_utils.Get Attribute
215 ... /redfish/v1/Managers/bmc/Truststore/Certificates/${cert_id} CertificateString
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500216 Should Contain ${cert_file_content} ${bmc_cert_content}
217
218 Upload And Activate Image ${IMAGE_FILE_PATH}
219 ... skip_if_active=${SKIP_UPDATE_IF_ACTIVE}
220 OBMC Reboot (off)
221 Verify Running BMC Image ${IMAGE_FILE_PATH}
222
Rahul Maheshwari6a849ad2020-02-26 03:31:19 -0600223 Redfish.Login
224 ${bmc_cert_content}= redfish_utils.Get Attribute
225 ... ${REDFISH_CA_CERTIFICATE_URI}/${cert_id} CertificateString
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500226 Should Contain ${cert_file_content} ${bmc_cert_content}
227
Rahul Maheshwari6a849ad2020-02-26 03:31:19 -0600228 Redfish.Logout
229
Rahul Maheshwari8b70ddd2018-10-08 06:50:26 -0500230
Sivas SRR77c69192017-11-02 23:56:39 -0500231Test Basic BMC Performance After Code Update
232 [Documentation] Check performance of memory, CPU & file system of BMC.
233 [Tags] Test_Basic_BMC_Performance_After_Code_Update
234
235 Open Connection And Log In
236 Check BMC Performance
237
Charles Paul Hofere8dc5252017-10-10 13:50:18 -0500238
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500239*** Keywords ***
240
George Keishing97ecb272017-09-12 04:30:20 -0500241Temporarily Set BMC Attribute
242 [Documentation] Update the BMC attribute value.
243 [Arguments] ${attribute_name} ${attribute_value}
244
245 # Description of argument(s):
246 # attribute_name BMC software attribute name (e.g. "Priority").
247 # attribute_value Value to be written.
248
249 ${image_ids}= Get Software Objects ${VERSION_PURPOSE_BMC}
250 ${init_bmc_properties}= Get Host Software Property ${image_ids[0]}
251 ${initial_priority}= Set Variable ${init_bmc_properties["Priority"]}
252
253 Set Host Software Property ${image_ids[0]} ${attribute_name}
254 ... ${attribute_value}
255
256 ${cur_bmc_properties}= Get Host Software Property ${image_ids[0]}
257 Should Be Equal As Integers ${cur_bmc_properties["Priority"]}
258 ... ${attribute_value}
259
260 # Revert to to initial value.
261 Set Host Software Property
262 ... ${image_ids[0]} ${attribute_name} ${initial_priority}
263
264
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500265Upload And Activate Multiple BMC Images Setup
266 [Documentation] Check that the ALTERNATE_FILE_PATH variable is set.
267
George Keishing1eb85f52017-08-30 22:55:13 -0500268 Should Not Be Empty ${ALTERNATE_IMAGE_FILE_PATH}
269
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -0500270
271REST BMC Code Update Teardown
272 [Documentation] Do code update test teardown.
273
274 FFDC On Test Case Fail
275 Run Keyword If Test Failed Fatal Error msg=Code update failed.
276
277
278Suite Setup Execution
George Keishing1eb85f52017-08-30 22:55:13 -0500279 [Documentation] Do code update test case setup.
280 # - Clean up all existing BMC dumps.
281
Michael Walshe78a4432018-03-29 16:36:04 -0500282 Run Key Delete All Dumps ignore=1
Charles Paul Hoferb9264082017-09-29 15:00:19 -0500283 Run Keyword And Ignore Error Smart Power Off
George Keishing00715492017-08-18 11:46:37 -0500284
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -0500285Test Teardown Execution
George Keishing00715492017-08-18 11:46:37 -0500286 [Documentation] Do code update test case teardown.
287 # 1. Collect FFDC if test case failed.
288 # 2. Collect FFDC if test PASS but error log exists.
289
Charles Paul Hoferd66c5dc2017-09-29 14:25:52 -0500290 # Don't delete our logs if we want to persist them for tests.
291 Return From Keyword If ${running_persistence_test}
292
George Keishing00715492017-08-18 11:46:37 -0500293 FFDC On Test Case Fail
294 Run Keyword If '${TEST_STATUS}' == 'PASS' Check Error And Collect FFDC
Sivas SRR77c69192017-11-02 23:56:39 -0500295 Close All Connections