blob: 0bedbb349116549c26566955d7608425bf6ccb0c [file] [log] [blame]
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -05001*** Settings ***
2Documentation Update the PNOR code on a target BMC.
3... Execution Method:
4... python -m robot -v OPENBMC_HOST:<hostname>
5... -v DELETE_OLD_PNOR_IMAGES:<"true" or "false">
Charles Paul Hofera5673162017-08-30 09:49:16 -05006... -v IMAGE_FILE_PATH:<path/*.tar>
7... -v ALTERNATE_IMAGE_FILE_PATH:<path/*.tar>
8... host_code_update.robot
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -05009...
10... Code update method BMC
11... Update work flow sequence:
12... - Upload image via REST
13... - Verify that the file exists on the BMC
14... - Check that software "Activation" is set to "Ready"
15... - Set "Requested Activation" to "Active"
16... - Wait for code update to complete
17... - Verify the new version
18
19Library ../../lib/bmc_ssh_utils.py
20Library ../../lib/code_update_utils.py
Michael Walshe78a4432018-03-29 16:36:04 -050021Library ../../lib/gen_robot_keyword.py
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050022Variables ../../data/variables.py
23Resource ../../lib/boot_utils.robot
24Resource code_update_utils.robot
25Resource ../../lib/code_update_utils.robot
George Keishing1eb85f52017-08-30 22:55:13 -050026Resource ../../lib/openbmc_ffdc.robot
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050027Resource ../../lib/state_manager.robot
George Keishing1eb85f52017-08-30 22:55:13 -050028Resource ../../lib/dump_utils.robot
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050029
George Keishing00715492017-08-18 11:46:37 -050030Test Teardown Code Update Test Teardown
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050031
George Keishing09712a12017-10-16 12:52:42 -050032Force Tags Host_Code_Update
33
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050034*** Variables ***
35
Steven Sombar9629b0e2018-08-23 07:26:58 -050036${QUIET} ${1}
37${IMAGE_FILE_PATH} ${EMPTY}
38${DELETE_OLD_PNOR_IMAGES} false
39${DELETE_OLD_GUARD_FILE} false
40${ALTERNATE_IMAGE_FILE_PATH} ${EMPTY}
41${cache_files_dir_path} /var/lib/phosphor-software-manager/pnor/prsv/
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050042
43*** Test Cases ***
44
45REST Host Code Update
46 [Documentation] Do a PNOR code update by uploading image on BMC via REST.
George Keishing00715492017-08-18 11:46:37 -050047 # 1. Delete error logs if there is any.
48 # 1. Do code update.
49 # 2. Do post update the following:
50 # - Collect FFDC if error log exist and delete error logs.
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050051 [Tags] REST_Host_Code_Update
52 [Setup] Code Update Setup
53
Sweta Potthuri8c7ada42018-01-15 05:05:59 -060054 Run Keyword And Ignore Error List Installed Images Host
55
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050056 Upload And Activate Image ${IMAGE_FILE_PATH}
57 OBMC Reboot (off)
58
59
60Post Update Boot To OS
61 [Documentation] Boot the host OS
62 [Tags] Post_Update_Boot_To_OS
Charles Paul Hofer0c4a87d2017-10-11 17:27:40 -050063 [Setup] Start SOL Console Logging
George Keishingda6bace2017-09-14 07:42:27 -050064 [Teardown] Run Keywords Stop SOL Console Logging
65 ... AND Code Update Test Teardown
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050066
67 Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL'
68 ... Fail Code update failed. No need to boot to OS.
George Keishing32fe4e12018-07-13 05:06:47 -050069 Delete All Error Logs
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050070 REST Power On
Charles Paul Hofere43fb2f2017-09-26 15:36:18 -050071 Verify Running Host Image ${IMAGE_FILE_PATH}
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -050072
73
Steven Sombar9629b0e2018-08-23 07:26:58 -050074Test Boot With No VPD Cache
75 [Documentation] After having done a PNOR update and
76 ... booted the OS in the tests above, remove the cached
77 ... VPD files and verify that the OS can still boot.
78 [Tags] Test_Boot_With_No_VPD_Cache
79 [Setup] Start SOL Console Logging
80 [Teardown] Run Keywords Stop SOL Console Logging
81 ... AND Code Update Test Teardown
82
83 ${num_vpd_files} ${stderr} ${rc}= BMC Execute Command
84 ... ls ${cache_files_dir_path} | grep VPD -c
85 # Typically, vpd files = "CVPD DJVPD MVPD NVRAM".
86 Should Be Equal As Integers ${num_vpd_files} ${3}
87 ... msg=Missing VPD files at ${cache_files_dir_path}.
88
89 # Delete the *VPD* files.
90 BMC Execute Command rm -f ${xxx_dir_path}*VPD*
91
92 REST Power On
93
94 # After powering-on the system, the VPD files should be present.
95 ${num_vpd_files} ${stderr} ${rc}= BMC Execute Command
96 ... ls ${cache_files_dir_path} | grep VPD -c
97 Should Be Equal As Integers ${num_vpd_files} ${3}
98 ... msg=Three VPD files expected at ${cache_files_dir_path}.
99
100 # Power off. The next test case will boot the OS with the new VPD files.
101 REST Power Off
102
103
Charles Paul Hofer7c6e7522017-10-18 17:09:27 -0500104REST Host Code Update While OS Is Running
105 [Documentation] Do a PNOR code update while the host is running.
106 [Tags] REST_Host_Code_Update_While_OS_Is_Running
Charles Paul Hofer4e8c09b2017-11-03 14:59:05 -0500107 [Teardown] Run Keywords REST Power Off stack_mode=skip
108 ... AND Code Update Test Teardown
Charles Paul Hofer7c6e7522017-10-18 17:09:27 -0500109
110 Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL'
111 ... Fail Cannot boot the OS.
112
113 REST Power On stack_mode=skip
George Keishing72373f82017-11-20 09:18:41 -0600114 Upload And Activate Image
115 ... ${ALTERNATE_IMAGE_FILE_PATH} skip_if_active=true
Charles Paul Hofer7c6e7522017-10-18 17:09:27 -0500116 REST Power On stack_mode=normal
117 Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH}
118
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500119Host Image Priority Attribute Test
120 [Documentation] Set "Priority" attribute.
121 [Tags] Host_Image_Priority_Attribute_Test
122 [Template] Temporarily Set PNOR Attribute
123
124 # Property Value
125 Priority ${0}
126 Priority ${1}
127 Priority ${127}
George Keishing97ecb272017-09-12 04:30:20 -0500128 Priority ${255}
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500129
130
Charles Paul Hofer42f17462017-09-12 14:09:32 -0500131Host Set Priority To Invalid Values
132 [Documentation] Attempt to set the priority of an image to an invalid
133 ... value and expect an error.
134 [Tags] Host_Set_Priority_To_Invalid_Values
135 [Template] Set Priority To Invalid Value And Expect Error
136
137 # Version Type Priority
138 ${VERSION_PURPOSE_HOST} ${-1}
139 ${VERSION_PURPOSE_HOST} ${256}
140
141
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500142Set RequestedActivation To None
143 [Documentation] Set the RequestedActivation of the image to None and
144 ... verify that it is in fact set to None.
145 [Tags] Set_RequestedActivation_To_None
146
147 ${software_objects}= Get Software Objects
148 Set Host Software Property @{software_objects}[0] RequestedActivation
149 ... ${REQUESTED_NONE}
150 ${software_properties}= Get Host Software Property @{software_objects}[0]
151 Should Be Equal As Strings &{software_properties}[RequestedActivation]
152 ... ${REQUESTED_NONE}
153
154
155Set RequestedActivation And Activation To Invalid Value
156 [Documentation] Set the RequestedActivation and Activation propreties of
157 ... the image to an invalid value and verify that it was not
158 ... changed.
159 [Template] Set Property To Invalid Value And Verify No Change
160 [Tags] Set_RequestedActivation_And_Activation_To_Invalid_Value
161
162 # Property Version Type
163 RequestedActivation ${VERSION_PURPOSE_HOST}
164 Activation ${VERSION_PURPOSE_HOST}
165
166
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500167Upload And Activate Multiple Host Images
168 [Documentation] Upload another PNOR image and verify that its state is
169 ... different from all others.
170 [Tags] Upload_And_Activate_Multiple_Host_Images
171 [Template] Activate Image And Verify No Duplicate Priorities
172 [Setup] Upload And Activate Multiple BMC Images Setup
173
174 # Image File Path Image Purpose
175 ${ALTERNATE_IMAGE_FILE_PATH} ${VERSION_PURPOSE_HOST}
176
177
Charles Paul Hofera5673162017-08-30 09:49:16 -0500178Set Same Priority For Multiple Host Images
179 [Documentation] Attempt to set the priority to be the same for two PNOR
180 ... images and verify that the priorities are not the same.
181 [Tags] Set_Same_Priority_For_Multiple_Host_Images
182
183 Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL'
184 ... Fail Activation of alternate image failed. Cannot set priority.
185 Set Same Priority For Multiple Images ${VERSION_PURPOSE_HOST}
186
187
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500188Delete Host Image
189 [Documentation] Delete a PNOR image from the BMC and PNOR flash chip.
190 [Tags] Delete_Host_Image
191 [Setup] Initiate Host PowerOff
192
193 ${software_objects}= Get Software Objects
194 ... version_type=${VERSION_PURPOSE_HOST}
195 ${num_images}= Get Length ${software_objects}
196 Should Be True 0 < ${num_images}
197 ... msg=There are no PNOR images on the BMC to delete.
198 Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST}
199
200
George Keishing287faaf2017-11-21 12:31:03 -0600201Verify Host Update When Host Reboot During Activation In Progress
202 [Documentation] Attempt to reboot the host while an image is activating.
203 [Tags] Verify_Host_Update_When_Host_Reboot_During_Activation_In_Progress
204
205 Upload And Activate Image ${IMAGE_FILE_PATH}
206 REST Power On
George Keishing32fe4e12018-07-13 05:06:47 -0500207 Delete All Error Logs
George Keishing287faaf2017-11-21 12:31:03 -0600208
209 ${version_id}= Upload And Activate Image ${ALTERNATE_IMAGE_FILE_PATH}
210 ... wait=${0}
211
212 ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id}
213 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
214
215 # Reboot Host during activation.
216 Host Reboot
217
218 Wait For Activation State Change ${version_id} ${ACTIVATING}
219
220 # New image priority should be 0.
221 ${new_host_properties}=
222 ... Get Host Software Property ${SOFTWARE_VERSION_URI}${version_id}
223 Should Be Equal As Integers ${new_host_properties["Priority"]} ${0}
224
225 # Reboot host to boot up with the new host image version.
226 Host Reboot
227 Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH}
228
229
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500230*** Keywords ***
231
232Temporarily Set PNOR Attribute
233 [Documentation] Update the PNOR attribute value.
234 [Arguments] ${attribute_name} ${attribute_value}
235
236 # Description of argument(s):
237 # attribute_name Host software attribute name (e.g. "Priority").
238 # attribute_value Value to be written.
239
240 ${image_ids}= Get Software Objects
241 ${init_host_properties}= Get Host Software Property ${image_ids[0]}
242 ${initial_priority}= Set Variable ${init_host_properties["Priority"]}
243
244 Set Host Software Property ${image_ids[0]} ${attribute_name}
245 ... ${attribute_value}
246
247 ${cur_host_properties}= Get Host Software Property ${image_ids[0]}
248 Should Be Equal As Integers ${cur_host_properties["Priority"]}
249 ... ${attribute_value}
250
251 # Revert to to initial value.
252 Set Host Software Property
253 ... ${image_ids[0]} ${attribute_name} ${initial_priority}
254
255
256Code Update Setup
257 [Documentation] Do code update test case setup.
George Keishing1eb85f52017-08-30 22:55:13 -0500258 # - Clean up all existing BMC dumps.
259 # - Clean up all currently install PNOR images.
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500260
Charles Paul Hoferb9264082017-09-29 15:00:19 -0500261 Run Keyword And Ignore Error Smart Power Off
Michael Walshe78a4432018-03-29 16:36:04 -0500262 Run Key Delete All Dumps ignore=1
George Keishing32fe4e12018-07-13 05:06:47 -0500263 Run Key Delete All Error Logs ignore=1
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500264 Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}'
265 ... Delete All PNOR Images
Charles Paul Hofer51b54c02017-09-13 22:13:49 -0500266 Run Keyword If 'true' == '${DELETE_OLD_GUARD_FILE}' BMC Execute Command
267 ... rm -f /var/lib/phosphor-software-manager/pnor/prsv/GUARD
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500268
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
273 Should Not Be Empty ${ALTERNATE_IMAGE_FILE_PATH}
Charles Paul Hofer4e8c09b2017-11-03 14:59:05 -0500274 Delete All PNOR Images
George Keishing72373f82017-11-20 09:18:41 -0600275 Upload And Activate Image ${IMAGE_FILE_PATH} skip_if_active=true
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500276
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500277Get PNOR Extended Version
278 [Documentation] Return the PNOR extended version.
279 [Arguments] ${manifest_path}
280
281 # Description of argument(s):
282 # manifest_path Path of the MANIFEST file
283 # (e.g. "/tmp/images/abc123/MANIFEST").
284
285 ${version}= BMC Execute Command
286 ... grep extended_version= ${manifest_path}
287 [return] ${version.split(",")}
George Keishing00715492017-08-18 11:46:37 -0500288
289
290Code Update Test Teardown
291 [Documentation] Do code update test case teardown.
292 # 1. Collect FFDC if test case failed.
293 # 2. Collect FFDC if test PASS but error log exists.
294
295 FFDC On Test Case Fail
296 Run Keyword If '${TEST_STATUS}' == 'PASS' Check Error And Collect FFDC