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 13Force 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 END 53 54 # Attempt another report creation and it should fail. 55 Create Basic Telemetry Report total power Periodic LogToMetricReportsCollection expected_result=fail 56 57 # Now delete the reports created. 58 Delete All Telemetry Reports 59 60 61Verify 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 68*** Keywords *** 69 70Suite Setup Execution 71 [Documentation] Do test case setup tasks. 72 73 Redfish.Login 74 Redfish Power On stack_mode=skip 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 91Add 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 107 108 109Test Teardown Execution 110 [Documentation] Do test teardown operation. 111 112 FFDC On Test Case Fail 113 Delete All Telemetry Reports 114 115 116Create Basic Telemetry Report 117 [Documentation] Create a basic telemetry report with single metric. 118 [Arguments] ${metric_definition_name} ${metric_definition_type} 119 ... ${report_action} ${append_limit}=10 ${expected_result}=success 120 121 # Description of argument(s): 122 # metric_definition_name Name of metric definition like Ambient_0_Temp. 123 # metric_definition_type Name of telemetry report which needs to be created. 124 # report_action Telemetry report action. 125 # append_limit Append limit of the metric data in the report. 126 # expected_result Expected result of report creation - success or fail. 127 128 ${metric_definition_name}= Set Variable ${english_actual_teleDef}[${metric_definition_name}] 129 ${resp}= Redfish.Get Properties 130 ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name} 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"]} 137 END 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 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 156 ${body}= Catenate {"Id": "${report_name}", 157 ... "MetricReportDefinitionType": "${metric_definition_type}", 158 ... "Name": "Report", 159 ... "ReportActions":["${report_action}"], 160 ... "Metrics":[{"CollectionDuration": "PT30.000S", 161 ... "MetricProperties":${metricProperties}}], 162 ... "ReportUpdates": "AppendWrapsWhenFull", 163 ... "AppendLimit": ${append_limit}, 164 ... "Schedule": {"RecurrenceInterval": "PT5.000S"}} 165 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 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 187 188Delete 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 195