2015-11-13 20:37:24 +00:00
|
|
|
package mqtt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-01-23 00:45:31 +00:00
|
|
|
"github.com/influxdb/telegraf/testutil"
|
2015-11-13 20:37:24 +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 = testutil.GetLocalHost() + ":1883"
|
|
|
|
m := &MQTT{
|
|
|
|
Servers: []string{url},
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that we can connect to the MQTT broker
|
|
|
|
err := m.Connect()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Verify that we can successfully write data to the mqtt broker
|
|
|
|
err = m.Write(testutil.MockBatchPoints().Points())
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|