1030ee006SAshwini Chandrappa*** Settings *** 2030ee006SAshwini ChandrappaDocumentation This suite tests Timed Power On(TPO) feature via busctl command 3030ee006SAshwini Chandrappa... and verify the power status of the system. 4030ee006SAshwini Chandrappa... 5030ee006SAshwini Chandrappa... System can be scheduled to Power ON at a specified time by using this feature. 6030ee006SAshwini Chandrappa 7030ee006SAshwini Chandrappa 8030ee006SAshwini ChandrappaResource ../lib/boot_utils.robot 9030ee006SAshwini ChandrappaResource ../lib/openbmc_ffdc.robot 10030ee006SAshwini ChandrappaResource ../lib/bmc_redfish_resource.robot 11030ee006SAshwini Chandrappa 12030ee006SAshwini Chandrappa 13030ee006SAshwini ChandrappaSuite Setup Redfish.Login 14030ee006SAshwini ChandrappaSuite Teardown Redfish.Logout 15030ee006SAshwini ChandrappaTest Setup Test Setup Execution 16030ee006SAshwini ChandrappaTest Teardown Test Teardown Execution 17030ee006SAshwini Chandrappa 18030ee006SAshwini Chandrappa 19030ee006SAshwini Chandrappa*** Variables **** 20030ee006SAshwini Chandrappa 215654fbedSGeorge Keishing${CMD_ENABLE_TPO} busctl set-property xyz.openbmc_project.State.ScheduledHostTransition 22808eafc2SAndrew Geissler... /xyz/openbmc_project/scheduled/host0 xyz.openbmc_project.State.ScheduledHostTransition 235654fbedSGeorge Keishing... ScheduledTransition s "xyz.openbmc_project.State.Host.Transition.On" 245654fbedSGeorge Keishing 25030ee006SAshwini Chandrappa${CMD_SET_TPO_TIME} busctl set-property xyz.openbmc_project.State.ScheduledHostTransition 26808eafc2SAndrew Geissler... /xyz/openbmc_project/scheduled/host0 xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime t 27030ee006SAshwini Chandrappa 28030ee006SAshwini Chandrappa${CMD_GET_TPO_TIME} busctl get-property xyz.openbmc_project.State.ScheduledHostTransition 29808eafc2SAndrew Geissler... /xyz/openbmc_project/scheduled/host0 xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime 30030ee006SAshwini Chandrappa 315654fbedSGeorge Keishing# Time in seconds. 32030ee006SAshwini Chandrappa${TIMER_POWER_ON} 100 33030ee006SAshwini Chandrappa 34096cc070SGeorge Keishing# All current versions of the following distributions: 35096cc070SGeorge Keishing# - Red Hat Enterprise Linux 36096cc070SGeorge Keishing# - SUSE Linux Enterprise Server 37096cc070SGeorge Keishing# Tested on RHEL 8.4. 38096cc070SGeorge Keishing 39096cc070SGeorge Keishing# Shut down the system and schedule it to restart in 1 hour. 40096cc070SGeorge Keishing# User can input -v HOST_TIMER_POWER_ON:h24 ( e.g. 24 hours ) 41096cc070SGeorge Keishing${HOST_TIMER_POWER_ON} h1 42096cc070SGeorge Keishing${HOST_TIMED_POWER_ON_REQUEST} set_poweron_time -d ${HOST_TIMER_POWER_ON} -s 43030ee006SAshwini Chandrappa 44030ee006SAshwini Chandrappa*** Test Cases *** 45030ee006SAshwini Chandrappa 465654fbedSGeorge KeishingTest Timed Powered On Via BMC 475654fbedSGeorge Keishing [Documentation] Set time to power on host attribute ScheduledTime and expect 485654fbedSGeorge Keishing ... the system to boot on scheduled time. 495654fbedSGeorge Keishing [Tags] Test_Timed_Powered_On_Via_BMC 505654fbedSGeorge Keishing 515654fbedSGeorge Keishing # Make sure the host is powered off. 525654fbedSGeorge Keishing Redfish Power Off stack_mode=skip 535654fbedSGeorge Keishing 545654fbedSGeorge Keishing # Set Host transition to ON to enable TPO. 555654fbedSGeorge Keishing BMC Execute Command ${CMD_ENABLE_TPO} 56030ee006SAshwini Chandrappa 57030ee006SAshwini Chandrappa ${tpo_set_value}= Set Timer For Power ON 58030ee006SAshwini Chandrappa ${new_tpo_value}= Get Time Power ON Value 595654fbedSGeorge Keishing 60030ee006SAshwini Chandrappa Should Be Equal ${new_tpo_value} ${tpo_set_value} 615654fbedSGeorge Keishing ... msg=TPO time set mismatched. 625654fbedSGeorge Keishing 635654fbedSGeorge Keishing # Check if the system BootProgress state changed. If changed, it implies the 645654fbedSGeorge Keishing # system is powering on. Though we have set system to power on in 100 seconds 655654fbedSGeorge Keishing # since, the system boot sometime to change. 665654fbedSGeorge Keishing Wait Until Keyword Succeeds 10 min 20 sec Is Boot Progress Changed 675654fbedSGeorge Keishing 68096cc070SGeorge Keishing Log To Console BMC Scheduled Time Power on success. 69096cc070SGeorge Keishing 70096cc070SGeorge Keishing 71096cc070SGeorge KeishingTest Timed Powered On Via Host OS 72096cc070SGeorge Keishing [Documentation] Set time to power on host via service aids tool set_poweron_time 73096cc070SGeorge Keishing ... and expect the system to boot on scheduled time. 74096cc070SGeorge Keishing [Tags] Test_Timed_Powered_On_Via_Host_OS 75096cc070SGeorge Keishing 76096cc070SGeorge Keishing # Make sure the host is powered on and booted to host OS partition. 77096cc070SGeorge Keishing Redfish Power On 78096cc070SGeorge Keishing 79096cc070SGeorge Keishing ${stdout} ${stderr} ${rc}= OS Execute Command which set_poweron_time ignore_err=${0} 80096cc070SGeorge Keishing # Skip the test if the tool does not exist or error getting the tool. 81096cc070SGeorge Keishing Skip If ${rc} != ${0} INFO: ${stdout} Skip the test since the tool does not. Install and re-run. 82096cc070SGeorge Keishing 83096cc070SGeorge Keishing # Set Host transition to ON to enable TPO. 84096cc070SGeorge Keishing ${stdout} ${stderr} ${rc}= OS Execute Command ${HOST_TIMED_POWER_ON_REQUEST} ignore_err=${0} 85096cc070SGeorge Keishing 86096cc070SGeorge Keishing # Wait for host to Power off. 87096cc070SGeorge Keishing Wait Until Keyword Succeeds 45 min 30 sec Is BMC Standby 88096cc070SGeorge Keishing 89096cc070SGeorge Keishing Log To Console Power Off completed. 90096cc070SGeorge Keishing 91096cc070SGeorge Keishing # Note: The verification could more precise by checking date and set time. 92096cc070SGeorge Keishing 93096cc070SGeorge Keishing # Check if the system BootProgress state changed. If changed, it implies the 94096cc070SGeorge Keishing # system is powering on after user timer set and delta time to update BootProgress 95096cc070SGeorge Keishing # state by the state manager. 96096cc070SGeorge Keishing # ${HOST_TIMER_POWER_ON} is in <m/h/d/><time> format 97096cc070SGeorge Keishing # Example: h1 , logic to convert x[1:] -> 1 and x[:1] ->h to robot format 1 h. 98096cc070SGeorge Keishing 99096cc070SGeorge Keishing Log To Console Waiting for system to power on. 100096cc070SGeorge Keishing Wait Until Keyword Succeeds ${HOST_TIMER_POWER_ON[1:]} ${HOST_TIMER_POWER_ON[:1]} 30 sec 101096cc070SGeorge Keishing ... Is Boot Progress Changed 102096cc070SGeorge Keishing 103096cc070SGeorge Keishing Log To Console Host Scheduled Time Power on success. 104030ee006SAshwini Chandrappa 105030ee006SAshwini Chandrappa 106030ee006SAshwini Chandrappa*** Keywords *** 107030ee006SAshwini Chandrappa 108030ee006SAshwini ChandrappaTest Setup Execution 109030ee006SAshwini Chandrappa [Documentation] Do test case setup tasks. 110030ee006SAshwini Chandrappa 1115654fbedSGeorge Keishing Redfish.Login 112f515e3eeSdnirmala Set Power Policy For TPO Automatic 113f515e3eeSdnirmala 114f515e3eeSdnirmala 115f515e3eeSdnirmalaSet Power Policy For TPO 116f515e3eeSdnirmala [Documentation] Change 'server power policy' option to automatic. 117f515e3eeSdnirmala [Arguments] ${power_policy_mode} 118f515e3eeSdnirmala 119f515e3eeSdnirmala # Description of argument(s): 120f515e3eeSdnirmala # power_policy_mode BIOS attribute value. E.g. "Stay On", "Automatic". 121f515e3eeSdnirmala 122c32434a3SYi Hu Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID}/Bios/Settings 123f515e3eeSdnirmala ... body={"Attributes":{"pvm_system_power_off_policy": "${power_policy_mode}"}} 124f515e3eeSdnirmala ... valid_status_codes=[${HTTP_OK}] 125030ee006SAshwini Chandrappa 126030ee006SAshwini Chandrappa 127030ee006SAshwini ChandrappaTest Teardown Execution 128030ee006SAshwini Chandrappa [Documentation] Do the test teardown 129030ee006SAshwini Chandrappa 130030ee006SAshwini Chandrappa FFDC On Test Case Fail 131030ee006SAshwini Chandrappa 132030ee006SAshwini Chandrappa 133030ee006SAshwini ChandrappaSet Timer For Power ON 134030ee006SAshwini Chandrappa [Documentation] Set the time for power ON with given value. 135030ee006SAshwini Chandrappa 136030ee006SAshwini Chandrappa ${current_bmc_time}= BMC Execute Command date +%s 137030ee006SAshwini Chandrappa ${time_set}= Evaluate ${current_bmc_time[0]} + ${TIMER_POWER_ON} 138030ee006SAshwini Chandrappa BMC Execute Command ${CMD_SET_TPO_TIME} ${time_set} 139030ee006SAshwini Chandrappa 140*409df05dSGeorge Keishing RETURN ${time_set} 141030ee006SAshwini Chandrappa 142030ee006SAshwini Chandrappa 143030ee006SAshwini ChandrappaGet Time Power ON Value 144030ee006SAshwini Chandrappa [Documentation] Returns time power ON value. 145030ee006SAshwini Chandrappa 146030ee006SAshwini Chandrappa ${timer_value}= BMC Execute Command ${CMD_GET_TPO_TIME} 147030ee006SAshwini Chandrappa @{return_value}= Split String ${timer_value[0]} 148030ee006SAshwini Chandrappa ${return_value}= Evaluate ${return_value}[1] 149030ee006SAshwini Chandrappa 150030ee006SAshwini Chandrappa # BMC command returns integer value. 151*409df05dSGeorge Keishing RETURN ${return_value} 152