2015-10-21 19:05:14 +00:00
|
|
|
package aerospike
|
|
|
|
|
|
|
|
import (
|
2016-01-06 23:11:16 +00:00
|
|
|
"testing"
|
|
|
|
|
2016-01-20 18:57:35 +00:00
|
|
|
"github.com/influxdata/telegraf/testutil"
|
2015-10-21 19:05:14 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAerospikeStatistics(t *testing.T) {
|
|
|
|
if testing.Short() {
|
2016-08-24 08:03:17 +00:00
|
|
|
t.Skip("Skipping aerospike integration tests.")
|
2015-10-21 19:05:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
a := &Aerospike{
|
|
|
|
Servers: []string{testutil.GetLocalHost() + ":3000"},
|
|
|
|
}
|
|
|
|
|
|
|
|
var acc testutil.Accumulator
|
|
|
|
|
2017-04-24 18:13:26 +00:00
|
|
|
err := acc.GatherError(a.Gather)
|
2015-10-21 19:05:14 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2016-07-15 05:12:32 +00:00
|
|
|
assert.True(t, acc.HasMeasurement("aerospike_node"))
|
2017-06-14 00:09:38 +00:00
|
|
|
assert.True(t, acc.HasTag("aerospike_node", "node_name"))
|
2016-07-15 05:12:32 +00:00
|
|
|
assert.True(t, acc.HasMeasurement("aerospike_namespace"))
|
2017-06-14 00:09:38 +00:00
|
|
|
assert.True(t, acc.HasTag("aerospike_namespace", "node_name"))
|
2017-05-16 22:25:30 +00:00
|
|
|
assert.True(t, acc.HasInt64Field("aerospike_node", "batch_error"))
|
2015-10-21 19:05:14 +00:00
|
|
|
}
|
|
|
|
|
2016-07-15 05:12:32 +00:00
|
|
|
func TestAerospikeStatisticsPartialErr(t *testing.T) {
|
|
|
|
if testing.Short() {
|
2016-08-24 08:03:17 +00:00
|
|
|
t.Skip("Skipping aerospike integration tests.")
|
2015-10-21 19:05:14 +00:00
|
|
|
}
|
|
|
|
|
2016-07-15 05:12:32 +00:00
|
|
|
a := &Aerospike{
|
|
|
|
Servers: []string{
|
|
|
|
testutil.GetLocalHost() + ":3000",
|
|
|
|
testutil.GetLocalHost() + ":9999",
|
|
|
|
},
|
2015-10-21 19:05:14 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 23:11:16 +00:00
|
|
|
var acc testutil.Accumulator
|
|
|
|
|
2017-04-24 18:13:26 +00:00
|
|
|
require.Error(t, acc.GatherError(a.Gather))
|
2016-01-06 23:11:16 +00:00
|
|
|
|
2016-07-15 05:12:32 +00:00
|
|
|
assert.True(t, acc.HasMeasurement("aerospike_node"))
|
|
|
|
assert.True(t, acc.HasMeasurement("aerospike_namespace"))
|
2017-05-16 22:25:30 +00:00
|
|
|
assert.True(t, acc.HasInt64Field("aerospike_node", "batch_error"))
|
2016-01-06 23:11:16 +00:00
|
|
|
}
|
2016-09-05 13:29:14 +00:00
|
|
|
|
|
|
|
func TestAerospikeParseValue(t *testing.T) {
|
|
|
|
// uint64 with value bigger than int64 max
|
2018-10-12 21:37:30 +00:00
|
|
|
val := parseValue("18446744041841121751")
|
|
|
|
require.Equal(t, uint64(18446744041841121751), val)
|
2016-09-05 13:29:14 +00:00
|
|
|
|
|
|
|
// int values
|
2018-10-12 21:37:30 +00:00
|
|
|
val = parseValue("42")
|
|
|
|
require.Equal(t, val, int64(42), "must be parsed as int")
|
2016-09-05 13:29:14 +00:00
|
|
|
|
|
|
|
// string values
|
2018-10-12 21:37:30 +00:00
|
|
|
val = parseValue("BB977942A2CA502")
|
|
|
|
require.Equal(t, val, `BB977942A2CA502`, "must be left as string")
|
2016-09-05 13:29:14 +00:00
|
|
|
}
|