blob: 77db19d3491149f37e92055f9abbcf2d281062f1 [file] [log] [blame]
George Keishingcba6d422019-07-09 15:01:59 -05001*** Settings ***
2Documentation Firmware image (BMC and Host) upload test using TFTP protocol.
3
4# Test Parameters:
5# TFTP_SERVER The TFTP server host name or IP address.
6# IMAGE_FILE_NAME The BMC or Host image file name.
7#
8# Firmware update states:
9# Enabled -> Image is installed and either functional or active.
10# Disabled -> Image installation failed or ready for activation.
11# Updating -> Image installation currently in progress.
12
13Resource ../../lib/resource.robot
14Resource ../../lib/boot_utils.robot
15Resource ../../lib/bmc_redfish_resource.robot
16Resource ../../lib/openbmc_ffdc.robot
17Resource ../../lib/code_update_utils.robot
Sushil Singhf953d742019-11-08 10:09:44 -060018Resource ../../lib/redfish_code_update_utils.robot
Sushil Singh8033d662020-02-10 07:19:25 -060019Resource ../../lib/utils.robot
George Keishingcba6d422019-07-09 15:01:59 -050020Library ../../lib/code_update_utils.py
21Library ../../lib/gen_robot_valid.py
George Keishingcfa950c2019-07-18 12:46:46 -050022Library ../../lib/tftp_update_utils.py
George Keishingcba6d422019-07-09 15:01:59 -050023
24Suite Setup Suite Setup Execution
25Suite Teardown Redfish.Logout
George Keishingcfa950c2019-07-18 12:46:46 -050026Test Setup Run Keywords Redfish Power Off stack_mode=skip quiet=1 AND Redfish.Login
George Keishingcba6d422019-07-09 15:01:59 -050027Test Teardown FFDC On Test Case Fail
28
George Keishing9899a902023-09-07 20:57:53 +053029Force Tags Firmware_Tftp_Upload_Image
George Keishingcba6d422019-07-09 15:01:59 -050030
31*** Test Cases ***
32
33TFTP Download Install With ApplyTime OnReset Policy
34 [Documentation] Download image to BMC using TFTP with OnReset policy and verify installation.
35 [Tags] TFTP_Download_Install_With_ApplyTime_OnReset_Policy
George Keishingcfa950c2019-07-18 12:46:46 -050036 [Template] TFTP Download Install
George Keishingcba6d422019-07-09 15:01:59 -050037
George Keishingcfa950c2019-07-18 12:46:46 -050038 # policy
39 OnReset
40
41
42TFTP Download Install With ApplyTime Immediate Policy
43 [Documentation] Download image to BMC using TFTP with Immediate policy and verify installation.
44 [Tags] TFTP_Download_Install_With_ApplyTime_Immediate_Policy
45 [Template] TFTP Download Install
46
47 # policy
48 Immediate
49
50
51ImageURI Download Install With ApplyTime OnReset Policy
52 [Documentation] Download image to BMC using ImageURI with OnReset policy and verify installation.
53 [Tags] ImageURI_Download_Install_With_ApplyTime_OnReset_Policy
54 [Template] ImageURI Download Install
55
56 # policy
57 OnReset
58
59
60ImageURI Download Install With ApplyTime Immediate Policy
61 [Documentation] Download image to BMC using ImageURI with Immediate policy and verify installation.
62 [Tags] ImageURI_Download_Install_With_ApplyTime_Immediate_Policy
63 [Template] ImageURI Download Install
64
65 # policy
66 Immediate
67
Sushil Singhf953d742019-11-08 10:09:44 -060068
69Install Same Image Two Times
70 [Documentation] Install firmware image and re-try using the same image which should fail.
71 [Tags] Install_Same_Image_Two_Times
72 [Template] Same Firmware Install Two Times
73
74 # policy
75 Immediate
76
77
George Keishingcfa950c2019-07-18 12:46:46 -050078*** Keywords ***
79
80Suite Setup Execution
81 [Documentation] Do the suite setup.
82
83 Redfish.Login
Michael Walshe7edb222019-08-19 17:39:38 -050084 Valid Value TFTP_SERVER
85 Valid Value IMAGE_FILE_NAME
George Keishingcfa950c2019-07-18 12:46:46 -050086
87
88TFTP Download Install
89 [Documentation] Download image to BMC using TFTP with ApplyTime policy and verify installation.
90 [Arguments] ${policy}
91
92 # Description of argument(s):
93 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
94
Sushil Singh8033d662020-02-10 07:19:25 -060095 ${post_code_update_actions}= Get Post Boot Action
George Keishingcfa950c2019-07-18 12:46:46 -050096 ${state}= Get Pre Reboot State
97 Rprint Vars state
98
99 Set ApplyTime policy=${policy}
George Keishingcba6d422019-07-09 15:01:59 -0500100
101 # Download image from TFTP server to BMC.
102 Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
103 ... body={"TransferProtocol" : "TFTP", "ImageURI" : "${TFTP_SERVER}/${IMAGE_FILE_NAME}"}
Sushil Singha70d5162023-10-06 07:13:11 -0500104 ... valid_status_codes=[${HTTP_OK}, ${HTTP_ACCEPTED}]
George Keishingcba6d422019-07-09 15:01:59 -0500105
106 # Wait for image tar file to download complete.
Sushil Singh827881e2020-02-18 05:32:18 -0600107 ${image_id}= Wait Until Keyword Succeeds 180 sec 10 sec Get Latest Image ID
George Keishingcba6d422019-07-09 15:01:59 -0500108 Rprint Vars image_id
109
110 # Let the image get extracted and it should not fail.
111 Sleep 5s
112 Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id}
113
114 # Get image version currently installation in progress.
115 ${install_version}= Get Firmware Image Version image_id=${image_id}
116 Rprint Vars install_version
117
118 Check Image Update Progress State match_state='Updating' image_id=${image_id}
119
120 # Wait for the image to install complete.
George Keishingcfa950c2019-07-18 12:46:46 -0500121 Wait Until Keyword Succeeds 8 min 15 sec
George Keishingcba6d422019-07-09 15:01:59 -0500122 ... Check Image Update Progress State match_state='Enabled' image_id=${image_id}
123
Sushil Singh8033d662020-02-10 07:19:25 -0600124 Run Key ${post_code_update_actions['BMC image']['${policy}']}
George Keishingcba6d422019-07-09 15:01:59 -0500125
126 # Verify the image is installed and functional.
127 ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g'
128 ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd}
Michael Walshe7edb222019-08-19 17:39:38 -0500129 Valid Value functional_version valid_values=['${install_version}']
George Keishingcba6d422019-07-09 15:01:59 -0500130 Rprint Vars functional_version
131
132
George Keishingcfa950c2019-07-18 12:46:46 -0500133ImageURI Download Install
134 [Documentation] Download image to BMC using ImageURI with ApplyTime policy and verify installation.
135 [Arguments] ${policy}
George Keishingcba6d422019-07-09 15:01:59 -0500136
George Keishingcfa950c2019-07-18 12:46:46 -0500137 # Description of argument(s):
138 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
George Keishingcba6d422019-07-09 15:01:59 -0500139
Sushil Singh8033d662020-02-10 07:19:25 -0600140 ${post_code_update_actions}= Get Post Boot Action
George Keishingcfa950c2019-07-18 12:46:46 -0500141 ${state}= Get Pre Reboot State
142 Rprint Vars state
143
144 Set ApplyTime policy=${policy}
145
146 # Download image from TFTP server via ImageURI to BMC.
147 Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
148 ... body={"ImageURI": "tftp://${TFTP_SERVER}/${IMAGE_FILE_NAME}"}
Sushil Singha70d5162023-10-06 07:13:11 -0500149 ... valid_status_codes=[${HTTP_OK}, ${HTTP_ACCEPTED}]
George Keishingcfa950c2019-07-18 12:46:46 -0500150
151 # Wait for image tar file download to complete.
Sushil Singh827881e2020-02-18 05:32:18 -0600152 ${image_id}= Wait Until Keyword Succeeds 180 sec 10 sec Get Latest Image ID
George Keishingcfa950c2019-07-18 12:46:46 -0500153 Rprint Vars image_id
154
155 # Let the image get extracted and it should not fail.
156 Sleep 5s
157 Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id}
158
159 ${install_version}= Get Firmware Image Version image_id=${image_id}
160 Rprint Vars install_version
161
162 Check Image Update Progress State match_state='Updating' image_id=${image_id}
163
164 # Wait for the image to install complete.
165 Wait Until Keyword Succeeds 8 min 15 sec
166 ... Check Image Update Progress State match_state='Enabled' image_id=${image_id}
167
Sushil Singh8033d662020-02-10 07:19:25 -0600168 Run Key ${post_code_update_actions['BMC image']['${policy}']}
George Keishingcfa950c2019-07-18 12:46:46 -0500169
170 # Verify the image is installed and functional.
171 ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g'
172 ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd}
Michael Walshe7edb222019-08-19 17:39:38 -0500173 Valid Value functional_version valid_values=['${install_version}']
George Keishingcfa950c2019-07-18 12:46:46 -0500174 Rprint Vars functional_version
175
176
Sushil Singhf953d742019-11-08 10:09:44 -0600177Same Firmware Install Two Times
178 [Documentation] Download same image twice to BMC via ImageURI. Second attempt would fail.
179 [Arguments] ${apply_time} ${tftp_server}=${TFTP_SERVER} ${image_file_name}=${IMAGE_FILE_NAME}
180
181 # Description of argument(s):
182 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate").
183 # tftp_server Server IP.
184 # image_file_name Image file name.
185
186 ImageURI Download Install ${apply_time}
187
188 # Download image from TFTP server via ImageURI to BMC.
189 Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
190 ... body={"ImageURI": "tftp://${tftp_server}/${image_file_name}"}
191
192 ${image_version}= Get Image Version From TFTP Server ${tftp_server} ${image_file_name}
193 ${software_inventory_record}= Get Software Inventory State By Version
194 ... ${image_version}
195 Rprint Vars software_inventory_record
196
Sushil Singh827881e2020-02-18 05:32:18 -0600197 ${image_id}= Wait Until Keyword Succeeds 180 sec 10 sec Get Latest Image ID
Sushil Singhf953d742019-11-08 10:09:44 -0600198 Rprint Vars image_id
199
200 Check Image Update Progress State match_state='Enabled' image_id=${image_id}
201 # Check if the existing firmware is functional.
202 Pass Execution If ${software_inventory_record['functional']}
203 ... The existing ${image_version} firmware is already functional.
204