blob: b562692fc10ee69578545af9738dc3d1cd32d5d5 [file] [log] [blame]
Steven Sombarc90c8e22019-05-21 11:28:48 -05001*** Settings ***
Steven Sombarb76d4df2019-08-06 15:03:47 -05002Documentation Inventory of hardware FRUs under redfish.
Steven Sombarc90c8e22019-05-21 11:28:48 -05003
4Resource ../../lib/bmc_redfish_resource.robot
5Resource ../../lib/bmc_redfish_utils.robot
6Resource ../../lib/openbmc_ffdc.robot
Steven Sombarbccfd512019-06-05 15:50:35 -05007Library ../../lib/gen_robot_valid.py
Steven Sombarc90c8e22019-05-21 11:28:48 -05008
9Suite Setup Suite Setup Execution
10Suite Teardown Suite Teardown Execution
Steven Sombarecf10e32019-07-25 08:51:00 -050011Test Setup Printn
Steven Sombarc90c8e22019-05-21 11:28:48 -050012Test Teardown Test Teardown Execution
13
14*** Variables ***
15
16# The passing criteria. Must have at least this many.
Steven Sombarbccfd512019-06-05 15:50:35 -050017${min_num_dimms} 2
18${min_num_cpus} 1
Steven Sombar815fa632019-07-16 14:24:40 -050019${min_num_cores} 18
Steven Sombarb76d4df2019-08-06 15:03:47 -050020${min_num_power_supplies} 1
Steven Sombarc90c8e22019-05-21 11:28:48 -050021
22
23*** Test Cases ***
24
Steven Sombarecf10e32019-07-25 08:51:00 -050025
Steven Sombarb76d4df2019-08-06 15:03:47 -050026Verify CPU And Core Count
27 [Documentation] Get the total number of CPUs and cores in the system.
28 ... Verify counts are above minimums.
29 [Tags] Verify_CPU_And_Core_Count
Steven Sombarc90c8e22019-05-21 11:28:48 -050030
Steven Sombarb76d4df2019-08-06 15:03:47 -050031 # Select only CPUs with Health = "OK".
32 ${cpus_ok}= Filter Struct ${cpu_info} [('Health', 'OK')]
33 ${num_cpus}= Get Length ${cpus_ok}
Steven Sombarc90c8e22019-05-21 11:28:48 -050034
Steven Sombarb76d4df2019-08-06 15:03:47 -050035 Rprint Vars num_cpus min_num_cpus
Steven Sombarc90c8e22019-05-21 11:28:48 -050036
Steven Sombarb76d4df2019-08-06 15:03:47 -050037 # Assert that num_cpus is greater than or equal to min_num_cpus.
38 Valid Range num_cpus ${min_num_cpus}
Steven Sombar815fa632019-07-16 14:24:40 -050039
Steven Sombarb76d4df2019-08-06 15:03:47 -050040 # Get the number of cores.
Steven Sombar815fa632019-07-16 14:24:40 -050041 ${total_num_cores}= Set Variable ${0}
Steven Sombarb76d4df2019-08-06 15:03:47 -050042 :FOR ${cpu} IN @{cpus_ok}
43 ${cores}= Get CPU TotalCores ${cpu}
44 ${total_num_cores}= Evaluate $total_num_cores + ${cores}
Steven Sombar815fa632019-07-16 14:24:40 -050045 END
46
Steven Sombarb76d4df2019-08-06 15:03:47 -050047 Rprint Vars total_num_cores min_num_cores
Steven Sombarecf10e32019-07-25 08:51:00 -050048
Steven Sombarb76d4df2019-08-06 15:03:47 -050049 # Assert that total_num_cores is greater than or equal to
50 # min_num_cores.
51 Valid Range total_num_cores ${min_num_cores}
Steven Sombar815fa632019-07-16 14:24:40 -050052
53
Steven Sombarc90c8e22019-05-21 11:28:48 -050054Get Memory Inventory Via Redfish And Verify
55 [Documentation] Get the number of DIMMs that are functional and enabled.
56 [Tags] Get_Memory_Inventory_Via_Redfish_And_Verify
57
Steven Sombarbccfd512019-06-05 15:50:35 -050058 Verify FRU Inventory Minimums Memory ${min_num_dimms}
59
60
Steven Sombar815fa632019-07-16 14:24:40 -050061Get System Serial And Verify Populated
62 [Documentation] Check that the System SerialNumber is non-blank.
63 [Tags] Get_System_Serial_And_Verify_Populated
Steven Sombarbccfd512019-06-05 15:50:35 -050064
65 ${serial_number}= Redfish.Get Attribute ${SYSTEM_BASE_URI} SerialNumber
Michael Walshe7edb222019-08-19 17:39:38 -050066 Valid Value serial_number
Steven Sombarbccfd512019-06-05 15:50:35 -050067 Rprint Vars serial_number
68
69
70Get Model And Verify Populated
71 [Documentation] Check that the Model is non-blank.
72 [Tags] Get_Model_And_Verify_Populated
73
74 ${model}= Redfish.Get Attribute ${SYSTEM_BASE_URI} Model
Michael Walshe7edb222019-08-19 17:39:38 -050075 Valid Value model
Steven Sombarbccfd512019-06-05 15:50:35 -050076 Rprint Vars model
Steven Sombarc90c8e22019-05-21 11:28:48 -050077
78
Steven Sombar815fa632019-07-16 14:24:40 -050079Get Available Power Supplies And Verify
80 [Documentation] Get the number of functional power supplies and
81 ... verify that it is at or above the minimum.
82 [Tags] Get_Available_Power_Supplies_And_Verify
83
Steven Sombarb76d4df2019-08-06 15:03:47 -050084 # Select only power supplies with Health = "OK".
85 ${power_supplies_ok}= Filter Struct ${power_supplies} [('Health', 'OK')]
Steven Sombar815fa632019-07-16 14:24:40 -050086
Steven Sombarb76d4df2019-08-06 15:03:47 -050087 # Count the power supplies that are Enabled or StandbyOffline.
88 ${total_num_supplies}= Set Variable ${0}
89 :FOR ${power_supply} IN @{power_supplies_ok}
90 # Example of power_supply:
91 # power_supply = {'@odata.id': '/redfish/v1/Chassis/chassis/Power#/PowerSupplies/0',
92 # 'Manufacturer': '', 'MemberId': 'powersupply0', 'Model': '2100', 'Name':
93 # 'powersupply0', 'PartNumber': 'PNPWR123', 'PowerInputWatts': 394.0,
94 # 'SerialNumber': '75B12W', 'Status': {'Health': 'OK', 'State': 'Enabled'}}
95 ${state}= Set Variable ${power_supply['Status']['State']}
96 ${good_state}= Evaluate
97 ... any(x in '${state}' for x in ('Enabled', 'StandbyOffline'))
98 Run Keyword If not ${good_state} Continue For Loop
99 ${total_num_supplies}= Evaluate $total_num_supplies + ${1}
Steven Sombar815fa632019-07-16 14:24:40 -0500100 END
101
Steven Sombarb76d4df2019-08-06 15:03:47 -0500102 Rprint Vars total_num_supplies min_num_power_supplies
Steven Sombar815fa632019-07-16 14:24:40 -0500103
Steven Sombarb76d4df2019-08-06 15:03:47 -0500104 Valid Range total_num_supplies ${min_num_power_supplies}
Steven Sombar815fa632019-07-16 14:24:40 -0500105
106
107Get Motherboard Serial And Verify Populated
108 [Documentation] Check that the Motherboard SerialNumber is non-blank.
109 [Tags] Get_Motherboard_Serial_And_Verify_Populated
110
111 ${serial_number}= Redfish.Get Attribute
112 ... ${REDFISH_CHASSIS_URI}motherboard SerialNumber
Michael Walshe7edb222019-08-19 17:39:38 -0500113 Valid Value serial_number
Steven Sombar815fa632019-07-16 14:24:40 -0500114 Rprint Vars serial_number
115
116
Steven Sombarb76d4df2019-08-06 15:03:47 -0500117Check GPU States When Power On
118 [Documentation] Check the State of each of the GPUs
119 ... in the system. A system may have 0-6 GPUs.
120 [Tags] Check_GPU_States_When_Power_On
Steven Sombarecf10e32019-07-25 08:51:00 -0500121
Steven Sombarb76d4df2019-08-06 15:03:47 -0500122 # System was powered-on in Suite Setup.
123 GPU State Check
Steven Sombarecf10e32019-07-25 08:51:00 -0500124
Steven Sombarb76d4df2019-08-06 15:03:47 -0500125
126Check GPU States When Power Off
127 [Documentation] Check the State of the GPUs when power is Off.
128 [Tags] Check_GPU_States_When_Power_Off
129
130 Redfish Power Off
131 Redfish.Login
132 GPU State Check
Steven Sombarecf10e32019-07-25 08:51:00 -0500133
134
Steven Sombarc90c8e22019-05-21 11:28:48 -0500135*** Keywords ***
136
137
Steven Sombarecf10e32019-07-25 08:51:00 -0500138Get CPU TotalCores
139 [Documentation] Return the TotalCores of a CPU.
140 ... Return 0 if this attribute is missing or NONE.
141 [Arguments] ${processor}
142
143 # Description of Argument(s):
144 # processor The Redfish URI of a CPU (e.g.
145 # "/redfish/v1/Systems/system/Processors/cpu0").
146
147 ${total_cores}= Redfish.Get Attribute ${processor} TotalCores
148 Return From Keyword If ${total_cores} is ${NONE} ${0}
149 [Return] ${total_cores}
150
151
Steven Sombarb76d4df2019-08-06 15:03:47 -0500152GPU State Check
153 [Documentation] The state of every "OK" GPU should be
154 ... "Absent", "Enabled", or "UnavailableOffline".
155
156 # Select only GPUs with Health = "OK".
157 ${gpus_ok}= Filter Struct ${gpu_info} [('Health', 'OK')]
158
159 :FOR ${gpu} IN @{gpus_ok}
160 ${status}= Redfish.Get Attribute ${gpu} Status
161 ${state}= Set Variable ${status['State']}
162 ${good_state}= Evaluate
163 ... any(x in '${state}' for x in ('Absent', 'Enabled', 'UnavailableOffline'))
164 Rprint Vars gpu state
165 Run Keyword If not ${good_state} Fail
166 ... msg=GPU State is not Absent, Enabled, or UnavailableOffline.
167 END
168
169
170Get Inventory URIs
171 [Documentation] Get and return a tuple of lists of URIs for CPU,
172 ... GPU and PowerSupplies.
173
174 ${processor_info}= Redfish_Utils.Enumerate Request
175 ... ${SYSTEM_BASE_URI}Processors return_json=0
176
177 ${cpu_info}= Filter Struct ${processor_info}
178 ... [('ProcessorType', 'CPU')] regex=1
179
180 ${gpu_info}= Filter Struct ${processor_info}
181 ... [('ProcessorType', 'Accelerator')] regex=1
182
183 ${power_supplies}= Redfish.Get Attribute
184 ... ${REDFISH_CHASSIS_POWER_URI} PowerSupplies
185
186 [Return] ${cpu_info} ${gpu_info} ${power_supplies}
187
188
Steven Sombarbccfd512019-06-05 15:50:35 -0500189Verify FRU Inventory Minimums
George Keishing3292d4a2019-06-19 02:04:53 -0500190 [Documentation] Verify a minimum number of FRUs.
Steven Sombarbccfd512019-06-05 15:50:35 -0500191 [Arguments] ${fru_type} ${min_num_frus}
Steven Sombarc90c8e22019-05-21 11:28:48 -0500192
193 # Description of Argument(s):
Steven Sombarbccfd512019-06-05 15:50:35 -0500194 # fru_type The type of FRU (e.g. "Processors", "Memory", etc.).
195 # min_num_frus The minimum acceptable number of FRUs found.
Steven Sombarc90c8e22019-05-21 11:28:48 -0500196
Steven Sombarbccfd512019-06-05 15:50:35 -0500197 # A valid FRU will have a "State" key of "Enabled" and a "Health" key
198 # of "OK".
Steven Sombarc90c8e22019-05-21 11:28:48 -0500199
Steven Sombarbccfd512019-06-05 15:50:35 -0500200 ${status} ${num_valid_frus}= Run Key U Get Num Valid FRUs \ ${fru_type}
Steven Sombarc90c8e22019-05-21 11:28:48 -0500201
Steven Sombarecf10e32019-07-25 08:51:00 -0500202 Rprint Vars fru_type num_valid_frus min_num_frus
203
Steven Sombarbccfd512019-06-05 15:50:35 -0500204 Return From Keyword If ${num_valid_frus} >= ${min_num_frus}
205 Fail Too few "${fru_type}" FRUs found, found only ${num_valid_frus}.
Steven Sombarc90c8e22019-05-21 11:28:48 -0500206
207
208Suite Teardown Execution
209 [Documentation] Do the post suite teardown.
210
211 Redfish.Logout
212
213
214Suite Setup Execution
215 [Documentation] Do test case setup tasks.
216
Steven Sombarecf10e32019-07-25 08:51:00 -0500217 Redfish Power On stack_mode=skip
Steven Sombarc90c8e22019-05-21 11:28:48 -0500218 Redfish.Login
Steven Sombarecf10e32019-07-25 08:51:00 -0500219
Steven Sombarb76d4df2019-08-06 15:03:47 -0500220 ${cpu_info} ${gpu_info} ${power_supplies}= Get Inventory URIs
Steven Sombarecf10e32019-07-25 08:51:00 -0500221
Steven Sombarb76d4df2019-08-06 15:03:47 -0500222 Set Suite Variable ${cpu_info}
223 Set Suite Variable ${gpu_info}
224 Set Suite Variable ${power_supplies}
Steven Sombarc90c8e22019-05-21 11:28:48 -0500225
226
227Test Teardown Execution
228 [Documentation] Do the post test teardown.
229
230 FFDC On Test Case Fail