blob: 7680d8399ba40d826beffe314854b7ed9fa53758 [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
29Force Tags tftp_update
30
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}"}
104
105 # Wait for image tar file to download complete.
Sushil Singh827881e2020-02-18 05:32:18 -0600106 ${image_id}= Wait Until Keyword Succeeds 180 sec 10 sec Get Latest Image ID
George Keishingcba6d422019-07-09 15:01:59 -0500107 Rprint Vars image_id
108
109 # Let the image get extracted and it should not fail.
110 Sleep 5s
111 Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id}
112
113 # Get image version currently installation in progress.
114 ${install_version}= Get Firmware Image Version image_id=${image_id}
115 Rprint Vars install_version
116
117 Check Image Update Progress State match_state='Updating' image_id=${image_id}
118
119 # Wait for the image to install complete.
George Keishingcfa950c2019-07-18 12:46:46 -0500120 Wait Until Keyword Succeeds 8 min 15 sec
George Keishingcba6d422019-07-09 15:01:59 -0500121 ... Check Image Update Progress State match_state='Enabled' image_id=${image_id}
122
Sushil Singh8033d662020-02-10 07:19:25 -0600123 Run Key ${post_code_update_actions['BMC image']['${policy}']}
George Keishingcba6d422019-07-09 15:01:59 -0500124
125 # Verify the image is installed and functional.
126 ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g'
127 ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd}
Michael Walshe7edb222019-08-19 17:39:38 -0500128 Valid Value functional_version valid_values=['${install_version}']
George Keishingcba6d422019-07-09 15:01:59 -0500129 Rprint Vars functional_version
130
131
George Keishingcfa950c2019-07-18 12:46:46 -0500132ImageURI Download Install
133 [Documentation] Download image to BMC using ImageURI with ApplyTime policy and verify installation.
134 [Arguments] ${policy}
George Keishingcba6d422019-07-09 15:01:59 -0500135
George Keishingcfa950c2019-07-18 12:46:46 -0500136 # Description of argument(s):
137 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
George Keishingcba6d422019-07-09 15:01:59 -0500138
Sushil Singh8033d662020-02-10 07:19:25 -0600139 ${post_code_update_actions}= Get Post Boot Action
George Keishingcfa950c2019-07-18 12:46:46 -0500140 ${state}= Get Pre Reboot State
141 Rprint Vars state
142
143 Set ApplyTime policy=${policy}
144
145 # Download image from TFTP server via ImageURI to BMC.
146 Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
147 ... body={"ImageURI": "tftp://${TFTP_SERVER}/${IMAGE_FILE_NAME}"}
148
149 # Wait for image tar file download to complete.
Sushil Singh827881e2020-02-18 05:32:18 -0600150 ${image_id}= Wait Until Keyword Succeeds 180 sec 10 sec Get Latest Image ID
George Keishingcfa950c2019-07-18 12:46:46 -0500151 Rprint Vars image_id
152
153 # Let the image get extracted and it should not fail.
154 Sleep 5s
155 Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id}
156
157 ${install_version}= Get Firmware Image Version image_id=${image_id}
158 Rprint Vars install_version
159
160 Check Image Update Progress State match_state='Updating' image_id=${image_id}
161
162 # Wait for the image to install complete.
163 Wait Until Keyword Succeeds 8 min 15 sec
164 ... Check Image Update Progress State match_state='Enabled' image_id=${image_id}
165
Sushil Singh8033d662020-02-10 07:19:25 -0600166 Run Key ${post_code_update_actions['BMC image']['${policy}']}
George Keishingcfa950c2019-07-18 12:46:46 -0500167
168 # Verify the image is installed and functional.
169 ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g'
170 ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd}
Michael Walshe7edb222019-08-19 17:39:38 -0500171 Valid Value functional_version valid_values=['${install_version}']
George Keishingcfa950c2019-07-18 12:46:46 -0500172 Rprint Vars functional_version
173
174
Sushil Singhf953d742019-11-08 10:09:44 -0600175Same Firmware Install Two Times
176 [Documentation] Download same image twice to BMC via ImageURI. Second attempt would fail.
177 [Arguments] ${apply_time} ${tftp_server}=${TFTP_SERVER} ${image_file_name}=${IMAGE_FILE_NAME}
178
179 # Description of argument(s):
180 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate").
181 # tftp_server Server IP.
182 # image_file_name Image file name.
183
184 ImageURI Download Install ${apply_time}
185
186 # Download image from TFTP server via ImageURI to BMC.
187 Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate
188 ... body={"ImageURI": "tftp://${tftp_server}/${image_file_name}"}
189
190 ${image_version}= Get Image Version From TFTP Server ${tftp_server} ${image_file_name}
191 ${software_inventory_record}= Get Software Inventory State By Version
192 ... ${image_version}
193 Rprint Vars software_inventory_record
194
Sushil Singh827881e2020-02-18 05:32:18 -0600195 ${image_id}= Wait Until Keyword Succeeds 180 sec 10 sec Get Latest Image ID
Sushil Singhf953d742019-11-08 10:09:44 -0600196 Rprint Vars image_id
197
198 Check Image Update Progress State match_state='Enabled' image_id=${image_id}
199 # Check if the existing firmware is functional.
200 Pass Execution If ${software_inventory_record['functional']}
201 ... The existing ${image_version} firmware is already functional.
202