blob: f365dfe3759ebe1e6d66c1dd98566084d4dd9224 [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
50 OperatingSystem.File Should Exist ${IMAGE_FILE_PATH}
51 ${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH}
52
53 ${image_data}= OperatingSystem.Get Binary File ${IMAGE_FILE_PATH}
54 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 Hoferda24d0a2017-08-09 15:03:40 -0500100Delete Host Image
101 [Documentation] Delete a PNOR image from the BMC and PNOR flash chip.
102 [Tags] Delete_Host_Image
103 [Setup] Initiate Host PowerOff
104
105 ${software_objects}= Get Software Objects
106 ... version_type=${VERSION_PURPOSE_HOST}
107 ${num_images}= Get Length ${software_objects}
108 Should Be True 0 < ${num_images}
109 ... msg=There are no PNOR images on the BMC to delete.
110 Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST}
111
112
113Delete BMC Image
114 [Documentation] Delete a BMC image from the BMC flash chip.
115 [Tags] Delete_BMC_Image
116
117 ${software_object}= Get Non Running BMC Software Object
118 Delete Image And Verify ${software_object} ${VERSION_PURPOSE_BMC}
119
120
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500121*** Keywords ***
122
George Keishingd3fb5922017-08-08 07:32:25 -0500123Set PNOR Attribute
124 [Documentation] Update the attribute value.
125 [Arguments] ${attribute_name} ${value}
126
127 # Description of argument(s):
128 # attribute_name Host software attribute name (e.g. "Priority").
129 # value Value to be written.
130
131 ${image_ids}= Get Software Objects
132 ${resp}= Get Host Software Property ${image_ids[0]}
133 ${initial_value}= Set Variable ${resp["Priority"]}
134
135 Set Host Software Property ${image_ids[0]} ${attribute_name} ${value}
136
137 ${resp}= Get Host Software Property ${image_ids[0]}
138 Should Be Equal As Integers ${resp["Priority"]} ${value}
139
140 # Revert to to initial value.
141 Set Host Software Property
142 ... ${image_ids[0]} ${attribute_name} ${initial_value}
143
144
Charles Paul Hofer2c731642017-08-03 18:13:27 -0500145Code Update Setup
146 [Documentation] Do code update test case setup.
147
148 Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}'
149 ... Delete All PNOR Images
150
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500151Code Update Teardown
152 [Documentation] Do code update test case teardown.
153
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500154 Close All Connections
155 FFDC On Test Case Fail
156
157Get PNOR Extended Version
158 [Documentation] Return the PNOR extended version.
159 ... Description of arguments:
160 ... path Path of the MANIFEST file
161 [Arguments] ${path}
162
163 Open Connection And Log In
164 ${version}= Execute Command On BMC
165 ... "grep \"extended_version=\" " + ${path}
166 [return] ${version.split(",")}
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -0500167
168Delete Image And Verify
169 [Documentation] Delete an image from the BMC and verify that it was
170 ... removed from software and the /tmp/images directory.
171 [Arguments] ${software_object} ${version_type}
172
173 # Description of argument(s):
174 # software_object The URI of the software object to delete.
175 # version_type The type of the software object, e.g.
176 # xyz.openbmc_project.Software.Version.VersionPurpose.Host
177 # or xyz.openbmc_project.Software.Version.VersionPurpose.BMC.
178
179 # Delete the image.
180 Delete Software Object ${software_object}
181 # TODO: If/when we don't have to delete twice anymore, take this out
182 Run Keyword And Ignore Error Delete Software Object ${software_object}
183
184 # Verify that it's gone from software.
185 ${software_objects}= Get Software Objects version_type=${version_type}
186 Should Not Contain ${software_objects} ${software_object}
187
188 # Check that there is no file in the /tmp/images directory.
189 ${image_id}= Fetch From Right ${software_object} /
190 BMC Execute Command
191 ... [ ! -d "/tmp/images/${image_id}" ]