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