blob: 76eb0610e050afe0118e0abfdcf0fef82911435d [file] [log] [blame]
Saqib Khanbb8b63f2017-05-24 10:58:01 -05001*** Settings ***
2Documentation Code update to a target BMC.
3... Execution Method:
4... python -m robot -v OPENBMC_HOST:<hostname>
Charles Paul Hofer2c731642017-08-03 18:13:27 -05005... -v DELETE_OLD_PNOR_IMAGES:<"true" or "false">
Saqib Khanbb8b63f2017-05-24 10:58:01 -05006... -v IMAGE_FILE_PATH:<path/*.tar> code_update.robot
7...
8... Code update method BMC
9... Update work flow sequence:
10... - Upload image via REST
11... - Verify that the file exists on the BMC
12... - Check software "Activation" status to be "Ready"
13... - Set "Requested Activation" to "Active"
14... - Wait for code update to complete
15... - Verify the new version
16
Charles Paul Hoferde7d4082017-08-08 14:41:01 -050017Library ../../lib/code_update_utils.py
Saqib Khanbb8b63f2017-05-24 10:58:01 -050018Library OperatingSystem
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -050019Library String
Saqib Khanbb8b63f2017-05-24 10:58:01 -050020Variables ../../data/variables.py
Saqib Khanbb8b63f2017-05-24 10:58:01 -050021Resource ../lib/rest_client.robot
22Resource ../lib/openbmc_ffdc.robot
George Keishingd3fb5922017-08-08 07:32:25 -050023Resource ../../lib/code_update_utils.robot
Charles Paul Hofere5100822017-08-01 10:02:23 -050024Resource ../../lib/boot_utils.robot
Charles Paul Hoferd68d0fa2017-08-17 13:51:24 -050025Resource ../../lib/utils.robot
26Resource code_update_utils.robot
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -050027Resource ../../lib/state_manager.robot
Saqib Khanbb8b63f2017-05-24 10:58:01 -050028
29Test Teardown Code Update Teardown
30
31*** Variables ***
32
33${QUIET} ${1}
34${version_id} ${EMPTY}
35${upload_dir_path} /tmp/images/
36${image_version} ${EMPTY}
37${image_purpose} ${EMPTY}
38${activation_state} ${EMPTY}
39${requested_state} ${EMPTY}
40${IMAGE_FILE_PATH} ${EMPTY}
Charles Paul Hofer2c731642017-08-03 18:13:27 -050041${DELETE_OLD_PNOR_IMAGES} false
Saqib Khanbb8b63f2017-05-24 10:58:01 -050042
43*** Test Cases ***
44
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050045REST Host Code Update
Saqib Khanbb8b63f2017-05-24 10:58:01 -050046 [Documentation] Do a PNOR code update by uploading image on BMC via REST.
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050047 [Tags] REST_Host_Code_Update
Charles Paul Hofer2c731642017-08-03 18:13:27 -050048 [Setup] Code Update Setup
Saqib Khanbb8b63f2017-05-24 10:58:01 -050049
Charles Paul Hofer12a7c1d2017-08-01 13:44:02 -050050 OperatingSystem.File Should Exist ${image_file_path}
51 ${image_version}= Get Version Tar ${image_file_path}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050052
Charles Paul Hofer12a7c1d2017-08-01 13:44:02 -050053 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050054 Upload Image To BMC /upload/image data=${image_data}
55 ${ret}= Verify Image Upload
56 Should Be True ${ret}
57
58 # Verify the image is 'READY' to be activated.
George Keishingff1e3ec2017-07-20 01:58:21 -050059 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050060 Should Be Equal As Strings &{software_state}[Activation] ${READY}
61
62 # Request the image to be activated.
63 ${args}= Create Dictionary data=${REQUESTED_ACTIVE}
George Keishingff1e3ec2017-07-20 01:58:21 -050064 Write Attribute ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050065 ... RequestedActivation data=${args}
George Keishingff1e3ec2017-07-20 01:58:21 -050066 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050067 Should Be Equal As Strings &{software_state}[RequestedActivation]
68 ... ${REQUESTED_ACTIVE}
69
70 # Verify code update was successful and Activation state is Active.
71 Wait For Activation State Change ${version_id} ${ACTIVATING}
George Keishingff1e3ec2017-07-20 01:58:21 -050072 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050073 Should Be Equal As Strings &{software_state}[Activation] ${ACTIVE}
74
Charles Paul Hoferbdbabf12017-08-18 12:30:14 -050075 OBMC Reboot (off)
Charles Paul Hofere5100822017-08-01 10:02:23 -050076
77
78Post Update Boot To OS
79 [Documentation] Boot the host OS
80 [Tags] Post_Update_Boot_To_OS
Charles Paul Hofer99108412017-08-21 09:22:36 -050081 [Teardown] Stop SOL Console Logging
Charles Paul Hofere5100822017-08-01 10:02:23 -050082
83 Run Keyword Unless '${PREV_TEST_STATUS}' == 'PASS'
84 ... Fail Code update failed. No need to boot to OS.
Charles Paul Hofer99108412017-08-21 09:22:36 -050085 Start SOL Console Logging
Charles Paul Hofere5100822017-08-01 10:02:23 -050086 REST Power On
87
George Keishingd3fb5922017-08-08 07:32:25 -050088
89Host Image Priority Attribute Test
90 [Documentation] Set "Priority" attribute.
91 [Tags] Host_Image_Priority_Attribute_Test
92 [Template] Set PNOR Attribute
93
94 # Property Value
95 Priority ${0}
96 Priority ${1}
97 Priority ${127}
98
Charles Paul Hofere5100822017-08-01 10:02:23 -050099
Charles Paul Hofer12a7c1d2017-08-01 13:44:02 -0500100Set RequestedActivation To None
101 [Documentation] Set the RequestedActivation of the image to None and
102 ... verify that it is in fact set to None.
103 [Tags] Set_RequestedActivation_To_None
104
105 ${sw_objs}= Get Software Objects
106 Set Host Software Property @{sw_objs}[0] RequestedActivation
107 ... ${REQUESTED_NONE}
108 ${sw_props}= Get Host Software Property @{sw_objs}[0]
109 Should Be Equal As Strings &{sw_props}[RequestedActivation]
110 ... ${REQUESTED_NONE}
111
112
113Set RequestedActivation To Invalid Value
114 [Documentation] Set the RequestedActivation proprety of the image to an
115 ... invalid value and verify that it was not changed.
116 [Template] Set Property To Invalid Value And Verify No Change
117 [Tags] Set_RequestedActivation_To_Invalid_Value
118
119 # Property
120 RequestedActivation
121
122
123Set Activation To Invalid Value
124 [Documentation] Set the Activation proprety of the image to an invalid
125 ... value and verify that it was not changed.
126 [Template] Set Property To Invalid Value And Verify No Change
127 [Tags] Set_Activation_To_Invalid_Value
128
129 # Property
130 Activation
131
132
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -0500133Delete Host Image
134 [Documentation] Delete a PNOR image from the BMC and PNOR flash chip.
135 [Tags] Delete_Host_Image
136 [Setup] Initiate Host PowerOff
137
138 ${software_objects}= Get Software Objects
139 ... version_type=${VERSION_PURPOSE_HOST}
140 ${num_images}= Get Length ${software_objects}
141 Should Be True 0 < ${num_images}
142 ... msg=There are no PNOR images on the BMC to delete.
143 Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST}
144
145
146Delete BMC Image
147 [Documentation] Delete a BMC image from the BMC flash chip.
148 [Tags] Delete_BMC_Image
149
150 ${software_object}= Get Non Running BMC Software Object
151 Delete Image And Verify ${software_object} ${VERSION_PURPOSE_BMC}
152
153
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500154*** Keywords ***
155
George Keishingd3fb5922017-08-08 07:32:25 -0500156Set PNOR Attribute
157 [Documentation] Update the attribute value.
158 [Arguments] ${attribute_name} ${value}
159
160 # Description of argument(s):
161 # attribute_name Host software attribute name (e.g. "Priority").
162 # value Value to be written.
163
164 ${image_ids}= Get Software Objects
165 ${resp}= Get Host Software Property ${image_ids[0]}
166 ${initial_value}= Set Variable ${resp["Priority"]}
167
168 Set Host Software Property ${image_ids[0]} ${attribute_name} ${value}
169
170 ${resp}= Get Host Software Property ${image_ids[0]}
171 Should Be Equal As Integers ${resp["Priority"]} ${value}
172
173 # Revert to to initial value.
174 Set Host Software Property
175 ... ${image_ids[0]} ${attribute_name} ${initial_value}
176
177
Charles Paul Hofer2c731642017-08-03 18:13:27 -0500178Code Update Setup
179 [Documentation] Do code update test case setup.
180
181 Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}'
182 ... Delete All PNOR Images
183
Charles Paul Hofer12a7c1d2017-08-01 13:44:02 -0500184
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500185Code Update Teardown
186 [Documentation] Do code update test case teardown.
187
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500188 FFDC On Test Case Fail
189
Charles Paul Hofer12a7c1d2017-08-01 13:44:02 -0500190
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500191Get PNOR Extended Version
192 [Documentation] Return the PNOR extended version.
Charles Paul Hofer12a7c1d2017-08-01 13:44:02 -0500193 [Arguments] ${path}
194
195 # Description of argument(s):
196 # path Path of the MANIFEST file.
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500197
198 Open Connection And Log In
199 ${version}= Execute Command On BMC
200 ... "grep \"extended_version=\" " + ${path}
201 [return] ${version.split(",")}
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -0500202
Charles Paul Hofer12a7c1d2017-08-01 13:44:02 -0500203
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -0500204Delete Image And Verify
205 [Documentation] Delete an image from the BMC and verify that it was
206 ... removed from software and the /tmp/images directory.
207 [Arguments] ${software_object} ${version_type}
208
209 # Description of argument(s):
210 # software_object The URI of the software object to delete.
211 # version_type The type of the software object, e.g.
212 # xyz.openbmc_project.Software.Version.VersionPurpose.Host
213 # or xyz.openbmc_project.Software.Version.VersionPurpose.BMC.
214
215 # Delete the image.
216 Delete Software Object ${software_object}
217 # TODO: If/when we don't have to delete twice anymore, take this out
218 Run Keyword And Ignore Error Delete Software Object ${software_object}
219
220 # Verify that it's gone from software.
221 ${software_objects}= Get Software Objects version_type=${version_type}
222 Should Not Contain ${software_objects} ${software_object}
223
224 # Check that there is no file in the /tmp/images directory.
225 ${image_id}= Fetch From Right ${software_object} /
226 BMC Execute Command
227 ... [ ! -d "/tmp/images/${image_id}" ]
Charles Paul Hofer12a7c1d2017-08-01 13:44:02 -0500228
229
230Set Property To Invalid Value And Verify No Change
231 [Documentation] Attempt to set a property and check that the value didn't
232 ... change.
233 [Arguments] ${property}
234
235 # Description of argument(s):
236 # property The property to attempt to set.
237
238 ${sw_objs}= Get Software Objects
239 ${prev_props}= Get Host Software Property @{sw_objs}[0]
240 Run Keyword And Expect Error 500 != 200
241 ... Set Host Software Property @{sw_objs}[0] ${property} foo
242 ${cur_props}= Get Host Software Property @{sw_objs}[0]
243 Should Be Equal As Strings &{prev_props}[${property}]
244 ... &{cur_props}[${property}]