Add systest/collection test cases and utility functions needed
- Add systest data collection test cases.
- Add functions/keywords for displaying non informational error
and event logs.
- Add URIs for inventory reading.
Signed-off-by: Joy Onyerikwu <Onyekachukwu.Joy.Onyerikwu@ibm.com>
Change-Id: Id4e7b131a029d7dd727c1e1511c60640b6007b2f
diff --git a/systest/collection/bmc_collect_esels.robot b/systest/collection/bmc_collect_esels.robot
new file mode 100644
index 0000000..776f920
--- /dev/null
+++ b/systest/collection/bmc_collect_esels.robot
@@ -0,0 +1,76 @@
+*** Settings ***
+Documentation BMC server health, collect eSELs.
+
+# Test Parameters:
+# OPENBMC_HOST The BMC host name or IP address.
+
+Resource ../../lib/bmc_redfish_resource.robot
+Resource ../../lib/openbmc_ffdc.robot
+
+Suite Setup Suite Setup Execution
+Suite Teardown Suite Teardown Execution
+Test Setup Printn
+
+*** Variables ***
+${QUIET} ${1}
+${error_logs_flagged_rest} Rest error log collection excluded
+${event_logs_flagged_redfish} Redfish event log collection excluded
+${rest_error_logs} Rest error log collection excluded
+${redfish_event_logs} Redfish error log collection excluded
+
+*** Test Cases ***
+
+Rest Collect eSELs
+ [Documentation] Collect eSEL using the OpenBMC Rest API.
+ [Tags] Rest_Collect_eSELs rest
+ [Teardown] FFDC On Test Case Fail clean_up=${FALSE}
+
+ ${error_logs}= Get Error Logs ${QUIET}
+ ${rest_error_logs}= gen_robot_print.Sprint Vars error_logs
+ Set Suite Variable ${rest_error_logs}
+ Log To Console ${rest_error_logs}
+
+ # Filter out informational error logs.
+ ${non_informational_error_logs}= Filter Struct ${error_logs} [('Severity', '\.Informational$')]
+ ... regex=1 invert=1
+ ${error_logs_flagged_rest}= gen_robot_print.Sprint Vars non_informational_error_logs
+ Set Suite Variable ${error_logs_flagged_rest}
+
+
+Redfish Collect eSELs
+ [Documentation] Collect eSEL with Redfish.
+ [Tags] Redfish_Collect_eSELs redfish
+ [Setup] Redfish.Login
+ [Teardown] Redfish Test Teardown Execution
+
+ ${redfish_event_logs}= Get Event Logs
+ ${redfish_event_logs}= gen_robot_print.Sprint Vars redfish_event_logs
+ Set Suite Variable ${redfish_event_logs}
+ Log To Console ${redfish_event_logs}
+ ${event_logs_flagged_redfish}= Get Event Logs Not Ok
+ ${event_logs_flagged_redfish}= gen_robot_print.Sprint Vars event_logs_flagged_redfish
+ Set Suite Variable ${event_logs_flagged_redfish}
+
+
+*** Keywords ***
+
+Suite Setup Execution
+ [Documentation] Do test suite setup tasks.
+
+ Set Log Level DEBUG
+ REST Power On stack_mode=skip
+
+
+Suite Teardown Execution
+ [Documentation] Do suite teardown tasks. Log error and event logs collected.
+
+ Log Many ${rest_error_logs} ${redfish_event_logs}
+ Log Flagged error logs found via REST:${\n}${error_logs_flagged_rest} console=true
+ Log Flagged events logs found via Redfish:${\n}${event_logs_flagged_redfish} console=true
+
+
+Redfish Test Teardown Execution
+ [Documentation] Do the post test teardown for redfish.
+
+ Redfish.Logout
+ FFDC On Test Case Fail clean_up=${FALSE}
diff --git a/systest/collection/bmc_collect_sensors.robot b/systest/collection/bmc_collect_sensors.robot
new file mode 100644
index 0000000..8862308
--- /dev/null
+++ b/systest/collection/bmc_collect_sensors.robot
@@ -0,0 +1,93 @@
+*** Settings ***
+Documentation BMC server health, collect sensors.
+
+# Test Parameters:
+# OPENBMC_HOST The BMC host name or IP address.
+
+Resource ../../lib/bmc_redfish_resource.robot
+Resource ../../lib/openbmc_ffdc.robot
+Library Collections
+Library ../syslib/utils_keywords.py
+
+Suite Setup Suite Setup Execution
+Suite Teardown Suite Teardown Execution
+Test Setup Printn
+
+*** Variables ***
+${QUIET} ${1}
+${sensors_values_rest} Rest sensors collection excluded
+${sensors_values_redfish} Redfish sensors collection excluded
+${sensors_flagged_rest} Rest sensors collection excluded
+${sensors_flagged_redfish} Redfish sensors collection excluded
+
+
+*** Test Cases ***
+
+Rest Collect Sensors
+ [Documentation] Collect the sensors values using the OpenBMC Rest API.
+ [Tags] Rest_Collect_Sensors rest
+ [Teardown] FFDC On Test Case Fail clean_up=${FALSE}
+
+ ${sensors}= OpenBMC Get Request ${SENSORS_URI}enumerate
+ ${sensors}= Evaluate $sensors.json()['data']
+ ${sensors_collected_via_rest}= gen_robot_print.Sprint Vars sensors
+ Log To Console ${sensors_collected_via_rest}
+ ${fans}= Filter Struct ${sensors} [('Unit', '\.RPMS$')] regex=1
+ ${no_fans}= Filter Struct ${sensors} [('WarningAlarmHigh', None),('WarningAlarmLow', None)]
+ ... invert=${True}
+ Log sensor values raw:${\n}${sensors}${\n}sensors no fans:${\n}${no_fans}${\n}fans:${\n}${fans}
+ ... level=DEBUG
+
+ ${fans_flagged}= Filter Struct ${fans}
+ ... [('CriticalAlarmHigh', False),('CriticalAlarmLow', False)] invert=${True}
+ ${filter_str}= Catenate [('CriticalAlarmHigh', False),('CriticalAlarmLow', False),
+ ... ('WarningAlarmHigh', False),('WarningAlarmLow', False)]
+ ${other_sensors_flagged}= Filter Struct ${no_fans} ${filter_str} invert=${True}
+ ${sensors_flagged_rest}= gen_robot_print.Sprint Vars fans_flagged other_sensors_flagged
+ Set Suite Variable ${sensors_flagged_rest}
+
+
+Redfish Collect Sensors
+ [Documentation] Collect the sensor values using Redfish.
+ [Tags] Redfish_Collect_Sensors redfish
+ [Setup] Redfish.Login
+ [Teardown] Redfish Test Teardown Execution
+
+ ${redfish_chassis_power}= Redfish_Utils.Enumerate Request ${REDFISH_CHASSIS_POWER_URI} ${0}
+ ${redfish_chassis_thermal}= Redfish_Utils.Enumerate Request ${REDFISH_CHASSIS_THERMAL_URI} ${0}
+ ${redfish_chassis_sensors}= Redfish_Utils.Enumerate Request ${REDFISH_CHASSIS_SENSORS_URI} ${0}
+ ${sensors_values_redfish}= gen_robot_print.Sprint Vars
+ ... redfish_chassis_power redfish_chassis_thermal redfish_chassis_sensors
+ Set Suite Variable ${sensors_values_redfish}
+ Log To Console ${sensors_values_redfish}
+
+ ${health_check_filter_dict}= Create Dictionary Health=OK
+ ${merged_dicts}= Evaluate {**$redfish_chassis_power, **$redfish_chassis_thermal}
+ Log ${merged_dicts} level=DEBUG
+ ${sensors_flagged_redfish}= Filter Struct ${merged_dicts} ${health_check_filter_dict} invert=${TRUE}
+ ${sensors_flagged_redfish}= gen_robot_print.Sprint Vars sensors_flagged_redfish
+ Set Suite Variable ${sensors_flagged_redfish}
+
+
+*** Keywords ***
+
+Suite Setup Execution
+ [Documentation] Do suite setup tasks.
+
+ Set Log Level DEBUG
+ REST Power On stack_mode=skip
+
+
+Suite Teardown Execution
+ [Documentation] Do suite teardown tasks. Log sensor values collected.
+
+ Log Many ${sensors_values_rest} ${sensors_values_redfish}
+ Log Sensors detected out of bounds via Rest:${\n}${sensors_flagged_rest} console=true
+ Log Sensors detected out of bounds via Redfish:${\n}${sensors_flagged_redfish} console=true
+
+
+Redfish Test Teardown Execution
+ [Documentation] Do the post test teardown for redfish.
+
+ Redfish.Logout
+ FFDC On Test Case Fail clean_up=${FALSE}
diff --git a/systest/collection/bmc_collect_vpd_and_hw_status.robot b/systest/collection/bmc_collect_vpd_and_hw_status.robot
new file mode 100644
index 0000000..2ce8040
--- /dev/null
+++ b/systest/collection/bmc_collect_vpd_and_hw_status.robot
@@ -0,0 +1,75 @@
+*** Settings ***
+Documentation BMC server health, collect VPD and hardware status.
+
+# Test Parameters:
+# OPENBMC_HOST The BMC host name or IP address.
+
+Resource ../../lib/bmc_redfish_resource.robot
+Resource ../../lib/openbmc_ffdc.robot
+
+Suite Setup Suite Setup Execution
+Suite Teardown Suite Teardown Execution
+Test Setup Printn
+
+*** Variables ***
+${QUIET} ${1}
+${rest_collected_values} Rest collection excluded
+${redfish_collected_values} Redfish collection excluded
+
+*** Test Cases ***
+
+Rest Collect VPD And Hardware Status
+ [Documentation] Collect VPD and hardware status using the OpenBMC Rest API.
+ [Tags] Rest_Collect_VPD_And_Hardware_Status rest
+ [Teardown] FFDC On Test Case Fail clean_up=${FALSE}
+
+ ${system_properties}= OpenBMC Get Request ${HOST_INVENTORY_URI}system
+ ${system_properties}= Evaluate $system_properties.json()
+ ${Type}= Read Attribute ${CHASSIS_INVENTORY_URI} Type
+ ${WaterCooled}= Read Attribute ${CHASSIS_INVENTORY_URI} WaterCooled
+ ${AirCooled}= Read Attribute ${CHASSIS_INVENTORY_URI} AirCooled
+ ${system_chassis}= OpenBMC Get Request ${MOTHERBOARD_INVENTORY_URI}enumerate
+ ${system_chassis}= Evaluate $system_chassis.json()
+ Rprint Vars system_properties Type WaterCooled AirCooled system_chassis
+ ${rest_collected_values}= gen_robot_print.Sprint Vars
+ ... system_properties Type WaterCooled AirCooled system_chassis
+ Set Global Variable ${rest_collected_values}
+
+
+Redfish Collect VPD And Hardware Status
+ [Documentation] Collect VPD and hardware status using Redfish.
+ [Tags] Redfish_Collect_VPD_And_Hardware_Status redfish
+ [Setup] Redfish.Login
+ [Teardown] Redfish Test Teardown Execution
+
+ ${system_properties}= Redfish_Utils.Get Properties ${SYSTEM_BASE_URI}
+ ${system_memory_info}= Redfish_Utils.Enumerate Request ${SYSTEM_BASE_URI}/Memory
+ ${system_processors_info}= Redfish_Utils.Enumerate Request ${SYSTEM_BASE_URI}/Processors
+ ${system_fans_info}= Redfish_Utils.Get Attribute ${REDFISH_CHASSIS_THERMAL_URI} Fans
+ Rprint Vars system_properties system_memory_info system_processors_info system_fans_info
+ ${redfish_collected_values}= gen_robot_print.Sprint Vars
+ ... system_properties system_memory_info system_processors_info system_fans_info
+ Set Global Variable ${redfish_collected_values}
+
+
+*** Keywords ***
+
+Suite Setup Execution
+ [Documentation] Do test case setup tasks.
+
+ Set Log Level DEBUG
+ REST Power On stack_mode=skip
+
+
+Suite Teardown Execution
+ [Documentation] Do suite teardown tasks. Log values and data collected.
+
+ Log Rest collected values:${\n}${rest_collected_values}
+ Log Redfish collected values:${\n}${redfish_collected_values}
+
+
+Redfish Test Teardown Execution
+ [Documentation] Do the post test teardown for redfish.
+
+ Redfish.Logout
+ FFDC On Test Case Fail clean_up=${FALSE}