[TASK] influxdb ping on startup
This commit is contained in:
parent
1464092a69
commit
0c4e17406d
@ -18,7 +18,7 @@ const (
|
||||
CounterMeasurementFirmware = "firmware" // Measurement for firmware statistics
|
||||
CounterMeasurementModel = "model" // Measurement for model statistics
|
||||
CounterMeasurementAutoupdater = "autoupdater" // Measurement for autoupdater
|
||||
batchMaxSize = 500
|
||||
batchMaxSize = 1000
|
||||
batchTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
@ -69,10 +69,15 @@ func Connect(configuration map[string]interface{}) (database.Connection, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, _, err = c.Ping(time.Millisecond * 50)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
db := &Connection{
|
||||
config: config,
|
||||
client: c,
|
||||
points: make(chan *client.Point, 1000),
|
||||
points: make(chan *client.Point, batchMaxSize),
|
||||
}
|
||||
|
||||
db.wg.Add(1)
|
||||
|
@ -1,6 +1,8 @@
|
||||
package influxdb
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -27,6 +29,21 @@ func TestConnect(t *testing.T) {
|
||||
"username": "",
|
||||
"password": "",
|
||||
})
|
||||
assert.Nil(conn)
|
||||
assert.Error(err)
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
conn, err = Connect(map[string]interface{}{
|
||||
"address": srv.URL,
|
||||
"database": "",
|
||||
"username": "",
|
||||
"password": "",
|
||||
})
|
||||
|
||||
assert.NotNil(conn)
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user