Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This suite tests Timed Power On(TPO) feature via busctl command |
| 3 | ... and verify the power status of the system. |
| 4 | ... |
| 5 | ... System can be scheduled to Power ON at a specified time by using this feature. |
| 6 | |
| 7 | |
| 8 | Resource ../lib/boot_utils.robot |
| 9 | Resource ../lib/openbmc_ffdc.robot |
| 10 | Resource ../lib/bmc_redfish_resource.robot |
| 11 | |
| 12 | |
| 13 | Suite Setup Redfish.Login |
| 14 | Suite Teardown Redfish.Logout |
| 15 | Test Setup Test Setup Execution |
| 16 | Test Teardown Test Teardown Execution |
| 17 | |
Sridevi Ramesh | 8966617 | 2025-09-28 04:15:29 -0500 | [diff] [blame] | 18 | Test Tags Test_Timed_Power_On |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 19 | |
| 20 | *** Variables **** |
| 21 | |
George Keishing | 5654fbe | 2022-07-13 06:48:55 -0500 | [diff] [blame] | 22 | ${CMD_ENABLE_TPO} busctl set-property xyz.openbmc_project.State.ScheduledHostTransition |
Andrew Geissler | 808eafc | 2023-03-02 14:04:15 -0600 | [diff] [blame] | 23 | ... /xyz/openbmc_project/scheduled/host0 xyz.openbmc_project.State.ScheduledHostTransition |
George Keishing | 5654fbe | 2022-07-13 06:48:55 -0500 | [diff] [blame] | 24 | ... ScheduledTransition s "xyz.openbmc_project.State.Host.Transition.On" |
| 25 | |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 26 | ${CMD_SET_TPO_TIME} busctl set-property xyz.openbmc_project.State.ScheduledHostTransition |
Andrew Geissler | 808eafc | 2023-03-02 14:04:15 -0600 | [diff] [blame] | 27 | ... /xyz/openbmc_project/scheduled/host0 xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime t |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 28 | |
| 29 | ${CMD_GET_TPO_TIME} busctl get-property xyz.openbmc_project.State.ScheduledHostTransition |
Andrew Geissler | 808eafc | 2023-03-02 14:04:15 -0600 | [diff] [blame] | 30 | ... /xyz/openbmc_project/scheduled/host0 xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 31 | |
George Keishing | 5654fbe | 2022-07-13 06:48:55 -0500 | [diff] [blame] | 32 | # Time in seconds. |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 33 | ${TIMER_POWER_ON} 100 |
| 34 | |
George Keishing | 096cc07 | 2022-07-13 11:57:15 -0500 | [diff] [blame] | 35 | # All current versions of the following distributions: |
| 36 | # - Red Hat Enterprise Linux |
| 37 | # - SUSE Linux Enterprise Server |
| 38 | # Tested on RHEL 8.4. |
| 39 | |
| 40 | # Shut down the system and schedule it to restart in 1 hour. |
| 41 | # User can input -v HOST_TIMER_POWER_ON:h24 ( e.g. 24 hours ) |
| 42 | ${HOST_TIMER_POWER_ON} h1 |
| 43 | ${HOST_TIMED_POWER_ON_REQUEST} set_poweron_time -d ${HOST_TIMER_POWER_ON} -s |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 44 | |
| 45 | *** Test Cases *** |
| 46 | |
George Keishing | 5654fbe | 2022-07-13 06:48:55 -0500 | [diff] [blame] | 47 | Test Timed Powered On Via BMC |
| 48 | [Documentation] Set time to power on host attribute ScheduledTime and expect |
| 49 | ... the system to boot on scheduled time. |
| 50 | [Tags] Test_Timed_Powered_On_Via_BMC |
| 51 | |
| 52 | # Make sure the host is powered off. |
| 53 | Redfish Power Off stack_mode=skip |
| 54 | |
| 55 | # Set Host transition to ON to enable TPO. |
| 56 | BMC Execute Command ${CMD_ENABLE_TPO} |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 57 | |
| 58 | ${tpo_set_value}= Set Timer For Power ON |
| 59 | ${new_tpo_value}= Get Time Power ON Value |
George Keishing | 5654fbe | 2022-07-13 06:48:55 -0500 | [diff] [blame] | 60 | |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 61 | Should Be Equal ${new_tpo_value} ${tpo_set_value} |
George Keishing | 5654fbe | 2022-07-13 06:48:55 -0500 | [diff] [blame] | 62 | ... msg=TPO time set mismatched. |
| 63 | |
| 64 | # Check if the system BootProgress state changed. If changed, it implies the |
| 65 | # system is powering on. Though we have set system to power on in 100 seconds |
| 66 | # since, the system boot sometime to change. |
| 67 | Wait Until Keyword Succeeds 10 min 20 sec Is Boot Progress Changed |
| 68 | |
George Keishing | 096cc07 | 2022-07-13 11:57:15 -0500 | [diff] [blame] | 69 | Log To Console BMC Scheduled Time Power on success. |
| 70 | |
| 71 | |
| 72 | Test Timed Powered On Via Host OS |
| 73 | [Documentation] Set time to power on host via service aids tool set_poweron_time |
| 74 | ... and expect the system to boot on scheduled time. |
| 75 | [Tags] Test_Timed_Powered_On_Via_Host_OS |
| 76 | |
| 77 | # Make sure the host is powered on and booted to host OS partition. |
| 78 | Redfish Power On |
| 79 | |
| 80 | ${stdout} ${stderr} ${rc}= OS Execute Command which set_poweron_time ignore_err=${0} |
| 81 | # Skip the test if the tool does not exist or error getting the tool. |
| 82 | Skip If ${rc} != ${0} INFO: ${stdout} Skip the test since the tool does not. Install and re-run. |
| 83 | |
| 84 | # Set Host transition to ON to enable TPO. |
| 85 | ${stdout} ${stderr} ${rc}= OS Execute Command ${HOST_TIMED_POWER_ON_REQUEST} ignore_err=${0} |
| 86 | |
| 87 | # Wait for host to Power off. |
| 88 | Wait Until Keyword Succeeds 45 min 30 sec Is BMC Standby |
| 89 | |
| 90 | Log To Console Power Off completed. |
| 91 | |
| 92 | # Note: The verification could more precise by checking date and set time. |
| 93 | |
| 94 | # Check if the system BootProgress state changed. If changed, it implies the |
| 95 | # system is powering on after user timer set and delta time to update BootProgress |
| 96 | # state by the state manager. |
| 97 | # ${HOST_TIMER_POWER_ON} is in <m/h/d/><time> format |
| 98 | # Example: h1 , logic to convert x[1:] -> 1 and x[:1] ->h to robot format 1 h. |
| 99 | |
| 100 | Log To Console Waiting for system to power on. |
| 101 | Wait Until Keyword Succeeds ${HOST_TIMER_POWER_ON[1:]} ${HOST_TIMER_POWER_ON[:1]} 30 sec |
| 102 | ... Is Boot Progress Changed |
| 103 | |
| 104 | Log To Console Host Scheduled Time Power on success. |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 105 | |
| 106 | |
| 107 | *** Keywords *** |
| 108 | |
| 109 | Test Setup Execution |
| 110 | [Documentation] Do test case setup tasks. |
| 111 | |
George Keishing | 5654fbe | 2022-07-13 06:48:55 -0500 | [diff] [blame] | 112 | Redfish.Login |
dnirmala | f515e3e | 2023-12-19 09:17:06 -0600 | [diff] [blame] | 113 | Set Power Policy For TPO Automatic |
| 114 | |
| 115 | |
| 116 | Set Power Policy For TPO |
| 117 | [Documentation] Change 'server power policy' option to automatic. |
| 118 | [Arguments] ${power_policy_mode} |
| 119 | |
| 120 | # Description of argument(s): |
| 121 | # power_policy_mode BIOS attribute value. E.g. "Stay On", "Automatic". |
| 122 | |
Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 123 | Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID}/Bios/Settings |
dnirmala | f515e3e | 2023-12-19 09:17:06 -0600 | [diff] [blame] | 124 | ... body={"Attributes":{"pvm_system_power_off_policy": "${power_policy_mode}"}} |
| 125 | ... valid_status_codes=[${HTTP_OK}] |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 126 | |
| 127 | |
| 128 | Test Teardown Execution |
| 129 | [Documentation] Do the test teardown |
| 130 | |
| 131 | FFDC On Test Case Fail |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 132 | |
| 133 | |
| 134 | Set Timer For Power ON |
| 135 | [Documentation] Set the time for power ON with given value. |
| 136 | |
| 137 | ${current_bmc_time}= BMC Execute Command date +%s |
| 138 | ${time_set}= Evaluate ${current_bmc_time[0]} + ${TIMER_POWER_ON} |
| 139 | BMC Execute Command ${CMD_SET_TPO_TIME} ${time_set} |
| 140 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 141 | RETURN ${time_set} |
Ashwini Chandrappa | 030ee00 | 2021-09-06 06:53:18 -0500 | [diff] [blame] | 142 | |
| 143 | |
| 144 | Get Time Power ON Value |
| 145 | [Documentation] Returns time power ON value. |
| 146 | |
| 147 | ${timer_value}= BMC Execute Command ${CMD_GET_TPO_TIME} |
| 148 | @{return_value}= Split String ${timer_value[0]} |
| 149 | ${return_value}= Evaluate ${return_value}[1] |
| 150 | |
| 151 | # BMC command returns integer value. |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 152 | RETURN ${return_value} |