blob: bf1ba512d745e6067108e3f37dfff20b20249bf8 [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
10Test Teardown Test Teardown Execution
11
George Keishing54316852023-10-16 14:03:29 +053012Force Tags Telemetry_Report
13
manashsarma663c2da2023-05-26 06:06:14 -050014*** Variables ***
15
16${metric_definition_base_uri} /redfish/v1/TelemetryService/MetricReportDefinitions
17${metric_report_base_uri} /redfish/v1/TelemetryService/MetricReports
18
19*** Test Cases ***
20
21Verify Basic Telemetry Report Creation
22 [Documentation] Verify if a telemetry basic report is created.
23 [Tags] Verify_Basic_Telemetry_Report_Creation
manashsarma1a0c6bf2023-07-27 02:27:56 -050024 [Teardown] Redfish.Delete ${metric_definition_base_uri}/${report_name}
25 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
manashsarma663c2da2023-05-26 06:06:14 -050026
27 ${report_name}= Set Variable Test_basic_report_ambient_temp
28 ${resp}= Redfish.Get Properties
29 ... /redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp
30 ${body}= Catenate {"Id": "${report_name}",
31 ... "MetricReportDefinitionType": "OnRequest",
32 ... "ReportActions":["LogToMetricReportsCollection"],
33 ... "Metrics":[{"MetricProperties":${resp["MetricProperties"]}}]}
34 ${body}= Replace String ${body} ' "
35 ${dict} Evaluate json.loads('''${body}''') json
36
37 Redfish.Post ${metric_definition_base_uri} body=&{dict}
38 ... valid_status_codes=[${HTTP_CREATED}]
39
40 Redfish.Get ${metric_report_base_uri}/Test_basic_report_ambient_temp
41 ... valid_status_codes=[${HTTP_OK}]
42
43
manashsarma1a0c6bf2023-07-27 02:27:56 -050044Verify Basic Periodic Telemetry Report Creation
45 [Documentation] Verify if a telemetry basic periodic report is created.
46 [Tags] Verify_Basic_Periodic_Telemetry_Report_Creation
47 [Teardown] Redfish.Delete ${metric_definition_base_uri}/${report_name}
48 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
49
50 ${report_name}= Set Variable Test_basic_periodic_report_ambient_temp
51 ${resp}= Redfish.Get Properties
52 ... /redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp
53 ${body}= Catenate {"Id": "${report_name}",
54 ... "MetricReportDefinitionType": "Periodic",
55 ... "Name": "Report",
56 ... "ReportActions":["LogToMetricReportsCollection"],
57 ... "Metrics":[{"CollectionDuration": "PT30.000S",
58 ... "CollectionFunction": "Average","MetricProperties":${resp["MetricProperties"]}}],
59 ... "ReportUpdates": "AppendWrapsWhenFull",
60 ... "AppendLimit":10,
61 ... "Schedule": {"RecurrenceInterval": "PT5.000S"}}
62 ${body}= Replace String ${body} ' "
63 ${dict} Evaluate json.loads('''${body}''') json
64
65 Redfish.Post ${metric_definition_base_uri} body=&{dict}
66 ... valid_status_codes=[${HTTP_CREATED}]
67
68 ${resp}= Redfish.Get ${metric_definition_base_uri}/${report_name}
69 Should Be True '${resp.dict["MetricReportDefinitionType"]}' == 'Periodic'
70
manashsarma46e243d2023-09-08 13:41:30 -050071
72Verify Error After Exceeding Maximum Report Creation
73 [Documentation] Verify error while creating telemetry report more than max report limit.
74 [Tags] Verify_Error_After_Exceeding_Maximum_Report_Creation
75
76 ${report_name}= Set Variable Testreport
77
78 # Delete any existing reports.
79 Delete All Telemetry Reports
80
81 # Create maximum number of reports.
82 ${resp}= Redfish.Get Properties /redfish/v1/TelemetryService
83 FOR ${i} IN RANGE ${resp["MaxReports"]}
84 Create Basic Telemetry Report Ambient_0_Temp ${report_name}${i} success
85 END
86
87 # Attempt another report creation and it should fail.
88 Create Basic Telemetry Report Ambient_0_Temp ${report_name}${resp["MaxReports"]} fail
89
90 # Now delete the reports created.
91 Delete All Telemetry Reports
92
manashsarma663c2da2023-05-26 06:06:14 -050093*** Keywords ***
94
95Suite Setup Execution
96 [Documentation] Do test case setup tasks.
97
98 Redfish.Login
99
100
101Test Teardown Execution
102 [Documentation] Do test teardown operation.
103
104 FFDC On Test Case Fail
manashsarma46e243d2023-09-08 13:41:30 -0500105
106
107Create Basic Telemetry Report
108 [Documentation] Create a basic telemetry report with single metric.
109 [Arguments] ${metric_definition_name} ${report_name} ${expected_result}=success
110
111 # Description of argument(s):
112 # metric_definition_name Name of metric definition like Ambient_0_Temp.
113 # report_name Name of telemetry report which needs to be created.
114 # expected_result Expected result of report creation - success or fail.
115
116 ${resp}= Redfish.Get Properties
117 ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name}
118 # Example of response from above Redfish GET request.
119 # "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp",
120 # "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition",
121 # "Id": "Ambient_0_Temp",
122 # "IsLinear": true,
123 # "MaxReadingRange": 127.0,
124 # "MetricDataType": "Decimal",
125 # "MetricProperties": [
126 # "/redfish/v1/Chassis/chassis/Sensors/temperature_Ambient_0_Temp"
127 # ],
128 # "MetricType": "Gauge",
129 # "MinReadingRange": -128.0,
130 # "Name": "Ambient_0_Temp",
131 # "Units": "Cel"
132
133 ${body}= Catenate {"Id": "${report_name}",
134 ... "MetricReportDefinitionType": "OnRequest",
135 ... "ReportActions":["LogToMetricReportsCollection"],
136 ... "Metrics":[{"MetricProperties":${resp["MetricProperties"]}}]}
137 ${body}= Replace String ${body} ' "
138 ${dict} Evaluate json.loads('''${body}''') json
139
140 ${status_code_expected}= Set Variable If
141 ... '${expected_result}' == 'success' [${HTTP_CREATED}]
142 ... '${expected_result}' == 'fail' [${HTTP_BAD_REQUEST}]
143
144 Redfish.Post ${metric_definition_base_uri} body=&{dict}
145 ... valid_status_codes=${status_code_expected}
146
147
148Delete All Telemetry Reports
149 [Documentation] Delete all existing telemetry reports.
150
151 ${report_list}= Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricReportDefinitions
152 FOR ${report} IN @{report_list}
153 Redfish.Delete ${report} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
154 END