1*** Settings *** 2Documentation Inventory of hardware FRUs under redfish. 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 14Test Tags Systems_Inventory 15 16*** Variables *** 17 18# The passing criteria. Must have at least this many. 19${min_num_dimms} 2 20${min_num_cpus} 1 21${min_num_cores} 18 22${min_num_power_supplies} 1 23 24 25*** Test Cases *** 26 27Verify CPU And Core Count 28 [Documentation] Get the total number of CPUs and cores in the system. 29 ... Verify counts are above minimums. 30 [Tags] Verify_CPU_And_Core_Count 31 32 # Select only CPUs with Health = "OK". 33 ${cpus_ok}= Filter Struct ${cpu_info} [('Health', 'OK')] 34 ${num_cpus}= Get Length ${cpus_ok} 35 36 Rprint Vars num_cpus min_num_cpus 37 38 # Assert that num_cpus is greater than or equal to min_num_cpus. 39 Valid Range num_cpus ${min_num_cpus} 40 41 # Get the number of cores. 42 ${total_num_cores}= Set Variable ${0} 43 FOR ${cpu} IN @{cpus_ok} 44 ${cores}= Get CPU TotalCores ${cpu} 45 ${total_num_cores}= Evaluate $total_num_cores + ${cores} 46 END 47 48 Rprint Vars total_num_cores min_num_cores 49 50 # Assert that total_num_cores is greater than or equal to 51 # min_num_cores. 52 Valid Range total_num_cores ${min_num_cores} 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 Memory Summary State And Verify Enabled 63 [Documentation] Check that the state of the MemorySummary attribute 64 ... under /redfish/v1/Systems/system is 'Enabled'. 65 [Tags] Get_Memory_Summary_State_And_Verify_Enabled 66 67 ${status}= Redfish.Get Attribute ${SYSTEM_BASE_URI} MemorySummary 68 ${memory_summary_state}= Set Variable ${status['Status']['State']} 69 Rprint Vars memory_summary_state 70 71 Should Be Equal As Strings Enabled ${memory_summary_state} 72 ... msg=MemorySummary State is not 'Enabled'. 73 74 75Get System Serial And Verify Populated 76 [Documentation] Check that the System SerialNumber is non-blank. 77 [Tags] Get_System_Serial_And_Verify_Populated 78 79 ${serial_number}= Redfish.Get Attribute ${SYSTEM_BASE_URI} SerialNumber 80 Valid Value serial_number 81 Rprint Vars serial_number 82 83 84Get Model And Verify Populated 85 [Documentation] Check that the Model is non-blank. 86 [Tags] Get_Model_And_Verify_Populated 87 88 ${model}= Redfish.Get Attribute ${SYSTEM_BASE_URI} Model 89 Valid Value model 90 Rprint Vars model 91 92 93Get Available Power Supplies And Verify 94 [Documentation] Get the number of functional power supplies and 95 ... verify that it is at or above the minimum. 96 [Tags] Get_Available_Power_Supplies_And_Verify 97 98 # Select only power supplies with Health = "OK". 99 ${power_supplies_ok}= Filter Struct ${power_supplies} [('Health', 'OK')] 100 101 # Count the power supplies that are Enabled or StandbyOffline. 102 ${total_num_supplies}= Set Variable ${0} 103 FOR ${power_supply} IN @{power_supplies_ok} 104 # Example of power_supply: 105 # power_supply = {'@odata.id': '/redfish/v1/Chassis/chassis/Power#/PowerSupplies/0', 106 # 'Manufacturer': '', 'MemberId': 'powersupply0', 'Model': '2100', 'Name': 107 # 'powersupply0', 'PartNumber': 'PNPWR123', 'PowerInputWatts': 394.0, 108 # 'SerialNumber': '75B12W', 'Status': {'Health': 'OK', 'State': 'Enabled'}} 109 ${state}= Set Variable ${power_supply['Status']['State']} 110 ${good_state}= Evaluate 111 ... any(x in '${state}' for x in ('Enabled', 'StandbyOffline')) 112 113 IF not ${good_state} CONTINUE 114 ${total_num_supplies}= Evaluate $total_num_supplies + ${1} 115 END 116 117 Rprint Vars total_num_supplies min_num_power_supplies 118 119 Valid Range total_num_supplies ${min_num_power_supplies} 120 121 122Get Motherboard Serial And Verify Populated 123 [Documentation] Check that the Motherboard SerialNumber is non-blank. 124 [Tags] Get_Motherboard_Serial_And_Verify_Populated 125 126 ${serial_number}= Redfish.Get Attribute ${REDFISH_CHASSIS_URI}${CHASSIS_ID} SerialNumber 127 Valid Value serial_number 128 Rprint Vars serial_number 129 130 131Verify Motherboard Manufacturer Field Value Populated 132 [Documentation] Check that the Motherboard manufacturer is non-blank. 133 [Tags] Verify_Motherboard_Manufacturer_Field_Value_Populated 134 135 ${motherboard_manufacturer}= Redfish.Get Attribute ${REDFISH_CHASSIS_URI}${CHASSIS_ID} Manufacturer 136 Valid Value motherboard_manufacturer 137 Rprint Vars motherboard_manufacturer 138 139 140Verify Motherboard Partnumber Field Value Populated 141 [Documentation] Check that the Motherboard partnumber is non-blank. 142 [Tags] Verify_Motherboard_Partnumber_Field_Value_Populated 143 144 ${motherboard_part_number}= Redfish.Get Attribute ${REDFISH_CHASSIS_URI}${CHASSIS_ID} PartNumber 145 Valid Value motherboard_part_number 146 Rprint Vars motherboard_part_number 147 148 149Check GPU States When Power On 150 [Documentation] Check the State of each of the GPUs 151 ... in the system. A system may have 0-6 GPUs. 152 [Tags] Check_GPU_States_When_Power_On 153 154 # System was powered-on in Suite Setup. 155 GPU State Check 156 157 158Check GPU States When Power Off 159 [Documentation] Check the State of the GPUs when power is Off. 160 [Tags] Check_GPU_States_When_Power_Off 161 162 Redfish Power Off 163 GPU State Check 164 165Verify Systems Collection With Unsupported Methods 166 [Documentation] Verify Systems collection with Unsupported methods 167 [Tags] Verify_Systems_Collection_With_Unsupported_Methods 168 169 # Get operation on Systems Collection 170 Redfish.Get /redfish/v1/Systems 171 ... valid_status_codes=[${HTTP_OK}] 172 173 # Put operation on Systems Collection 174 Redfish.Put /redfish/v1/Systems 175 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 176 177 # Post operation on Systems Collection 178 Redfish.Post /redfish/v1/Systems 179 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 180 181 # Delete operation on Systems Collection 182 Redfish.Delete /redfish/v1/Systems 183 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 184 185 # Patch operation on Systems Collection 186 Redfish.Patch /redfish/v1/Systems 187 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 188 189Verify Systems Instance Collection With Unsupported Methods 190 [Documentation] Verify Systems Instance collection with Unsupported methods 191 [Tags] Verify_Systems_Instance_Collection_With_Unsupported_Methods 192 193 # Get operation on Systems Instance Collection 194 Redfish.Get /redfish/v1/Systems/system 195 ... valid_status_codes=[${HTTP_OK}] 196 197 # Put operation on Systems Instance Collection 198 Redfish.Put /redfish/v1/Systems/system 199 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 200 201 # Post operation on Systems Instance Collection 202 Redfish.Post /redfish/v1/Systems/system 203 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 204 205 # Delete operation on Systems Instance Collection 206 Redfish.Delete /redfish/v1/Systems/system 207 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 208 209*** Keywords *** 210 211 212Get CPU TotalCores 213 [Documentation] Return the TotalCores of a CPU. 214 ... Return 0 if this attribute is missing or NONE. 215 [Arguments] ${processor} 216 217 # Description of Argument(s): 218 # processor The Redfish URI of a CPU (e.g. 219 # "/redfish/v1/Systems/system/Processors/cpu0"). 220 221 ${total_cores}= Redfish.Get Attribute ${processor} TotalCores 222 IF ${total_cores} is ${NONE} RETURN ${0} 223 RETURN ${total_cores} 224 225 226GPU State Check 227 [Documentation] The state of every "OK" GPU should be 228 ... "Absent", "Enabled", or "UnavailableOffline". 229 230 # Select only GPUs with Health = "OK". 231 ${gpus_ok}= Filter Struct ${gpu_info} [('Health', 'OK')] 232 233 FOR ${gpu} IN @{gpus_ok} 234 ${status}= Redfish.Get Attribute ${gpu} Status 235 ${state}= Set Variable ${status['State']} 236 ${good_state}= Evaluate 237 ... any(x in '${state}' for x in ('Absent', 'Enabled', 'UnavailableOffline')) 238 Rprint Vars gpu state 239 IF not ${good_state} 240 Fail msg=GPU State is not Absent, Enabled, or UnavailableOffline. 241 END 242 END 243 244 245Get Inventory URIs 246 [Documentation] Get and return a tuple of lists of URIs for CPU, 247 ... GPU and PowerSupplies. 248 249 250 ${processor_info}= Redfish_Utils.Enumerate Request 251 ... ${SYSTEM_BASE_URI}Processors return_json=0 252 253 ${cpu_info}= Filter Struct ${processor_info} 254 ... [('ProcessorType', 'CPU')] regex=1 255 256 ${gpu_info}= Filter Struct ${processor_info} 257 ... [('ProcessorType', 'Accelerator')] regex=1 258 259 ${power_supplies}= Redfish.Get Attribute 260 ... ${REDFISH_CHASSIS_URI}${CHASSIS_ID}/Power PowerSupplies 261 262 RETURN ${cpu_info} ${gpu_info} ${power_supplies} 263 264 265Verify FRU Inventory Minimums 266 [Documentation] Verify a minimum number of FRUs. 267 [Arguments] ${fru_type} ${min_num_frus} 268 269 # Description of Argument(s): 270 # fru_type The type of FRU (e.g. "Processors", "Memory", etc.). 271 # min_num_frus The minimum acceptable number of FRUs found. 272 273 # A valid FRU will have a "State" key of "Enabled" and a "Health" key 274 # of "OK". 275 276 ${status} ${num_valid_frus}= Run Key U Get Num Valid FRUs \ ${fru_type} 277 278 Rprint Vars fru_type num_valid_frus min_num_frus 279 280 Return From Keyword If ${num_valid_frus} >= ${min_num_frus} 281 Fail Too few "${fru_type}" FRUs found, found only ${num_valid_frus}. 282 283 284Suite Teardown Execution 285 [Documentation] Do the post suite teardown. 286 287 Redfish.Logout 288 289 290Suite Setup Execution 291 [Documentation] Do test case setup tasks. 292 293 Redfish.Login 294 Redfish Power On stack_mode=skip 295 296 ${cpu_info} ${gpu_info} ${power_supplies}= Get Inventory URIs 297 298 Set Suite Variable ${cpu_info} 299 Set Suite Variable ${gpu_info} 300 Set Suite Variable ${power_supplies} 301 302 303Test Teardown Execution 304 [Documentation] Do the post test teardown. 305 306 FFDC On Test Case Fail 307