Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions cmd/tools/grafana/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2169,3 +2169,54 @@ func checkMultiSelectEnabled(t *testing.T, path string, data []byte) {
return true
})
}

func TestTimeSeriesDefaults(t *testing.T) {
VisitDashboards(Dashboards, func(path string, data []byte) {
checkTimeSeriesDefaults(t, path, data)
})
}

func checkTimeSeriesDefaults(t *testing.T, path string, data []byte) {
path = ShortPath(path)

VisitAllPanels(data, func(_ string, _, value gjson.Result) {
panelType := value.Get("type").ClonedString()
if panelType != "timeseries" {
return
}

title := value.Get("title").ClonedString()
lineWidth := value.Get("fieldConfig.defaults.custom.lineWidth")

if lineWidth.Exists() && lineWidth.Int() != 1 {
t.Errorf(`dashboard=%s title="%s" fieldConfig.defaults.custom.lineWidth got=[%d] want=1`,
path, title, lineWidth.Int())
}

showPoints := value.Get("fieldConfig.defaults.custom.showPoints")

if showPoints.Exists() && showPoints.String() != "never" {
t.Errorf(`dashboard=%s title="%s" fieldConfig.defaults.custom.showPoints got=[%s] want=never`,
path, title, showPoints.String())
}

// Check overrides
value.Get("fieldConfig.overrides").ForEach(func(_, anOverride gjson.Result) bool {
anOverride.Get("properties").ForEach(func(_, propValue gjson.Result) bool {
id := propValue.Get("id").ClonedString()
switch id {
case "custom.showPoints":
if propValue.Get("value").String() != "never" {
t.Errorf(`dashboard=%s title="%s" has override for custom.showPoints with value=%s, want=never`, path, title, propValue.Get("value").String())
}
case "custom.lineWidth":
if propValue.Get("value").Int() != 1 {
t.Errorf(`dashboard=%s title="%s" has override for custom.lineWidth with value=%d, want=1`, path, title, propValue.Get("value").Int())
}
}
Comment thread
cgrinds marked this conversation as resolved.
return true
})
return true
})
})
}
24 changes: 12 additions & 12 deletions grafana/dashboards/7mode/aggregate7.json
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -972,7 +972,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1058,7 +1058,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1144,7 +1144,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1231,7 +1231,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1317,7 +1317,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1409,7 +1409,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1501,7 +1501,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1594,7 +1594,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1680,7 +1680,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1766,7 +1766,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1859,7 +1859,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down
12 changes: 6 additions & 6 deletions grafana/dashboards/7mode/cluster7.json
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1132,7 +1132,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1222,7 +1222,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1313,7 +1313,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1404,7 +1404,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1496,7 +1496,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down
14 changes: 7 additions & 7 deletions grafana/dashboards/7mode/disk7.json
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1088,7 +1088,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1515,7 +1515,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1613,7 +1613,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1711,7 +1711,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1802,7 +1802,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down Expand Up @@ -1929,7 +1929,7 @@
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
Expand Down
Loading
Loading