2015-10-13 23:15:39 +00:00
|
|
|
package zookeeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-01-20 18:57:35 +00:00
|
|
|
"github.com/influxdata/telegraf/testutil"
|
2015-10-13 23:15:39 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2015-10-14 02:01:07 +00:00
|
|
|
func TestZookeeperGeneratesMetrics(t *testing.T) {
|
2015-10-13 23:15:39 +00:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("Skipping integration test in short mode")
|
|
|
|
}
|
|
|
|
|
|
|
|
z := &Zookeeper{
|
2015-10-27 22:22:21 +00:00
|
|
|
Servers: []string{testutil.GetLocalHost() + ":2181"},
|
2015-10-13 23:15:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var acc testutil.Accumulator
|
|
|
|
|
2017-04-24 18:13:26 +00:00
|
|
|
require.NoError(t, acc.GatherError(z.Gather))
|
2015-10-13 23:15:39 +00:00
|
|
|
|
2015-10-16 22:13:32 +00:00
|
|
|
intMetrics := []string{
|
|
|
|
"avg_latency",
|
|
|
|
"max_latency",
|
|
|
|
"min_latency",
|
|
|
|
"packets_received",
|
|
|
|
"packets_sent",
|
|
|
|
"outstanding_requests",
|
|
|
|
"znode_count",
|
|
|
|
"watch_count",
|
|
|
|
"ephemerals_count",
|
|
|
|
"approximate_data_size",
|
|
|
|
"open_file_descriptor_count",
|
|
|
|
"max_file_descriptor_count",
|
|
|
|
}
|
2015-10-13 23:15:39 +00:00
|
|
|
|
|
|
|
for _, metric := range intMetrics {
|
2017-05-16 22:25:30 +00:00
|
|
|
assert.True(t, acc.HasInt64Field("zookeeper", metric), metric)
|
2015-10-13 23:15:39 +00:00
|
|
|
}
|
|
|
|
}
|