blob: d5d99a720e7967bdd967e20adcf52471b0815abf [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
manashsarmad0cb6e12023-10-10 09:18:40 -050028 # 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
manashsarma1a0c6bf2023-07-27 02:27:56 -050038
manashsarma46e243d2023-09-08 13:41:30 -050039
40Verify 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
manashsarma46e243d2023-09-08 13:41:30 -050046 # Create maximum number of reports.
47 ${resp}= Redfish.Get Properties /redfish/v1/TelemetryService
48 FOR ${i} IN RANGE ${resp["MaxReports"]}
manashsarmad0cb6e12023-10-10 09:18:40 -050049 Create Basic Telemetry Report total_power Periodic LogToMetricReportsCollection
manashsarma46e243d2023-09-08 13:41:30 -050050 END
51
52 # Attempt another report creation and it should fail.
manashsarmad0cb6e12023-10-10 09:18:40 -050053 Create Basic Telemetry Report total_power Periodic LogToMetricReportsCollection expected_result=fail
manashsarma46e243d2023-09-08 13:41:30 -050054
55 # Now delete the reports created.
56 Delete All Telemetry Reports
57
manashsarmad0cb6e12023-10-10 09:18:40 -050058
manashsarma663c2da2023-05-26 06:06:14 -050059*** Keywords ***
60
61Suite Setup Execution
62 [Documentation] Do test case setup tasks.
63
64 Redfish.Login
manashsarmad0cb6e12023-10-10 09:18:40 -050065 Redfish Power On stack_mode=skip
manashsarma663c2da2023-05-26 06:06:14 -050066
67
68Test Teardown Execution
69 [Documentation] Do test teardown operation.
70
71 FFDC On Test Case Fail
manashsarmad0cb6e12023-10-10 09:18:40 -050072 Delete All Telemetry Reports
manashsarma46e243d2023-09-08 13:41:30 -050073
74
75Create Basic Telemetry Report
76 [Documentation] Create a basic telemetry report with single metric.
manashsarmad0cb6e12023-10-10 09:18:40 -050077 [Arguments] ${metric_definition_name} ${metric_definition_type}
78 ... ${report_action} ${append_limit}=10 ${expected_result}=success
manashsarma46e243d2023-09-08 13:41:30 -050079
80 # Description of argument(s):
81 # metric_definition_name Name of metric definition like Ambient_0_Temp.
manashsarmad0cb6e12023-10-10 09:18:40 -050082 # 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.
manashsarma46e243d2023-09-08 13:41:30 -050085 # 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
manashsarmad0cb6e12023-10-10 09:18:40 -0500104 # 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
manashsarma46e243d2023-09-08 13:41:30 -0500107 ${body}= Catenate {"Id": "${report_name}",
manashsarmad0cb6e12023-10-10 09:18:40 -0500108 ... "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
manashsarma46e243d2023-09-08 13:41:30 -0500117 ${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
manashsarmad0cb6e12023-10-10 09:18:40 -0500127 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
manashsarma46e243d2023-09-08 13:41:30 -0500138
139Delete 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