blob: d2e16ed80ee8704d24d0b4978336d59c6b085e05 [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
17#TODO: Move test_uploadimage.py to lib/
18Library ../test_uploadimage.py
19Library code_update.py
20Library OperatingSystem
21Variables ../../data/variables.py
Saqib Khanbb8b63f2017-05-24 10:58:01 -050022Resource ../lib/rest_client.robot
23Resource ../lib/openbmc_ffdc.robot
George Keishingd3fb5922017-08-08 07:32:25 -050024Resource ../../lib/code_update_utils.robot
Saqib Khanbb8b63f2017-05-24 10:58:01 -050025
26Test Teardown Code Update Teardown
27
28*** Variables ***
29
30${QUIET} ${1}
31${version_id} ${EMPTY}
32${upload_dir_path} /tmp/images/
33${image_version} ${EMPTY}
34${image_purpose} ${EMPTY}
35${activation_state} ${EMPTY}
36${requested_state} ${EMPTY}
37${IMAGE_FILE_PATH} ${EMPTY}
Charles Paul Hofer2c731642017-08-03 18:13:27 -050038${DELETE_OLD_PNOR_IMAGES} false
Saqib Khanbb8b63f2017-05-24 10:58:01 -050039
40*** Test Cases ***
41
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050042REST Host Code Update
Saqib Khanbb8b63f2017-05-24 10:58:01 -050043 [Documentation] Do a PNOR code update by uploading image on BMC via REST.
Charles Paul Hofer9a5c7222017-08-03 18:21:08 -050044 [Tags] REST_Host_Code_Update
Charles Paul Hofer2c731642017-08-03 18:13:27 -050045 [Setup] Code Update Setup
Saqib Khanbb8b63f2017-05-24 10:58:01 -050046
47 OperatingSystem.File Should Exist ${IMAGE_FILE_PATH}
48 ${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH}
49
50 ${image_data}= OperatingSystem.Get Binary File ${IMAGE_FILE_PATH}
51 Upload Image To BMC /upload/image data=${image_data}
52 ${ret}= Verify Image Upload
53 Should Be True ${ret}
54
55 # Verify the image is 'READY' to be activated.
George Keishingff1e3ec2017-07-20 01:58:21 -050056 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050057 Should Be Equal As Strings &{software_state}[Activation] ${READY}
58
59 # Request the image to be activated.
60 ${args}= Create Dictionary data=${REQUESTED_ACTIVE}
George Keishingff1e3ec2017-07-20 01:58:21 -050061 Write Attribute ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050062 ... RequestedActivation data=${args}
George Keishingff1e3ec2017-07-20 01:58:21 -050063 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050064 Should Be Equal As Strings &{software_state}[RequestedActivation]
65 ... ${REQUESTED_ACTIVE}
66
67 # Verify code update was successful and Activation state is Active.
68 Wait For Activation State Change ${version_id} ${ACTIVATING}
George Keishingff1e3ec2017-07-20 01:58:21 -050069 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Saqib Khanbb8b63f2017-05-24 10:58:01 -050070 Should Be Equal As Strings &{software_state}[Activation] ${ACTIVE}
71
George Keishingd3fb5922017-08-08 07:32:25 -050072
73Host Image Priority Attribute Test
74 [Documentation] Set "Priority" attribute.
75 [Tags] Host_Image_Priority_Attribute_Test
76 [Template] Set PNOR Attribute
77
78 # Property Value
79 Priority ${0}
80 Priority ${1}
81 Priority ${127}
82
Saqib Khanbb8b63f2017-05-24 10:58:01 -050083*** Keywords ***
84
George Keishingd3fb5922017-08-08 07:32:25 -050085Set PNOR Attribute
86 [Documentation] Update the attribute value.
87 [Arguments] ${attribute_name} ${value}
88
89 # Description of argument(s):
90 # attribute_name Host software attribute name (e.g. "Priority").
91 # value Value to be written.
92
93 ${image_ids}= Get Software Objects
94 ${resp}= Get Host Software Property ${image_ids[0]}
95 ${initial_value}= Set Variable ${resp["Priority"]}
96
97 Set Host Software Property ${image_ids[0]} ${attribute_name} ${value}
98
99 ${resp}= Get Host Software Property ${image_ids[0]}
100 Should Be Equal As Integers ${resp["Priority"]} ${value}
101
102 # Revert to to initial value.
103 Set Host Software Property
104 ... ${image_ids[0]} ${attribute_name} ${initial_value}
105
106
Charles Paul Hofer2c731642017-08-03 18:13:27 -0500107Code Update Setup
108 [Documentation] Do code update test case setup.
109
110 Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}'
111 ... Delete All PNOR Images
112
Saqib Khanbb8b63f2017-05-24 10:58:01 -0500113Code Update Teardown
114 [Documentation] Do code update test case teardown.
115
116 #TODO: Use the Delete interface instead once delivered
117 Open Connection And Log In
118 Execute Command On BMC rm -rf /tmp/images/*
119
120 Close All Connections
121 FFDC On Test Case Fail
122
123Get PNOR Extended Version
124 [Documentation] Return the PNOR extended version.
125 ... Description of arguments:
126 ... path Path of the MANIFEST file
127 [Arguments] ${path}
128
129 Open Connection And Log In
130 ${version}= Execute Command On BMC
131 ... "grep \"extended_version=\" " + ${path}
132 [return] ${version.split(",")}