manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Test telemetry functionality of OpenBMC. |
| 4 | |
| 5 | Resource ../../lib/bmc_redfish_resource.robot |
| 6 | Resource ../../lib/openbmc_ffdc.robot |
| 7 | |
| 8 | Suite Setup Suite Setup Execution |
| 9 | Suite Teardown Redfish.Logout |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 10 | Test Setup Delete All Telemetry Reports |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 11 | Test Teardown Test Teardown Execution |
| 12 | |
George Keishing | 5431685 | 2023-10-16 14:03:29 +0530 | [diff] [blame] | 13 | Force Tags Telemetry_Report |
| 14 | |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 15 | *** Variables *** |
| 16 | |
| 17 | ${metric_definition_base_uri} /redfish/v1/TelemetryService/MetricReportDefinitions |
| 18 | ${metric_report_base_uri} /redfish/v1/TelemetryService/MetricReports |
| 19 | |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 20 | |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 21 | *** Test Cases *** |
| 22 | |
| 23 | Verify Basic Telemetry Report Creation |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 24 | [Documentation] Verify basic telemetry report creations for different metrics. |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 25 | [Tags] Verify_Basic_Telemetry_Report_Creation |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 26 | [Template] Create Basic Telemetry Report |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 27 | |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 28 | # Metric definition Metric ReportDefinition Type Report Actions Append Limit |
| 29 | total_power OnRequest LogToMetricReportsCollection |
| 30 | Battery_Voltage Periodic LogToMetricReportsCollection 100 |
| 31 | Ambient_0_Temp OnRequest LogToMetricReportsCollection |
| 32 | proc0_core1_1_temp Periodic LogToMetricReportsCollection 500 |
| 33 | PCIE_0_Temp OnRequest LogToMetricReportsCollection |
| 34 | dimm0_pmic_temp Periodic LogToMetricReportsCollection 1000 |
| 35 | Relative_Humidity OnRequest LogToMetricReportsCollection |
| 36 | pcie_dcm0_power Periodic LogToMetricReportsCollection 32768 |
| 37 | io_dcm0_power OnRequest LogToMetricReportsCollection |
manashsarma | 1a0c6bf | 2023-07-27 02:27:56 -0500 | [diff] [blame] | 38 | |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 39 | |
| 40 | Verify Error After Exceeding Maximum Report Creation |
| 41 | [Documentation] Verify error while creating telemetry report more than max report limit. |
| 42 | [Tags] Verify_Error_After_Exceeding_Maximum_Report_Creation |
| 43 | |
| 44 | ${report_name}= Set Variable Testreport |
| 45 | |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 46 | # Create maximum number of reports. |
| 47 | ${resp}= Redfish.Get Properties /redfish/v1/TelemetryService |
| 48 | FOR ${i} IN RANGE ${resp["MaxReports"]} |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 49 | Create Basic Telemetry Report total_power Periodic LogToMetricReportsCollection |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 50 | END |
| 51 | |
| 52 | # Attempt another report creation and it should fail. |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 53 | Create Basic Telemetry Report total_power Periodic LogToMetricReportsCollection expected_result=fail |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 54 | |
| 55 | # Now delete the reports created. |
| 56 | Delete All Telemetry Reports |
| 57 | |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 58 | |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 59 | *** Keywords *** |
| 60 | |
| 61 | Suite Setup Execution |
| 62 | [Documentation] Do test case setup tasks. |
| 63 | |
| 64 | Redfish.Login |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 65 | Redfish Power On stack_mode=skip |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 66 | |
| 67 | |
| 68 | Test Teardown Execution |
| 69 | [Documentation] Do test teardown operation. |
| 70 | |
| 71 | FFDC On Test Case Fail |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 72 | Delete All Telemetry Reports |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 73 | |
| 74 | |
| 75 | Create Basic Telemetry Report |
| 76 | [Documentation] Create a basic telemetry report with single metric. |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 77 | [Arguments] ${metric_definition_name} ${metric_definition_type} |
| 78 | ... ${report_action} ${append_limit}=10 ${expected_result}=success |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 79 | |
| 80 | # Description of argument(s): |
| 81 | # metric_definition_name Name of metric definition like Ambient_0_Temp. |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 82 | # metric_definition_type Name of telemetry report which needs to be created. |
| 83 | # report_action Telemetry report action. |
| 84 | # append_limit Append limit of the metric data in the report. |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 85 | # expected_result Expected result of report creation - success or fail. |
| 86 | |
| 87 | ${resp}= Redfish.Get Properties |
| 88 | ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name} |
| 89 | # Example of response from above Redfish GET request. |
| 90 | # "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp", |
| 91 | # "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition", |
| 92 | # "Id": "Ambient_0_Temp", |
| 93 | # "IsLinear": true, |
| 94 | # "MaxReadingRange": 127.0, |
| 95 | # "MetricDataType": "Decimal", |
| 96 | # "MetricProperties": [ |
| 97 | # "/redfish/v1/Chassis/chassis/Sensors/temperature_Ambient_0_Temp" |
| 98 | # ], |
| 99 | # "MetricType": "Gauge", |
| 100 | # "MinReadingRange": -128.0, |
| 101 | # "Name": "Ambient_0_Temp", |
| 102 | # "Units": "Cel" |
| 103 | |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 104 | # Report name is from random generated string with length 16 which |
| 105 | # is enough to maintain uniqueness in report name. |
| 106 | ${report_name}= Generate Random String 16 [NUMBERS]abcdef |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 107 | ${body}= Catenate {"Id": "${report_name}", |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 108 | ... "MetricReportDefinitionType": "${metric_definition_type}", |
| 109 | ... "Name": "Report", |
| 110 | ... "ReportActions":["${report_action}"], |
| 111 | ... "Metrics":[{"CollectionDuration": "PT30.000S", |
| 112 | ... "MetricProperties":${resp["MetricProperties"]}}], |
| 113 | ... "ReportUpdates": "AppendWrapsWhenFull", |
| 114 | ... "AppendLimit": ${append_limit}, |
| 115 | ... "Schedule": {"RecurrenceInterval": "PT5.000S"}} |
| 116 | |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 117 | ${body}= Replace String ${body} ' " |
| 118 | ${dict} Evaluate json.loads('''${body}''') json |
| 119 | |
| 120 | ${status_code_expected}= Set Variable If |
| 121 | ... '${expected_result}' == 'success' [${HTTP_CREATED}] |
| 122 | ... '${expected_result}' == 'fail' [${HTTP_BAD_REQUEST}] |
| 123 | |
| 124 | Redfish.Post ${metric_definition_base_uri} body=&{dict} |
| 125 | ... valid_status_codes=${status_code_expected} |
| 126 | |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame^] | 127 | IF '${expected_result}' == 'success' |
| 128 | # Verify definition of report has attributes provided at the time of creation. |
| 129 | ${resp_report}= Redfish.Get ${metric_definition_base_uri}/${report_name} |
| 130 | ... valid_status_codes=[${HTTP_OK}] |
| 131 | Should Be True '${resp_report.dict["MetricReportDefinitionType"]}' == '${metric_definition_type}' |
| 132 | Should Be True '${resp_report.dict["AppendLimit"]}' == '${AppendLimit}' |
| 133 | Should Be True '${resp_report.dict["ReportActions"][0]}' == '${report_action}' |
| 134 | Should Be True |
| 135 | ... '${resp_report.dict["Metrics"]}[0][MetricProperties][0]' == '${resp["MetricProperties"][0]}' |
| 136 | END |
| 137 | |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 138 | |
| 139 | Delete All Telemetry Reports |
| 140 | [Documentation] Delete all existing telemetry reports. |
| 141 | |
| 142 | ${report_list}= Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricReportDefinitions |
| 143 | FOR ${report} IN @{report_list} |
| 144 | Redfish.Delete ${report} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 145 | END |