blob: 5398d7ebf7f16e69d5efe2e84e33173529334b00 [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
19Variables ../../data/variables.py
Saqib Khanbb8b63f2017-05-24 10:58:01 -050020Resource ../lib/rest_client.robot
21Resource ../lib/openbmc_ffdc.robot
George Keishingd3fb5922017-08-08 07:32:25 -050022Resource ../../lib/code_update_utils.robot
Charles Paul Hofere5100822017-08-01 10:02:23 -050023Resource ../../lib/boot_utils.robot
Charles Paul Hoferd68d0fa2017-08-17 13:51:24 -050024Resource ../../lib/utils.robot
25Resource code_update_utils.robot
Saqib Khanbb8b63f2017-05-24 10:58:01 -050026
27Test Teardown Code Update Teardown
28
29*** Variables ***
30
31${QUIET} ${1}
32${version_id} ${EMPTY}
33${upload_dir_path} /tmp/images/
34${image_version} ${EMPTY}
35${image_purpose} ${EMPTY}
36${activation_state} ${EMPTY}
37${requested_state} ${EMPTY}
38${IMAGE_FILE_PATH} ${EMPTY}
Charles Paul Hofer2c731642017-08-03 18:13:27 -050039${DELETE_OLD_PNOR_IMAGES} false
Saqib Khanbb8b63f2017-05-24 10:58:01 -050040
41*** Test Cases ***
42
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050043REST Host Code Update
Saqib Khanbb8b63f2017-05-24 10:58:01 -050044 [Documentation] Do a PNOR code update by uploading image on BMC via REST.
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050045 [Tags] REST_Host_Code_Update
Charles Paul Hofer2c731642017-08-03 18:13:27 -050046 [Setup] Code Update Setup
Saqib Khanbb8b63f2017-05-24 10:58:01 -050047
48 OperatingSystem.File Should Exist ${IMAGE_FILE_PATH}
49 ${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH}
50
51 ${image_data}= OperatingSystem.Get Binary File ${IMAGE_FILE_PATH}
52 Upload Image To BMC /upload/image data=${image_data}
53 ${ret}= Verify Image Upload
54 Should Be True ${ret}
55
56 # Verify the image is 'READY' to be activated.
George Keishingff1e3ec2017-07-20 01:58:21 -050057 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050058 Should Be Equal As Strings &{software_state}[Activation] ${READY}
59
60 # Request the image to be activated.
61 ${args}= Create Dictionary data=${REQUESTED_ACTIVE}
George Keishingff1e3ec2017-07-20 01:58:21 -050062 Write Attribute ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050063 ... RequestedActivation data=${args}
George Keishingff1e3ec2017-07-20 01:58:21 -050064 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050065 Should Be Equal As Strings &{software_state}[RequestedActivation]
66 ... ${REQUESTED_ACTIVE}
67
68 # Verify code update was successful and Activation state is Active.
69 Wait For Activation State Change ${version_id} ${ACTIVATING}
George Keishingff1e3ec2017-07-20 01:58:21 -050070 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050071 Should Be Equal As Strings &{software_state}[Activation] ${ACTIVE}
72
Charles Paul Hoferbdbabf12017-08-18 12:30:14 -050073 OBMC Reboot (off)
Charles Paul Hofere5100822017-08-01 10:02:23 -050074
75
76Post Update Boot To OS
77 [Documentation] Boot the host OS
78 [Tags] Post_Update_Boot_To_OS
Charles Paul Hofer99108412017-08-21 09:22:36 -050079 [Teardown] Stop SOL Console Logging
Charles Paul Hofere5100822017-08-01 10:02:23 -050080
81 Run Keyword Unless '${PREV_TEST_STATUS}' == 'PASS'
82 ... Fail Code update failed. No need to boot to OS.
Charles Paul Hofer99108412017-08-21 09:22:36 -050083 Start SOL Console Logging
Charles Paul Hofere5100822017-08-01 10:02:23 -050084 REST Power On
85
George Keishingd3fb5922017-08-08 07:32:25 -050086
87Host Image Priority Attribute Test
88 [Documentation] Set "Priority" attribute.
89 [Tags] Host_Image_Priority_Attribute_Test
90 [Template] Set PNOR Attribute
91
92 # Property Value
93 Priority ${0}
94 Priority ${1}
95 Priority ${127}
96
Charles Paul Hofere5100822017-08-01 10:02:23 -050097
Saqib Khanbb8b63f2017-05-24 10:58:01 -050098*** Keywords ***
99
George Keishingd3fb5922017-08-08 07:32:25 -0500100Set PNOR Attribute
101 [Documentation] Update the attribute value.
102 [Arguments] ${attribute_name} ${value}
103
104 # Description of argument(s):
105 # attribute_name Host software attribute name (e.g. "Priority").
106 # value Value to be written.
107
108 ${image_ids}= Get Software Objects
109 ${resp}= Get Host Software Property ${image_ids[0]}
110 ${initial_value}= Set Variable ${resp["Priority"]}
111
112 Set Host Software Property ${image_ids[0]} ${attribute_name} ${value}
113
114 ${resp}= Get Host Software Property ${image_ids[0]}
115 Should Be Equal As Integers ${resp["Priority"]} ${value}
116
117 # Revert to to initial value.
118 Set Host Software Property
119 ... ${image_ids[0]} ${attribute_name} ${initial_value}
120
121
Charles Paul Hofer2c731642017-08-03 18:13:27 -0500122Code Update Setup
123 [Documentation] Do code update test case setup.
124
125 Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}'
126 ... Delete All PNOR Images
127
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500128Code Update Teardown
129 [Documentation] Do code update test case teardown.
130
131 #TODO: Use the Delete interface instead once delivered
132 Open Connection And Log In
133 Execute Command On BMC rm -rf /tmp/images/*
134
135 Close All Connections
136 FFDC On Test Case Fail
137
138Get PNOR Extended Version
139 [Documentation] Return the PNOR extended version.
140 ... Description of arguments:
141 ... path Path of the MANIFEST file
142 [Arguments] ${path}
143
144 Open Connection And Log In
145 ${version}= Execute Command On BMC
146 ... "grep \"extended_version=\" " + ${path}
147 [return] ${version.split(",")}