forked from aerospike/aerospike-prometheus-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gauge_stats_test.go
101 lines (65 loc) · 2.63 KB
/
gauge_stats_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
package main
import (
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetGaugesNotEmpty(t *testing.T) {
// this is to force-reload the config in the NamespaceWatcher, this is a check on this param in NamespaceWatcher implementation
os.Setenv(TESTCASE_MODE, TESTCASE_MODE_TRUE)
fmt.Println("initializing GaugeMetrics ... TestGetGaugesNotEmpty")
// Initialize and validate Gauge config
gaugeList := new(GaugeStats)
initGaugeStats(METRICS_CONFIG_FILE, gaugeList)
nslist := gaugeList.NamespaceStats
nodelist := gaugeList.NodeStats
assert.NotEmpty(t, nslist)
assert.NotEmpty(t, nodelist)
}
func TestGetGaugesCounts(t *testing.T) {
// this is to force-reload the config in the NamespaceWatcher, this is a check on this param in NamespaceWatcher implementation
os.Setenv(TESTCASE_MODE, TESTCASE_MODE_TRUE)
fmt.Println("initializing GaugeMetrics ... TestGetGaugesCounts")
// Initialize and validate Gauge config
gaugeList := new(GaugeStats)
initGaugeStats(METRICS_CONFIG_FILE, gaugeList)
glist := gaugeList.NamespaceStats
assert.Equal(t, len(glist), 96)
glist = gaugeList.NodeStats
assert.Equal(t, len(glist), 74)
glist = gaugeList.SetsStats
assert.Equal(t, len(glist), 7)
glist = gaugeList.SindexStats
assert.Equal(t, len(glist), 13)
glist = gaugeList.XdrStats
assert.Equal(t, len(glist), 10)
}
func TestIsAGaugeTrue(t *testing.T) {
// this is to force-reload the config in the NamespaceWatcher, this is a check on this param in NamespaceWatcher implementation
os.Setenv(TESTCASE_MODE, TESTCASE_MODE_TRUE)
// Initialize and validate Gauge config
gaugeList := new(GaugeStats)
initGaugeStats(METRICS_CONFIG_FILE, gaugeList)
exists := false
exists = gaugeList.isGauge(CTX_NAMESPACE, "cache_read_pct")
assert.Equal(t, exists, true)
exists = gaugeList.isGauge(CTX_NODE_STATS, "cluster_clock_skew_stop_writes_sec")
assert.Equal(t, exists, true)
exists = gaugeList.isGauge(CTX_SINDEX, "entries_per_rec")
assert.Equal(t, exists, true)
exists = gaugeList.isGauge(CTX_XDR, "recoveries_pending")
assert.Equal(t, exists, true)
exists = gaugeList.isGauge(CTX_SETS, "truncate_lut")
assert.Equal(t, exists, true)
}
func TestNoGaugeExists(t *testing.T) {
// this is to force-reload the config in the NamespaceWatcher, this is a check on this param in NamespaceWatcher implementation
os.Setenv(TESTCASE_MODE, TESTCASE_MODE_TRUE)
fmt.Println("initializing GaugeMetrics ... TestNoGaugeExists")
// Initialize and validate Gauge config
gaugeList := new(GaugeStats)
initGaugeStats(METRICS_CONFIG_FILE, gaugeList)
exists := gaugeList.isGauge(CTX_NAMESPACE, "non-existing-key")
assert.Equal(t, exists, false)
}