xref: /openbmc/openbmc-test-automation/redfish/systems/test_power_operations.robot (revision 069b266e40a93fda3992c888062745b1ac920473)
1*** Settings ***
2Documentation    This suite tests Redfish Host power operations.
3
4Resource         ../../lib/boot_utils.robot
5Resource         ../../lib/common_utils.robot
6Resource         ../../lib/open_power_utils.robot
7
8Test Setup       Test Setup Execution
9Test Teardown    Test Teardown Execution
10
11*** Variables ***
12
13# Extended code to check OCC state, power metric and others.
14${additional_power_check}      ${0}
15${additional_occ_check}        ${0}
16
17# By default disable SOL logging collection.
18${capture_sol}                 ${0}
19
20*** Test Cases ***
21
22Verify Redfish Host GracefulShutdown
23    [Documentation]  Verify Redfish host graceful shutdown operation.
24    [Tags]  Verify_Redfish_Host_GracefulShutdown
25
26    Redfish Power Off
27
28
29Verify Redfish BMC PowerOn With OCC State
30    [Documentation]  Verify Redfish host power on operation.
31    [Tags]  Verify_Redfish_BMC_PowerOn_With_OCC_State
32
33    Redfish Power On
34
35    # TODO: Replace OCC state check with redfish property when available.
36    Verify OCC State
37
38
39Verify Redfish Host PowerOn
40    [Documentation]  Verify Redfish host power on operation.
41    [Tags]  Verify_Redfish_Host_PowerOn
42
43    Redfish Power On
44
45    IF  ${additional_occ_check} == ${1}
46        Wait Until Keyword Succeeds  3 mins  30 secs  Match OCC And CPU State Count
47    END
48
49    IF  ${additional_power_check} == ${1}  Power Check
50
51
52Verify Redfish Host GracefulRestart
53    [Documentation]  Verify Redfish host graceful restart operation.
54    [Tags]  Verify_Redfish_Host_GracefulRestart
55
56    RF SYS GracefulRestart
57
58
59Verify Redfish Host PowerOff
60    [Documentation]  Verify Redfish host power off operation.
61    [Tags]  Verify_Redfish_Host_PowerOff
62
63    Redfish Hard Power Off
64
65*** Keywords ***
66
67Test Setup Execution
68    [Documentation]  Do test case setup tasks.
69
70    Printn
71    IF  ${capture_sol} == ${1}  Start SOL Console Logging
72    Redfish.Login
73
74
75Test Teardown Execution
76    [Documentation]  Collect FFDC and SOL log.
77
78    FFDC On Test Case Fail
79    IF  ${capture_sol} == ${1}  Stop SOL Capture
80
81    IF  ${REDFISH_SUPPORTED}
82        Redfish Set Auto Reboot  RetryAttempts
83    ELSE
84       Set Auto Reboot  ${1}
85    END
86
87    Redfish.Logout
88
89
90Stop SOL Capture
91    [Documentation]  Stop SOL log collection.
92
93    ${sol_log}=    Stop SOL Console Logging
94    Log   ${sol_log}
95
96
97Power Check
98    [Documentation]  Verify PowerConsumedWatts property.
99
100    ${power_uri_list}=  redfish_utils.Get Members URI  /redfish/v1/Chassis/  PowerControl
101    Log List  ${power_uri_list}
102
103    # Power entries could be seen across different redfish path, remove the URI
104    # where the attribute is non-existent.
105    # Example:
106    #     ['/redfish/v1/Chassis/chassis/Power',
107    #      '/redfish/v1/Chassis/motherboard/Power']
108    FOR  ${idx}  IN  @{power_uri_list}
109        ${power_control}=  redfish_utils.Get Attribute  ${idx}  PowerControl
110        Log Dictionary  ${power_control[0]}
111
112        # Ensure the path does have the attribute else set to EMPTY as default to skip.
113        ${value}=  Get Variable Value  ${power_control[0]['PowerConsumedWatts']}  ${EMPTY}
114        IF  "${value}" == "${EMPTY}"
115            Remove Values From List  ${power_uri_list}  ${idx}
116        END
117
118        # Check the next available element in the list.
119        IF  "${value}" == "${EMPTY}"  CONTINUE
120
121        Valid Dict  power_control[${0}]  ['PowerConsumedWatts']
122
123    END
124
125    # Double check, the validation has at least one valid path.
126    Should Not Be Empty  ${power_uri_list}
127    ...  msg=Should contain at least one element in the list.
128