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 20 21*** Test Cases *** 22 23Verify Basic Telemetry Report Creation 24 [Documentation] Verify basic telemetry report creations for different metrics. 25 [Tags] Verify_Basic_Telemetry_Report_Creation 26 [Template] Create Basic Telemetry Report 27 28 # Metric definition Metric ReportDefinition Type Report Actions Append Limit Expected Result 29 total_power OnRequest LogToMetricReportsCollection 30 Battery_Voltage Periodic LogToMetricReportsCollection 100 31 Ambient_0_Temp OnRequest LogToMetricReportsCollection 32 proc0_core1_1_temp Periodic LogToMetricReportsCollection 500 33 PCIE_0_Temp OnRequest LogToMetricReportsCollection 34 dimm0_pmic_temp Periodic LogToMetricReportsCollection 1000 35 Relative_Humidity OnRequest LogToMetricReportsCollection 36 pcie_dcm0_power Periodic LogToMetricReportsCollection 32768 37 io_dcm0_power OnRequest LogToMetricReportsCollection 38 invalid_value OnRequest LogToMetricReportsCollection 100 fail 39 40 41Verify Error After Exceeding Maximum Report Creation 42 [Documentation] Verify error while creating telemetry report more than max report limit. 43 [Tags] Verify_Error_After_Exceeding_Maximum_Report_Creation 44 45 ${report_name}= Set Variable Testreport 46 47 # Create maximum number of reports. 48 ${resp}= Redfish.Get Properties /redfish/v1/TelemetryService 49 FOR ${i} IN RANGE ${resp["MaxReports"]} 50 Create Basic Telemetry Report total_power Periodic LogToMetricReportsCollection 51 END 52 53 # Attempt another report creation and it should fail. 54 Create Basic Telemetry Report total_power Periodic LogToMetricReportsCollection expected_result=fail 55 56 # Now delete the reports created. 57 Delete All Telemetry Reports 58 59 60*** Keywords *** 61 62Suite Setup Execution 63 [Documentation] Do test case setup tasks. 64 65 Redfish.Login 66 Redfish Power On stack_mode=skip 67 68 69Test Teardown Execution 70 [Documentation] Do test teardown operation. 71 72 FFDC On Test Case Fail 73 Delete All Telemetry Reports 74 75 76Create Basic Telemetry Report 77 [Documentation] Create a basic telemetry report with single metric. 78 [Arguments] ${metric_definition_name} ${metric_definition_type} 79 ... ${report_action} ${append_limit}=10 ${expected_result}=success 80 81 # Description of argument(s): 82 # metric_definition_name Name of metric definition like Ambient_0_Temp. 83 # metric_definition_type Name of telemetry report which needs to be created. 84 # report_action Telemetry report action. 85 # append_limit Append limit of the metric data in the report. 86 # expected_result Expected result of report creation - success or fail. 87 88 ${resp}= Redfish.Get Properties 89 ... /redfish/v1/TelemetryService/MetricDefinitions/${metric_definition_name} 90 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] 91 ${telemetry_data_unavailable}= Run Keyword And Return Status Should Contain ${resp} error 92 IF ${telemetry_data_unavailable} == ${True} 93 ${metricProperties}= Set Variable "" 94 ELSE 95 ${metricProperties}= Set Variable ${resp["MetricProperties"]} 96 END 97 # Example of response from above Redfish GET request. 98 # "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Ambient_0_Temp", 99 # "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition", 100 # "Id": "Ambient_0_Temp", 101 # "IsLinear": true, 102 # "MaxReadingRange": 127.0, 103 # "MetricDataType": "Decimal", 104 # "MetricProperties": [ 105 # "/redfish/v1/Chassis/chassis/Sensors/temperature_Ambient_0_Temp" 106 # ], 107 # "MetricType": "Gauge", 108 # "MinReadingRange": -128.0, 109 # "Name": "Ambient_0_Temp", 110 # "Units": "Cel" 111 112 # Report name is from random generated string with length 16 which 113 # is enough to maintain uniqueness in report name. 114 ${report_name}= Generate Random String 16 [NUMBERS]abcdef 115 ${body}= Catenate {"Id": "${report_name}", 116 ... "MetricReportDefinitionType": "${metric_definition_type}", 117 ... "Name": "Report", 118 ... "ReportActions":["${report_action}"], 119 ... "Metrics":[{"CollectionDuration": "PT30.000S", 120 ... "MetricProperties":${metricProperties}}], 121 ... "ReportUpdates": "AppendWrapsWhenFull", 122 ... "AppendLimit": ${append_limit}, 123 ... "Schedule": {"RecurrenceInterval": "PT5.000S"}} 124 125 ${body}= Replace String ${body} ' " 126 ${dict} Evaluate json.loads('''${body}''') json 127 128 ${status_code_expected}= Set Variable If 129 ... '${expected_result}' == 'success' [${HTTP_CREATED}] 130 ... '${expected_result}' == 'fail' [${HTTP_BAD_REQUEST}] 131 132 Redfish.Post ${metric_definition_base_uri} body=&{dict} 133 ... valid_status_codes=${status_code_expected} 134 135 IF '${expected_result}' == 'success' 136 # Verify definition of report has attributes provided at the time of creation. 137 ${resp_report}= Redfish.Get ${metric_definition_base_uri}/${report_name} 138 ... valid_status_codes=[${HTTP_OK}] 139 Should Be True '${resp_report.dict["MetricReportDefinitionType"]}' == '${metric_definition_type}' 140 Should Be True '${resp_report.dict["AppendLimit"]}' == '${AppendLimit}' 141 Should Be True '${resp_report.dict["ReportActions"][0]}' == '${report_action}' 142 Should Be True 143 ... '${resp_report.dict["Metrics"]}[0][MetricProperties][0]' == '${resp["MetricProperties"][0]}' 144 END 145 146 147Delete All Telemetry Reports 148 [Documentation] Delete all existing telemetry reports. 149 150 ${report_list}= Redfish_Utils.Get Member List /redfish/v1/TelemetryService/MetricReportDefinitions 151 FOR ${report} IN @{report_list} 152 Redfish.Delete ${report} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 153 END 154