xref: /openbmc/openbmc-test-automation/redfish/systems/test_power_operations.robot (revision 49c1b53931191184251a4d1d9ba9ab127ee9f9fb)
1d737eb95SSridevi Ramesh*** Settings ***
24583a08cSGeorge KeishingDocumentation    This suite tests Redfish Host power operations.
34583a08cSGeorge Keishing
4d737eb95SSridevi RameshResource         ../../lib/boot_utils.robot
536c39aabSGeorge KeishingResource         ../../lib/common_utils.robot
6d8c8b318SGeorge KeishingResource         ../../lib/open_power_utils.robot
7d737eb95SSridevi Ramesh
836c39aabSGeorge KeishingTest Setup       Test Setup Execution
936c39aabSGeorge KeishingTest Teardown    Test Teardown Execution
10d737eb95SSridevi Ramesh
11f6888001SGeorge Keishing*** Variables ***
12f6888001SGeorge Keishing
13f6888001SGeorge Keishing# Extended code to check OCC state, power metric and others.
14af9da9e6SGeorge Keishing${additional_power_check}      ${0}
15af9da9e6SGeorge Keishing${additional_occ_check}        ${0}
16f6888001SGeorge Keishing
1715f94d26SGeorge Keishing# By default disable SOL logging collection.
1815f94d26SGeorge Keishing${capture_sol}                 ${0}
1915f94d26SGeorge Keishing
20d737eb95SSridevi Ramesh*** Test Cases ***
21d737eb95SSridevi Ramesh
224583a08cSGeorge KeishingVerify Redfish Host GracefulShutdown
234583a08cSGeorge Keishing    [Documentation]  Verify Redfish host graceful shutdown operation.
244583a08cSGeorge Keishing    [Tags]  Verify_Redfish_Host_GracefulShutdown
25d737eb95SSridevi Ramesh
26d737eb95SSridevi Ramesh    Redfish Power Off
27d737eb95SSridevi Ramesh
289833f96bSGeorge Keishing
2946b1a8e2SLei YUVerify Redfish BMC PowerOn With OCC State
3046b1a8e2SLei YU    [Documentation]  Verify Redfish host power on operation.
3146b1a8e2SLei YU    [Tags]  Verify_Redfish_BMC_PowerOn_With_OCC_State
3246b1a8e2SLei YU
3346b1a8e2SLei YU    Redfish Power On
3446b1a8e2SLei YU
3546b1a8e2SLei YU    # TODO: Replace OCC state check with redfish property when available.
3646b1a8e2SLei YU    Verify OCC State
3746b1a8e2SLei YU
3846b1a8e2SLei YU
395236ec54SGeorge KeishingVerify Redfish Host PowerOn
404583a08cSGeorge Keishing    [Documentation]  Verify Redfish host power on operation.
414583a08cSGeorge Keishing    [Tags]  Verify_Redfish_Host_PowerOn
42d737eb95SSridevi Ramesh
43d737eb95SSridevi Ramesh    Redfish Power On
44d737eb95SSridevi Ramesh
45*49c1b539SSridevi Ramesh    IF  ${additional_occ_check} == ${1}
46*49c1b539SSridevi Ramesh        Wait Until Keyword Succeeds  3 mins  30 secs  Match OCC And CPU State Count
47*49c1b539SSridevi Ramesh    END
48d918148dSGeorge Keishing
49*49c1b539SSridevi Ramesh    IF  ${additional_power_check} == ${1}  Power Check
506dbadc58SGeorge Keishing
519833f96bSGeorge Keishing
525236ec54SGeorge KeishingVerify Redfish Host GracefulRestart
534583a08cSGeorge Keishing    [Documentation]  Verify Redfish host graceful restart operation.
544583a08cSGeorge Keishing    [Tags]  Verify_Redfish_Host_GracefulRestart
55d737eb95SSridevi Ramesh
56e523fc04SGeorge Keishing    RF SYS GracefulRestart
57d737eb95SSridevi Ramesh
589833f96bSGeorge Keishing
595236ec54SGeorge KeishingVerify Redfish Host PowerOff
604583a08cSGeorge Keishing    [Documentation]  Verify Redfish host power off operation.
614583a08cSGeorge Keishing    [Tags]  Verify_Redfish_Host_PowerOff
62d737eb95SSridevi Ramesh
63d737eb95SSridevi Ramesh    Redfish Hard Power Off
6436c39aabSGeorge Keishing
6536c39aabSGeorge Keishing*** Keywords ***
6636c39aabSGeorge Keishing
6736c39aabSGeorge KeishingTest Setup Execution
6836c39aabSGeorge Keishing    [Documentation]  Do test case setup tasks.
6936c39aabSGeorge Keishing
709833f96bSGeorge Keishing    Printn
71*49c1b539SSridevi Ramesh    IF  ${capture_sol} == ${1}  Start SOL Console Logging
722997a28cSGeorge Keishing    Redfish.Login
7336c39aabSGeorge Keishing
7436c39aabSGeorge Keishing
7536c39aabSGeorge KeishingTest Teardown Execution
7636c39aabSGeorge Keishing    [Documentation]  Collect FFDC and SOL log.
7736c39aabSGeorge Keishing
7836c39aabSGeorge Keishing    FFDC On Test Case Fail
79*49c1b539SSridevi Ramesh    IF  ${capture_sol} == ${1}  Stop SOL Capture
8099a62057SGeorge Keishing
81*49c1b539SSridevi Ramesh    IF  ${REDFISH_SUPPORTED}
82*49c1b539SSridevi Ramesh        Redfish Set Auto Reboot  RetryAttempts
83*49c1b539SSridevi Ramesh    ELSE
84*49c1b539SSridevi Ramesh       Set Auto Reboot  ${1}
85*49c1b539SSridevi Ramesh    END
86*49c1b539SSridevi Ramesh
872997a28cSGeorge Keishing    Redfish.Logout
88f6888001SGeorge Keishing
89f6888001SGeorge Keishing
9015f94d26SGeorge KeishingStop SOL Capture
9115f94d26SGeorge Keishing    [Documentation]  Stop SOL log collection.
9215f94d26SGeorge Keishing
9315f94d26SGeorge Keishing    ${sol_log}=    Stop SOL Console Logging
9415f94d26SGeorge Keishing    Log   ${sol_log}
9515f94d26SGeorge Keishing
9615f94d26SGeorge Keishing
97d918148dSGeorge KeishingPower Check
98d918148dSGeorge Keishing    [Documentation]  Verify PowerConsumedWatts property.
99f6888001SGeorge Keishing
100f6888001SGeorge Keishing    ${power_uri_list}=  redfish_utils.Get Members URI  /redfish/v1/Chassis/  PowerControl
101f6888001SGeorge Keishing    Log List  ${power_uri_list}
102f6888001SGeorge Keishing
103f6888001SGeorge Keishing    # Power entries could be seen across different redfish path, remove the URI
104f6888001SGeorge Keishing    # where the attribute is non-existent.
105f6888001SGeorge Keishing    # Example:
106f6888001SGeorge Keishing    #     ['/redfish/v1/Chassis/chassis/Power',
107f6888001SGeorge Keishing    #      '/redfish/v1/Chassis/motherboard/Power']
108f6888001SGeorge Keishing    FOR  ${idx}  IN  @{power_uri_list}
109f6888001SGeorge Keishing        ${power_control}=  redfish_utils.Get Attribute  ${idx}  PowerControl
110f6888001SGeorge Keishing        Log Dictionary  ${power_control[0]}
111f6888001SGeorge Keishing
112f6888001SGeorge Keishing        # Ensure the path does have the attribute else set to EMPTY as default to skip.
113f6888001SGeorge Keishing        ${value}=  Get Variable Value  ${power_control[0]['PowerConsumedWatts']}  ${EMPTY}
114*49c1b539SSridevi Ramesh        IF  "${value}" == "${EMPTY}"
115*49c1b539SSridevi Ramesh            Remove Values From List  ${power_uri_list}  ${idx}
116*49c1b539SSridevi Ramesh        END
117f6888001SGeorge Keishing
118f6888001SGeorge Keishing        # Check the next available element in the list.
119ac155720SSridevi Ramesh        IF  "${value}" == "${EMPTY}"  CONTINUE
120f6888001SGeorge Keishing
121f6888001SGeorge Keishing        Valid Dict  power_control[${0}]  ['PowerConsumedWatts']
122f6888001SGeorge Keishing
123f6888001SGeorge Keishing    END
124f6888001SGeorge Keishing
125f6888001SGeorge Keishing    # Double check, the validation has at least one valid path.
126f6888001SGeorge Keishing    Should Not Be Empty  ${power_uri_list}
127f6888001SGeorge Keishing    ...  msg=Should contain at least one element in the list.
128