1*** Settings ***
2Documentation   Suite to test OCC power module.
3
4Resource        ../lib/bmc_redfish_resource.robot
5Resource        ../lib/open_power_utils.robot
6Resource        ../lib/boot_utils.robot
7Resource        ../lib/state_manager.robot
8Resource        ../lib/openbmc_ffdc.robot
9Resource        ../lib/utils.robot
10
11Suite Setup     Suite Setup Execution
12Test Teardown   Test Teardown Execution
13
14*** Test Cases ***
15
16Verify OCC Object Count
17    [Documentation]  Verify that OCC and inventory entries match.
18    [Tags]  Verify_OCC_Object_Count
19
20    # Example:
21    # /org/open_power/control/enumerate
22    # {
23    #    "/org/open_power/control/host0": {},
24    #    "/org/open_power/control/occ0": {
25    #       "OccActive": 0
26    #   },
27    # "/org/open_power/control/occ1": {
28    #       "OccActive": 0
29    #   }
30    # }
31
32    # Inventory counterpart cpu's:
33    # "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0",
34    # "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1",
35
36    ${inventory_count}=  Count Object Entries
37    ...  ${HOST_INVENTORY_URI}system/chassis/motherboard/  cpu*
38
39    Should Be Equal  ${occ_count}  ${inventory_count}
40    ...  msg=OCC and inventory entry counts are mismatched.
41
42
43Verify OCC State When Host Is Booted
44    [Documentation]  Verify OCC state when host is booted.
45    [Tags]  Verify_OCC_State_When_Host_Is_Booted
46
47    Verify OCC State  ${1}
48
49
50Verify OCC State After Host Reboot
51    [Documentation]  Verify OCC state and count after host reboot.
52    [Tags]  Verify_OCC_State_After_Host_Reboot
53
54    ${occ_count_before}=  Count OCC Object Entry
55    Verify OCC State  ${1}
56    RF SYS GracefulRestart
57    Verify OCC State  ${1}
58    ${occ_count_after}=  Count OCC Object Entry
59    Should be Equal  ${occ_count_before}  ${occ_count_after}
60
61
62Verify OCC State After BMC Reset
63    [Documentation]  Verify OCC state and count after BMC reset.
64    [Tags]  Verify_OCC_State_After_BMC_Reset
65
66    ${occ_count_before}=  Count OCC Object Entry
67    Redfish OBMC Reboot (run)
68    Verify OCC State  ${1}
69    ${occ_count_after}=  Count OCC Object Entry
70    Should be Equal  ${occ_count_before}  ${occ_count_after}
71
72
73Verify OCC State At Standby
74    [Documentation]  Verify OCC state at standby.
75    [Tags]  Verify_OCC_State_At_Standby
76
77    Redfish Power Off  stack_mode=normal
78    Verify OCC State  ${0}
79
80*** Keywords ***
81
82Suite Setup Execution
83    [Documentation]  Do the initial test suite setup.
84
85    Redfish Power On
86    Count OCC Object Entry
87
88Count OCC Object Entry
89    [Documentation]  Count OCC object entry and set count.
90
91    ${object_count}=  Count Object Entries  ${OPENPOWER_CONTROL}  occ*
92    Set Suite Variable  ${occ_count]  ${object_count}
93
94
95Test Teardown Execution
96    [Documentation]  Do the post test teardown.
97    # - Capture FFDC on test failure.
98    # - Delete error logs.
99    # - Close all open SSH connections.
100
101    FFDC On Test Case Fail
102    Redfish.Login
103    Redfish Purge Event Log
104    Close All Connections
105