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 Setup Delete All Telemetry Reports 11Test Teardown Test Teardown Execution 12 13Test Tags Telemetry_Report 14 15*** Variables *** 16 17${metric_definition_base_uri} /redfish/v1/TelemetryService/MetricReportDefinitions 18${metric_report_base_uri} /redfish/v1/TelemetryService/MetricReports 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 23 24 25*** Test Cases *** 26 27Verify Basic Telemetry Report Creation 28 [Documentation] Verify basic telemetry report creations for different metrics. 29 [Tags] Verify_Basic_Telemetry_Report_Creation 30 [Template] Create Basic Telemetry Report 31 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 40 41 42Verify 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 48 # Create maximum number of reports. 49 ${resp}= Redfish.Get Properties /redfish/v1/TelemetryService 50 FOR ${i} IN RANGE ${resp["MaxReports"]} 51 Create Basic Telemetry Report total power Periodic LogToMetricReportsCollection 52 ... delete_report=False 53 END 54 55 # Attempt another report creation and it should fail. 56 Create Basic Telemetry Report 57 ... total power Periodic LogToMetricReportsCollection expected_result=fail 58 59 # Now delete the reports created. 60 Delete All Telemetry Reports 61 62 63Verify Basic Telemetry Report Creation For PCIE 64 [Documentation] Verify basic telemetry report creations for PCIE. 65 [Tags] Verify_Basic_Telemetry_Report_Creation_For_PCIE 66 67 Create Basic Telemetry Report 68 ... pcie temperature OnRequest LogToMetricReportsCollection 69 70Verify Telemetry Service Unsupported Methods 71 [Documentation] Verify Telemetry Service with Unsupported methods. 72 [Tags] Verify_Telemetry_Service_Unsupported_Methods 73 74 Verify Supported And Unsupported Methods uri=/redfish/v1/TelemetryService 75 76Verify Telemetry Service MetricReports Unsupported Methods 77 [Documentation] Verify Telemetry Service MetricReports with Unsupported methods. 78 [Tags] Verify_Telemetry_Service_Metric_Reports_Unsupported_Methods 79 80 Verify Supported And Unsupported Methods uri=/redfish/v1/TelemetryService/MetricReports 81 82 83*** Keywords *** 84 85Verify Supported And Unsupported Methods 86 [Documentation] Verify Supported And Unsupported Methods for given URI. 87 [Arguments] ${uri} 88 # Description of argument(s): 89 # uri The URI to be tested. 90 91 # GET operation on Telemetry Service 92 Redfish.Get ${uri} 93 ... valid_status_codes=[${HTTP_OK}] 94 95 # Put operation on Telemetry Service 96 Redfish.Put ${uri} 97 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 98 99 # Post operation on Telemetry Service 100 Redfish.Post ${uri} 101 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 102 103 # Delete operation on Telemetry Service 104 Redfish.Delete ${uri} 105 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 106 107 # Patch operation on Telemetry Service 108 Redfish.Patch ${uri} 109 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 110 111Suite Setup Execution 112 [Documentation] Do test case setup tasks. 113 114 Redfish.Login 115 Redfish Power On stack_mode=skip 116 ${metric_definitions_list}= 117 ... Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricDefinitions 118 119 # Create a dictionary of ordinary english naming and actual naming of 120 # telemetry definition. 121 ${english_actual_teleDef}= Create Dictionary 122 123 Set Suite Variable ${english_actual_teleDef} 124 Set Suite Variable ${metric_definitions_list} 125 126 Set To Dictionary ${english_actual_teleDef} invalid value invalid_value 127 128 # Find and collect actual telemetry definitions. 129 FOR ${key} IN @{user_tele_def.keys()} 130 Add To Telemetry definition Record ${key} ${user_tele_def['${key}']} 131 END 132 133 134Add To Telemetry definition Record 135 [Documentation] Find actual telemetry definitions available and store. 136 ... Definitions are stored in a dictionary as key and value 137 ... as described in argument documentation. 138 [Arguments] ${key} ${value} 139 140 # Description of argument(s): 141 # key Name of metric definition in plain english. 142 # Example: ambient temperature 143 # value Equivalent regex expression of telemetry definition. 144 # Example: Ambient.*Temp 145 146 Set To Dictionary ${english_actual_teleDef} ${key}=Not found 147 FOR ${item} IN @{metric_definitions_list} 148 ${regex_matching_output}= Get Regexp Matches ${item} ${value} 149 IF ${regex_matching_output} != [] 150 Set To Dictionary ${english_actual_teleDef} ${key}=${regex_matching_output}[0] 151 BREAK 152 END 153 END 154 155 156Test Teardown Execution 157 [Documentation] Do test teardown operation. 158 159 FFDC On Test Case Fail 160 Delete All Telemetry Reports 161 162 163Create Basic Telemetry Report 164 [Documentation] Create a basic telemetry report with single metric. 165 [Arguments] ${metric_definition_name} ${metric_definition_type} 166 ... ${report_action} ${append_limit}=10 ${expected_result}=success ${delete_report}=True 167 168 # Description of argument(s): 169 # metric_definition_name Name of metric definition like Ambient_0_Temp. 170 # metric_definition_type Name of telemetry report which needs to be created. 171 # report_action Telemetry report action. 172 # append_limit Append limit of the metric data in the report. 173 # expected_result Expected result of report creation - success or fail. 174 # delete_report Flag to decide if telemetry report needs to be deleted after creation. 175 176 ${metric_definition_name}= Set Variable ${english_actual_teleDef}[${metric_definition_name}] 177 Skip If '${metric_definition_name}' == 'Not found' Metric definition is not found. 178 179 ${resp}= Redfish.Get Properties 180 ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name} 181 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] 182 ${telemetry_data_unavailable}= Run Keyword And Return Status Should Contain ${resp} error 183 IF ${telemetry_data_unavailable} == ${True} 184 ${metricProperties}= Set Variable "" 185 ELSE 186 ${metricProperties}= Set Variable ${resp["MetricProperties"]} 187 END 188 # Example of response from above Redfish GET request. 189 # "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp", 190 # "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition", 191 # "Id": "Ambient_0_Temp", 192 # "IsLinear": true, 193 # "MaxReadingRange": 127.0, 194 # "MetricDataType": "Decimal", 195 # "MetricProperties": [ 196 # "/redfish/v1/Chassis/chassis/Sensors/temperature_Ambient_0_Temp" 197 # ], 198 # "MetricType": "Gauge", 199 # "MinReadingRange": -128.0, 200 # "Name": "Ambient_0_Temp", 201 # "Units": "Cel" 202 203 # Report name is from random generated string with length 16 which 204 # is enough to maintain uniqueness in report name. 205 ${report_name}= Generate Random String 16 [NUMBERS]abcdef 206 ${body}= Catenate {"Id": "${report_name}", 207 ... "MetricReportDefinitionType": "${metric_definition_type}", 208 ... "Name": "Report", 209 ... "ReportActions":["${report_action}"], 210 ... "Metrics":[{"CollectionDuration": "PT30.000S", 211 ... "MetricProperties":${metricProperties}}], 212 ... "ReportUpdates": "AppendWrapsWhenFull", 213 ... "AppendLimit": ${append_limit}, 214 ... "Schedule": {"RecurrenceInterval": "PT5.000S"}} 215 216 ${body}= Replace String ${body} ' " 217 ${dict} Evaluate json.loads('''${body}''') json 218 219 ${status_code_expected}= Set Variable If 220 ... '${expected_result}' == 'success' [${HTTP_CREATED}] 221 ... '${expected_result}' == 'fail' [${HTTP_BAD_REQUEST}] 222 223 Redfish.Post ${metric_definition_base_uri} body=&{dict} 224 ... valid_status_codes=${status_code_expected} 225 226 IF '${expected_result}' == 'success' 227 # Verify definition of report has attributes provided at the time of creation. 228 ${resp_report}= Redfish.Get ${metric_definition_base_uri}/${report_name} 229 ... valid_status_codes=[${HTTP_OK}] 230 Should Be True '${resp_report.dict["MetricReportDefinitionType"]}' == '${metric_definition_type}' 231 Should Be True '${resp_report.dict["AppendLimit"]}' == '${AppendLimit}' 232 Should Be True '${resp_report.dict["ReportActions"][0]}' == '${report_action}' 233 Should Be True 234 ... '${resp_report.dict["Metrics"]}[0][MetricProperties][0]' == '${resp["MetricProperties"][0]}' 235 END 236 237 IF ${delete_report} == ${True} 238 Delete All Telemetry Reports 239 END 240 241 242Delete All Telemetry Reports 243 [Documentation] Delete all existing telemetry reports. 244 245 ${report_list}= Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricReportDefinitions 246 FOR ${report} IN @{report_list} 247 Redfish.Delete ${report} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 248 END 249