2015-09-15 18:16:53 +00:00
|
|
|
package amqp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-01-23 00:45:31 +00:00
|
|
|
"github.com/influxdb/telegraf/testutil"
|
2015-09-15 18:16:53 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConnectAndWrite(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("Skipping integration test in short mode")
|
|
|
|
}
|
|
|
|
|
|
|
|
var url = "amqp://" + testutil.GetLocalHost() + ":5672/"
|
|
|
|
q := &AMQP{
|
|
|
|
URL: url,
|
|
|
|
Exchange: "telegraf_test",
|
|
|
|
}
|
|
|
|
|
2015-09-16 00:25:56 +00:00
|
|
|
// Verify that we can connect to the AMQP broker
|
2015-09-15 18:16:53 +00:00
|
|
|
err := q.Connect()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2015-09-16 00:25:56 +00:00
|
|
|
// Verify that we can successfully write data to the amqp broker
|
2015-10-16 22:13:32 +00:00
|
|
|
err = q.Write(testutil.MockBatchPoints().Points())
|
2015-09-15 18:16:53 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
}
|