forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 15
/
pgbouncer_test.go
65 lines (54 loc) · 1.32 KB
/
pgbouncer_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
package pgbouncer
import (
"fmt"
"testing"
"github.com/influxdata/telegraf/plugins/inputs/postgresql"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPgBouncerGeneratesMetricsIntegration(t *testing.T) {
t.Skip("Skipping due to not allowed (SQLSTATE 08P01)")
p := &PgBouncer{
Service: postgresql.Service{
Address: fmt.Sprintf(
"host=%s user=pgbouncer password=pgbouncer dbname=pgbouncer port=6432 sslmode=disable",
testutil.GetLocalHost(),
),
IsPgBouncer: true,
},
}
var acc testutil.Accumulator
require.NoError(t, p.Start(&acc))
require.NoError(t, p.Gather(&acc))
intMetrics := []string{
"total_requests",
"total_received",
"total_sent",
"total_query_time",
"avg_req",
"avg_recv",
"avg_sent",
"avg_query",
"cl_active",
"cl_waiting",
"sv_active",
"sv_idle",
"sv_used",
"sv_tested",
"sv_login",
"maxwait",
}
int32Metrics := []string{}
metricsCounted := 0
for _, metric := range intMetrics {
assert.True(t, acc.HasInt64Field("pgbouncer", metric))
metricsCounted++
}
for _, metric := range int32Metrics {
assert.True(t, acc.HasInt32Field("pgbouncer", metric))
metricsCounted++
}
assert.True(t, metricsCounted > 0)
assert.Equal(t, len(intMetrics)+len(int32Metrics), metricsCounted)
}