Repository: NetApp/harvest
Pull request #1884 (2023-03-31 15:30:35)

test: Ensure all dashboard heatmaps use the same colorScheme and style


Patch:
diff --git a/grafana/dashboards/storagegrid/overview.json b/grafana/dashboards/storagegrid/overview.json
index 9b99fe9c..9bec4e81 100644
--- a/grafana/dashboards/storagegrid/overview.json
+++ b/grafana/dashboards/storagegrid/overview.json
@@ -1995,9 +1995,9 @@
           "color": {
             "cardColor": "#b4ff00",
             "colorScale": "sqrt",
-            "colorScheme": "interpolateTurbo",
+            "colorScheme": "interpolateRdYlGn",
             "exponent": 0.5,
-            "mode": "opacity"
+            "mode": "spectrum"
           },
           "dataFormat": "tsbuckets",
           "datasource": "${DS_PROMETHEUS}",
@@ -2061,9 +2061,9 @@
           "color": {
             "cardColor": "#b4ff00",
             "colorScale": "sqrt",
-            "colorScheme": "interpolateTurbo",
+            "colorScheme": "interpolateRdYlGn",
             "exponent": 0.5,
-            "mode": "opacity"
+            "mode": "spectrum"
           },
           "dataFormat": "tsbuckets",
           "datasource": "${DS_PROMETHEUS}",


Test patch:
diff --git a/cmd/tools/grafana/dashboard_test.go b/cmd/tools/grafana/dashboard_test.go
index 91a87068..51665511 100644
--- a/cmd/tools/grafana/dashboard_test.go
+++ b/cmd/tools/grafana/dashboard_test.go
@@ -871,3 +871,36 @@ func checkDashboardRefresh(t *testing.T, path string, data []byte) {
 		return true
 	})
 }
+
+func TestHeatmapSettings(t *testing.T) {
+	visitDashboards(
+		[]string{"../../../grafana/dashboards/cmode", "../../../grafana/dashboards/storagegrid"},
+		func(path string, data []byte) {
+			checkHeatmapSettings(t, shortPath(path), data)
+		},
+	)
+}
+
+func checkHeatmapSettings(t *testing.T, path string, data []byte) {
+	dashPath := shortPath(path)
+	const (
+		wantColorScheme = "interpolateRdYlGn"
+		wantColorMode   = "spectrum"
+	)
+	visitAllPanels(data, func(path string, key, value gjson.Result) {
+		panelType := value.Get("type").String()
+		if panelType != "heatmap" {
+			return
+		}
+		colorScheme := value.Get("color.colorScheme").String()
+		colorMode := value.Get("color.mode").String()
+		if colorScheme != wantColorScheme {
+			t.Errorf(`dashboard=%s path=%s panel="%s" got color.scheme=%s, want=%s`,
+				dashPath, path, value.Get("title").String(), colorScheme, wantColorScheme)
+		}
+		if colorMode != wantColorMode {
+			t.Errorf(`dashboard=%s path=%s panel="%s" got color.mode=%s, want=%s`,
+				dashPath, path, value.Get("title").String(), colorMode, wantColorMode)
+		}
+	})
+}
diff --git a/pkg/conf/conf_test.go b/pkg/conf/conf_test.go
index 92742d18..c461dc66 100644
--- a/pkg/conf/conf_test.go
+++ b/pkg/conf/conf_test.go
@@ -191,10 +191,7 @@ func TestFlowStyle(t *testing.T) {
 
 func TestUniqueExportersByType(t *testing.T) {
 	path := "../../cmd/tools/doctor/testdata/testConfig.yml"
-	err := LoadHarvestConfig(path)
-	if err != nil {
-		panic(err)
-	}
+	TestLoadHarvestConfig(path)
 	poller2, _ := PollerNamed("overlapping")
 	t.Run("Exporters are unique by type", func(t *testing.T) {
 		exporters := GetUniqueExporters(poller2.Exporters)