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 70 71*** Keywords *** 72 73Suite Setup Execution 74 [Documentation] Do test case setup tasks. 75 76 Redfish.Login 77 Redfish Power On stack_mode=skip 78 ${metric_definitions_list}= 79 ... Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricDefinitions 80 81 # Create a dictionary of ordinary english naming and actual naming of 82 # telemetry definition. 83 ${english_actual_teleDef}= Create Dictionary 84 85 Set Suite Variable ${english_actual_teleDef} 86 Set Suite Variable ${metric_definitions_list} 87 88 Set To Dictionary ${english_actual_teleDef} invalid value invalid_value 89 90 # Find and collect actual telemetry definitions. 91 FOR ${key} IN @{user_tele_def.keys()} 92 Add To Telemetry definition Record ${key} ${user_tele_def['${key}']} 93 END 94 95 96Add To Telemetry definition Record 97 [Documentation] Find actual telemetry definitions available and store. 98 ... Definitions are stored in a dictionary as key and value 99 ... as described in argument documentation. 100 [Arguments] ${key} ${value} 101 102 # Description of argument(s): 103 # key Name of metric definition in plain english. 104 # Example: ambient temperature 105 # value Equivalent regex expression of telemetry definition. 106 # Example: Ambient.*Temp 107 108 Set To Dictionary ${english_actual_teleDef} ${key}=Not found 109 FOR ${item} IN @{metric_definitions_list} 110 ${regex_matching_output}= Get Regexp Matches ${item} ${value} 111 IF ${regex_matching_output} != [] 112 Set To Dictionary ${english_actual_teleDef} ${key}=${regex_matching_output}[0] 113 BREAK 114 END 115 END 116 117 118Test Teardown Execution 119 [Documentation] Do test teardown operation. 120 121 FFDC On Test Case Fail 122 Delete All Telemetry Reports 123 124 125Create Basic Telemetry Report 126 [Documentation] Create a basic telemetry report with single metric. 127 [Arguments] ${metric_definition_name} ${metric_definition_type} 128 ... ${report_action} ${append_limit}=10 ${expected_result}=success ${delete_report}=True 129 130 # Description of argument(s): 131 # metric_definition_name Name of metric definition like Ambient_0_Temp. 132 # metric_definition_type Name of telemetry report which needs to be created. 133 # report_action Telemetry report action. 134 # append_limit Append limit of the metric data in the report. 135 # expected_result Expected result of report creation - success or fail. 136 # delete_report Flag to decide if telemetry report needs to be deleted after creation. 137 138 ${metric_definition_name}= Set Variable ${english_actual_teleDef}[${metric_definition_name}] 139 Skip If '${metric_definition_name}' == 'Not found' Metric definition is not found. 140 141 ${resp}= Redfish.Get Properties 142 ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name} 143 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] 144 ${telemetry_data_unavailable}= Run Keyword And Return Status Should Contain ${resp} error 145 IF ${telemetry_data_unavailable} == ${True} 146 ${metricProperties}= Set Variable "" 147 ELSE 148 ${metricProperties}= Set Variable ${resp["MetricProperties"]} 149 END 150 # Example of response from above Redfish GET request. 151 # "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp", 152 # "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition", 153 # "Id": "Ambient_0_Temp", 154 # "IsLinear": true, 155 # "MaxReadingRange": 127.0, 156 # "MetricDataType": "Decimal", 157 # "MetricProperties": [ 158 # "/redfish/v1/Chassis/chassis/Sensors/temperature_Ambient_0_Temp" 159 # ], 160 # "MetricType": "Gauge", 161 # "MinReadingRange": -128.0, 162 # "Name": "Ambient_0_Temp", 163 # "Units": "Cel" 164 165 # Report name is from random generated string with length 16 which 166 # is enough to maintain uniqueness in report name. 167 ${report_name}= Generate Random String 16 [NUMBERS]abcdef 168 ${body}= Catenate {"Id": "${report_name}", 169 ... "MetricReportDefinitionType": "${metric_definition_type}", 170 ... "Name": "Report", 171 ... "ReportActions":["${report_action}"], 172 ... "Metrics":[{"CollectionDuration": "PT30.000S", 173 ... "MetricProperties":${metricProperties}}], 174 ... "ReportUpdates": "AppendWrapsWhenFull", 175 ... "AppendLimit": ${append_limit}, 176 ... "Schedule": {"RecurrenceInterval": "PT5.000S"}} 177 178 ${body}= Replace String ${body} ' " 179 ${dict} Evaluate json.loads('''${body}''') json 180 181 ${status_code_expected}= Set Variable If 182 ... '${expected_result}' == 'success' [${HTTP_CREATED}] 183 ... '${expected_result}' == 'fail' [${HTTP_BAD_REQUEST}] 184 185 Redfish.Post ${metric_definition_base_uri} body=&{dict} 186 ... valid_status_codes=${status_code_expected} 187 188 IF '${expected_result}' == 'success' 189 # Verify definition of report has attributes provided at the time of creation. 190 ${resp_report}= Redfish.Get ${metric_definition_base_uri}/${report_name} 191 ... valid_status_codes=[${HTTP_OK}] 192 Should Be True '${resp_report.dict["MetricReportDefinitionType"]}' == '${metric_definition_type}' 193 Should Be True '${resp_report.dict["AppendLimit"]}' == '${AppendLimit}' 194 Should Be True '${resp_report.dict["ReportActions"][0]}' == '${report_action}' 195 Should Be True 196 ... '${resp_report.dict["Metrics"]}[0][MetricProperties][0]' == '${resp["MetricProperties"][0]}' 197 END 198 199 IF ${delete_report} == ${True} 200 Delete All Telemetry Reports 201 END 202 203 204Delete All Telemetry Reports 205 [Documentation] Delete all existing telemetry reports. 206 207 ${report_list}= Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricReportDefinitions 208 FOR ${report} IN @{report_list} 209 Redfish.Delete ${report} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 210 END 211