xref: /openbmc/openbmc-test-automation/redfish/systems/test_systems_inventory.robot (revision ecf10e32633363e54d9e95f1c5cee4df80e6492c)
1*** Settings ***
2Documentation       Inventory of hardware FRUs under redfish/systems.
3
4Resource            ../../lib/bmc_redfish_resource.robot
5Resource            ../../lib/bmc_redfish_utils.robot
6Resource            ../../lib/openbmc_ffdc.robot
7Library             ../../lib/gen_robot_valid.py
8
9Suite Setup         Suite Setup Execution
10Suite Teardown      Suite Teardown Execution
11Test Setup          Printn
12Test Teardown       Test Teardown Execution
13
14*** Variables ***
15
16# The passing criteria.  Must have at least this many.
17${min_num_dimms}   2
18${min_num_cpus}    1
19${min_num_cores}   18
20${min_num_powersupplies}  1
21
22
23*** Test Cases ***
24
25
26Get Processor Inventory Via Redfish And Verify
27    [Documentation]  Get the number of CPUs that are functional and enabled.
28    [Tags]  Get_Processor_Inventory_Via_Redfish_And_Verify
29
30    Rprint Vars  num_valid_cpus
31    Rprint Vars  min_num_cpus
32    Rvalid Range  num_valid_cpus  ${min_num_cpus}..
33
34
35Get Available CPU Cores And Verify
36    [Documentation]  Get the total number of cores in the system and
37    ...              verify that it is at or above the minimum.
38    [Tags]  Get_Available_CPU_Cores_And_Verify
39
40    ${total_num_cores}=  Set Variable  ${0}
41
42    :FOR  ${processor}  IN  @{cpu_uris}
43        ${is_functional}=  Check If FRU Is Functional  ${processor}
44        Run Keyword If  not ${is_functional}  Continue For Loop
45        ${processor_cores}=   Get CPU TotalCores  ${processor}
46        ${total_num_cores}=  Evaluate  $total_num_cores + $processor_cores
47    END
48
49    Rprint Vars  total_num_cores
50
51    Run Keyword If  ${total_num_cores} < ${min_num_cores}
52    ...  Fail  Too few CPU cores found.
53
54
55Get Memory Inventory Via Redfish And Verify
56    [Documentation]  Get the number of DIMMs that are functional and enabled.
57    [Tags]  Get_Memory_Inventory_Via_Redfish_And_Verify
58
59    Verify FRU Inventory Minimums  Memory  ${min_num_dimms}
60
61
62Get System Serial And Verify Populated
63    [Documentation]  Check that the System SerialNumber is non-blank.
64    [Tags]  Get_System_Serial_And_Verify_Populated
65
66    ${serial_number}=  Redfish.Get Attribute  ${SYSTEM_BASE_URI}  SerialNumber
67    Rvalid Value  serial_number
68    Rprint Vars  serial_number
69
70
71Get Model And Verify Populated
72    [Documentation]  Check that the Model is non-blank.
73    [Tags]  Get_Model_And_Verify_Populated
74
75    ${model}=  Redfish.Get Attribute  ${SYSTEM_BASE_URI}  Model
76    Rvalid Value  model
77    Rprint Vars  model
78
79
80Get Available Power Supplies And Verify
81    [Documentation]  Get the number of functional power supplies and
82    ...              verify that it is at or above the minimum.
83    [Tags]  Get_Available_Power_Supplies_And_Verify
84
85    ${total_num_supplies}=  Set Variable  ${0}
86
87    :FOR  ${chassis_uri}  IN  @{powersupply_uris}
88        ${is_functional}=  Check If FRU Is Functional  ${chassis_uri}
89        ${total_num_supplies}=  Evaluate  $total_num_supplies + $is_functional
90    END
91
92    Rprint Vars  total_num_supplies
93
94    Run Keyword If  ${total_num_supplies} < ${min_num_powersupplies}
95    ...  Fail  Too few power supplies found.
96
97
98Get Motherboard Serial And Verify Populated
99    [Documentation]  Check that the Motherboard SerialNumber is non-blank.
100    [Tags]  Get_Motherboard_Serial_And_Verify_Populated
101
102    ${serial_number}=  Redfish.Get Attribute
103    ...  ${REDFISH_CHASSIS_URI}motherboard  SerialNumber
104    Rvalid Value  serial_number
105    Rprint Vars  serial_number
106
107
108Get GPU Inventory Via Redfish
109    [Documentation]  Get the number of GPUs.
110    [Tags]  Get_GPU_Inventory_Via_Redfish
111
112    # There may be 0-6 GPUs in a system.
113    # GPUs may have one of three states:
114    # "Absent", "Enabled", or "UnavailableOffline".
115    # Or GPUs may not be listed at all under the URI
116    # /redfish/v1/Systems/system/Processors.
117    # So for now, only print the total of GPUs present.
118
119    Rprint Vars  num_valid_gpus
120
121
122*** Keywords ***
123
124
125Get Inventory URIs
126    [Documentation]  Get and return a tuple of lists of URIs for CPU,
127    ...              GPU and PowerSupplies.
128
129    ${processor_uris}=
130    ...  Redfish_Utils.Get Member List  ${SYSTEM_BASE_URI}Processors
131    # Example of processor_uris:
132    # /redfish/v1/Systems/system/Processors/cpu0
133    # /redfish/v1/Systems/system/Processors/cpu1
134    # /redfish/v1/Systems/system/Processors/gv100card0
135    # /redfish/v1/Systems/system/Processors/gv100card1
136    # /redfish/v1/Systems/system/Processors/gv100card2
137    # /redfish/v1/Systems/system/Processors/gv100card3
138    # /redfish/v1/Systems/system/Processors/gv100card4
139
140    ${cpu_uris}=  Get Matches  ${processor_uris}  *cpu*
141    ${gpu_uris}=  Get Matches  ${processor_uris}  *gv*
142
143    ${chassis_uris}=  Redfish_Utils.Get Member List  ${REDFISH_CHASSIS_URI}
144    # Example of chassis_uris:
145    # /redfish/v1/Chassis/chasis
146    # /redfish/v1/Chassis/motherboard
147    # /redfish/v1/Chassis/powersupply0
148    # /redfish/v1/Chassis/powersupply1
149
150    ${powersupply_uris}=  Get Matches  ${chassis_uris}  *powersupp*
151
152    [Return]  ${cpu_uris}  ${gpu_uris}  ${powersupply_uris}
153
154
155Get CPU TotalCores
156    [Documentation]  Return the TotalCores of a CPU.
157    ...              Return 0 if this attribute is missing or NONE.
158    [Arguments]      ${processor}
159
160    # Description of Argument(s):
161    # processor     The Redfish URI of a CPU (e.g.
162    #               "/redfish/v1/Systems/system/Processors/cpu0").
163
164    ${total_cores}=  Redfish.Get Attribute  ${processor}  TotalCores
165    Return From Keyword If  ${total_cores} is ${NONE}  ${0}
166    [Return]  ${total_cores}
167
168
169Verify FRU Inventory Minimums
170    [Documentation]  Verify a minimum number of FRUs.
171    [Arguments]  ${fru_type}  ${min_num_frus}
172
173    # Description of Argument(s):
174    # fru_type      The type of FRU (e.g. "Processors", "Memory", etc.).
175    # min_num_frus  The minimum acceptable number of FRUs found.
176
177    # A valid FRU  will have a "State" key of "Enabled" and a "Health" key
178    # of "OK".
179
180    ${status}  ${num_valid_frus}=  Run Key U  Get Num Valid FRUs \ ${fru_type}
181
182    Rprint Vars  fru_type  num_valid_frus  min_num_frus
183
184    Return From Keyword If  ${num_valid_frus} >= ${min_num_frus}
185    Fail  Too few "${fru_type}" FRUs found, found only ${num_valid_frus}.
186
187
188Check If FRU Is Functional
189    [Documentation]  Return 1 if a power supply is OK and either
190    ...   Enabled or StandbyOffline.  Return 0 otherwise.
191    [Arguments]  ${chassis_uri}
192
193    # Description of Argument(s):
194    # chassis_uri    The Redfish uri of a power supply
195    #                (e.g. "/redfish/v1/Chassis/powersupply0").
196
197    ${status}=  Redfish.Get Attribute  ${chassis_uri}  Status
198
199    ${state_check}=  Set Variable  "${status['Health']}" == "OK" and
200    ${state_check}=  Catenate  ${state_check}  ("${status['State']}" == "StandbyOffline" or
201    ${state_check}=  Catenate  ${state_check}  "${status['State']}" == "Enabled")
202
203    ${is_functional}=  Run Keyword If  ${state_check}
204    ...     Set Variable  ${1}
205    ...  ELSE
206    ...     Set Variable  ${0}
207
208    [Return]  ${is_functional}
209
210
211Suite Teardown Execution
212    [Documentation]  Do the post suite teardown.
213
214    Redfish.Logout
215
216
217Suite Setup Execution
218    [Documentation]  Do test case setup tasks.
219
220    Redfish Power On  stack_mode=skip
221    Redfish.Login
222
223    ${cpu_uris}  ${gpu_uris}  ${powersupply_uris}=  Get Inventory URIs
224
225    Set Suite Variable  ${cpu_uris}
226    Set Suite Variable  ${gpu_uris}
227    Set Suite Variable  ${powersupply_uris}
228
229    ${num_valid_cpus}=  Get Length  ${cpu_uris}
230    ${num_valid_gpus}=  Get Length  ${gpu_uris}
231
232    Set Suite Variable  ${num_valid_cpus}
233    Set Suite Variable  ${num_valid_gpus}
234
235
236Test Teardown Execution
237    [Documentation]  Do the post test teardown.
238
239    FFDC On Test Case Fail
240