blob: 96fdc7db288e7abc55704a813aa7fe8d8f23811c [file] [log] [blame]
*** Settings ***
Documentation System inventory related test.
Resource ../lib/rest_client.robot
Resource ../lib/utils.robot
Resource ../lib/state_manager.robot
Resource ../lib/openbmc_ffdc.robot
Resource ../lib/list_utils.robot
Resource ../lib/boot_utils.robot
Resource ../lib/fan_utils.robot
Library ../lib/utilities.py
Library Collections
Variables ../data/variables.py
Variables ../data/inventory.py
Suite Setup Suite Setup Execution
Test Teardown FFDC On Test Case Fail
Force Tags Inventory
***Variables***
${LOOP_COUNT} ${1}
*** Test Cases ***
Verify System Inventory Path
[Documentation] Check if system inventory path exist.
[Tags] Verify_System_Inventory_Path
# When the host is booted, system inventory path should exist.
# Example: /xyz/openbmc_project/inventory/system
Get Inventory system
Verify Boxelder Present Property
[Documentation] Boxelder should be present by default.
[Tags] Verify_Boxelder_Present_Property
# Example:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc":
# {
# "BuildDate": "",
# "FieldReplaceable": 0,
# "Manufacturer": "<Manufacturer Name>",
# "Model": "",
# "PartNumber": "01DH051",
# "Present": 1,
# "PrettyName": "BMC PLANAR ",
# "SerialNumber": "000000000000"
# },
${json_data}= Get Inventory system/chassis/motherboard/boxelder/bmc
Should Be True ${json_data["data"]["Present"]}
Should Not Be Equal As Strings
... ${json_data["data"]["SerialNumber"]} 000000000000
... msg=BMC planar serial number invalid.
Verify UUID Entry
[Documentation] UUID entry should exist in BMC planar property.
[Tags] Verify_UUID_Entry
# Example:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc":
# {
# "BuildDate": "",
# "FieldReplaceable": 0,
# "Manufacturer": "<Manufacturer Name>",
# "Model": "",
# "PartNumber": "01DH051",
# "Present": 1,
# "PrettyName": "BMC PLANAR ",
# "SerialNumber": "000000000000"
# "UUID": ""
# },
${resp}= OpenBMC Get Request
... ${HOST_INVENTORY_URI}system/chassis/motherboard/boxelder/bmc/attr/UUID
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Verify Boxelder MAC Address Property Is Populated
[Documentation] Boxelder should be present by default.
[Tags] Verify_Boxelder_MAC_Address_Property_Is_Populated
# Example:
# /xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc/ethernet
# {
# "FieldReplaceable": 0,
# "MACAddress": "00:00:00:00:00:00",
# "Present": 1,
# "PrettyName": ""
# }
${json_data}= Get Inventory
... system/chassis/motherboard/boxelder/bmc/ethernet
Should Be True ${json_data["data"]["Present"]}
Should Not Be Equal As Strings
... ${json_data["data"]["MACAddress"]} 00:00:00:00:00:00
# eth0 Link encap:Ethernet HWaddr 70:E2:84:14:23:F9
${mac_addr} ${stderr} ${rc}= BMC Execute Command
... /sbin/ifconfig -a | grep eth0 | grep HWaddr | awk -F'HWaddr ' '{print $2}'
... return_stderr=True
Should Be Empty ${stderr}
Should Be Equal As Strings ${json_data["data"]["MACAddress"]}
... ${mac_addr.strip()} msg=MAC address configured incorrectly.
... ignore_case=True
Verify Chassis Motherboard Properties
[Documentation] Check if chassis motherboard properties are
... populated valid.
[Tags] Verify_Chassis_Motherboard_Properties
# When the host is booted, the following properties should
# be populated Manufacturer, PartNumber, SerialNumber and
# it should not be zero's.
# Example:
# "data": {
# "/xyz/openbmc_project/inventory/system/chassis/motherboard": {
# "BuildDate": "",
# "Manufacturer": "0000000000000000",
# "Model": "",
# "PartNumber": "0000000",
# "Present": 0,
# "PrettyName": "SYSTEM PLANAR ",
# "SerialNumber": "000000000000"
# }
${properties}= Get Inventory system/chassis/motherboard
Should Not Be Equal As Strings
... ${properties["data"]["PartNumber"]} 0000000
... msg=motherboard part number invalid.
Should Not Be Equal As Strings
... ${properties["data"]["SerialNumber"]} 000000000000
... msg=motherboard serial number invalid.
Verify CPU Present
[Documentation] Check if the FRU "Present" is set for CPU's.
[Tags] Verify_CPU_Present
# System inventory cpu list:
# /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
# /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1
# Example:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0": {
# "FieldReplaceable": 1,
# "BuildDate": "",
# "Cached": 0,
# "SerialNumber": "YA3933741574",
# "Version": "10",
# "Model": "",
# "PrettyName": "PROCESSOR MODULE",
# "PartNumber": "01HL322",
# "Present": 1,
# "Manufacturer": "<Manufacturer Name>"
# },
# The CPU properties "Present" should be boolean 1.
${cpu_list}= Get Endpoint Paths ${HOST_INVENTORY_URI}system cpu
FOR ${cpu_uri} IN @{cpu_list}
${present}= Read Attribute ${cpu_uri} Present
Should Be True ${present}
END
Verify DIMM Present
[Documentation] Check if the FRU "Present" is set for DIMM's.
[Tags] Verify_DIMM_Present
# Example:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0": {
# "FieldReplaceable": 1,
# "BuildDate": "",
# "Cached": 0,
# "SerialNumber": "0x0300cf4f",
# "Version": "0x00",
# "Model": "M393A1G40EB1-CRC ",
# "PrettyName": "0x0c",
# "PartNumber": "",
# "Present": 1,
# "Manufacturer": "0xce80"
# },
# The DIMM properties "Present" should be boolean 1.
${dimm_list}= Get Endpoint Paths ${HOST_INVENTORY_URI}system dimm
FOR ${dimm_uri} IN @{dimm_list}
${present}= Read Attribute ${dimm_uri} Present
Should Be True ${present}
END
Verify FRU Properties
[Documentation] Verify the FRU properties fields.
[Tags] Verify_FRU_Properties
# Example:
# A FRU would have "FieldReplaceable" set to boolean 1 and should have
# the following entries
# "fru": [
# "FieldReplaceable"
# "BuildDate",
# "Cached"
# "SerialNumber",
# "Version",
# "Model",
# "PrettyName",
# "PartNumber",
# "Present",
# "Manufacturer",
# ]
# and FRU which doesn't have one of this fields is an error.
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0": {
# "FieldReplaceable": 1,
# "BuildDate": "",
# "Cached": 0,
# "SerialNumber": "0x0300cf4f",
# "Version": "0x00",
# "Model": "M393A1G40EB1-CRC ",
# "PrettyName": "0x0c",
# "PartNumber": "",
# "Present": 1,
# "Manufacturer": "0xce80"
# },
${system_list}= Get Endpoint Paths ${HOST_INVENTORY_URI}system *
${fru_list}= Qualified FRU List @{system_list}
Validate FRU Properties Fields fru EQU @{fru_list}
Verify GPU Properties
[Documentation] Verify the GPU properties fields.
[Tags] Verify_GPU_Properties
# Example:
# A GPU property should have the following entries:
# "gpu":[
# "FieldReplaceable",
# "PrettyName",
# "Present",
# "Functional"
# ]
# GPU inventory:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card2": {
# "FieldReplaceable": 1,
# "Functional": 1,
# "Present": 1,
# "PrettyName": ""
# },
${system_list}= Get Endpoint Paths
... ${HOST_INVENTORY_URI}system/chassis/motherboard gv*
Validate FRU Properties Fields gpu EQU @{system_list}
Verify Core Properties
[Documentation] Verify the core property fields.
[Tags] Verify_Core_Properties
# Example:
# A core property should have the following entries:
# "core":[
# "PrettyName",
# "Present",
# "Functional"
# ]
# core inventory:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core0": {
# "Functional": 1,
# "Present": 1,
# "PrettyName": ""
# },
${system_list}= Get Endpoint Paths
... ${HOST_INVENTORY_URI}system/chassis/motherboard core*
Validate FRU Properties Fields core EQU @{system_list}
Verify Fan Properties
[Documentation] Verify the fan property fields.
[Tags] Verify_Fan_Properties
# Example:
# A fan property should have the following entries:
# "core":[
# "PrettyName",
# "Present",
# "MeetsMinimumShipLevel",
# "Functional"
# ]
# fan inventory:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/fan0": {
# "Functional": 1,
# "MeetsMinimumShipLevel": 1,
# "Present": 1,
# "PrettyName": "fan0"
# },
${water_cooled}= Is Water Cooled
${system_list}= Get Endpoint Paths
... ${HOST_INVENTORY_URI}system/chassis/motherboard fan*
Printn
Rprint Vars water_cooled system_list
Run Keyword If ${water_cooled}
... Validate FRU Properties Fields fan_wc SUBSET @{system_list}
... ELSE
... Validate FRU Properties Fields fan EQU @{system_list}
Verify Core Functional State
[Documentation] Verify that "Present" core property is set if "Functional"
... core property is set.
[Tags] Verify_Core_Functional_State
# Example:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core5":{
# "Functional": 1,
# "Present": 1,
# "PrettyName": ""
# },
${core_list}= Get Endpoint Paths ${HOST_INVENTORY_URI}system core
FOR ${core_uri} IN @{core_list}
${status}= Run Keyword And Return Status
... Check URL Property Is Functional ${core_uri}
Continue For Loop If '${status}' == '${False}'
${present}= Read Attribute ${core_uri} Present
Should Be True ${present}
... msg=${core_uri} is functional but not present.
END
Verify DIMM Functional State
[Documentation] Verify that "Present" DIMM property is set if "Functional"
... DIMM property is set.
[Tags] Verify_DIMM_Functional_State
# Example:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0": {
# "BuildDate": "",
# "Cached": 0,
# "FieldReplaceable": 1,
# "Functional": 1,
# "Manufacturer": "0xce80",
# "Model": "M393A1G40EB1-CRC ",
# "PartNumber": "",
# "Present": 1,
# "PrettyName": "0x0c",
# "SerialNumber": "0x0300cf4f",
# "Version": "0x00"
# },
${dimm_list}= Get Endpoint Paths ${HOST_INVENTORY_URI}system dimm
FOR ${dimm_uri} IN @{dimm_list}
${status}= Run Keyword And Return Status
... Check URL Property Is Functional ${dimm_uri}
Continue For Loop If '${status}' == '${False}'
${present}= Read Attribute ${dimm_uri} Present
Should Be True ${present}
... msg=${dimm_uri} is functional but not present.
END
Verify Fan Functional State
[Documentation] Verify that "Present" fan property is set if "Functional"
... fan property is set.
[Tags] Verify_Fan_Functional_State
# Example:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/fan0": {
# "Functional": 1,
# "Present": 1,
# "PrettyName": "fan0"
# },
${fan_list}= Get Endpoint Paths ${HOST_INVENTORY_URI}system fan*
Should Not Be Empty ${fan_list}
FOR ${fan_uri} IN @{fan_list}
${status}= Run Keyword And Return Status
... Check URL Property Is Functional ${fan_uri}
Continue For Loop If '${status}' == '${False}'
${present}= Read Attribute ${fan_uri} Present
Should Be True ${present}
... msg=${fan_uri} is functional but "Present" is not set.
END
Verify CPU Functional State
[Documentation] Verify that "Present" CPU property is set if "Functional"
... CPU property is set.
[Tags] Verify_CPU_Functional_State
# Example of cpu* endpoint data:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0": {
# "Functional": 1,
# "Present": 1,
# "PrettyName": "cpu0"
# },
${cpu_list}= Get Endpoint Paths ${HOST_INVENTORY_URI}system cpu*
Should Not Be Empty ${cpu_list}
FOR ${cpu_uri} IN @{cpu_list}
${status}= Run Keyword And Return Status
... Check URL Property Is Functional ${cpu_uri}
Continue For Loop If '${status}' == '${False}'
${present}= Read Attribute ${cpu_uri} Present
Should Be True ${present}
... msg=${cpu_uri} is functional but "Present" is not set.
END
Verify GPU Functional State
[Documentation] Verify that "Functional" GPU property is set if "Present"
... GPU property is set
[Tags] Verify_GPU_Functional_State
# Example of gv* endpoint data:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card4": {
# "Functional": 1,
# "Present": 1,
# "PrettyName": ""
# },
${gpu_list}= Get Endpoint Paths
... ${HOST_INVENTORY_URI}system/chassis/motherboard gv*
Should Not Be Empty ${gpu_list}
FOR ${gpu_uri} IN @{gpu_list}
${status}= Run Keyword And Return Status
... Check URL Property Is Functional ${gpu_uri}
Continue For Loop If '${status}' == '${False}'
${present}= Read Attribute ${gpu_uri} Present
Should Be True ${present}
... msg=${gpu_uri} is functional but "Present" is not set.
END
Check Air Or Water Cooled
[Documentation] Check if this system is Air or water cooled.
[Tags] Check_Air_Or_Water_Cooled
# Example:
# "/xyz/openbmc_project/inventory/system/chassis": {
# "AirCooled": 1,
# "WaterCooled": 0
# },
${air_cooled}= Read Attribute
... /xyz/openbmc_project/inventory/system/chassis AirCooled
Log AirCooled:${air_cooled}
${water_cooled}= Read Attribute
... /xyz/openbmc_project/inventory/system/chassis WaterCooled
Log WaterCooled:${water_cooled}
Run Keyword If ${air_cooled}==${0} and ${water_cooled}==${0}
... Fail Neither AirCooled or WaterCooled.
Verify Minimal CPU Inventory
[Documentation] Verify minimal CPU inventory.
[Tags] Verify_Minimal_CPU_Inventory
[Template] Minimum Inventory
# item minimum_count
cpu 1
Verify Minimal DIMM Inventory
[Documentation] Verify minimal DIMM inventory.
[Tags] Verify_Minimal_DIMM_Inventory
[Template] Minimum Inventory
# item minimum_count
dimm 2
Verify Minimal Core Inventory
[Documentation] Verify minimal core inventory.
[Tags] Verify_Minimal_Core_Inventory
[Template] Minimum Inventory
# item minimum_count
core 1
Verify Minimal Memory Buffer Inventory
[Documentation] Verify minimal memory buffer inventory.
[Tags] Verify_Minimal_Memory_Buffer_Inventory
[Template] Minimum Inventory
# item minimum_count
memory_buffer 1
Verify Minimal Fan Inventory
[Documentation] Verify minimal fan inventory.
[Tags] Verify_Minimal_Fan_Inventory
[Template] Minimum Inventory
# item minimum_count
fan 2
Verify Minimal Main Planar Inventory
[Documentation] Verify minimal main planar inventory.
[Tags] Verify_Minimal_Main_Planar_Inventory
[Template] Minimum Inventory
# item minimum_count
main_planar 1
Verify Minimal System Inventory
[Documentation] Verify minimal system inventory.
[Tags] Verify_Minimal_System_Inventory
[Template] Minimum Inventory
# item minimum_count
system 1
Verify Minimal Power Supply Inventory
[Documentation] Verify minimal power supply inventory.
[Tags] Verify_Minimal_Power_Supply_Inventory
[Template] Minimum Inventory
# Example:
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0",
# "/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply1",
# item minimum_count
powersupply 1
Verify Inventory List After Reboot
[Documentation] Verify inventory list after reboot.
[Tags] Verify_Inventory_List_After_Reboot
Repeat Keyword ${LOOP_COUNT} times Choose Boot Option reboot
Verify Inventory List After Reset
[Documentation] Verify inventory list after reset.
[Tags] Verify_Inventory_List_After_Reset
Repeat Keyword ${LOOP_COUNT} times Choose Boot Option reset
*** Keywords ***
Suite Setup Execution
[Documentation] Do the initial suite setup.
Smart Power Off
REST Power On
Delete All Error Logs
Get Inventory
[Documentation] Get the properties of an endpoint.
[Arguments] ${endpoint}
# Description of arguments:
# endpoint string for which url path ending.
# Example: "system" is the endpoint for url
# /xyz/openbmc_project/inventory/system
${resp}= OpenBMC Get Request ${HOST_INVENTORY_URI}${endpoint}
Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
${jsondata}= To JSON ${resp.content}
[Return] ${jsondata}
Qualified FRU List
[Documentation] Build the list of valid FRUs.
[Arguments] @{system_list}
# Description of arguments:
# system_list List of system inventory URLs.
# Example:
# /xyz/openbmc_project/inventory/system/chassis/motherboard
# /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
# /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1
# /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0
# /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm1
# /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm2
# /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm3
# /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm4
# /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm5
# /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm6
# /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm7
${fru_list}= Create List
FOR ${fru_uri} IN @{system_list}
${resp}= OpenBMC Get Request ${fru_uri}/attr/FieldReplaceable
... quiet=${1}
${jsondata}= To JSON ${resp.content}
${status}= Run Keyword And Return Status
... Should Be True ${jsondata['data']} == ${1}
Run Keyword If '${status}' == '${True}'
... Append To List ${fru_list} ${fru_uri}
END
${fru_valid_list}= Filter GPU FRU Entries ${fru_list}
[Return] ${fru_valid_list}
Filter GPU FRU Entries
[Documentation] Remove GPU entries from FRU list and return the result.
[Arguments] ${fru_list}
# Description of arguments:
# fru_list List of FRU system inventory URIs.
# Example FRUs list:
# [u'/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm1',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card1',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card3',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card4']
# Example of the matched GPU FRUs entries:
# [u'/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card1',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card3',
# u'/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card4']
${gpu_matches}= Get Matches ${fru_list} *gv*
Remove Values From List ${fru_list} @{gpu_matches}
[Return] ${fru_list}
Validate FRU Properties Fields
[Documentation] Compare valid FRUs from system to expected FRU set.
[Arguments] ${fru_type} ${comparison_type} @{fru_list}
# Description of argument(s):
# fru_type FRU type name (e.g. "gpu", "fru", "fan", etc.).
# comparison_type A string indicating the comparison method.
# "EQU" for equality, "SUBSET" for subset comparison.
# fru_list List of FRU URLs.
# Get the pre-defined fru_type attributes from the inventory dictionary
# for the fru_type. Example:
# set(['Version', 'PartNumber', 'SerialNumber', 'FieldReplaceable',
# 'BuildDate', 'Present', 'Manufacturer', 'PrettyName', 'Cached', 'Model'])
${fru_set}= List To Set ${inventory_dict['${fru_type}']}
Rprint Vars fru_set
# Iterate through the url of the FRU and compare its attributes with
# the pre-defined fru_type attributes.
FOR ${fru_url_path} IN @{fru_list}
${fru_field}= Read Properties ${fru_url_path}
${fru_keys}= List To Set ${fru_field.viewkeys()}
Rprint Vars fru_keys
Run Keyword If '${comparison_type}' == 'EQU'
... Should Be Equal ${fru_keys} ${fru_set}
... ELSE
... Should Be True $fru_set.issubset($fru_keys)
END
Check URL Property Is Functional
[Documentation] Verify that the given url property is functional.
[Arguments] ${url_path}
# Description of arguments:
# url_path Full url path of the inventory object.
# Example: DIMM / core property url's
# /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0
# /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core0
${state}= Read Attribute ${url_path} Functional
Should Be True ${state}
Choose Boot Option
[Documentation] Choose BMC reset or host reboot.
[Arguments] ${option}
Run Keyword If '${option}' == 'reboot'
... Verify Inventory List Before And After Reboot
... ELSE
... Verify Inventory List Before And After Reset
Verify Inventory List Before And After Reboot
[Documentation] Verify inventory list before and after reboot.
REST Power On stack_mode=skip quiet=1
Delete All Error Logs
${inventory_before}= Get URL List ${HOST_INVENTORY_URI}
Host Reboot
Delete All Error Logs
${inventory_after}= Get URL List ${HOST_INVENTORY_URI}
Lists Should Be Equal ${inventory_before} ${inventory_after}
Verify Inventory List Before And After Reset
[Documentation] Verify inventory list before and after BMC reset.
REST Power On stack_mode=skip quiet=1
Delete All Error Logs
${inventory_before}= Get URL List ${HOST_INVENTORY_URI}
OBMC Reboot (run)
Delete All Error Logs
${inventory_after}= Get URL List ${HOST_INVENTORY_URI}
Lists Should Be Equal ${inventory_before} ${inventory_after}
Minimum Inventory
[Documentation] Check for minimum inventory.
[Arguments] ${item} ${minimum_count}
# Description of argument(s):
# item Inventory name (example: "fan/cpu/dimm/etc").
# minimum_count The minimum number of the given item.
${count}= Get Number Hardware Items ${item}
Should Be True ${count}>=${minimum_count}
Get Number Hardware Items
[Documentation] Get the count of the total present currently on inventory.
[Arguments] ${item}
# Description of argument(s):
# item Inventory name (example: "fan/cpu/dimm/etc").
${count_inventory} Set Variable ${0}
${list}= Get Endpoint Paths ${HOST_INVENTORY_URI}system/
... ${item}
FOR ${element} IN @{list}
${present}= Read Properties ${element}
${count_inventory}= Set Variable if ${present['Present']} == 1
... ${count_inventory+1} ${count_inventory}
END
[return] ${count_inventory}