blob: 3bfa241b11f67d9f5441f0aa650171cd0b241ea6 [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
manashsarma46e243d2023-09-08 13:41:30 -050052 END
53
54 # Attempt another report creation and it should fail.
George Keishing3e469a82024-05-29 11:38:26 +053055 Create Basic Telemetry Report
56 ... total power Periodic LogToMetricReportsCollection expected_result=fail
manashsarma46e243d2023-09-08 13:41:30 -050057
58 # Now delete the reports created.
59 Delete All Telemetry Reports
60
manashsarmad0cb6e12023-10-10 09:18:40 -050061
manashsarma20dc0fd2024-04-25 01:23:22 -050062Verify Basic Telemetry Report Creation For PCIE
63 [Documentation] Verify basic telemetry report creations for PCIE.
64 [Tags] Verify_Basic_Telemetry_Report_Creation_For_PCIE
65
George Keishing3e469a82024-05-29 11:38:26 +053066 Create Basic Telemetry Report
67 ... pcie temperature OnRequest LogToMetricReportsCollection
manashsarma20dc0fd2024-04-25 01:23:22 -050068
69
manashsarma663c2da2023-05-26 06:06:14 -050070*** Keywords ***
71
72Suite Setup Execution
73 [Documentation] Do test case setup tasks.
74
75 Redfish.Login
manashsarmad0cb6e12023-10-10 09:18:40 -050076 Redfish Power On stack_mode=skip
George Keishing3e469a82024-05-29 11:38:26 +053077 ${metric_definitions_list}=
78 ... Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricDefinitions
manashsarma20dc0fd2024-04-25 01:23:22 -050079
George Keishing3e469a82024-05-29 11:38:26 +053080 # Create a dictionary of ordinary english naming and actual naming of
81 # telemtry definition.
manashsarma20dc0fd2024-04-25 01:23:22 -050082 ${english_actual_teleDef}= Create Dictionary
83
84 Set Suite Variable ${english_actual_teleDef}
85 Set Suite Variable ${metric_definitions_list}
86
87 Set To Dictionary ${english_actual_teleDef} invalid value invalid_value
88
89 # Find and collect actual telemetry definitions.
90 FOR ${key} IN @{user_tele_def.keys()}
91 Add To Telemetry definition Record ${key} ${user_tele_def['${key}']}
92 END
93
94
95Add To Telemetry definition Record
George Keishing3e469a82024-05-29 11:38:26 +053096 [Documentation] Find actual telemetry definitions available and store.
97 ... Definitions are stored in a dictionary as key and value
98 ... as described in argument documentation.
manashsarma20dc0fd2024-04-25 01:23:22 -050099 [Arguments] ${key} ${value}
100
101 # Description of argument(s):
George Keishing3e469a82024-05-29 11:38:26 +0530102 # key Name of metric definition in plain english.
103 # Example: ambient temperature
104 # value Equivalent regex expression of telemetry definition.
105 # Example: Ambient.*Temp
manashsarma20dc0fd2024-04-25 01:23:22 -0500106
107 FOR ${item} IN @{metric_definitions_list}
108 ${regex_matching_output}= Get Regexp Matches ${item} ${value}
109 IF ${regex_matching_output} != []
110 Set To Dictionary ${english_actual_teleDef} ${key}=${regex_matching_output}[0]
111 Exit For Loop
112 END
113 END
manashsarma663c2da2023-05-26 06:06:14 -0500114
115
116Test Teardown Execution
117 [Documentation] Do test teardown operation.
118
119 FFDC On Test Case Fail
manashsarmad0cb6e12023-10-10 09:18:40 -0500120 Delete All Telemetry Reports
manashsarma46e243d2023-09-08 13:41:30 -0500121
122
123Create Basic Telemetry Report
124 [Documentation] Create a basic telemetry report with single metric.
manashsarmad0cb6e12023-10-10 09:18:40 -0500125 [Arguments] ${metric_definition_name} ${metric_definition_type}
126 ... ${report_action} ${append_limit}=10 ${expected_result}=success
manashsarma46e243d2023-09-08 13:41:30 -0500127
128 # Description of argument(s):
129 # metric_definition_name Name of metric definition like Ambient_0_Temp.
manashsarmad0cb6e12023-10-10 09:18:40 -0500130 # metric_definition_type Name of telemetry report which needs to be created.
131 # report_action Telemetry report action.
George Keishingc55a8992023-11-13 12:03:43 +0530132 # append_limit Append limit of the metric data in the report.
manashsarma46e243d2023-09-08 13:41:30 -0500133 # expected_result Expected result of report creation - success or fail.
134
manashsarma20dc0fd2024-04-25 01:23:22 -0500135 ${metric_definition_name}= Set Variable ${english_actual_teleDef}[${metric_definition_name}]
manashsarma46e243d2023-09-08 13:41:30 -0500136 ${resp}= Redfish.Get Properties
137 ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name}
manashsarmad874e9e2023-12-13 02:28:51 -0600138 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
139 ${telemetry_data_unavailable}= Run Keyword And Return Status Should Contain ${resp} error
140 IF ${telemetry_data_unavailable} == ${True}
141 ${metricProperties}= Set Variable ""
142 ELSE
143 ${metricProperties}= Set Variable ${resp["MetricProperties"]}
George Keishingee0103d2024-01-30 12:35:37 +0530144 END
manashsarma46e243d2023-09-08 13:41:30 -0500145 # Example of response from above Redfish GET request.
146 # "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp",
147 # "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition",
148 # "Id": "Ambient_0_Temp",
149 # "IsLinear": true,
150 # "MaxReadingRange": 127.0,
151 # "MetricDataType": "Decimal",
152 # "MetricProperties": [
153 # "/redfish/v1/Chassis/chassis/Sensors/temperature_Ambient_0_Temp"
154 # ],
155 # "MetricType": "Gauge",
156 # "MinReadingRange": -128.0,
157 # "Name": "Ambient_0_Temp",
158 # "Units": "Cel"
159
manashsarmad0cb6e12023-10-10 09:18:40 -0500160 # Report name is from random generated string with length 16 which
161 # is enough to maintain uniqueness in report name.
162 ${report_name}= Generate Random String 16 [NUMBERS]abcdef
manashsarma46e243d2023-09-08 13:41:30 -0500163 ${body}= Catenate {"Id": "${report_name}",
manashsarmad0cb6e12023-10-10 09:18:40 -0500164 ... "MetricReportDefinitionType": "${metric_definition_type}",
165 ... "Name": "Report",
166 ... "ReportActions":["${report_action}"],
167 ... "Metrics":[{"CollectionDuration": "PT30.000S",
manashsarmad874e9e2023-12-13 02:28:51 -0600168 ... "MetricProperties":${metricProperties}}],
manashsarmad0cb6e12023-10-10 09:18:40 -0500169 ... "ReportUpdates": "AppendWrapsWhenFull",
170 ... "AppendLimit": ${append_limit},
171 ... "Schedule": {"RecurrenceInterval": "PT5.000S"}}
172
manashsarma46e243d2023-09-08 13:41:30 -0500173 ${body}= Replace String ${body} ' "
174 ${dict} Evaluate json.loads('''${body}''') json
175
176 ${status_code_expected}= Set Variable If
177 ... '${expected_result}' == 'success' [${HTTP_CREATED}]
178 ... '${expected_result}' == 'fail' [${HTTP_BAD_REQUEST}]
179
180 Redfish.Post ${metric_definition_base_uri} body=&{dict}
181 ... valid_status_codes=${status_code_expected}
182
manashsarmad0cb6e12023-10-10 09:18:40 -0500183 IF '${expected_result}' == 'success'
184 # Verify definition of report has attributes provided at the time of creation.
185 ${resp_report}= Redfish.Get ${metric_definition_base_uri}/${report_name}
186 ... valid_status_codes=[${HTTP_OK}]
187 Should Be True '${resp_report.dict["MetricReportDefinitionType"]}' == '${metric_definition_type}'
188 Should Be True '${resp_report.dict["AppendLimit"]}' == '${AppendLimit}'
189 Should Be True '${resp_report.dict["ReportActions"][0]}' == '${report_action}'
190 Should Be True
191 ... '${resp_report.dict["Metrics"]}[0][MetricProperties][0]' == '${resp["MetricProperties"][0]}'
192 END
193
manashsarma46e243d2023-09-08 13:41:30 -0500194
195Delete All Telemetry Reports
196 [Documentation] Delete all existing telemetry reports.
197
198 ${report_list}= Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricReportDefinitions
199 FOR ${report} IN @{report_list}
200 Redfish.Delete ${report} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
201 END