blob: 5a1d2e4d76ff4b3623d2c10b10054e894b1f1c00 [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
George Keishing54316852023-10-16 14:03:29 +053013Force Tags Telemetry_Report
14
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
19
manashsarmad0cb6e12023-10-10 09:18:40 -050020
manashsarma663c2da2023-05-26 06:06:14 -050021*** Test Cases ***
22
23Verify Basic Telemetry Report Creation
manashsarmad0cb6e12023-10-10 09:18:40 -050024 [Documentation] Verify basic telemetry report creations for different metrics.
manashsarma663c2da2023-05-26 06:06:14 -050025 [Tags] Verify_Basic_Telemetry_Report_Creation
manashsarmad0cb6e12023-10-10 09:18:40 -050026 [Template] Create Basic Telemetry Report
manashsarma663c2da2023-05-26 06:06:14 -050027
manashsarmad874e9e2023-12-13 02:28:51 -060028 # Metric definition Metric ReportDefinition Type Report Actions Append Limit Expected Result
manashsarmad0cb6e12023-10-10 09:18:40 -050029 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
manashsarmad874e9e2023-12-13 02:28:51 -060038 invalid_value OnRequest LogToMetricReportsCollection 100 fail
manashsarma1a0c6bf2023-07-27 02:27:56 -050039
manashsarma46e243d2023-09-08 13:41:30 -050040
41Verify Error After Exceeding Maximum Report Creation
42 [Documentation] Verify error while creating telemetry report more than max report limit.
43 [Tags] Verify_Error_After_Exceeding_Maximum_Report_Creation
44
45 ${report_name}= Set Variable Testreport
46
manashsarma46e243d2023-09-08 13:41:30 -050047 # Create maximum number of reports.
48 ${resp}= Redfish.Get Properties /redfish/v1/TelemetryService
49 FOR ${i} IN RANGE ${resp["MaxReports"]}
manashsarmad0cb6e12023-10-10 09:18:40 -050050 Create Basic Telemetry Report total_power Periodic LogToMetricReportsCollection
manashsarma46e243d2023-09-08 13:41:30 -050051 END
52
53 # Attempt another report creation and it should fail.
manashsarmad0cb6e12023-10-10 09:18:40 -050054 Create Basic Telemetry Report total_power Periodic LogToMetricReportsCollection expected_result=fail
manashsarma46e243d2023-09-08 13:41:30 -050055
56 # Now delete the reports created.
57 Delete All Telemetry Reports
58
manashsarmad0cb6e12023-10-10 09:18:40 -050059
manashsarma663c2da2023-05-26 06:06:14 -050060*** Keywords ***
61
62Suite Setup Execution
63 [Documentation] Do test case setup tasks.
64
65 Redfish.Login
manashsarmad0cb6e12023-10-10 09:18:40 -050066 Redfish Power On stack_mode=skip
manashsarma663c2da2023-05-26 06:06:14 -050067
68
69Test Teardown Execution
70 [Documentation] Do test teardown operation.
71
72 FFDC On Test Case Fail
manashsarmad0cb6e12023-10-10 09:18:40 -050073 Delete All Telemetry Reports
manashsarma46e243d2023-09-08 13:41:30 -050074
75
76Create Basic Telemetry Report
77 [Documentation] Create a basic telemetry report with single metric.
manashsarmad0cb6e12023-10-10 09:18:40 -050078 [Arguments] ${metric_definition_name} ${metric_definition_type}
79 ... ${report_action} ${append_limit}=10 ${expected_result}=success
manashsarma46e243d2023-09-08 13:41:30 -050080
81 # Description of argument(s):
82 # metric_definition_name Name of metric definition like Ambient_0_Temp.
manashsarmad0cb6e12023-10-10 09:18:40 -050083 # metric_definition_type Name of telemetry report which needs to be created.
84 # report_action Telemetry report action.
George Keishingc55a8992023-11-13 12:03:43 +053085 # append_limit Append limit of the metric data in the report.
manashsarma46e243d2023-09-08 13:41:30 -050086 # expected_result Expected result of report creation - success or fail.
87
88 ${resp}= Redfish.Get Properties
89 ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name}
manashsarmad874e9e2023-12-13 02:28:51 -060090 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
91 ${telemetry_data_unavailable}= Run Keyword And Return Status Should Contain ${resp} error
92 IF ${telemetry_data_unavailable} == ${True}
93 ${metricProperties}= Set Variable ""
94 ELSE
95 ${metricProperties}= Set Variable ${resp["MetricProperties"]}
George Keishingee0103d2024-01-30 12:35:37 +053096 END
manashsarma46e243d2023-09-08 13:41:30 -050097 # Example of response from above Redfish GET request.
98 # "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp",
99 # "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition",
100 # "Id": "Ambient_0_Temp",
101 # "IsLinear": true,
102 # "MaxReadingRange": 127.0,
103 # "MetricDataType": "Decimal",
104 # "MetricProperties": [
105 # "/redfish/v1/Chassis/chassis/Sensors/temperature_Ambient_0_Temp"
106 # ],
107 # "MetricType": "Gauge",
108 # "MinReadingRange": -128.0,
109 # "Name": "Ambient_0_Temp",
110 # "Units": "Cel"
111
manashsarmad0cb6e12023-10-10 09:18:40 -0500112 # Report name is from random generated string with length 16 which
113 # is enough to maintain uniqueness in report name.
114 ${report_name}= Generate Random String 16 [NUMBERS]abcdef
manashsarma46e243d2023-09-08 13:41:30 -0500115 ${body}= Catenate {"Id": "${report_name}",
manashsarmad0cb6e12023-10-10 09:18:40 -0500116 ... "MetricReportDefinitionType": "${metric_definition_type}",
117 ... "Name": "Report",
118 ... "ReportActions":["${report_action}"],
119 ... "Metrics":[{"CollectionDuration": "PT30.000S",
manashsarmad874e9e2023-12-13 02:28:51 -0600120 ... "MetricProperties":${metricProperties}}],
manashsarmad0cb6e12023-10-10 09:18:40 -0500121 ... "ReportUpdates": "AppendWrapsWhenFull",
122 ... "AppendLimit": ${append_limit},
123 ... "Schedule": {"RecurrenceInterval": "PT5.000S"}}
124
manashsarma46e243d2023-09-08 13:41:30 -0500125 ${body}= Replace String ${body} ' "
126 ${dict} Evaluate json.loads('''${body}''') json
127
128 ${status_code_expected}= Set Variable If
129 ... '${expected_result}' == 'success' [${HTTP_CREATED}]
130 ... '${expected_result}' == 'fail' [${HTTP_BAD_REQUEST}]
131
132 Redfish.Post ${metric_definition_base_uri} body=&{dict}
133 ... valid_status_codes=${status_code_expected}
134
manashsarmad0cb6e12023-10-10 09:18:40 -0500135 IF '${expected_result}' == 'success'
136 # Verify definition of report has attributes provided at the time of creation.
137 ${resp_report}= Redfish.Get ${metric_definition_base_uri}/${report_name}
138 ... valid_status_codes=[${HTTP_OK}]
139 Should Be True '${resp_report.dict["MetricReportDefinitionType"]}' == '${metric_definition_type}'
140 Should Be True '${resp_report.dict["AppendLimit"]}' == '${AppendLimit}'
141 Should Be True '${resp_report.dict["ReportActions"][0]}' == '${report_action}'
142 Should Be True
143 ... '${resp_report.dict["Metrics"]}[0][MetricProperties][0]' == '${resp["MetricProperties"][0]}'
144 END
145
manashsarma46e243d2023-09-08 13:41:30 -0500146
147Delete All Telemetry Reports
148 [Documentation] Delete all existing telemetry reports.
149
150 ${report_list}= Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricReportDefinitions
151 FOR ${report} IN @{report_list}
152 Redfish.Delete ${report} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
153 END