mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-27 13:48:49 +08:00

* Add InfluxDB reader Summary: - Add basic reader features - Update Makefile Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Raise test coverage Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update README.md and docker composition Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Fix docker-compose.yml Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Remove exposed ports Ports are already exposed by mapping, so no need to explicity expose them. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package influxdb_test
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
influxdb "github.com/influxdata/influxdb/client/v2"
|
|
dockertest "gopkg.in/ory-am/dockertest.v3"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
pool, err := dockertest.NewPool("")
|
|
if err != nil {
|
|
testLog.Error(fmt.Sprintf("Could not connect to docker: %s", err))
|
|
}
|
|
|
|
cfg := []string{
|
|
"INFLUXDB_USER=test",
|
|
"INFLUXDB_USER_PASSWORD=test",
|
|
"INFLUXDB_DB=test",
|
|
}
|
|
container, err := pool.Run("influxdb", "1.5.2-alpine", cfg)
|
|
if err != nil {
|
|
testLog.Error(fmt.Sprintf("Could not start container: %s", err))
|
|
}
|
|
|
|
port = container.GetPort("8086/tcp")
|
|
clientCfg.Addr = fmt.Sprintf("http://localhost:%s", port)
|
|
|
|
if err := pool.Retry(func() error {
|
|
client, err = influxdb.NewHTTPClient(clientCfg)
|
|
_, _, err = client.Ping(5 * time.Millisecond)
|
|
return err
|
|
}); err != nil {
|
|
testLog.Error(fmt.Sprintf("Could not connect to docker: %s", err))
|
|
}
|
|
|
|
code := m.Run()
|
|
|
|
if err := pool.Purge(container); err != nil {
|
|
testLog.Error(fmt.Sprintf("Could not purge container: %s", err))
|
|
}
|
|
|
|
os.Exit(code)
|
|
}
|