forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetricreportdefinition_test.go
116 lines (110 loc) · 3.18 KB
/
metricreportdefinition_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"fmt"
"strings"
"testing"
)
var metricReportDefinitonBody = `{
"@odata.type": "#MetricReportDefinition.v1_4_2.MetricReportDefinition",
"@odata.context": "/redfish/v1/$metadata#MetricReportDefinition.MetricReportDefinition",
"@odata.id": "/redfish/v1/TelemetryService/MetricReportDefinitions/CPUSensor",
"Id": "CPUSensor",
"Name": "CPU Sensor Metric Report",
"Description": "CPU Sensor",
"AppendLimit": 2400,
"MetricReportDefinitionEnabled": false,
"MetricReportDefinitionType": "Periodic",
"MetricReportHeartbeatInterval": "PT0H0M0S",
"SuppressRepeatedMetricValue": false,
"ReportTimespan": "PT0H0M0S",
"ReportUpdates": "Overwrite",
"Wildcards": [],
"[email protected]": [
"Periodic",
"OnChange",
"OnRequest"
],
"[email protected]": [
"AppendStopsWhenFull",
"AppendWrapsWhenFull",
"NewReport",
"Overwrite"
],
"ReportActions": [
"RedfishEvent",
"LogToMetricReportsCollection"
],
"[email protected]": [
"LogToMetricReportsCollection",
"RedfishEvent"
],
"Status": {
"State": "Disabled"
},
"Schedule": {
"RecurrenceInterval": "PT0H1M0S"
},
"Metrics": [
{
"MetricId": "TemperatureReading",
"MetricProperties": [],
"CollectionFunction": null,
"CollectionDuration": null,
"CollectionTimeScope": "Point",
"Oem": {
"Dell": {
"@odata.type": "#DellMetric.v1_1_0.DellMetric",
"CustomLabel": null,
"FQDD": "iDRAC.Embedded.1#CPU%Temp",
"Source": null
}
}
}
],
"Links": {
"Triggers": [
{
"@odata.id": "/redfish/v1/TelemetryService/Triggers/CPUCriticalTrigger"
},
{
"@odata.id": "/redfish/v1/TelemetryService/Triggers/CPUWarnTrigger"
},
{
"@odata.id": "/redfish/v1/TelemetryService/Triggers/TMPCpuCriticalTrigger"
},
{
"@odata.id": "/redfish/v1/TelemetryService/Triggers/TMPCpuWarnTrigger"
}
]
},
"Oem": {
"Dell": {
"@odata.type": "#DellMetricReportDefinition.v1_1_0.DellMetricReportDefinition",
"Digest": "5230bb90347b1362c6a2b6c69a26ada70369b5c8c5e4379f4d932bb639b6a630",
"iDRACFirmwareVersion": "7.00.60.00"
}
}
}`
// TestMetricReportDefinition tests the parsing of MetricReportDefinition objects.
func TestMetricReportDefinition(t *testing.T) {
var result MetricReportDefinition
err := json.NewDecoder(strings.NewReader(metricReportDefinitonBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "CPUSensor", result.ID)
assertEquals(t, "CPU Sensor Metric Report", result.Name)
assertEquals(t, "CPU Sensor", result.Description)
assertEquals(t, "2400", fmt.Sprintf("%d", result.AppendLimit))
assertEquals(t, "false", fmt.Sprintf("%t", result.MetricReportDefinitionEnabled))
assertEquals(t, "PT0H0M0S", result.ReportTimespan)
assertEquals(t, "2", fmt.Sprintf("%d", len(result.ReportActions)))
assertEquals(t, "1", fmt.Sprintf("%d", len(result.Metrics)))
assertEquals(t, "TemperatureReading", result.Metrics[0].MetricID)
assertEquals(t, "4", fmt.Sprintf("%d", len(result.triggers)))
assertEquals(t, "/redfish/v1/TelemetryService/Triggers/CPUCriticalTrigger", result.triggers[0])
}