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