manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Test telemetry functionality of OpenBMC. |
| 4 | |
| 5 | Resource ../../lib/bmc_redfish_resource.robot |
| 6 | Resource ../../lib/openbmc_ffdc.robot |
| 7 | |
| 8 | Suite Setup Suite Setup Execution |
| 9 | Suite Teardown Redfish.Logout |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 10 | Test Setup Delete All Telemetry Reports |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 11 | Test Teardown Test Teardown Execution |
| 12 | |
George Keishing | 5431685 | 2023-10-16 14:03:29 +0530 | [diff] [blame] | 13 | Force Tags Telemetry_Report |
| 14 | |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 15 | *** Variables *** |
| 16 | |
| 17 | ${metric_definition_base_uri} /redfish/v1/TelemetryService/MetricReportDefinitions |
| 18 | ${metric_report_base_uri} /redfish/v1/TelemetryService/MetricReports |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 19 | &{user_tele_def} ambient temperature=Ambient.*Temp pcie temperature=PCIE.*Temp |
| 20 | ... processor temperature=proc.*temp dimm temperature=dimm.*temp |
| 21 | ... battery voltage=Battery_Voltage total power=total_power |
| 22 | ... relative humidity=Relative_Humidity |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 23 | |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 24 | |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 25 | *** Test Cases *** |
| 26 | |
| 27 | Verify Basic Telemetry Report Creation |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 28 | [Documentation] Verify basic telemetry report creations for different metrics. |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 29 | [Tags] Verify_Basic_Telemetry_Report_Creation |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 30 | [Template] Create Basic Telemetry Report |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 31 | |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 32 | # Metric definition Metric ReportDefinition Type Report Actions Append Limit Expected Result |
| 33 | ambient temperature OnRequest LogToMetricReportsCollection |
| 34 | processor temperature Periodic LogToMetricReportsCollection 500 |
| 35 | dimm temperature Periodic LogToMetricReportsCollection 1000 |
| 36 | total power OnRequest LogToMetricReportsCollection |
| 37 | invalid value OnRequest LogToMetricReportsCollection 100 fail |
| 38 | relative humidity OnRequest LogToMetricReportsCollection |
| 39 | battery voltage Periodic LogToMetricReportsCollection 100 |
manashsarma | 1a0c6bf | 2023-07-27 02:27:56 -0500 | [diff] [blame] | 40 | |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 41 | |
| 42 | Verify Error After Exceeding Maximum Report Creation |
| 43 | [Documentation] Verify error while creating telemetry report more than max report limit. |
| 44 | [Tags] Verify_Error_After_Exceeding_Maximum_Report_Creation |
| 45 | |
| 46 | ${report_name}= Set Variable Testreport |
| 47 | |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 48 | # Create maximum number of reports. |
| 49 | ${resp}= Redfish.Get Properties /redfish/v1/TelemetryService |
| 50 | FOR ${i} IN RANGE ${resp["MaxReports"]} |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 51 | Create Basic Telemetry Report total power Periodic LogToMetricReportsCollection |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 52 | END |
| 53 | |
| 54 | # Attempt another report creation and it should fail. |
George Keishing | 3e469a8 | 2024-05-29 11:38:26 +0530 | [diff] [blame] | 55 | Create Basic Telemetry Report |
| 56 | ... total power Periodic LogToMetricReportsCollection expected_result=fail |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 57 | |
| 58 | # Now delete the reports created. |
| 59 | Delete All Telemetry Reports |
| 60 | |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 61 | |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 62 | Verify Basic Telemetry Report Creation For PCIE |
| 63 | [Documentation] Verify basic telemetry report creations for PCIE. |
| 64 | [Tags] Verify_Basic_Telemetry_Report_Creation_For_PCIE |
| 65 | |
George Keishing | 3e469a8 | 2024-05-29 11:38:26 +0530 | [diff] [blame] | 66 | Create Basic Telemetry Report |
| 67 | ... pcie temperature OnRequest LogToMetricReportsCollection |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 68 | |
| 69 | |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 70 | *** Keywords *** |
| 71 | |
| 72 | Suite Setup Execution |
| 73 | [Documentation] Do test case setup tasks. |
| 74 | |
| 75 | Redfish.Login |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 76 | Redfish Power On stack_mode=skip |
George Keishing | 3e469a8 | 2024-05-29 11:38:26 +0530 | [diff] [blame] | 77 | ${metric_definitions_list}= |
| 78 | ... Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricDefinitions |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 79 | |
George Keishing | 3e469a8 | 2024-05-29 11:38:26 +0530 | [diff] [blame] | 80 | # Create a dictionary of ordinary english naming and actual naming of |
| 81 | # telemtry definition. |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 82 | ${english_actual_teleDef}= Create Dictionary |
| 83 | |
| 84 | Set Suite Variable ${english_actual_teleDef} |
| 85 | Set Suite Variable ${metric_definitions_list} |
| 86 | |
| 87 | Set To Dictionary ${english_actual_teleDef} invalid value invalid_value |
| 88 | |
| 89 | # Find and collect actual telemetry definitions. |
| 90 | FOR ${key} IN @{user_tele_def.keys()} |
| 91 | Add To Telemetry definition Record ${key} ${user_tele_def['${key}']} |
| 92 | END |
| 93 | |
| 94 | |
| 95 | Add To Telemetry definition Record |
George Keishing | 3e469a8 | 2024-05-29 11:38:26 +0530 | [diff] [blame] | 96 | [Documentation] Find actual telemetry definitions available and store. |
| 97 | ... Definitions are stored in a dictionary as key and value |
| 98 | ... as described in argument documentation. |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 99 | [Arguments] ${key} ${value} |
| 100 | |
| 101 | # Description of argument(s): |
George Keishing | 3e469a8 | 2024-05-29 11:38:26 +0530 | [diff] [blame] | 102 | # key Name of metric definition in plain english. |
| 103 | # Example: ambient temperature |
| 104 | # value Equivalent regex expression of telemetry definition. |
| 105 | # Example: Ambient.*Temp |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 106 | |
| 107 | FOR ${item} IN @{metric_definitions_list} |
| 108 | ${regex_matching_output}= Get Regexp Matches ${item} ${value} |
| 109 | IF ${regex_matching_output} != [] |
| 110 | Set To Dictionary ${english_actual_teleDef} ${key}=${regex_matching_output}[0] |
| 111 | Exit For Loop |
| 112 | END |
| 113 | END |
manashsarma | 663c2da | 2023-05-26 06:06:14 -0500 | [diff] [blame] | 114 | |
| 115 | |
| 116 | Test Teardown Execution |
| 117 | [Documentation] Do test teardown operation. |
| 118 | |
| 119 | FFDC On Test Case Fail |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 120 | Delete All Telemetry Reports |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 121 | |
| 122 | |
| 123 | Create Basic Telemetry Report |
| 124 | [Documentation] Create a basic telemetry report with single metric. |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 125 | [Arguments] ${metric_definition_name} ${metric_definition_type} |
| 126 | ... ${report_action} ${append_limit}=10 ${expected_result}=success |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 127 | |
| 128 | # Description of argument(s): |
| 129 | # metric_definition_name Name of metric definition like Ambient_0_Temp. |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 130 | # metric_definition_type Name of telemetry report which needs to be created. |
| 131 | # report_action Telemetry report action. |
George Keishing | c55a899 | 2023-11-13 12:03:43 +0530 | [diff] [blame] | 132 | # append_limit Append limit of the metric data in the report. |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 133 | # expected_result Expected result of report creation - success or fail. |
| 134 | |
manashsarma | 20dc0fd | 2024-04-25 01:23:22 -0500 | [diff] [blame] | 135 | ${metric_definition_name}= Set Variable ${english_actual_teleDef}[${metric_definition_name}] |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 136 | ${resp}= Redfish.Get Properties |
| 137 | ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name} |
manashsarma | d874e9e | 2023-12-13 02:28:51 -0600 | [diff] [blame] | 138 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] |
| 139 | ${telemetry_data_unavailable}= Run Keyword And Return Status Should Contain ${resp} error |
| 140 | IF ${telemetry_data_unavailable} == ${True} |
| 141 | ${metricProperties}= Set Variable "" |
| 142 | ELSE |
| 143 | ${metricProperties}= Set Variable ${resp["MetricProperties"]} |
George Keishing | ee0103d | 2024-01-30 12:35:37 +0530 | [diff] [blame] | 144 | END |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 145 | # Example of response from above Redfish GET request. |
| 146 | # "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp", |
| 147 | # "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition", |
| 148 | # "Id": "Ambient_0_Temp", |
| 149 | # "IsLinear": true, |
| 150 | # "MaxReadingRange": 127.0, |
| 151 | # "MetricDataType": "Decimal", |
| 152 | # "MetricProperties": [ |
| 153 | # "/redfish/v1/Chassis/chassis/Sensors/temperature_Ambient_0_Temp" |
| 154 | # ], |
| 155 | # "MetricType": "Gauge", |
| 156 | # "MinReadingRange": -128.0, |
| 157 | # "Name": "Ambient_0_Temp", |
| 158 | # "Units": "Cel" |
| 159 | |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 160 | # Report name is from random generated string with length 16 which |
| 161 | # is enough to maintain uniqueness in report name. |
| 162 | ${report_name}= Generate Random String 16 [NUMBERS]abcdef |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 163 | ${body}= Catenate {"Id": "${report_name}", |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 164 | ... "MetricReportDefinitionType": "${metric_definition_type}", |
| 165 | ... "Name": "Report", |
| 166 | ... "ReportActions":["${report_action}"], |
| 167 | ... "Metrics":[{"CollectionDuration": "PT30.000S", |
manashsarma | d874e9e | 2023-12-13 02:28:51 -0600 | [diff] [blame] | 168 | ... "MetricProperties":${metricProperties}}], |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 169 | ... "ReportUpdates": "AppendWrapsWhenFull", |
| 170 | ... "AppendLimit": ${append_limit}, |
| 171 | ... "Schedule": {"RecurrenceInterval": "PT5.000S"}} |
| 172 | |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 173 | ${body}= Replace String ${body} ' " |
| 174 | ${dict} Evaluate json.loads('''${body}''') json |
| 175 | |
| 176 | ${status_code_expected}= Set Variable If |
| 177 | ... '${expected_result}' == 'success' [${HTTP_CREATED}] |
| 178 | ... '${expected_result}' == 'fail' [${HTTP_BAD_REQUEST}] |
| 179 | |
| 180 | Redfish.Post ${metric_definition_base_uri} body=&{dict} |
| 181 | ... valid_status_codes=${status_code_expected} |
| 182 | |
manashsarma | d0cb6e1 | 2023-10-10 09:18:40 -0500 | [diff] [blame] | 183 | IF '${expected_result}' == 'success' |
| 184 | # Verify definition of report has attributes provided at the time of creation. |
| 185 | ${resp_report}= Redfish.Get ${metric_definition_base_uri}/${report_name} |
| 186 | ... valid_status_codes=[${HTTP_OK}] |
| 187 | Should Be True '${resp_report.dict["MetricReportDefinitionType"]}' == '${metric_definition_type}' |
| 188 | Should Be True '${resp_report.dict["AppendLimit"]}' == '${AppendLimit}' |
| 189 | Should Be True '${resp_report.dict["ReportActions"][0]}' == '${report_action}' |
| 190 | Should Be True |
| 191 | ... '${resp_report.dict["Metrics"]}[0][MetricProperties][0]' == '${resp["MetricProperties"][0]}' |
| 192 | END |
| 193 | |
manashsarma | 46e243d | 2023-09-08 13:41:30 -0500 | [diff] [blame] | 194 | |
| 195 | Delete All Telemetry Reports |
| 196 | [Documentation] Delete all existing telemetry reports. |
| 197 | |
| 198 | ${report_list}= Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricReportDefinitions |
| 199 | FOR ${report} IN @{report_list} |
| 200 | Redfish.Delete ${report} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 201 | END |