2015-11-13 17:39:36 +00:00
|
|
|
package influxdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
|
|
|
|
2016-01-23 00:45:31 +00:00
|
|
|
"github.com/influxdb/telegraf/testutil"
|
2015-11-13 17:39:36 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUDPInflux(t *testing.T) {
|
|
|
|
i := InfluxDB{
|
|
|
|
URLs: []string{"udp://localhost:8089"},
|
|
|
|
}
|
|
|
|
|
|
|
|
err := i.Connect()
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = i.Write(testutil.MockBatchPoints().Points())
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHTTPInflux(t *testing.T) {
|
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
fmt.Fprintln(w, `{"results":[{}]}`)
|
|
|
|
}))
|
|
|
|
defer ts.Close()
|
|
|
|
|
|
|
|
i := InfluxDB{
|
|
|
|
URLs: []string{ts.URL},
|
|
|
|
}
|
|
|
|
|
|
|
|
err := i.Connect()
|
|
|
|
require.NoError(t, err)
|
|
|
|
err = i.Write(testutil.MockBatchPoints().Points())
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|