summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/agent/module/charts.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:15:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:15:20 +0000
commit87d772a7d708fec12f48cd8adc0dedff6e1025da (patch)
tree1fee344c64cc3f43074a01981e21126c8482a522 /src/go/collectors/go.d.plugin/agent/module/charts.go
parentAdding upstream version 1.46.3. (diff)
downloadnetdata-upstream.tar.xz
netdata-upstream.zip
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/go/plugin/go.d/agent/module/charts.go (renamed from src/go/collectors/go.d.plugin/agent/module/charts.go)37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/go/collectors/go.d.plugin/agent/module/charts.go b/src/go/plugin/go.d/agent/module/charts.go
index 2b9c35c3b..b60b3bac1 100644
--- a/src/go/collectors/go.d.plugin/agent/module/charts.go
+++ b/src/go/plugin/go.d/agent/module/charts.go
@@ -6,7 +6,10 @@ import (
"errors"
"fmt"
"strings"
+ "testing"
"unicode"
+
+ "github.com/stretchr/testify/assert"
)
type (
@@ -436,7 +439,7 @@ func checkDim(d *Dim) error {
if d.ID == "" {
return errors.New("empty dim ID")
}
- if id := checkID(d.ID); id != -1 {
+ if id := checkID(d.ID); id != -1 && (d.Name == "" || checkID(d.Name) != -1) {
return fmt.Errorf("unacceptable symbol in dim ID '%s' : '%c'", d.ID, id)
}
return nil
@@ -460,3 +463,35 @@ func checkID(id string) int {
}
return -1
}
+
+func TestMetricsHasAllChartsDims(t *testing.T, charts *Charts, mx map[string]int64) {
+ for _, chart := range *charts {
+ if chart.Obsolete {
+ continue
+ }
+ for _, dim := range chart.Dims {
+ _, ok := mx[dim.ID]
+ assert.Truef(t, ok, "missing data for dimension '%s' in chart '%s'", dim.ID, chart.ID)
+ }
+ for _, v := range chart.Vars {
+ _, ok := mx[v.ID]
+ assert.Truef(t, ok, "missing data for variable '%s' in chart '%s'", v.ID, chart.ID)
+ }
+ }
+}
+
+func TestMetricsHasAllChartsDimsSkip(t *testing.T, charts *Charts, mx map[string]int64, skip func(chart *Chart) bool) {
+ for _, chart := range *charts {
+ if chart.Obsolete || (skip != nil && skip(chart)) {
+ continue
+ }
+ for _, dim := range chart.Dims {
+ _, ok := mx[dim.ID]
+ assert.Truef(t, ok, "missing data for dimension '%s' in chart '%s'", dim.ID, chart.ID)
+ }
+ for _, v := range chart.Vars {
+ _, ok := mx[v.ID]
+ assert.Truef(t, ok, "missing data for variable '%s' in chart '%s'", v.ID, chart.ID)
+ }
+ }
+}