blob: 7f56976bfefefae7f78a5c70cd457d087de827c6 [file] [log] [blame]
Ashwini Chandrappa030ee002021-09-06 06:53:18 -05001*** Settings ***
2Documentation 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
8Resource ../lib/boot_utils.robot
9Resource ../lib/openbmc_ffdc.robot
10Resource ../lib/bmc_redfish_resource.robot
11
12
13Suite Setup Redfish.Login
14Suite Teardown Redfish.Logout
15Test Setup Test Setup Execution
16Test Teardown Test Teardown Execution
17
Sridevi Ramesh89666172025-09-28 04:15:29 -050018Test Tags Test_Timed_Power_On
Ashwini Chandrappa030ee002021-09-06 06:53:18 -050019
20*** Variables ****
21
George Keishing5654fbe2022-07-13 06:48:55 -050022${CMD_ENABLE_TPO} busctl set-property xyz.openbmc_project.State.ScheduledHostTransition
Andrew Geissler808eafc2023-03-02 14:04:15 -060023... /xyz/openbmc_project/scheduled/host0 xyz.openbmc_project.State.ScheduledHostTransition
George Keishing5654fbe2022-07-13 06:48:55 -050024... ScheduledTransition s "xyz.openbmc_project.State.Host.Transition.On"
25
Ashwini Chandrappa030ee002021-09-06 06:53:18 -050026${CMD_SET_TPO_TIME} busctl set-property xyz.openbmc_project.State.ScheduledHostTransition
Andrew Geissler808eafc2023-03-02 14:04:15 -060027... /xyz/openbmc_project/scheduled/host0 xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime t
Ashwini Chandrappa030ee002021-09-06 06:53:18 -050028
29${CMD_GET_TPO_TIME} busctl get-property xyz.openbmc_project.State.ScheduledHostTransition
Andrew Geissler808eafc2023-03-02 14:04:15 -060030... /xyz/openbmc_project/scheduled/host0 xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime
Ashwini Chandrappa030ee002021-09-06 06:53:18 -050031
George Keishing5654fbe2022-07-13 06:48:55 -050032# Time in seconds.
Ashwini Chandrappa030ee002021-09-06 06:53:18 -050033${TIMER_POWER_ON} 100
34
George Keishing096cc072022-07-13 11:57:15 -050035# 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 Chandrappa030ee002021-09-06 06:53:18 -050044
45*** Test Cases ***
46
George Keishing5654fbe2022-07-13 06:48:55 -050047Test 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 Chandrappa030ee002021-09-06 06:53:18 -050057
58 ${tpo_set_value}= Set Timer For Power ON
59 ${new_tpo_value}= Get Time Power ON Value
George Keishing5654fbe2022-07-13 06:48:55 -050060
Ashwini Chandrappa030ee002021-09-06 06:53:18 -050061 Should Be Equal ${new_tpo_value} ${tpo_set_value}
George Keishing5654fbe2022-07-13 06:48:55 -050062 ... 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 Keishing096cc072022-07-13 11:57:15 -050069 Log To Console BMC Scheduled Time Power on success.
70
71
72Test 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 Chandrappa030ee002021-09-06 06:53:18 -0500105
106
107*** Keywords ***
108
109Test Setup Execution
110 [Documentation] Do test case setup tasks.
111
George Keishing5654fbe2022-07-13 06:48:55 -0500112 Redfish.Login
dnirmalaf515e3e2023-12-19 09:17:06 -0600113 Set Power Policy For TPO Automatic
114
115
116Set 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 Huc32434a2024-01-11 17:33:10 -0800123 Redfish.Patch /redfish/v1/Systems/${SYSTEM_ID}/Bios/Settings
dnirmalaf515e3e2023-12-19 09:17:06 -0600124 ... body={"Attributes":{"pvm_system_power_off_policy": "${power_policy_mode}"}}
125 ... valid_status_codes=[${HTTP_OK}]
Ashwini Chandrappa030ee002021-09-06 06:53:18 -0500126
127
128Test Teardown Execution
129 [Documentation] Do the test teardown
130
131 FFDC On Test Case Fail
Ashwini Chandrappa030ee002021-09-06 06:53:18 -0500132
133
134Set 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 Keishing409df052024-01-17 22:36:14 +0530141 RETURN ${time_set}
Ashwini Chandrappa030ee002021-09-06 06:53:18 -0500142
143
144Get 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 Keishing409df052024-01-17 22:36:14 +0530152 RETURN ${return_value}