xref: /openbmc/openbmc-test-automation/redfish/telemetry_service/test_telemetry_report.robot (revision 87dc442c6650dd0badacef4a71ac62667d20ab40)
1*** 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
12Force Tags          Telemetry_Report
13
14*** 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
24    [Teardown]  Redfish.Delete  ${metric_definition_base_uri}/${report_name}
25    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
26
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
44Verify 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
71
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
93*** 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
105
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
155