1cba6d420SGeorge Keishing*** Settings *** 2cba6d420SGeorge KeishingDocumentation Firmware image (BMC and Host) upload test using TFTP protocol. 3cba6d420SGeorge Keishing 4cba6d420SGeorge Keishing# Test Parameters: 5cba6d420SGeorge Keishing# TFTP_SERVER The TFTP server host name or IP address. 6cba6d420SGeorge Keishing# IMAGE_FILE_NAME The BMC or Host image file name. 7cba6d420SGeorge Keishing# 8cba6d420SGeorge Keishing# Firmware update states: 9cba6d420SGeorge Keishing# Enabled -> Image is installed and either functional or active. 10cba6d420SGeorge Keishing# Disabled -> Image installation failed or ready for activation. 11cba6d420SGeorge Keishing# Updating -> Image installation currently in progress. 12cba6d420SGeorge Keishing 13cba6d420SGeorge KeishingResource ../../lib/resource.robot 14cba6d420SGeorge KeishingResource ../../lib/boot_utils.robot 15cba6d420SGeorge KeishingResource ../../lib/bmc_redfish_resource.robot 16cba6d420SGeorge KeishingResource ../../lib/openbmc_ffdc.robot 17cba6d420SGeorge KeishingResource ../../lib/code_update_utils.robot 18f953d74aSSushil SinghResource ../../lib/redfish_code_update_utils.robot 198033d663SSushil SinghResource ../../lib/utils.robot 20cba6d420SGeorge KeishingLibrary ../../lib/code_update_utils.py 21cba6d420SGeorge KeishingLibrary ../../lib/gen_robot_valid.py 22cfa950c7SGeorge KeishingLibrary ../../lib/tftp_update_utils.py 23cba6d420SGeorge Keishing 24cba6d420SGeorge KeishingSuite Setup Suite Setup Execution 25cba6d420SGeorge KeishingSuite Teardown Redfish.Logout 26cfa950c7SGeorge KeishingTest Setup Run Keywords Redfish Power Off stack_mode=skip quiet=1 AND Redfish.Login 27cba6d420SGeorge KeishingTest Teardown FFDC On Test Case Fail 28cba6d420SGeorge Keishing 29*6fb70d98SMatt FischerTest Tags Firmware_Tftp_Upload_Image 30cba6d420SGeorge Keishing 31cba6d420SGeorge Keishing*** Test Cases *** 32cba6d420SGeorge Keishing 33cba6d420SGeorge KeishingTFTP Download Install With ApplyTime OnReset Policy 34cba6d420SGeorge Keishing [Documentation] Download image to BMC using TFTP with OnReset policy and verify installation. 35cba6d420SGeorge Keishing [Tags] TFTP_Download_Install_With_ApplyTime_OnReset_Policy 36cfa950c7SGeorge Keishing [Template] TFTP Download Install 37cba6d420SGeorge Keishing 38cfa950c7SGeorge Keishing # policy 39cfa950c7SGeorge Keishing OnReset 40cfa950c7SGeorge Keishing 41cfa950c7SGeorge Keishing 42cfa950c7SGeorge KeishingTFTP Download Install With ApplyTime Immediate Policy 43cfa950c7SGeorge Keishing [Documentation] Download image to BMC using TFTP with Immediate policy and verify installation. 44cfa950c7SGeorge Keishing [Tags] TFTP_Download_Install_With_ApplyTime_Immediate_Policy 45cfa950c7SGeorge Keishing [Template] TFTP Download Install 46cfa950c7SGeorge Keishing 47cfa950c7SGeorge Keishing # policy 48cfa950c7SGeorge Keishing Immediate 49cfa950c7SGeorge Keishing 50cfa950c7SGeorge Keishing 51cfa950c7SGeorge KeishingImageURI Download Install With ApplyTime OnReset Policy 52cfa950c7SGeorge Keishing [Documentation] Download image to BMC using ImageURI with OnReset policy and verify installation. 53cfa950c7SGeorge Keishing [Tags] ImageURI_Download_Install_With_ApplyTime_OnReset_Policy 54cfa950c7SGeorge Keishing [Template] ImageURI Download Install 55cfa950c7SGeorge Keishing 56cfa950c7SGeorge Keishing # policy 57cfa950c7SGeorge Keishing OnReset 58cfa950c7SGeorge Keishing 59cfa950c7SGeorge Keishing 60cfa950c7SGeorge KeishingImageURI Download Install With ApplyTime Immediate Policy 61cfa950c7SGeorge Keishing [Documentation] Download image to BMC using ImageURI with Immediate policy and verify installation. 62cfa950c7SGeorge Keishing [Tags] ImageURI_Download_Install_With_ApplyTime_Immediate_Policy 63cfa950c7SGeorge Keishing [Template] ImageURI Download Install 64cfa950c7SGeorge Keishing 65cfa950c7SGeorge Keishing # policy 66cfa950c7SGeorge Keishing Immediate 67cfa950c7SGeorge Keishing 68f953d74aSSushil Singh 69f953d74aSSushil SinghInstall Same Image Two Times 70f953d74aSSushil Singh [Documentation] Install firmware image and re-try using the same image which should fail. 71f953d74aSSushil Singh [Tags] Install_Same_Image_Two_Times 72f953d74aSSushil Singh [Template] Same Firmware Install Two Times 73f953d74aSSushil Singh 74f953d74aSSushil Singh # policy 75f953d74aSSushil Singh Immediate 76f953d74aSSushil Singh 77f953d74aSSushil Singh 78cfa950c7SGeorge Keishing*** Keywords *** 79cfa950c7SGeorge Keishing 80cfa950c7SGeorge KeishingSuite Setup Execution 81cfa950c7SGeorge Keishing [Documentation] Do the suite setup. 82cfa950c7SGeorge Keishing 83cfa950c7SGeorge Keishing Redfish.Login 84e7edb22cSMichael Walsh Valid Value TFTP_SERVER 85e7edb22cSMichael Walsh Valid Value IMAGE_FILE_NAME 86cfa950c7SGeorge Keishing 87cfa950c7SGeorge Keishing 88cfa950c7SGeorge KeishingTFTP Download Install 89cfa950c7SGeorge Keishing [Documentation] Download image to BMC using TFTP with ApplyTime policy and verify installation. 90cfa950c7SGeorge Keishing [Arguments] ${policy} 91cfa950c7SGeorge Keishing 92cfa950c7SGeorge Keishing # Description of argument(s): 93cfa950c7SGeorge Keishing # policy ApplyTime allowed values (e.g. "OnReset", "Immediate"). 94cfa950c7SGeorge Keishing 958033d663SSushil Singh ${post_code_update_actions}= Get Post Boot Action 96cfa950c7SGeorge Keishing ${state}= Get Pre Reboot State 97cfa950c7SGeorge Keishing Rprint Vars state 98cfa950c7SGeorge Keishing 99cfa950c7SGeorge Keishing Set ApplyTime policy=${policy} 100cba6d420SGeorge Keishing 101cba6d420SGeorge Keishing # Download image from TFTP server to BMC. 102cba6d420SGeorge Keishing Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate 103cba6d420SGeorge Keishing ... body={"TransferProtocol" : "TFTP", "ImageURI" : "${TFTP_SERVER}/${IMAGE_FILE_NAME}"} 104a70d5169SSushil Singh ... valid_status_codes=[${HTTP_OK}, ${HTTP_ACCEPTED}] 105cba6d420SGeorge Keishing 106cba6d420SGeorge Keishing # Wait for image tar file to download complete. 107827881e2SSushil Singh ${image_id}= Wait Until Keyword Succeeds 180 sec 10 sec Get Latest Image ID 108cba6d420SGeorge Keishing Rprint Vars image_id 109cba6d420SGeorge Keishing 110cba6d420SGeorge Keishing # Let the image get extracted and it should not fail. 111cba6d420SGeorge Keishing Sleep 5s 112cba6d420SGeorge Keishing Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id} 113cba6d420SGeorge Keishing 114cba6d420SGeorge Keishing # Get image version currently installation in progress. 115cba6d420SGeorge Keishing ${install_version}= Get Firmware Image Version image_id=${image_id} 116cba6d420SGeorge Keishing Rprint Vars install_version 117cba6d420SGeorge Keishing 118cba6d420SGeorge Keishing Check Image Update Progress State match_state='Updating' image_id=${image_id} 119cba6d420SGeorge Keishing 120cba6d420SGeorge Keishing # Wait for the image to install complete. 121cfa950c7SGeorge Keishing Wait Until Keyword Succeeds 8 min 15 sec 122cba6d420SGeorge Keishing ... Check Image Update Progress State match_state='Enabled' image_id=${image_id} 123cba6d420SGeorge Keishing 1248033d663SSushil Singh Run Key ${post_code_update_actions['BMC image']['${policy}']} 125cba6d420SGeorge Keishing 126cba6d420SGeorge Keishing # Verify the image is installed and functional. 127cba6d420SGeorge Keishing ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g' 128cba6d420SGeorge Keishing ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd} 129e7edb22cSMichael Walsh Valid Value functional_version valid_values=['${install_version}'] 130cba6d420SGeorge Keishing Rprint Vars functional_version 131cba6d420SGeorge Keishing 132cba6d420SGeorge Keishing 133cfa950c7SGeorge KeishingImageURI Download Install 134cfa950c7SGeorge Keishing [Documentation] Download image to BMC using ImageURI with ApplyTime policy and verify installation. 135cfa950c7SGeorge Keishing [Arguments] ${policy} 136cba6d420SGeorge Keishing 137cfa950c7SGeorge Keishing # Description of argument(s): 138cfa950c7SGeorge Keishing # policy ApplyTime allowed values (e.g. "OnReset", "Immediate"). 139cba6d420SGeorge Keishing 1408033d663SSushil Singh ${post_code_update_actions}= Get Post Boot Action 141cfa950c7SGeorge Keishing ${state}= Get Pre Reboot State 142cfa950c7SGeorge Keishing Rprint Vars state 143cfa950c7SGeorge Keishing 144cfa950c7SGeorge Keishing Set ApplyTime policy=${policy} 145cfa950c7SGeorge Keishing 146cfa950c7SGeorge Keishing # Download image from TFTP server via ImageURI to BMC. 147cfa950c7SGeorge Keishing Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate 148cfa950c7SGeorge Keishing ... body={"ImageURI": "tftp://${TFTP_SERVER}/${IMAGE_FILE_NAME}"} 149a70d5169SSushil Singh ... valid_status_codes=[${HTTP_OK}, ${HTTP_ACCEPTED}] 150cfa950c7SGeorge Keishing 151cfa950c7SGeorge Keishing # Wait for image tar file download to complete. 152827881e2SSushil Singh ${image_id}= Wait Until Keyword Succeeds 180 sec 10 sec Get Latest Image ID 153cfa950c7SGeorge Keishing Rprint Vars image_id 154cfa950c7SGeorge Keishing 155cfa950c7SGeorge Keishing # Let the image get extracted and it should not fail. 156cfa950c7SGeorge Keishing Sleep 5s 157cfa950c7SGeorge Keishing Check Image Update Progress State match_state='Disabled', 'Updating' image_id=${image_id} 158cfa950c7SGeorge Keishing 159cfa950c7SGeorge Keishing ${install_version}= Get Firmware Image Version image_id=${image_id} 160cfa950c7SGeorge Keishing Rprint Vars install_version 161cfa950c7SGeorge Keishing 162cfa950c7SGeorge Keishing Check Image Update Progress State match_state='Updating' image_id=${image_id} 163cfa950c7SGeorge Keishing 164cfa950c7SGeorge Keishing # Wait for the image to install complete. 165cfa950c7SGeorge Keishing Wait Until Keyword Succeeds 8 min 15 sec 166cfa950c7SGeorge Keishing ... Check Image Update Progress State match_state='Enabled' image_id=${image_id} 167cfa950c7SGeorge Keishing 1688033d663SSushil Singh Run Key ${post_code_update_actions['BMC image']['${policy}']} 169cfa950c7SGeorge Keishing 170cfa950c7SGeorge Keishing # Verify the image is installed and functional. 171cfa950c7SGeorge Keishing ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' | sed 's/"//g' 172cfa950c7SGeorge Keishing ${functional_version} ${stderr} ${rc}= BMC Execute Command ${cmd} 173e7edb22cSMichael Walsh Valid Value functional_version valid_values=['${install_version}'] 174cfa950c7SGeorge Keishing Rprint Vars functional_version 175cfa950c7SGeorge Keishing 176cfa950c7SGeorge Keishing 177f953d74aSSushil SinghSame Firmware Install Two Times 178f953d74aSSushil Singh [Documentation] Download same image twice to BMC via ImageURI. Second attempt would fail. 179f953d74aSSushil Singh [Arguments] ${apply_time} ${tftp_server}=${TFTP_SERVER} ${image_file_name}=${IMAGE_FILE_NAME} 180f953d74aSSushil Singh 181f953d74aSSushil Singh # Description of argument(s): 182f953d74aSSushil Singh # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate"). 183f953d74aSSushil Singh # tftp_server Server IP. 184f953d74aSSushil Singh # image_file_name Image file name. 185f953d74aSSushil Singh 186f953d74aSSushil Singh ImageURI Download Install ${apply_time} 187f953d74aSSushil Singh 188f953d74aSSushil Singh # Download image from TFTP server via ImageURI to BMC. 189f953d74aSSushil Singh Redfish.Post /redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate 190f953d74aSSushil Singh ... body={"ImageURI": "tftp://${tftp_server}/${image_file_name}"} 191f953d74aSSushil Singh 192f953d74aSSushil Singh ${image_version}= Get Image Version From TFTP Server ${tftp_server} ${image_file_name} 193f953d74aSSushil Singh ${software_inventory_record}= Get Software Inventory State By Version 194f953d74aSSushil Singh ... ${image_version} 195f953d74aSSushil Singh Rprint Vars software_inventory_record 196f953d74aSSushil Singh 197827881e2SSushil Singh ${image_id}= Wait Until Keyword Succeeds 180 sec 10 sec Get Latest Image ID 198f953d74aSSushil Singh Rprint Vars image_id 199f953d74aSSushil Singh 200f953d74aSSushil Singh Check Image Update Progress State match_state='Enabled' image_id=${image_id} 201f953d74aSSushil Singh # Check if the existing firmware is functional. 202f953d74aSSushil Singh Pass Execution If ${software_inventory_record['functional']} 203f953d74aSSushil Singh ... The existing ${image_version} firmware is already functional. 204f953d74aSSushil Singh 205