forked from influxdata/influxdb-client-go
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from bonitoo-io/feat/v3/status
feat: implement status methods
- Loading branch information
Showing
17 changed files
with
710 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
artifacts_path := /tmp/artifacts | ||
|
||
help: | ||
@echo 'Targets:' | ||
@echo ' all - runs lint, server, coverage' | ||
@echo ' lint - runs code style checks' | ||
@echo ' shorttest - runs unit and integration tests' | ||
@echo ' test - runs all tests, including e2e tests - requires running influxdb 2 server' | ||
@echo ' coverage - runs all tests, including e2e tests, with coverage report - requires running influxdb 2 server' | ||
@echo ' server - prepares InfluxDB in docker environment' | ||
|
||
lint: | ||
go vet ./... | ||
go install honnef.co/go/tools/cmd/staticcheck@latest && staticcheck --checks='all' --tags e2e ./... | ||
go install golang.org/x/lint/golint@latest && golint ./... | ||
|
||
shorttest: | ||
go test -race -v -count=1 ./... | ||
|
||
test: | ||
go test -race -v -count=1 --tags e2e ./... | ||
|
||
coverage: | ||
go install gotest.tools/gotestsum@latest && gotestsum --junitfile /tmp/test-results/unit-tests.xml -- -race -coverprofile=coverage.txt -covermode=atomic -tags e2e ./... | ||
if test ! -e $(artifacts_path); then mkdir $(artifacts_path); fi | ||
go tool cover -html=coverage.txt -o $(artifacts_path)/coverage.html | ||
|
||
server: | ||
./scripts/influxdb-restart.sh | ||
|
||
all: lint server coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// +build e2e | ||
|
||
// Copyright 2020-2021 InfluxData, Inc. All rights reserved. | ||
// Use of this source code is governed by MIT | ||
// license that can be found in the LICENSE file. | ||
|
||
package influxclient_test | ||
|
||
import ( | ||
"github.com/influxdata/influxdb-client-go/influxclient" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestReady(t *testing.T) { | ||
client, ctx := newClient(t) | ||
|
||
up, err := client.Ready(ctx) | ||
require.NoError(t, err) | ||
assert.NotZero(t, up) | ||
} | ||
|
||
func TestHealth(t *testing.T) { | ||
client, ctx := newClient(t) | ||
|
||
health, err := client.Health(ctx) | ||
require.NoError(t, err) | ||
assert.NotNil(t, health) | ||
assert.NotEmpty(t, health.Name) | ||
assert.Equal(t, "influxdb", health.Name) | ||
assert.NotEmpty(t, health.Status) | ||
assert.Equal(t, "pass", string(health.Status)) | ||
assert.NotEmpty(t, health.Commit) | ||
assert.NotEmpty(t, health.Version) | ||
} | ||
|
||
func TestPing(t *testing.T) { | ||
client, ctx := newClient(t) | ||
|
||
err := client.Ping(ctx) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestDeletePoints(t *testing.T) { | ||
client, ctx := newClient(t) | ||
|
||
err := client.DeletePoints(ctx, nil) | ||
assert.Error(t, err) | ||
|
||
err = client.DeletePoints(ctx, &influxclient.DeleteParams{}) | ||
assert.Error(t, err) | ||
|
||
err = client.DeletePoints(ctx, &influxclient.DeleteParams{ | ||
Org: orgName, | ||
}) | ||
assert.Error(t, err) | ||
|
||
err = client.DeletePoints(ctx, &influxclient.DeleteParams{ | ||
Bucket: bucketName, | ||
}) | ||
assert.Error(t, err) | ||
|
||
err = client.DeletePoints(ctx, &influxclient.DeleteParams{ | ||
Org: orgName, | ||
Bucket: bucketName, | ||
}) | ||
assert.Error(t, err) | ||
|
||
err = client.DeletePoints(ctx, &influxclient.DeleteParams{ | ||
Org: orgName, | ||
Bucket: bucketName, | ||
Start: time.Now(), | ||
}) | ||
assert.Error(t, err) | ||
|
||
err = client.DeletePoints(ctx, &influxclient.DeleteParams{ | ||
Org: orgName, | ||
Bucket: bucketName, | ||
Stop: time.Now(), | ||
}) | ||
assert.Error(t, err) | ||
|
||
err = client.DeletePoints(ctx, &influxclient.DeleteParams{ | ||
Org: orgName, | ||
Bucket: bucketName, | ||
// without predicate | ||
Start: time.Now().AddDate(0, 0, -1), | ||
Stop: time.Now(), | ||
}) | ||
assert.NoError(t, err) | ||
|
||
org, err := client.OrganizationAPI().FindOne(ctx, &influxclient.Filter{Name: orgName}) | ||
require.NoError(t, err) | ||
require.NotNil(t, org) | ||
bucket, err := client.BucketsAPI().FindOne(ctx, &influxclient.Filter{Name: bucketName}) | ||
require.NoError(t, err) | ||
require.NotNil(t, bucket) | ||
|
||
err = client.DeletePoints(ctx, &influxclient.DeleteParams{ | ||
OrgID: *org.Id, | ||
BucketID: *bucket.Id, | ||
Predicate: `_measurement="sensorData"`, | ||
Start: time.Now().AddDate(0, 0, -1), | ||
Stop: time.Now(), | ||
}) | ||
assert.NoError(t, err) | ||
} |
Oops, something went wrong.