2015-08-26 17:02:10 +00:00
|
|
|
package kafka
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-02-10 22:50:07 +00:00
|
|
|
"github.com/influxdata/telegraf/plugins/serializers"
|
2016-01-20 18:57:35 +00:00
|
|
|
"github.com/influxdata/telegraf/testutil"
|
2015-08-26 17:02:10 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConnectAndWrite(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("Skipping integration test in short mode")
|
|
|
|
}
|
|
|
|
|
|
|
|
brokers := []string{testutil.GetLocalHost() + ":9092"}
|
2016-02-10 22:50:07 +00:00
|
|
|
s, _ := serializers.NewInfluxSerializer()
|
2015-08-26 17:02:10 +00:00
|
|
|
k := &Kafka{
|
2016-02-10 22:50:07 +00:00
|
|
|
Brokers: brokers,
|
|
|
|
Topic: "Test",
|
|
|
|
serializer: s,
|
2015-08-26 17:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that we can connect to the Kafka broker
|
|
|
|
err := k.Connect()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Verify that we can successfully write data to the kafka broker
|
2016-01-27 23:15:14 +00:00
|
|
|
err = k.Write(testutil.MockMetrics())
|
2015-08-26 17:02:10 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
}
|