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"))
|
|
|
|
assert.True(t, acc.HasMeasurement("aerospike_namespace"))
|
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
|
|
|
|
val, err := parseValue("18446744041841121751")
|
|
|
|
assert.Nil(t, val)
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
// int values
|
|
|
|
val, err = parseValue("42")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, val, int64(42), "must be parsed as int")
|
|
|
|
|
|
|
|
// string values
|
|
|
|
val, err = parseValue("BB977942A2CA502")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, val, `BB977942A2CA502`, "must be left as string")
|
|
|
|
}
|