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