Inventory test suite
Added support for following:
- Suite Setup
- Keywords to support test
- Add test "Verify System Inventory"
- Add test "Verify Chassis Motherboard Properties"
Resolves openbmc/openbmc-test-automation#260
Change-Id: Ieb8c2c7b9bdb3102cdb05e19441d3e3c595f6ed3
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/data/variables.py b/data/variables.py
index ab6ab98..a597165 100644
--- a/data/variables.py
+++ b/data/variables.py
@@ -43,6 +43,9 @@
SOFTWARE_VERSION_URI = '/xyz/openbmc_project/software/'
ACTIVE = 'xyz.openbmc_project.Software.Activation.Activations.Active'
+# Inventory URI
+HOST_INVENTORY_URI = '/xyz/openbmc_project/inventory/'
+
'''
QEMU HTTPS variable:
diff --git a/tests/test_inventory.robot b/tests/test_inventory.robot
index acee981..e4102f0 100644
--- a/tests/test_inventory.robot
+++ b/tests/test_inventory.robot
@@ -1,123 +1,73 @@
*** Settings ***
-Documentation This testsuite is for testing inventory
-Suite Teardown Delete All Sessions
+Documentation System inventory related test.
+
Resource ../lib/rest_client.robot
Resource ../lib/utils.robot
Resource ../lib/state_manager.robot
Resource ../lib/openbmc_ffdc.robot
-Library ../lib/utilities.py
-Library String
-Library Collections
Variables ../data/variables.py
+Variables ../data/inventory.py
-Suite setup Setup The Suite
+Suite setup Test Suite Setup
Test Teardown FFDC On Test Case Fail
-Force Tags chassisboot inventory
-
*** Test Cases ***
-Minimal CPU Inventory
- [Tags] Minimal_CPU_Inventory
+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
- ${count}= Get Total Present cpu
- Should Be True ${count}>${0}
-Minimal DIMM Inventory
- [Tags] Minimal DIMM Inventory
-
- ${count}= Get Total Present dimm
- Should Be True ${count}>=${2}
-
-Minimal Core Inventory
- [Tags] Minimal_Core_Inventory
-
- ${count}= Get Total Present core
- Should Be True ${count}>${0}
-
-Minimal Memory Buffer Inventory
- [Tags] Minimal_Memory_Buffer_Inventory
-
- ${count}= Get Total Present membuf
- Should Be True ${count}>${0}
-
-Minimal Fan Inventory
- [Tags] Minimal_Fan_Inventory
-
- ${count}= Get Total Present fan
- Should Be True ${count}>${2}
-
-Minimal Main Planar Inventory
- [Tags] Minimal_Main_Planar_Inventory
-
- ${count}= Get Total Present motherboard
- Should Be True ${count}>${0}
-
-Minimal System Inventory
- [Tags] Minimal_System_Inventory
-
- ${count}= Get Total Present system
- Should Be True ${count}>${0}
-
-Verify CPU VPD Properties
- [Tags] Verify_CPU_VPD_Properties
-
- Verify Properties CPU
-
-Verify DIMM VPD Properties
- [Tags] Verify_DIMM_VPD_Properties
-
- Verify Properties DIMM
-
-Verify Memory Buffer VPD Properties
- [Tags] Verify_Memory_Buffer_VPD_Properties
-
- Verify Properties MEMORY_BUFFER
-
-Verify Fan VPD Properties
- [Tags] Verify_Fan_VPD_Properties
-
- Verify Properties FAN
-
-Verify System VPD Properties
- [Tags] Verify_System_VPD_Properties
-
- Verify Properties SYSTEM
-
+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"]["Manufacturer"]} 0000000000000000
+ ... msg=motherboard field invalid.
+ 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.
*** Keywords ***
-Setup The Suite
- ${host_state}= Get Host State
- Run Keyword If '${host_state}' == 'Off' Initiate Host Boot
+Test Suite Setup
+ [Documentation] Do the initial suite setup.
+ ${current_state}= Get Host State
+ Run Keyword If '${current_state}' == 'Off'
+ ... Initiate Host Boot
- ${resp}= Read Properties ${INVENTORY_URI}enumerate
- Set Suite Variable ${SYSTEM_INFO} ${resp}
- Log Dictionary ${resp}
-Get Total Present
- [Arguments] ${type}
- ${l}= Create List []
- ${resp}= Get Dictionary Keys ${SYSTEM_INFO}
- ${list}= Get Matches ${resp} regexp=^.*[0-9a-z_].${type}[0-9]*$
- : FOR ${element} IN @{list}
- \ Append To List ${l} ${SYSTEM_INFO['${element}']['present']}
-
- ${sum}= Get Count ${l} True
- [Return] ${sum}
-
-Verify Properties
- [Arguments] ${type}
-
- ${list}= Get VPD Inventory List ${OPENBMC_MODEL} ${type}
- : FOR ${element} IN @{list}
- \ ${d}= Get From Dictionary ${SYSTEM_INFO} ${element}
- \ Run Keyword If ${d['present']} == True Verify Present Properties ${d} ${type}
-
-Verify Present Properties
- [Arguments] ${d} ${type}
- ${keys}= Get Dictionary Keys ${d}
- Log List ${keys}
- Log List ${INVENTORY_ITEMS['${type}']}
- Lists Should Be Equal ${INVENTORY_ITEMS['${type}']} ${keys}
+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}