blob: 18895306a7687abc1a1957a48cdc51001e8569bc [file] [log] [blame]
manashsarma663c2da2023-05-26 06:06:14 -05001*** Settings ***
2
3Documentation Test telemetry functionality of OpenBMC.
4
5Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/openbmc_ffdc.robot
7
8Suite Setup Suite Setup Execution
9Suite Teardown Redfish.Logout
manashsarmad0cb6e12023-10-10 09:18:40 -050010Test Setup Delete All Telemetry Reports
manashsarma663c2da2023-05-26 06:06:14 -050011Test Teardown Test Teardown Execution
12
Matt Fischer6fb70d92023-10-24 19:06:33 -060013Test Tags Telemetry_Report
George Keishing54316852023-10-16 14:03:29 +053014
manashsarma663c2da2023-05-26 06:06:14 -050015*** Variables ***
16
17${metric_definition_base_uri} /redfish/v1/TelemetryService/MetricReportDefinitions
18${metric_report_base_uri} /redfish/v1/TelemetryService/MetricReports
manashsarma20dc0fd2024-04-25 01:23:22 -050019&{user_tele_def} ambient temperature=Ambient.*Temp pcie temperature=PCIE.*Temp
20... processor temperature=proc.*temp dimm temperature=dimm.*temp
21... battery voltage=Battery_Voltage total power=total_power
22... relative humidity=Relative_Humidity
manashsarma663c2da2023-05-26 06:06:14 -050023
manashsarmad0cb6e12023-10-10 09:18:40 -050024
manashsarma663c2da2023-05-26 06:06:14 -050025*** Test Cases ***
26
27Verify Basic Telemetry Report Creation
manashsarmad0cb6e12023-10-10 09:18:40 -050028 [Documentation] Verify basic telemetry report creations for different metrics.
manashsarma663c2da2023-05-26 06:06:14 -050029 [Tags] Verify_Basic_Telemetry_Report_Creation
manashsarmad0cb6e12023-10-10 09:18:40 -050030 [Template] Create Basic Telemetry Report
manashsarma663c2da2023-05-26 06:06:14 -050031
manashsarma20dc0fd2024-04-25 01:23:22 -050032 # Metric definition Metric ReportDefinition Type Report Actions Append Limit Expected Result
33 ambient temperature OnRequest LogToMetricReportsCollection
34 processor temperature Periodic LogToMetricReportsCollection 500
35 dimm temperature Periodic LogToMetricReportsCollection 1000
36 total power OnRequest LogToMetricReportsCollection
37 invalid value OnRequest LogToMetricReportsCollection 100 fail
38 relative humidity OnRequest LogToMetricReportsCollection
39 battery voltage Periodic LogToMetricReportsCollection 100
manashsarma1a0c6bf2023-07-27 02:27:56 -050040
manashsarma46e243d2023-09-08 13:41:30 -050041
42Verify Error After Exceeding Maximum Report Creation
43 [Documentation] Verify error while creating telemetry report more than max report limit.
44 [Tags] Verify_Error_After_Exceeding_Maximum_Report_Creation
45
46 ${report_name}= Set Variable Testreport
47
manashsarma46e243d2023-09-08 13:41:30 -050048 # Create maximum number of reports.
49 ${resp}= Redfish.Get Properties /redfish/v1/TelemetryService
50 FOR ${i} IN RANGE ${resp["MaxReports"]}
manashsarma20dc0fd2024-04-25 01:23:22 -050051 Create Basic Telemetry Report total power Periodic LogToMetricReportsCollection
Manash Sarmac7d333b2025-10-24 17:43:36 +053052 ... delete_report=False
manashsarma46e243d2023-09-08 13:41:30 -050053 END
54
55 # Attempt another report creation and it should fail.
George Keishing3e469a82024-05-29 11:38:26 +053056 Create Basic Telemetry Report
57 ... total power Periodic LogToMetricReportsCollection expected_result=fail
manashsarma46e243d2023-09-08 13:41:30 -050058
59 # Now delete the reports created.
60 Delete All Telemetry Reports
61
manashsarmad0cb6e12023-10-10 09:18:40 -050062
manashsarma20dc0fd2024-04-25 01:23:22 -050063Verify Basic Telemetry Report Creation For PCIE
64 [Documentation] Verify basic telemetry report creations for PCIE.
65 [Tags] Verify_Basic_Telemetry_Report_Creation_For_PCIE
66
George Keishing3e469a82024-05-29 11:38:26 +053067 Create Basic Telemetry Report
68 ... pcie temperature OnRequest LogToMetricReportsCollection
manashsarma20dc0fd2024-04-25 01:23:22 -050069
Nandakumar Babu2067a772025-12-01 11:02:16 +053070Verify Telemetry Service Unsupported Methods
71 [Documentation] Verify Telemetry Service with Unsupported methods.
72 [Tags] Verify_Telemetry_Service_Unsupported_Methods
73
74 Verify Supported And Unsupported Methods uri=/redfish/v1/TelemetryService
75
76Verify Telemetry Service MetricReports Unsupported Methods
77 [Documentation] Verify Telemetry Service MetricReports with Unsupported methods.
78 [Tags] Verify_Telemetry_Service_Metric_Reports_Unsupported_Methods
79
80 Verify Supported And Unsupported Methods uri=/redfish/v1/TelemetryService/MetricReports
81
manashsarma20dc0fd2024-04-25 01:23:22 -050082
manashsarma663c2da2023-05-26 06:06:14 -050083*** Keywords ***
84
Nandakumar Babu2067a772025-12-01 11:02:16 +053085Verify Supported And Unsupported Methods
86 [Documentation] Verify Supported And Unsupported Methods for given URI.
87 [Arguments] ${uri}
88 # Description of argument(s):
89 # uri The URI to be tested.
90
91 # GET operation on Telemetry Service
92 Redfish.Get ${uri}
93 ... valid_status_codes=[${HTTP_OK}]
94
95 # Put operation on Telemetry Service
96 Redfish.Put ${uri}
97 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
98
99 # Post operation on Telemetry Service
100 Redfish.Post ${uri}
101 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
102
103 # Delete operation on Telemetry Service
104 Redfish.Delete ${uri}
105 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
106
107 # Patch operation on Telemetry Service
108 Redfish.Patch ${uri}
109 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}]
110
manashsarma663c2da2023-05-26 06:06:14 -0500111Suite Setup Execution
112 [Documentation] Do test case setup tasks.
113
114 Redfish.Login
manashsarmad0cb6e12023-10-10 09:18:40 -0500115 Redfish Power On stack_mode=skip
George Keishing3e469a82024-05-29 11:38:26 +0530116 ${metric_definitions_list}=
117 ... Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricDefinitions
manashsarma20dc0fd2024-04-25 01:23:22 -0500118
George Keishing3e469a82024-05-29 11:38:26 +0530119 # Create a dictionary of ordinary english naming and actual naming of
George Keishing010f2212025-01-08 20:25:22 +0530120 # telemetry definition.
manashsarma20dc0fd2024-04-25 01:23:22 -0500121 ${english_actual_teleDef}= Create Dictionary
122
123 Set Suite Variable ${english_actual_teleDef}
124 Set Suite Variable ${metric_definitions_list}
125
126 Set To Dictionary ${english_actual_teleDef} invalid value invalid_value
127
128 # Find and collect actual telemetry definitions.
129 FOR ${key} IN @{user_tele_def.keys()}
130 Add To Telemetry definition Record ${key} ${user_tele_def['${key}']}
131 END
132
133
134Add To Telemetry definition Record
George Keishing3e469a82024-05-29 11:38:26 +0530135 [Documentation] Find actual telemetry definitions available and store.
136 ... Definitions are stored in a dictionary as key and value
137 ... as described in argument documentation.
manashsarma20dc0fd2024-04-25 01:23:22 -0500138 [Arguments] ${key} ${value}
139
140 # Description of argument(s):
George Keishing3e469a82024-05-29 11:38:26 +0530141 # key Name of metric definition in plain english.
142 # Example: ambient temperature
143 # value Equivalent regex expression of telemetry definition.
144 # Example: Ambient.*Temp
manashsarma20dc0fd2024-04-25 01:23:22 -0500145
Manash Sarmac7d333b2025-10-24 17:43:36 +0530146 Set To Dictionary ${english_actual_teleDef} ${key}=Not found
manashsarma20dc0fd2024-04-25 01:23:22 -0500147 FOR ${item} IN @{metric_definitions_list}
148 ${regex_matching_output}= Get Regexp Matches ${item} ${value}
149 IF ${regex_matching_output} != []
150 Set To Dictionary ${english_actual_teleDef} ${key}=${regex_matching_output}[0]
Sridevi Ramesh6dcfc392025-05-06 11:09:43 -0500151 BREAK
manashsarma20dc0fd2024-04-25 01:23:22 -0500152 END
153 END
manashsarma663c2da2023-05-26 06:06:14 -0500154
155
156Test Teardown Execution
157 [Documentation] Do test teardown operation.
158
159 FFDC On Test Case Fail
manashsarmad0cb6e12023-10-10 09:18:40 -0500160 Delete All Telemetry Reports
manashsarma46e243d2023-09-08 13:41:30 -0500161
162
163Create Basic Telemetry Report
164 [Documentation] Create a basic telemetry report with single metric.
manashsarmad0cb6e12023-10-10 09:18:40 -0500165 [Arguments] ${metric_definition_name} ${metric_definition_type}
Manash Sarmac7d333b2025-10-24 17:43:36 +0530166 ... ${report_action} ${append_limit}=10 ${expected_result}=success ${delete_report}=True
manashsarma46e243d2023-09-08 13:41:30 -0500167
168 # Description of argument(s):
169 # metric_definition_name Name of metric definition like Ambient_0_Temp.
manashsarmad0cb6e12023-10-10 09:18:40 -0500170 # metric_definition_type Name of telemetry report which needs to be created.
171 # report_action Telemetry report action.
George Keishingc55a8992023-11-13 12:03:43 +0530172 # append_limit Append limit of the metric data in the report.
manashsarma46e243d2023-09-08 13:41:30 -0500173 # expected_result Expected result of report creation - success or fail.
Manash Sarmac7d333b2025-10-24 17:43:36 +0530174 # delete_report Flag to decide if telemetry report needs to be deleted after creation.
manashsarma46e243d2023-09-08 13:41:30 -0500175
manashsarma20dc0fd2024-04-25 01:23:22 -0500176 ${metric_definition_name}= Set Variable ${english_actual_teleDef}[${metric_definition_name}]
Manash Sarmac7d333b2025-10-24 17:43:36 +0530177 Skip If '${metric_definition_name}' == 'Not found' Metric definition is not found.
178
manashsarma46e243d2023-09-08 13:41:30 -0500179 ${resp}= Redfish.Get Properties
180 ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name}
manashsarmad874e9e2023-12-13 02:28:51 -0600181 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
182 ${telemetry_data_unavailable}= Run Keyword And Return Status Should Contain ${resp} error
183 IF ${telemetry_data_unavailable} == ${True}
184 ${metricProperties}= Set Variable ""
185 ELSE
186 ${metricProperties}= Set Variable ${resp["MetricProperties"]}
George Keishingee0103d2024-01-30 12:35:37 +0530187 END
manashsarma46e243d2023-09-08 13:41:30 -0500188 # Example of response from above Redfish GET request.
189 # "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp",
190 # "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition",
191 # "Id": "Ambient_0_Temp",
192 # "IsLinear": true,
193 # "MaxReadingRange": 127.0,
194 # "MetricDataType": "Decimal",
195 # "MetricProperties": [
196 # "/redfish/v1/Chassis/chassis/Sensors/temperature_Ambient_0_Temp"
197 # ],
198 # "MetricType": "Gauge",
199 # "MinReadingRange": -128.0,
200 # "Name": "Ambient_0_Temp",
201 # "Units": "Cel"
202
manashsarmad0cb6e12023-10-10 09:18:40 -0500203 # Report name is from random generated string with length 16 which
204 # is enough to maintain uniqueness in report name.
205 ${report_name}= Generate Random String 16 [NUMBERS]abcdef
manashsarma46e243d2023-09-08 13:41:30 -0500206 ${body}= Catenate {"Id": "${report_name}",
manashsarmad0cb6e12023-10-10 09:18:40 -0500207 ... "MetricReportDefinitionType": "${metric_definition_type}",
208 ... "Name": "Report",
209 ... "ReportActions":["${report_action}"],
210 ... "Metrics":[{"CollectionDuration": "PT30.000S",
manashsarmad874e9e2023-12-13 02:28:51 -0600211 ... "MetricProperties":${metricProperties}}],
manashsarmad0cb6e12023-10-10 09:18:40 -0500212 ... "ReportUpdates": "AppendWrapsWhenFull",
213 ... "AppendLimit": ${append_limit},
214 ... "Schedule": {"RecurrenceInterval": "PT5.000S"}}
215
manashsarma46e243d2023-09-08 13:41:30 -0500216 ${body}= Replace String ${body} ' "
217 ${dict} Evaluate json.loads('''${body}''') json
218
219 ${status_code_expected}= Set Variable If
220 ... '${expected_result}' == 'success' [${HTTP_CREATED}]
221 ... '${expected_result}' == 'fail' [${HTTP_BAD_REQUEST}]
222
223 Redfish.Post ${metric_definition_base_uri} body=&{dict}
224 ... valid_status_codes=${status_code_expected}
225
manashsarmad0cb6e12023-10-10 09:18:40 -0500226 IF '${expected_result}' == 'success'
227 # Verify definition of report has attributes provided at the time of creation.
228 ${resp_report}= Redfish.Get ${metric_definition_base_uri}/${report_name}
229 ... valid_status_codes=[${HTTP_OK}]
230 Should Be True '${resp_report.dict["MetricReportDefinitionType"]}' == '${metric_definition_type}'
231 Should Be True '${resp_report.dict["AppendLimit"]}' == '${AppendLimit}'
232 Should Be True '${resp_report.dict["ReportActions"][0]}' == '${report_action}'
233 Should Be True
234 ... '${resp_report.dict["Metrics"]}[0][MetricProperties][0]' == '${resp["MetricProperties"][0]}'
235 END
236
Manash Sarmac7d333b2025-10-24 17:43:36 +0530237 IF ${delete_report} == ${True}
238 Delete All Telemetry Reports
239 END
240
manashsarma46e243d2023-09-08 13:41:30 -0500241
242Delete All Telemetry Reports
243 [Documentation] Delete all existing telemetry reports.
244
245 ${report_list}= Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricReportDefinitions
246 FOR ${report} IN @{report_list}
247 Redfish.Delete ${report} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
248 END