2015-10-13 23:15:39 +00:00
|
|
|
package zookeeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-01-20 20:19:03 +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
|
|
|
|
|
|
|
|
err := z.Gather(&acc)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
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 {
|
2016-01-07 01:19:18 +00:00
|
|
|
assert.True(t, acc.HasIntField("zookeeper", metric), metric)
|
2015-10-13 23:15:39 +00:00
|
|
|
}
|
|
|
|
}
|