xref: /openbmc/openbmc-test-automation/redfish/systems/test_systems_inventory.robot (revision 409df05d4b10b9a8c81e282da8fef0199db5bdea)
1c90c8e23SSteven Sombar*** Settings ***
2b76d4dfcSSteven SombarDocumentation       Inventory of hardware FRUs under redfish.
3c90c8e23SSteven Sombar
4c90c8e23SSteven SombarResource            ../../lib/bmc_redfish_resource.robot
5c90c8e23SSteven SombarResource            ../../lib/bmc_redfish_utils.robot
6c90c8e23SSteven SombarResource            ../../lib/openbmc_ffdc.robot
7bccfd513SSteven SombarLibrary             ../../lib/gen_robot_valid.py
8c90c8e23SSteven Sombar
9c90c8e23SSteven SombarSuite Setup         Suite Setup Execution
10c90c8e23SSteven SombarSuite Teardown      Suite Teardown Execution
11ecf10e32SSteven SombarTest Setup          Printn
12c90c8e23SSteven SombarTest Teardown       Test Teardown Execution
13c90c8e23SSteven Sombar
14c90c8e23SSteven Sombar*** Variables ***
15c90c8e23SSteven Sombar
16c90c8e23SSteven Sombar# The passing criteria.  Must have at least this many.
17bccfd513SSteven Sombar${min_num_dimms}   2
18bccfd513SSteven Sombar${min_num_cpus}    1
19815fa63fSSteven Sombar${min_num_cores}   18
20b76d4dfcSSteven Sombar${min_num_power_supplies}  1
21c90c8e23SSteven Sombar
22c90c8e23SSteven Sombar
23c90c8e23SSteven Sombar*** Test Cases ***
24c90c8e23SSteven Sombar
25ecf10e32SSteven Sombar
26b76d4dfcSSteven SombarVerify CPU And Core Count
27b76d4dfcSSteven Sombar    [Documentation]  Get the total number of CPUs and cores in the system.
28b76d4dfcSSteven Sombar    ...              Verify counts are above minimums.
29b76d4dfcSSteven Sombar    [Tags]  Verify_CPU_And_Core_Count
30c90c8e23SSteven Sombar
31b76d4dfcSSteven Sombar    # Select only CPUs with Health = "OK".
32b76d4dfcSSteven Sombar    ${cpus_ok}=  Filter Struct  ${cpu_info}  [('Health', 'OK')]
33b76d4dfcSSteven Sombar    ${num_cpus}=   Get Length  ${cpus_ok}
34c90c8e23SSteven Sombar
35b76d4dfcSSteven Sombar    Rprint Vars  num_cpus  min_num_cpus
36c90c8e23SSteven Sombar
37b76d4dfcSSteven Sombar    # Assert that num_cpus is greater than or equal to min_num_cpus.
38b76d4dfcSSteven Sombar    Valid Range  num_cpus  ${min_num_cpus}
39815fa63fSSteven Sombar
40b76d4dfcSSteven Sombar    # Get the number of cores.
41815fa63fSSteven Sombar    ${total_num_cores}=  Set Variable  ${0}
42d27fc31eSSushma M M    FOR  ${cpu}  IN  @{cpus_ok}
43b76d4dfcSSteven Sombar        ${cores}=   Get CPU TotalCores  ${cpu}
44b76d4dfcSSteven Sombar        ${total_num_cores}=  Evaluate  $total_num_cores + ${cores}
45815fa63fSSteven Sombar    END
46815fa63fSSteven Sombar
47b76d4dfcSSteven Sombar    Rprint Vars  total_num_cores  min_num_cores
48ecf10e32SSteven Sombar
49b76d4dfcSSteven Sombar    # Assert that total_num_cores is greater than or equal to
50b76d4dfcSSteven Sombar    # min_num_cores.
51b76d4dfcSSteven Sombar    Valid Range  total_num_cores  ${min_num_cores}
52815fa63fSSteven Sombar
53815fa63fSSteven Sombar
54c90c8e23SSteven SombarGet Memory Inventory Via Redfish And Verify
55c90c8e23SSteven Sombar    [Documentation]  Get the number of DIMMs that are functional and enabled.
56c90c8e23SSteven Sombar    [Tags]  Get_Memory_Inventory_Via_Redfish_And_Verify
57c90c8e23SSteven Sombar
58bccfd513SSteven Sombar    Verify FRU Inventory Minimums  Memory  ${min_num_dimms}
59bccfd513SSteven Sombar
60bccfd513SSteven Sombar
61c5d65841SSteven SombarGet Memory Summary State And Verify Enabled
62c5d65841SSteven Sombar    [Documentation]  Check that the state of the MemorySummary attribute
63c5d65841SSteven Sombar    ...              under /redfish/v1/Systems/system is 'Enabled'.
64c5d65841SSteven Sombar    [Tags]  Get_Memory_Summary_State_And_Verify_Enabled
65c5d65841SSteven Sombar
66c5d65841SSteven Sombar    ${status}=  Redfish.Get Attribute  ${SYSTEM_BASE_URI}  MemorySummary
67c5d65841SSteven Sombar    ${memory_summary_state}=  Set Variable  ${status['Status']['State']}
68c5d65841SSteven Sombar    Rprint Vars  memory_summary_state
69c5d65841SSteven Sombar
70c5d65841SSteven Sombar    Should Be Equal As Strings  Enabled  ${memory_summary_state}
71c5d65841SSteven Sombar    ...  msg=MemorySummary State is not 'Enabled'.
72c5d65841SSteven Sombar
73c5d65841SSteven Sombar
74815fa63fSSteven SombarGet System Serial And Verify Populated
75815fa63fSSteven Sombar    [Documentation]  Check that the System SerialNumber is non-blank.
76815fa63fSSteven Sombar    [Tags]  Get_System_Serial_And_Verify_Populated
77bccfd513SSteven Sombar
78bccfd513SSteven Sombar    ${serial_number}=  Redfish.Get Attribute  ${SYSTEM_BASE_URI}  SerialNumber
79e7edb22cSMichael Walsh    Valid Value  serial_number
80bccfd513SSteven Sombar    Rprint Vars  serial_number
81bccfd513SSteven Sombar
82bccfd513SSteven Sombar
83bccfd513SSteven SombarGet Model And Verify Populated
84bccfd513SSteven Sombar    [Documentation]  Check that the Model is non-blank.
85bccfd513SSteven Sombar    [Tags]  Get_Model_And_Verify_Populated
86bccfd513SSteven Sombar
87bccfd513SSteven Sombar    ${model}=  Redfish.Get Attribute  ${SYSTEM_BASE_URI}  Model
88e7edb22cSMichael Walsh    Valid Value  model
89bccfd513SSteven Sombar    Rprint Vars  model
90c90c8e23SSteven Sombar
91c90c8e23SSteven Sombar
92815fa63fSSteven SombarGet Available Power Supplies And Verify
93815fa63fSSteven Sombar    [Documentation]  Get the number of functional power supplies and
94815fa63fSSteven Sombar    ...              verify that it is at or above the minimum.
95815fa63fSSteven Sombar    [Tags]  Get_Available_Power_Supplies_And_Verify
96815fa63fSSteven Sombar
97b76d4dfcSSteven Sombar    # Select only power supplies with Health = "OK".
98b76d4dfcSSteven Sombar    ${power_supplies_ok}=  Filter Struct  ${power_supplies}  [('Health', 'OK')]
99815fa63fSSteven Sombar
100b76d4dfcSSteven Sombar    # Count the power supplies that are Enabled or StandbyOffline.
101b76d4dfcSSteven Sombar    ${total_num_supplies}=  Set Variable  ${0}
102d27fc31eSSushma M M    FOR  ${power_supply}  IN  @{power_supplies_ok}
103b76d4dfcSSteven Sombar        # Example of power_supply:
104b76d4dfcSSteven Sombar        # power_supply = {'@odata.id': '/redfish/v1/Chassis/chassis/Power#/PowerSupplies/0',
105b76d4dfcSSteven Sombar        # 'Manufacturer': '', 'MemberId': 'powersupply0', 'Model': '2100', 'Name':
106b76d4dfcSSteven Sombar        # 'powersupply0', 'PartNumber': 'PNPWR123', 'PowerInputWatts': 394.0,
107b76d4dfcSSteven Sombar        # 'SerialNumber': '75B12W', 'Status': {'Health': 'OK', 'State': 'Enabled'}}
108b76d4dfcSSteven Sombar        ${state}=  Set Variable  ${power_supply['Status']['State']}
109b76d4dfcSSteven Sombar        ${good_state}=  Evaluate
110b76d4dfcSSteven Sombar        ...  any(x in '${state}' for x in ('Enabled', 'StandbyOffline'))
111b76d4dfcSSteven Sombar        Run Keyword If  not ${good_state}  Continue For Loop
112b76d4dfcSSteven Sombar        ${total_num_supplies}=  Evaluate  $total_num_supplies + ${1}
113815fa63fSSteven Sombar    END
114815fa63fSSteven Sombar
115b76d4dfcSSteven Sombar    Rprint Vars  total_num_supplies  min_num_power_supplies
116815fa63fSSteven Sombar
117b76d4dfcSSteven Sombar    Valid Range  total_num_supplies  ${min_num_power_supplies}
118815fa63fSSteven Sombar
119815fa63fSSteven Sombar
120815fa63fSSteven SombarGet Motherboard Serial And Verify Populated
121815fa63fSSteven Sombar    [Documentation]  Check that the Motherboard SerialNumber is non-blank.
122815fa63fSSteven Sombar    [Tags]  Get_Motherboard_Serial_And_Verify_Populated
123815fa63fSSteven Sombar
1246ec9d708SGeorge Keishing    ${serial_number}=  Redfish.Get Attribute  ${REDFISH_CHASSIS_URI}${CHASSIS_ID}  SerialNumber
125e7edb22cSMichael Walsh    Valid Value  serial_number
126815fa63fSSteven Sombar    Rprint Vars  serial_number
127815fa63fSSteven Sombar
128815fa63fSSteven Sombar
129c2ace203SSteven SombarVerify Motherboard Manufacturer Field Value Populated
130c2ace203SSteven Sombar    [Documentation]  Check that the Motherboard manufacturer is non-blank.
131c2ace203SSteven Sombar    [Tags]  Verify_Motherboard_Manufacturer_Field_Value_Populated
132c2ace203SSteven Sombar
1336ec9d708SGeorge Keishing    ${motherboard_manufacturer}=  Redfish.Get Attribute  ${REDFISH_CHASSIS_URI}${CHASSIS_ID}  Manufacturer
134c2ace203SSteven Sombar    Valid Value  motherboard_manufacturer
135d2f210a0SGeorge Keishing    Rprint Vars  motherboard_manufacturer
136c2ace203SSteven Sombar
137c2ace203SSteven Sombar
138c2ace203SSteven SombarVerify Motherboard Partnumber Field Value Populated
139c2ace203SSteven Sombar    [Documentation]  Check that the Motherboard partnumber is non-blank.
140c2ace203SSteven Sombar    [Tags]  Verify_Motherboard_Partnumber_Field_Value_Populated
141c2ace203SSteven Sombar
1426ec9d708SGeorge Keishing    ${motherboard_part_number}=  Redfish.Get Attribute  ${REDFISH_CHASSIS_URI}${CHASSIS_ID}  PartNumber
143c2ace203SSteven Sombar    Valid Value  motherboard_part_number
144d2f210a0SGeorge Keishing    Rprint Vars  motherboard_part_number
145c2ace203SSteven Sombar
146c2ace203SSteven Sombar
147b76d4dfcSSteven SombarCheck GPU States When Power On
148b76d4dfcSSteven Sombar    [Documentation]  Check the State of each of the GPUs
149b76d4dfcSSteven Sombar    ...              in the system.  A system may have 0-6 GPUs.
150b76d4dfcSSteven Sombar    [Tags]  Check_GPU_States_When_Power_On
151ecf10e32SSteven Sombar
152b76d4dfcSSteven Sombar    # System was powered-on in Suite Setup.
153b76d4dfcSSteven Sombar    GPU State Check
154ecf10e32SSteven Sombar
155b76d4dfcSSteven Sombar
156b76d4dfcSSteven SombarCheck GPU States When Power Off
157b76d4dfcSSteven Sombar    [Documentation]  Check the State of the GPUs when power is Off.
158b76d4dfcSSteven Sombar    [Tags]  Check_GPU_States_When_Power_Off
159b76d4dfcSSteven Sombar
160b76d4dfcSSteven Sombar    Redfish Power Off
161b76d4dfcSSteven Sombar    GPU State Check
162ecf10e32SSteven Sombar
163ecf10e32SSteven Sombar
164c90c8e23SSteven Sombar*** Keywords ***
165c90c8e23SSteven Sombar
166c90c8e23SSteven Sombar
167ecf10e32SSteven SombarGet CPU TotalCores
168ecf10e32SSteven Sombar    [Documentation]  Return the TotalCores of a CPU.
169ecf10e32SSteven Sombar    ...              Return 0 if this attribute is missing or NONE.
170ecf10e32SSteven Sombar    [Arguments]      ${processor}
171ecf10e32SSteven Sombar
172ecf10e32SSteven Sombar    # Description of Argument(s):
173ecf10e32SSteven Sombar    # processor     The Redfish URI of a CPU (e.g.
174ecf10e32SSteven Sombar    #               "/redfish/v1/Systems/system/Processors/cpu0").
175ecf10e32SSteven Sombar
176ecf10e32SSteven Sombar    ${total_cores}=  Redfish.Get Attribute  ${processor}  TotalCores
177ecf10e32SSteven Sombar    Return From Keyword If  ${total_cores} is ${NONE}  ${0}
178*409df05dSGeorge Keishing    RETURN  ${total_cores}
179ecf10e32SSteven Sombar
180ecf10e32SSteven Sombar
181b76d4dfcSSteven SombarGPU State Check
182b76d4dfcSSteven Sombar    [Documentation]  The state of every "OK" GPU should be
183b76d4dfcSSteven Sombar    ...              "Absent", "Enabled", or "UnavailableOffline".
184b76d4dfcSSteven Sombar
185b76d4dfcSSteven Sombar    # Select only GPUs with Health = "OK".
186b76d4dfcSSteven Sombar    ${gpus_ok}=  Filter Struct  ${gpu_info}  [('Health', 'OK')]
187b76d4dfcSSteven Sombar
188d27fc31eSSushma M M    FOR  ${gpu}  IN  @{gpus_ok}
189b76d4dfcSSteven Sombar        ${status}=  Redfish.Get Attribute  ${gpu}  Status
190b76d4dfcSSteven Sombar        ${state}=  Set Variable  ${status['State']}
191b76d4dfcSSteven Sombar        ${good_state}=  Evaluate
192b76d4dfcSSteven Sombar        ...  any(x in '${state}' for x in ('Absent', 'Enabled', 'UnavailableOffline'))
193b76d4dfcSSteven Sombar        Rprint Vars  gpu  state
194b76d4dfcSSteven Sombar        Run Keyword If  not ${good_state}  Fail
195b76d4dfcSSteven Sombar        ...  msg=GPU State is not Absent, Enabled, or UnavailableOffline.
196b76d4dfcSSteven Sombar    END
197b76d4dfcSSteven Sombar
198b76d4dfcSSteven Sombar
199b76d4dfcSSteven SombarGet Inventory URIs
200b76d4dfcSSteven Sombar    [Documentation]  Get and return a tuple of lists of URIs for CPU,
201b76d4dfcSSteven Sombar    ...              GPU and PowerSupplies.
202b76d4dfcSSteven Sombar
203b76d4dfcSSteven Sombar    ${processor_info}=  Redfish_Utils.Enumerate Request
204b76d4dfcSSteven Sombar    ...  ${SYSTEM_BASE_URI}Processors  return_json=0
205b76d4dfcSSteven Sombar
206b76d4dfcSSteven Sombar    ${cpu_info}=  Filter Struct  ${processor_info}
207b76d4dfcSSteven Sombar    ...  [('ProcessorType', 'CPU')]  regex=1
208b76d4dfcSSteven Sombar
209b76d4dfcSSteven Sombar    ${gpu_info}=  Filter Struct  ${processor_info}
210b76d4dfcSSteven Sombar    ...  [('ProcessorType', 'Accelerator')]  regex=1
211b76d4dfcSSteven Sombar
212b76d4dfcSSteven Sombar    ${power_supplies}=  Redfish.Get Attribute
213148b5b82SGlukhov Mikhail    ...  ${REDFISH_CHASSIS_URI}${CHASSIS_ID}/Power  PowerSupplies
214b76d4dfcSSteven Sombar
215*409df05dSGeorge Keishing    RETURN  ${cpu_info}  ${gpu_info}  ${power_supplies}
216b76d4dfcSSteven Sombar
217b76d4dfcSSteven Sombar
218bccfd513SSteven SombarVerify FRU Inventory Minimums
2193292d4acSGeorge Keishing    [Documentation]  Verify a minimum number of FRUs.
220bccfd513SSteven Sombar    [Arguments]  ${fru_type}  ${min_num_frus}
221c90c8e23SSteven Sombar
222c90c8e23SSteven Sombar    # Description of Argument(s):
223bccfd513SSteven Sombar    # fru_type      The type of FRU (e.g. "Processors", "Memory", etc.).
224bccfd513SSteven Sombar    # min_num_frus  The minimum acceptable number of FRUs found.
225c90c8e23SSteven Sombar
226bccfd513SSteven Sombar    # A valid FRU  will have a "State" key of "Enabled" and a "Health" key
227bccfd513SSteven Sombar    # of "OK".
228c90c8e23SSteven Sombar
229bccfd513SSteven Sombar    ${status}  ${num_valid_frus}=  Run Key U  Get Num Valid FRUs \ ${fru_type}
230c90c8e23SSteven Sombar
231ecf10e32SSteven Sombar    Rprint Vars  fru_type  num_valid_frus  min_num_frus
232ecf10e32SSteven Sombar
233bccfd513SSteven Sombar    Return From Keyword If  ${num_valid_frus} >= ${min_num_frus}
234bccfd513SSteven Sombar    Fail  Too few "${fru_type}" FRUs found, found only ${num_valid_frus}.
235c90c8e23SSteven Sombar
236c90c8e23SSteven Sombar
237c90c8e23SSteven SombarSuite Teardown Execution
238c90c8e23SSteven Sombar    [Documentation]  Do the post suite teardown.
239c90c8e23SSteven Sombar
240c90c8e23SSteven Sombar    Redfish.Logout
241c90c8e23SSteven Sombar
242c90c8e23SSteven Sombar
243c90c8e23SSteven SombarSuite Setup Execution
244c90c8e23SSteven Sombar    [Documentation]  Do test case setup tasks.
245c90c8e23SSteven Sombar
246c90c8e23SSteven Sombar    Redfish.Login
24707fb41f7SGeorge Keishing    Redfish Power On  stack_mode=skip
248ecf10e32SSteven Sombar
249b76d4dfcSSteven Sombar    ${cpu_info}  ${gpu_info}  ${power_supplies}=  Get Inventory URIs
250ecf10e32SSteven Sombar
251b76d4dfcSSteven Sombar    Set Suite Variable  ${cpu_info}
252b76d4dfcSSteven Sombar    Set Suite Variable  ${gpu_info}
253b76d4dfcSSteven Sombar    Set Suite Variable  ${power_supplies}
254c90c8e23SSteven Sombar
255c90c8e23SSteven Sombar
256c90c8e23SSteven SombarTest Teardown Execution
257c90c8e23SSteven Sombar    [Documentation]  Do the post test teardown.
258c90c8e23SSteven Sombar
259c90c8e23SSteven Sombar    FFDC On Test Case Fail
260