From bf96de29f6d6b496d98d76d34ee9ab66533fdfc2 Mon Sep 17 00:00:00 2001 From: vlastahajek Date: Thu, 28 Jul 2022 17:07:40 +0200 Subject: [PATCH] feat: Adding makefile for simplifying testing --- .circleci/config.yml | 12 ++++-------- CHANGELOG.md | 19 +++++++++++-------- Makefile | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 Makefile diff --git a/.circleci/config.yml b/.circleci/config.yml index e50e7134..af800916 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,16 +40,12 @@ jobs: - run: sudo tar -C /usr/local -xzf /tmp/go.tgz - run: go version - run: go get -v -t -d ./... - - run: go vet ./... - - run: go install honnef.co/go/tools/cmd/staticcheck@latest && staticcheck --checks='all' --tags e2e ./... - - run: go install golang.org/x/lint/golint@latest && golint ./... + - run: make lint - run: name: "Start InfluxDB service" - command: ./scripts/influxdb-restart.sh + command: make server - run: - command: | - go install gotest.tools/gotestsum@latest && gotestsum --junitfile /tmp/test-results/unit-tests.xml -- -race -coverprofile=coverage.txt -covermode=atomic -coverpkg '.,./api/...,./internal/.../,./log/...' -tags e2e ./... - go tool cover -html=coverage.txt -o /tmp/artifacts/coverage.html + command: make coverage - run: name: Collecting coverage reports command: | @@ -67,4 +63,4 @@ jobs: path: /tmp/test-results destination: raw-test-output - store_test_results: - path: /tmp/test-results \ No newline at end of file + path: /tmp/test-results diff --git a/CHANGELOG.md b/CHANGELOG.md index 946e3734..fca77f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,15 @@ ## [unreleased] ### Bug fixes -- [#341](https://github.com/influxdata/influxdb-client-go/issues/341) Changing logging level of messages about discarding batch to Error. -- [#344](https://github.com/influxdata/influxdb-client-go/issues/344) `WriteAPI.Flush()` writes also batches from the retry queue. +- [#341](https://github.com/influxdata/influxdb-client-go/pull/341) Changing logging level of messages about discarding batch to Error. +- [#344](https://github.com/influxdata/influxdb-client-go/pull/344) `WriteAPI.Flush()` writes also batches from the retry queue. + +### Test +- [#345](https://github.com/influxdata/influxdb-client-go/pul/345) Added makefile for simplifing testing from command line. ## 2.9.1 [2022-06-24] ### Bug fixes -- [#332](https://github.com/influxdata/influxdb-client-go/issues/332) Retry strategy drops expired batches as soon as they expire. -- [#335](https://github.com/influxdata/influxdb-client-go/issues/335) Retry strategy keeps max retry delay for new batches. +- [#332](https://github.com/influxdata/influxdb-client-go/pull/332) Retry strategy drops expired batches as soon as they expire. +- [#335](https://github.com/influxdata/influxdb-client-go/pull/335) Retry strategy keeps max retry delay for new batches. ## 2.9.0 [2022-05-20] ### Features @@ -14,7 +17,7 @@ - [#328](https://github.com/influxdata/influxdb-client-go/pull/328) Added `Client.SetupWithToken` allowing to specify a custom token. ### Bug fixes -- [#324](https://github.com/influxdata/influxdb-client-go/issues/324) Non-empty error channel will not block writes +- [#324](https://github.com/influxdata/influxdb-client-go/pull/324) Non-empty error channel will not block writes ## 2.8.2 [2022-04-19] ### Bug fixes @@ -97,7 +100,7 @@ ### Bug fixes 1. [#252](https://github.com/influxdata/influxdb-client-go/pull/252) Fixed panic when getting not present standard Flux columns 1. [#253](https://github.com/influxdata/influxdb-client-go/pull/253) Conditional debug logging of buffers -1. [#254](https://github.com/influxdata/influxdb-client-go/pull/254) Fixed golint issues +1. [#254](https://github.com/influxdata/influxdb-client-go/pull/254) Fixed golint pull ## 2.2.3 [2021-04-01] ### Bug fixes @@ -193,8 +196,8 @@ 1. [#124](https://github.com/influxdata/influxdb-client-go/pull/124) Buckets API ### Bug fixes -1. [#108](https://github.com/influxdata/influxdb-client-go/issues/108) Fix default retry interval doc -1. [#110](https://github.com/influxdata/influxdb-client-go/issues/110) Allowing empty (nil) values in query result +1. [#108](https://github.com/influxdata/influxdb-client-go/pull/108) Fix default retry interval doc +1. [#110](https://github.com/influxdata/influxdb-client-go/pull/110) Allowing empty (nil) values in query result ### Documentation - [#112](https://github.com/influxdata/influxdb-client-go/pull/112) Clarify how to use client with InfluxDB 1.8+ diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..849aef17 --- /dev/null +++ b/Makefile @@ -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 -coverpkg '.,./api/...,./internal/.../,./log/...' -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