blob: 1292d6a2cbec1701dbae6153f2a089bedac88667 [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
George Keishingcba6d422019-07-09 15:01:59 -050019Library ../../lib/code_update_utils.py
20Library ../../lib/gen_robot_valid.py
George Keishingcfa950c2019-07-18 12:46:46 -050021Library ../../lib/tftp_update_utils.py
George Keishingcba6d422019-07-09 15:01:59 -050022
23Suite Setup Suite Setup Execution
24Suite Teardown Redfish.Logout
George Keishingcfa950c2019-07-18 12:46:46 -050025Test Setup Run Keywords Redfish Power Off stack_mode=skip quiet=1 AND Redfish.Login
George Keishingcba6d422019-07-09 15:01:59 -050026Test Teardown FFDC On Test Case Fail
27
28Force Tags tftp_update
29
30*** Test Cases ***
31
32TFTP Download Install With ApplyTime OnReset Policy
33 [Documentation] Download image to BMC using TFTP with OnReset policy and verify installation.
34 [Tags] TFTP_Download_Install_With_ApplyTime_OnReset_Policy
George Keishingcfa950c2019-07-18 12:46:46 -050035 [Template] TFTP Download Install
George Keishingcba6d422019-07-09 15:01:59 -050036
George Keishingcfa950c2019-07-18 12:46:46 -050037 # policy
38 OnReset
39
40
41TFTP Download Install With ApplyTime Immediate Policy
42 [Documentation] Download image to BMC using TFTP with Immediate policy and verify installation.
43 [Tags] TFTP_Download_Install_With_ApplyTime_Immediate_Policy
44 [Template] TFTP Download Install
45
46 # policy
47 Immediate
48
49
50ImageURI Download Install With ApplyTime OnReset Policy
51 [Documentation] Download image to BMC using ImageURI with OnReset policy and verify installation.
52 [Tags] ImageURI_Download_Install_With_ApplyTime_OnReset_Policy
53 [Template] ImageURI Download Install
54
55 # policy
56 OnReset
57
58
59ImageURI Download Install With ApplyTime Immediate Policy
60 [Documentation] Download image to BMC using ImageURI with Immediate policy and verify installation.
61 [Tags] ImageURI_Download_Install_With_ApplyTime_Immediate_Policy
62 [Template] ImageURI Download Install
63
64 # policy
65 Immediate
66
Sushil Singhf953d742019-11-08 10:09:44 -060067
68Install Same Image Two Times
69 [Documentation] Install firmware image and re-try using the same image which should fail.
70 [Tags] Install_Same_Image_Two_Times
71 [Template] Same Firmware Install Two Times
72
73 # policy
74 Immediate
75
76
George Keishingcfa950c2019-07-18 12:46:46 -050077*** Keywords ***
78
79Suite Setup Execution
80 [Documentation] Do the suite setup.
81
82 Redfish.Login
Michael Walshe7edb222019-08-19 17:39:38 -050083 Valid Value TFTP_SERVER
84 Valid Value IMAGE_FILE_NAME
George Keishingcfa950c2019-07-18 12:46:46 -050085
86
87TFTP Download Install
88 [Documentation] Download image to BMC using TFTP with ApplyTime policy and verify installation.
89 [Arguments] ${policy}
90
91 # Description of argument(s):
92 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
93
94 ${state}= Get Pre Reboot State
95 Rprint Vars state
96
97 Set ApplyTime policy=${policy}
George Keishingcba6d422019-07-09 15:01:59 -050098
99 # Download image from TFTP server to BMC.
100 Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
101 ... body={"TransferProtocol" : "TFTP", "ImageURI" : "${TFTP_SERVER}/${IMAGE_FILE_NAME}"}
102
103 # Wait for image tar file to download complete.
104 ${image_id}= Wait Until Keyword Succeeds 60 sec 10 sec Get Latest Image ID
105 Rprint Vars image_id
106
107 # Let the image get extracted and it should not fail.
108 Sleep 5s
109 Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id}
110
111 # Get image version currently installation in progress.
112 ${install_version}= Get Firmware Image Version image_id=${image_id}
113 Rprint Vars install_version
114
115 Check Image Update Progress State match_state='Updating' image_id=${image_id}
116
117 # Wait for the image to install complete.
George Keishingcfa950c2019-07-18 12:46:46 -0500118 Wait Until Keyword Succeeds 8 min 15 sec
George Keishingcba6d422019-07-09 15:01:59 -0500119 ... Check Image Update Progress State match_state='Enabled' image_id=${image_id}
120
George Keishingcfa950c2019-07-18 12:46:46 -0500121 Reboot And Wait For BMC Standby policy=${policy} start_boot_seconds=${state['epoch_seconds']}
George Keishingcba6d422019-07-09 15:01:59 -0500122
123 # Verify the image is installed and functional.
124 ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g'
125 ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd}
Michael Walshe7edb222019-08-19 17:39:38 -0500126 Valid Value functional_version valid_values=['${install_version}']
George Keishingcba6d422019-07-09 15:01:59 -0500127 Rprint Vars functional_version
128
129
George Keishingcfa950c2019-07-18 12:46:46 -0500130ImageURI Download Install
131 [Documentation] Download image to BMC using ImageURI with ApplyTime policy and verify installation.
132 [Arguments] ${policy}
George Keishingcba6d422019-07-09 15:01:59 -0500133
George Keishingcfa950c2019-07-18 12:46:46 -0500134 # Description of argument(s):
135 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
George Keishingcba6d422019-07-09 15:01:59 -0500136
George Keishingcfa950c2019-07-18 12:46:46 -0500137 ${state}= Get Pre Reboot State
138 Rprint Vars state
139
140 Set ApplyTime policy=${policy}
141
142 # Download image from TFTP server via ImageURI to BMC.
143 Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
144 ... body={"ImageURI": "tftp://${TFTP_SERVER}/${IMAGE_FILE_NAME}"}
145
146 # Wait for image tar file download to complete.
147 ${image_id}= Wait Until Keyword Succeeds 60 sec 10 sec Get Latest Image ID
148 Rprint Vars image_id
149
150 # Let the image get extracted and it should not fail.
151 Sleep 5s
152 Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id}
153
154 ${install_version}= Get Firmware Image Version image_id=${image_id}
155 Rprint Vars install_version
156
157 Check Image Update Progress State match_state='Updating' image_id=${image_id}
158
159 # Wait for the image to install complete.
160 Wait Until Keyword Succeeds 8 min 15 sec
161 ... Check Image Update Progress State match_state='Enabled' image_id=${image_id}
162
163 Reboot And Wait For BMC Standby policy=${policy} start_boot_seconds=${state['epoch_seconds']}
164
165 # Verify the image is installed and functional.
166 ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g'
167 ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd}
Michael Walshe7edb222019-08-19 17:39:38 -0500168 Valid Value functional_version valid_values=['${install_version}']
George Keishingcfa950c2019-07-18 12:46:46 -0500169 Rprint Vars functional_version
170
171
Sushil Singhf953d742019-11-08 10:09:44 -0600172Same Firmware Install Two Times
173 [Documentation] Download same image twice to BMC via ImageURI. Second attempt would fail.
174 [Arguments] ${apply_time} ${tftp_server}=${TFTP_SERVER} ${image_file_name}=${IMAGE_FILE_NAME}
175
176 # Description of argument(s):
177 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate").
178 # tftp_server Server IP.
179 # image_file_name Image file name.
180
181 ImageURI Download Install ${apply_time}
182
183 # Download image from TFTP server via ImageURI to BMC.
184 Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
185 ... body={"ImageURI": "tftp://${tftp_server}/${image_file_name}"}
186
187 ${image_version}= Get Image Version From TFTP Server ${tftp_server} ${image_file_name}
188 ${software_inventory_record}= Get Software Inventory State By Version
189 ... ${image_version}
190 Rprint Vars software_inventory_record
191
192 ${image_id}= Wait Until Keyword Succeeds 60 sec 10 sec Get Latest Image ID
193 Rprint Vars image_id
194
195 Check Image Update Progress State match_state='Enabled' image_id=${image_id}
196 # Check if the existing firmware is functional.
197 Pass Execution If ${software_inventory_record['functional']}
198 ... The existing ${image_version} firmware is already functional.
199
200
George Keishingcfa950c2019-07-18 12:46:46 -0500201Reboot And Wait For BMC Standby
202 [Documentation] Reboot or wait for BMC standby post reboot.
203 [Arguments] ${policy} ${start_boot_seconds}
204
205 # Description of argument(s):
206 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
207 # start_boot_seconds See 'Wait For Reboot' for details.
208
209 Run Keyword If '${policy}' == 'OnReset'
210 ... Redfish OBMC Reboot (off)
211 ... ELSE
212 ... Wait For Reboot start_boot_seconds=${start_boot_seconds}