From 4c750ae524cdc0648e83964134f1985d5439a171 Mon Sep 17 00:00:00 2001 From: kpango Date: Thu, 30 Apr 2020 14:58:21 +0900 Subject: [PATCH] add goleak Signed-off-by: kpango --- Makefile | 7 + Makefile.d/functions.mk | 10 + assets/test/templates/common/function.tmpl | 1 + assets/test/templates/common/header.tmpl | 1 + assets/test/templates/option/function.tmpl | 1 + cmd/agent/ngt/main_test.go | 7 +- cmd/discoverer/k8s/main_test.go | 7 +- cmd/gateway/vald/main_test.go | 7 +- cmd/manager/backup/cassandra/main_test.go | 7 +- cmd/manager/backup/mysql/main_test.go | 7 +- cmd/manager/compressor/main_test.go | 7 +- cmd/manager/index/main_test.go | 7 +- cmd/manager/replication/agent/main_test.go | 7 +- .../replication/controller/main_test.go | 7 +- cmd/meta/cassandra/main_test.go | 7 +- cmd/meta/redis/main_test.go | 7 +- go.mod | 4 +- go.sum | 8 +- hack/benchmark/core/benchmark/option_test.go | 8 +- .../core/benchmark/strategy/strategy.go | 2 +- .../strategy/strategy_option_test.go | 10 + .../core/benchmark/strategy/strategy_test.go | 9 + .../core/benchmark/strategy/util_test.go | 5 + .../benchmark/internal/assets/dataset_test.go | 17 + hack/benchmark/internal/assets/loader_test.go | 12 +- .../internal/client/ngtd/grpc/client_test.go | 33 ++ .../internal/client/ngtd/grpc/option_test.go | 4 + .../internal/client/ngtd/rest/client_test.go | 31 + .../internal/client/ngtd/rest/option_test.go | 7 +- hack/benchmark/internal/core/gongt/gongt.go | 2 +- .../internal/core/gongt/gongt_test.go | 15 + .../internal/core/gongt/option_test.go | 9 +- hack/benchmark/internal/core/ngt/ngt_test.go | 5 + .../internal/core/ngt/option_test.go | 9 +- hack/benchmark/internal/e2e/option_test.go | 6 + .../e2e/strategy/create_index_option_test.go | 4 + .../e2e/strategy/insert_option_test.go | 7 +- .../e2e/strategy/remove_option_test.go | 7 +- .../e2e/strategy/search_option_test.go | 4 + .../e2e/strategy/stream_insert_test.go | 5 + .../e2e/strategy/stream_remove_test.go | 5 + .../e2e/strategy/stream_search_option_test.go | 3 + .../e2e/strategy/stream_search_test.go | 5 + .../internal/starter/agent/ngt/ngt_test.go | 4 + .../internal/starter/agent/ngt/option_test.go | 6 + .../starter/external/ngtd/ngtd_test.go | 8 +- .../starter/external/ngtd/option_test.go | 10 +- hack/license/gen/main_test.go | 5 + hack/swagger/main_test.go | 3 + hack/tools/config/agent/ngt/main_test.go | 7 +- hack/tools/config/discoverer/k8s/main_test.go | 7 +- hack/tools/config/gateway/vald/main_test.go | 7 +- .../config/manager/backup/mysql/main_test.go | 7 +- hack/tools/config/meta/redis/main_test.go | 7 +- hack/tools/metrics/main_test.go | 7 +- internal/backoff/backoff_test.go | 5 + internal/backoff/option_test.go | 3 + internal/cache/cache_test.go | 3 + internal/cache/gache/option_test.go | 6 + internal/cache/option_test.go | 6 + internal/client/agent/ngt/grpc/client_test.go | 27 +- internal/client/agent/ngt/grpc/option_test.go | 4 + internal/client/agent/ngt/rest/client_test.go | 23 + internal/client/agent/ngt/rest/option_test.go | 7 +- internal/client/compressor/client_test.go | 12 + internal/client/compressor/option_test.go | 4 + internal/client/discoverer/discover_test.go | 10 + internal/client/discoverer/option_test.go | 17 + .../client/gateway/vald/grpc/client_test.go | 26 +- .../client/gateway/vald/grpc/option_test.go | 4 + .../client/gateway/vald/rest/client_test.go | 22 + .../client/gateway/vald/rest/option_test.go | 7 +- internal/compress/gob_test.go | 5 + internal/compress/gzip_option_test.go | 8 +- internal/compress/gzip_test.go | 5 + internal/compress/lz4_option_test.go | 8 +- internal/compress/lz4_test.go | 5 + internal/compress/zstd_option_test.go | 8 +- internal/compress/zstd_test.go | 5 + internal/config/config_test.go | 10 +- .../core/converter/tensorflow/option_test.go | 17 +- .../converter/tensorflow/tensorflow_test.go | 8 + internal/db/kvs/redis/option_test.go | 29 + internal/db/kvs/redis/redis_test.go | 3 + internal/db/nosql/cassandra/option_test.go | 341 +++++++++++ internal/db/rdb/mysql/mysql_test.go | 16 + internal/db/rdb/mysql/option_test.go | 17 + internal/errgroup/group_test.go | 11 + .../internal => internal}/errors/benchmark.go | 6 +- internal/errors/cassandra_test.go | 10 +- .../internal => internal}/errors/gongt.go | 4 +- internal/errors/mysql_test.go | 10 +- internal/errors/redis_test.go | 6 +- internal/k8s/metrics/node/node_test.go | 9 + internal/k8s/metrics/node/option_test.go | 6 + internal/k8s/metrics/pod/option_test.go | 6 + internal/k8s/metrics/pod/pod_test.go | 11 +- internal/k8s/node/node_test.go | 9 + internal/k8s/node/option_test.go | 6 + internal/k8s/option_test.go | 9 + internal/k8s/pod/option_test.go | 6 + internal/k8s/pod/pod_test.go | 9 + internal/k8s/reconciler_test.go | 4 + internal/log/format/format_test.go | 2 + internal/log/glg/glg_test.go | 14 + internal/log/level/level_test.go | 2 + internal/log/log_test.go | 3 + internal/log/logger/type_test.go | 2 + internal/log/mock/logger_test.go | 16 +- internal/log/mock/retry_test.go | 8 +- internal/log/retry/retry_test.go | 4 + internal/net/grpc/client_test.go | 14 + internal/net/grpc/option_test.go | 27 + internal/net/grpc/pool/option_test.go | 12 + internal/net/grpc/pool/pool_test.go | 19 + internal/net/grpc/status/status_test.go | 28 +- internal/net/grpc/stream_test.go | 4 + internal/net/http/json/json_test.go | 6 + internal/net/http/middleware/timeout_test.go | 3 + internal/net/http/routing/router_test.go | 3 + internal/net/http/transport/roundtrip_test.go | 4 + internal/net/net_test.go | 11 +- internal/net/tcp/control_darwin_test.go | 3 + internal/net/tcp/control_other_test.go | 4 +- internal/net/tcp/control_unix_test.go | 3 + internal/net/tcp/control_windows_test.go | 4 +- internal/net/tcp/dialer_test.go | 8 + .../collector/collector_option_test.go | 9 + .../observability/collector/collector_test.go | 9 +- .../exporter/jaeger/jaeger_option_test.go | 13 +- .../exporter/jaeger/jaeger_test.go | 8 +- .../prometheus/prometheus_option_test.go | 9 +- .../exporter/prometheus/prometheus_test.go | 10 +- .../metrics/agent/ngt/ngt_test.go | 8 +- .../manager/compressor/compressor_test.go | 8 +- .../observability/metrics/mem/mem_test.go | 8 +- .../observability/metrics/metrics_test.go | 6 + .../metrics/runtime/cgo/cgo_test.go | 8 +- .../runtime/goroutine/goroutine_test.go | 8 +- .../metrics/version/version_test.go | 9 +- .../observability_option_test.go | 7 + internal/observability/observability_test.go | 7 + .../observability/trace/trace_option_test.go | 7 +- internal/params/option_test.go | 12 +- internal/params/params_test.go | 6 + internal/runner/option_test.go | 6 + internal/runner/runner_test.go | 4 + internal/servers/server/option_test.go | 3 + internal/servers/server/server_test.go | 7 + internal/servers/servers_test.go | 4 + internal/servers/starter/starter_test.go | 5 + internal/singleflight/singleflight.go | 8 +- internal/singleflight/singleflight_test.go | 8 +- internal/tls/option_test.go | 6 + internal/tls/tls_test.go | 5 + internal/worker/queue_option_test.go | 5 + internal/worker/queue_test.go | 9 + internal/worker/worker_option_test.go | 6 + internal/worker/worker_test.go | 13 + pkg/agent/ngt/config/config_test.go | 4 +- pkg/agent/ngt/handler/grpc/handler_test.go | 24 + pkg/agent/ngt/handler/grpc/option_test.go | 4 + pkg/agent/ngt/handler/rest/handler_test.go | 19 +- pkg/agent/ngt/handler/rest/option_test.go | 3 + pkg/agent/ngt/router/option_test.go | 5 + pkg/agent/ngt/service/ngt_test.go | 28 + pkg/agent/ngt/usecase/agentd_test.go | 10 +- pkg/discoverer/k8s/config/config_test.go | 4 +- pkg/discoverer/k8s/handler/grpc/handler.go | 4 +- .../k8s/handler/grpc/handler_test.go | 9 +- .../k8s/handler/grpc/option_test.go | 3 + .../k8s/handler/rest/handler_test.go | 8 +- .../k8s/handler/rest/option_test.go | 3 + pkg/discoverer/k8s/router/option_test.go | 5 + pkg/discoverer/k8s/service/discover_test.go | 6 + pkg/discoverer/k8s/service/option_test.go | 6 + pkg/discoverer/k8s/usecase/discovered_test.go | 10 +- pkg/gateway/vald/config/config_test.go | 4 +- pkg/gateway/vald/handler/grpc/handler_test.go | 23 + pkg/gateway/vald/handler/grpc/option_test.go | 10 + pkg/gateway/vald/handler/rest/handler_test.go | 16 +- pkg/gateway/vald/handler/rest/option_test.go | 3 + pkg/gateway/vald/router/option_test.go | 4 + .../vald/service/backup_option_test.go | 4 + pkg/gateway/vald/service/backup_test.go | 10 + .../vald/service/filter_option_test.go | 3 + pkg/gateway/vald/service/filter_test.go | 5 + .../vald/service/gateway_option_test.go | 4 + pkg/gateway/vald/service/gateway_test.go | 8 + pkg/gateway/vald/service/meta_option_test.go | 9 + pkg/gateway/vald/service/meta_test.go | 15 + pkg/gateway/vald/usecase/vald_test.go | 8 + .../backup/cassandra/config/config_test.go | 4 +- .../cassandra/handler/grpc/handler_test.go | 13 + .../cassandra/handler/grpc/option_test.go | 3 + .../cassandra/handler/rest/handler_test.go | 13 +- .../cassandra/handler/rest/option_test.go | 3 + .../backup/cassandra/router/option_test.go | 5 + .../cassandra/service/cassandra_test.go | 16 +- .../backup/cassandra/usecase/backupd_test.go | 10 +- .../backup/mysql/config/config_test.go | 4 +- .../backup/mysql/handler/grpc/handler_test.go | 13 + .../backup/mysql/handler/grpc/option_test.go | 3 + .../backup/mysql/handler/rest/handler_test.go | 13 +- .../backup/mysql/handler/rest/option_test.go | 3 + .../backup/mysql/router/option_test.go | 5 + .../backup/mysql/service/mysql_test.go | 15 +- .../backup/mysql/usecase/backupd_test.go | 10 +- pkg/manager/compressor/config/config_test.go | 4 +- .../compressor/handler/grpc/handler_test.go | 13 +- .../compressor/handler/grpc/option_test.go | 5 + .../compressor/handler/rest/handler_test.go | 13 +- .../compressor/handler/rest/option_test.go | 3 + pkg/manager/compressor/router/option_test.go | 5 + .../compressor/service/backup_option_test.go | 4 + pkg/manager/compressor/service/backup_test.go | 12 + .../service/compress_option_test.go | 6 + .../compressor/service/compress_test.go | 14 + .../service/registerer_option_test.go | 7 + .../compressor/service/registerer_test.go | 14 + .../compressor/usecase/compressord_test.go | 8 + pkg/manager/index/config/config_test.go | 4 +- .../index/handler/grpc/handler_test.go | 6 +- pkg/manager/index/handler/grpc/option_test.go | 3 + .../index/handler/rest/handler_test.go | 7 +- pkg/manager/index/handler/rest/option_test.go | 3 + pkg/manager/index/router/option_test.go | 4 + pkg/manager/index/service/indexer_test.go | 9 + pkg/manager/index/service/option_test.go | 9 + pkg/manager/index/usecase/indexer_test.go | 10 +- .../replication/agent/config/config_test.go | 4 +- .../agent/handler/grpc/handler_test.go | 8 +- .../agent/handler/rest/handler_test.go | 13 +- .../agent/handler/rest/option_test.go | 3 + .../replication/agent/router/option_test.go | 5 + .../replication/agent/usecase/backupd_test.go | 10 +- .../controller/config/config_test.go | 4 +- .../controller/handler/grpc/handler_test.go | 6 +- .../controller/handler/grpc/option_test.go | 3 + .../controller/handler/rest/handler_test.go | 6 +- .../controller/handler/rest/option_test.go | 3 + .../controller/router/option_test.go | 5 + .../controller/service/discover_test.go | 6 + .../controller/service/option_test.go | 6 + .../controller/usecase/discovered_test.go | 10 +- pkg/meta/cassandra/config/config_test.go | 4 +- .../cassandra/handler/grpc/handler_test.go | 13 + .../cassandra/handler/grpc/option_test.go | 3 + .../cassandra/handler/rest/handler_test.go | 16 +- .../cassandra/handler/rest/option_test.go | 3 + pkg/meta/cassandra/router/option_test.go | 5 + pkg/meta/cassandra/service/cassandra_test.go | 17 + pkg/meta/cassandra/usecase/meta_test.go | 10 +- pkg/meta/redis/config/config_test.go | 4 +- pkg/meta/redis/handler/grpc/handler_test.go | 13 + pkg/meta/redis/handler/grpc/option_test.go | 3 + pkg/meta/redis/handler/rest/handler_test.go | 16 +- pkg/meta/redis/handler/rest/option_test.go | 3 + pkg/meta/redis/router/option_test.go | 5 + pkg/meta/redis/service/redis_test.go | 20 + pkg/meta/redis/usecase/meta_test.go | 10 +- pkg/tools/cli/loadtest/config/config_test.go | 101 ++++ pkg/tools/cli/loadtest/usecase/load_test.go | 549 ++++++++++++++++++ 263 files changed, 2976 insertions(+), 137 deletions(-) rename {hack/benchmark/internal => internal}/errors/benchmark.go (86%) rename {hack/benchmark/internal => internal}/errors/gongt.go (86%) create mode 100644 pkg/tools/cli/loadtest/config/config_test.go create mode 100644 pkg/tools/cli/loadtest/usecase/load_test.go diff --git a/Makefile b/Makefile index 2c1ecc9653a..224669a86a3 100644 --- a/Makefile +++ b/Makefile @@ -273,6 +273,13 @@ tensorflow/install: /usr/local/lib/libtensorflow.so gentest: $(call gen-test) + +.PHONY: fixtest +## fixtest +fixtest: + $(call fix-test) + + .PHONY: test ## run tests test: diff --git a/Makefile.d/functions.mk b/Makefile.d/functions.mk index f1c373be5bb..05141e7addd 100644 --- a/Makefile.d/functions.mk +++ b/Makefile.d/functions.mk @@ -95,6 +95,7 @@ define gen-test find . -type d | \ grep "./cmd\|./hack\|./internal\|./pkg" | \ grep -v "./cmd/cli\| \ + ./internal/core/ngt\| \ ./hack/benchmark/internal/client/ngtd\| \ ./hack/benchmark/internal/starter/agent\| \ ./hack/benchmark/internal/starter/external\| \ @@ -114,3 +115,12 @@ define gen-test done; \ done endef + +define fix-test + find $(ROOTDIR)/internal/k8s/* -name '*_test.go' | xargs sed -i -E "s%k8s.io/apimachinery/pkg/api/errors%github.com/vdaas/vald/internal/errors%g" + find $(ROOTDIR)/* -name '*_test.go' | xargs sed -i -E "s%cockroachdb/errors%vdaas/vald/internal/errors%g" + find $(ROOTDIR)/* -name '*_test.go' | xargs sed -i -E "s%pkg/errors%vdaas/vald/internal/errors%g" + find $(ROOTDIR)/internal/errors -name '*_test.go' | xargs sed -i -E "s%\"github.com/vdaas/vald/internal/errors\"%%g" + find $(ROOTDIR)/internal/errors -name '*_test.go' | xargs sed -i -E "s/errors\.//g" + go mod tidy +endef diff --git a/assets/test/templates/common/function.tmpl b/assets/test/templates/common/function.tmpl index 5f78b37d856..2bfe85d647f 100644 --- a/assets/test/templates/common/function.tmpl +++ b/assets/test/templates/common/function.tmpl @@ -109,6 +109,7 @@ func {{ .TestName }}(t *testing.T) { for {{- if (or .Subtests (not .IsNaked)) }} _, test := {{- end }} range tests { {{- if .Subtests }} t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc({{- if .TestParameters }} test.args {{- end }}) } diff --git a/assets/test/templates/common/header.tmpl b/assets/test/templates/common/header.tmpl index 245569df7e7..a4bb3209b2f 100644 --- a/assets/test/templates/common/header.tmpl +++ b/assets/test/templates/common/header.tmpl @@ -6,5 +6,6 @@ package {{.Package}} import ( {{range .Imports}}{{.Name}} {{.Path}} {{end}} + "go.uber.org/goleak" ) {{end}} diff --git a/assets/test/templates/option/function.tmpl b/assets/test/templates/option/function.tmpl index 67a60d9647f..c424690d60a 100644 --- a/assets/test/templates/option/function.tmpl +++ b/assets/test/templates/option/function.tmpl @@ -117,6 +117,7 @@ func {{ .TestName }}(t *testing.T) { for {{- if (or .Subtests (not .IsNaked)) }} _, test := {{- end }} range tests { {{- if .Subtests }} t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc({{- if .TestParameters }} test.args {{- end }}) } diff --git a/cmd/agent/ngt/main_test.go b/cmd/agent/ngt/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/agent/ngt/main_test.go +++ b/cmd/agent/ngt/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/discoverer/k8s/main_test.go b/cmd/discoverer/k8s/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/discoverer/k8s/main_test.go +++ b/cmd/discoverer/k8s/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/gateway/vald/main_test.go b/cmd/gateway/vald/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/gateway/vald/main_test.go +++ b/cmd/gateway/vald/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/manager/backup/cassandra/main_test.go b/cmd/manager/backup/cassandra/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/manager/backup/cassandra/main_test.go +++ b/cmd/manager/backup/cassandra/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/manager/backup/mysql/main_test.go b/cmd/manager/backup/mysql/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/manager/backup/mysql/main_test.go +++ b/cmd/manager/backup/mysql/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/manager/compressor/main_test.go b/cmd/manager/compressor/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/manager/compressor/main_test.go +++ b/cmd/manager/compressor/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/manager/index/main_test.go b/cmd/manager/index/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/manager/index/main_test.go +++ b/cmd/manager/index/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/manager/replication/agent/main_test.go b/cmd/manager/replication/agent/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/manager/replication/agent/main_test.go +++ b/cmd/manager/replication/agent/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/manager/replication/controller/main_test.go b/cmd/manager/replication/controller/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/manager/replication/controller/main_test.go +++ b/cmd/manager/replication/controller/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/meta/cassandra/main_test.go b/cmd/meta/cassandra/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/meta/cassandra/main_test.go +++ b/cmd/meta/cassandra/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/cmd/meta/redis/main_test.go b/cmd/meta/redis/main_test.go index 59300f450b5..77175e62955 100644 --- a/cmd/meta/redis/main_test.go +++ b/cmd/meta/redis/main_test.go @@ -17,7 +17,11 @@ // Package main provides program main package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -56,6 +60,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/go.mod b/go.mod index bed5970b38e..ac3b3f0a474 100755 --- a/go.mod +++ b/go.mod @@ -53,11 +53,11 @@ require ( go.uber.org/automaxprocs v1.3.0 go.uber.org/goleak v1.0.0 golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 - golang.org/x/tools v0.0.0-20200429213335-127c98bd7927 // indirect + golang.org/x/tools v0.0.0-20200501005904-d351ea090f9b // indirect gonum.org/v1/hdf5 v0.0.0-20191105085658-fe04b73f3b53 gonum.org/v1/netlib v0.0.0-20200317120129-c5a04cffd98a // indirect gonum.org/v1/plot v0.7.0 - google.golang.org/genproto v0.0.0-20200429120912-1f37eeb960b2 + google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84 google.golang.org/grpc v1.29.1 gopkg.in/yaml.v2 v2.2.8 k8s.io/api v0.18.2 diff --git a/go.sum b/go.sum index 1df19b51409..526f81b8c91 100644 --- a/go.sum +++ b/go.sum @@ -596,8 +596,8 @@ golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200429213335-127c98bd7927 h1:qunaQbmBN1l/xZt8mr6MLr8G/IOFiMbXvxYbGVqKlyw= -golang.org/x/tools v0.0.0-20200429213335-127c98bd7927/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200501005904-d351ea090f9b h1:2hSR2MyOaYEy6yJYg/CpErymr/m7xJEJpm9kfT7ZMg4= +golang.org/x/tools v0.0.0-20200501005904-d351ea090f9b/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= @@ -628,8 +628,8 @@ google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200429120912-1f37eeb960b2 h1:fhZC+JJ5NhTWQS4q+Q1p9bkXUduHUDEVxsHM1HGtfDo= -google.golang.org/genproto v0.0.0-20200429120912-1f37eeb960b2/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84 h1:pSLkPbrjnPyLDYUO2VM9mDLqo2V6CFBY84lFSZAfoi4= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/hack/benchmark/core/benchmark/option_test.go b/hack/benchmark/core/benchmark/option_test.go index 9369047350d..815334eac2e 100644 --- a/hack/benchmark/core/benchmark/option_test.go +++ b/hack/benchmark/core/benchmark/option_test.go @@ -17,7 +17,11 @@ // Package benchmark provides benchmark frame package benchmark -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithName(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithStrategy(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/core/benchmark/strategy/strategy.go b/hack/benchmark/core/benchmark/strategy/strategy.go index 503f42164ce..cc1a513fec9 100644 --- a/hack/benchmark/core/benchmark/strategy/strategy.go +++ b/hack/benchmark/core/benchmark/strategy/strategy.go @@ -25,7 +25,7 @@ import ( "github.com/vdaas/vald/hack/benchmark/core/benchmark" "github.com/vdaas/vald/hack/benchmark/internal/assets" "github.com/vdaas/vald/hack/benchmark/internal/core" - "github.com/vdaas/vald/hack/benchmark/internal/errors" + "github.com/vdaas/vald/internal/errors" ) type strategy struct { diff --git a/hack/benchmark/core/benchmark/strategy/strategy_option_test.go b/hack/benchmark/core/benchmark/strategy/strategy_option_test.go index 3c2651fc067..868fb3d0088 100644 --- a/hack/benchmark/core/benchmark/strategy/strategy_option_test.go +++ b/hack/benchmark/core/benchmark/strategy/strategy_option_test.go @@ -23,6 +23,8 @@ import ( "github.com/vdaas/vald/hack/benchmark/internal/assets" "github.com/vdaas/vald/hack/benchmark/internal/core" + + "go.uber.org/goleak" ) func TestWithPreProp32(t *testing.T) { @@ -101,6 +103,7 @@ func TestWithPreProp32(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -213,6 +216,7 @@ func TestWithProp32(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -325,6 +329,7 @@ func TestWithPreProp64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -437,6 +442,7 @@ func TestWithProp64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -549,6 +555,7 @@ func TestWithPropName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -661,6 +668,7 @@ func TestWithCore32(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -773,6 +781,7 @@ func TestWithCore64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -875,6 +884,7 @@ func TestWithParallel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/hack/benchmark/core/benchmark/strategy/strategy_test.go b/hack/benchmark/core/benchmark/strategy/strategy_test.go index 86b77e551e0..ea986e96b28 100644 --- a/hack/benchmark/core/benchmark/strategy/strategy_test.go +++ b/hack/benchmark/core/benchmark/strategy/strategy_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/hack/benchmark/internal/assets" "github.com/vdaas/vald/hack/benchmark/internal/core" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func Test_newStrategy(t *testing.T) { @@ -79,6 +81,7 @@ func Test_newStrategy(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -198,6 +201,7 @@ func Test_strategy_Init(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -335,6 +339,7 @@ func Test_strategy_PreProp(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -467,6 +472,7 @@ func Test_strategy_Run(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -579,6 +585,7 @@ func Test_strategy_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -713,6 +720,7 @@ func Test_strategy_float32(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -847,6 +855,7 @@ func Test_strategy_float64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/core/benchmark/strategy/util_test.go b/hack/benchmark/core/benchmark/strategy/util_test.go index 9f16aaf54c2..fa868017d53 100644 --- a/hack/benchmark/core/benchmark/strategy/util_test.go +++ b/hack/benchmark/core/benchmark/strategy/util_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/hack/benchmark/internal/assets" "github.com/vdaas/vald/hack/benchmark/internal/core" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func Test_wrapErrors(t *testing.T) { @@ -78,6 +80,7 @@ func Test_wrapErrors(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -158,6 +161,7 @@ func Test_insertAndCreateIndex32(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -238,6 +242,7 @@ func Test_insertAndCreateIndex64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/assets/dataset_test.go b/hack/benchmark/internal/assets/dataset_test.go index 35e91f8ea08..6314f091190 100644 --- a/hack/benchmark/internal/assets/dataset_test.go +++ b/hack/benchmark/internal/assets/dataset_test.go @@ -21,6 +21,7 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func Test_identity(t *testing.T) { @@ -74,6 +75,7 @@ func Test_identity(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -144,6 +146,7 @@ func Test_datasetDir(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -214,6 +217,7 @@ func TestData(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -326,6 +330,7 @@ func Test_dataset_Train(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -455,6 +460,7 @@ func Test_dataset_TrainAsFloat64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -584,6 +590,7 @@ func Test_dataset_Query(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -713,6 +720,7 @@ func Test_dataset_QueryAsFloat64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -842,6 +850,7 @@ func Test_dataset_Distances(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -971,6 +980,7 @@ func Test_dataset_DistancesAsFloat64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1100,6 +1110,7 @@ func Test_dataset_Neighbors(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1229,6 +1240,7 @@ func Test_dataset_IDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1358,6 +1370,7 @@ func Test_dataset_Name(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1487,6 +1500,7 @@ func Test_dataset_Dimension(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1616,6 +1630,7 @@ func Test_dataset_DistanceType(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1745,6 +1760,7 @@ func Test_dataset_ObjectType(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1832,6 +1848,7 @@ func Test_float32To64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/assets/loader_test.go b/hack/benchmark/internal/assets/loader_test.go index 7daf1326629..3dc8533f4f7 100644 --- a/hack/benchmark/internal/assets/loader_test.go +++ b/hack/benchmark/internal/assets/loader_test.go @@ -19,8 +19,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" "gonum.org/v1/hdf5" + + "go.uber.org/goleak" ) func Test_loadFloat32(t *testing.T) { @@ -87,6 +89,7 @@ func Test_loadFloat32(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -170,6 +173,7 @@ func Test_loadInt(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_loadDataset(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func TestLoad(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -414,6 +420,7 @@ func TestCreateRandomIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -484,6 +491,7 @@ func TestCreateSequentialIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -578,6 +586,7 @@ func TestLoadDataWithRandomIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -672,6 +681,7 @@ func TestLoadDataWithSequentialIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/client/ngtd/grpc/client_test.go b/hack/benchmark/internal/client/ngtd/grpc/client_test.go index d5a001642c6..6d5c3c434f6 100644 --- a/hack/benchmark/internal/client/ngtd/grpc/client_test.go +++ b/hack/benchmark/internal/client/ngtd/grpc/client_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" proto "github.com/yahoojapan/ngtd/proto" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -86,6 +88,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -179,6 +182,7 @@ func Test_ngtdClient_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -277,6 +281,7 @@ func Test_ngtdClient_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -375,6 +380,7 @@ func Test_ngtdClient_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -472,6 +478,7 @@ func Test_ngtdClient_StreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -569,6 +576,7 @@ func Test_ngtdClient_StreamSearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -663,6 +671,7 @@ func Test_ngtdClient_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -760,6 +769,7 @@ func Test_ngtdClient_StreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -854,6 +864,7 @@ func Test_ngtdClient_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -948,6 +959,7 @@ func Test_ngtdClient_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1045,6 +1057,7 @@ func Test_ngtdClient_StreamUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1139,6 +1152,7 @@ func Test_ngtdClient_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1233,6 +1247,7 @@ func Test_ngtdClient_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1330,6 +1345,7 @@ func Test_ngtdClient_StreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1424,6 +1440,7 @@ func Test_ngtdClient_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1522,6 +1539,7 @@ func Test_ngtdClient_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1619,6 +1637,7 @@ func Test_ngtdClient_StreamGetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1713,6 +1732,7 @@ func Test_ngtdClient_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1804,6 +1824,7 @@ func Test_ngtdClient_SaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1898,6 +1919,7 @@ func Test_ngtdClient_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1993,6 +2015,7 @@ func Test_ngtdClient_IndexInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2068,6 +2091,7 @@ func Test_searchRequestToNgtdSearchRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2138,6 +2162,7 @@ func Test_searchIDRequestToNgtdSearchRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2208,6 +2233,7 @@ func Test_ngtdSearchResponseToSearchResponse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2278,6 +2304,7 @@ func Test_ngtdGetObjectResponseToObjectVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2348,6 +2375,7 @@ func Test_objectVectorToNGTDInsertRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2418,6 +2446,7 @@ func Test_objectIDToNGTDRemoveRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2488,6 +2517,7 @@ func Test_objectIDToNGTDGetObjectRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2558,6 +2588,7 @@ func Test_controlCreateIndexRequestToCreateIndexRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2632,6 +2663,7 @@ func Test_getSizeAndEpsilon(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2702,6 +2734,7 @@ func Test_tofloat64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/client/ngtd/grpc/option_test.go b/hack/benchmark/internal/client/ngtd/grpc/option_test.go index 7fb6d7732cb..f5ae4a334e9 100644 --- a/hack/benchmark/internal/client/ngtd/grpc/option_test.go +++ b/hack/benchmark/internal/client/ngtd/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestWithAddr(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithGRPCClientOption(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/client/ngtd/rest/client_test.go b/hack/benchmark/internal/client/ngtd/rest/client_test.go index e6753b4839e..3dacda5561a 100644 --- a/hack/benchmark/internal/client/ngtd/rest/client_test.go +++ b/hack/benchmark/internal/client/ngtd/rest/client_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/internal/client" "github.com/vdaas/vald/internal/errors" "github.com/yahoojapan/ngtd/model" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -172,6 +175,7 @@ func Test_ngtdClient_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -262,6 +266,7 @@ func Test_ngtdClient_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -352,6 +357,7 @@ func Test_ngtdClient_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -441,6 +447,7 @@ func Test_ngtdClient_StreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -530,6 +537,7 @@ func Test_ngtdClient_StreamSearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -616,6 +624,7 @@ func Test_ngtdClient_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -705,6 +714,7 @@ func Test_ngtdClient_StreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -791,6 +801,7 @@ func Test_ngtdClient_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -877,6 +888,7 @@ func Test_ngtdClient_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -966,6 +978,7 @@ func Test_ngtdClient_StreamUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1052,6 +1065,7 @@ func Test_ngtdClient_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1138,6 +1152,7 @@ func Test_ngtdClient_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1227,6 +1242,7 @@ func Test_ngtdClient_StreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1313,6 +1329,7 @@ func Test_ngtdClient_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1403,6 +1420,7 @@ func Test_ngtdClient_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1492,6 +1510,7 @@ func Test_ngtdClient_StreamGetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1578,6 +1597,7 @@ func Test_ngtdClient_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1661,6 +1681,7 @@ func Test_ngtdClient_SaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1747,6 +1768,7 @@ func Test_ngtdClient_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1834,6 +1856,7 @@ func Test_ngtdClient_IndexInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1907,6 +1930,7 @@ func Test_searchRequestToNgtdSearchRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1977,6 +2001,7 @@ func Test_searchIDRequestToNgtdSearchRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2047,6 +2072,7 @@ func Test_objectVectorToNgtdInsertRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2117,6 +2143,7 @@ func Test_objectVectorsToNgtdMultiInsertRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2187,6 +2214,7 @@ func Test_objectIDsToNgtdMultiRemoveRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2257,6 +2285,7 @@ func Test_ngtdSearchResponseToSearchResponse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2331,6 +2360,7 @@ func Test_getSizeAndEpsilon(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2401,6 +2431,7 @@ func Test_tofloat64(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/client/ngtd/rest/option_test.go b/hack/benchmark/internal/client/ngtd/rest/option_test.go index 5c13e402f84..012ab58e7a7 100644 --- a/hack/benchmark/internal/client/ngtd/rest/option_test.go +++ b/hack/benchmark/internal/client/ngtd/rest/option_test.go @@ -17,7 +17,11 @@ // Package rest provides rest client functions package rest -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithAddr(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/core/gongt/gongt.go b/hack/benchmark/internal/core/gongt/gongt.go index dee129c1ee2..4b201079b9d 100644 --- a/hack/benchmark/internal/core/gongt/gongt.go +++ b/hack/benchmark/internal/core/gongt/gongt.go @@ -22,7 +22,7 @@ import ( "os" icore "github.com/vdaas/vald/hack/benchmark/internal/core" - "github.com/vdaas/vald/hack/benchmark/internal/errors" + "github.com/vdaas/vald/internal/errors" "github.com/yahoojapan/gongt" ) diff --git a/hack/benchmark/internal/core/gongt/gongt_test.go b/hack/benchmark/internal/core/gongt/gongt_test.go index 18538bd7494..87609d3462a 100644 --- a/hack/benchmark/internal/core/gongt/gongt_test.go +++ b/hack/benchmark/internal/core/gongt/gongt_test.go @@ -24,6 +24,8 @@ import ( icore "github.com/vdaas/vald/hack/benchmark/internal/core" "github.com/vdaas/vald/internal/errors" "github.com/yahoojapan/gongt" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -81,6 +83,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -186,6 +189,7 @@ func Test_core_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -289,6 +293,7 @@ func Test_core_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -395,6 +400,7 @@ func Test_core_InsertCommit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -498,6 +504,7 @@ func Test_core_BulkInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -604,6 +611,7 @@ func Test_core_BulkInsertCommit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -703,6 +711,7 @@ func Test_core_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -802,6 +811,7 @@ func Test_core_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -901,6 +911,7 @@ func Test_core_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1000,6 +1011,7 @@ func Test_core_BulkRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1103,6 +1115,7 @@ func Test_core_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1188,6 +1201,7 @@ func Test_core_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1264,6 +1278,7 @@ func Test_toUint(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/core/gongt/option_test.go b/hack/benchmark/internal/core/gongt/option_test.go index eb1904361b0..375c3ef6ebf 100644 --- a/hack/benchmark/internal/core/gongt/option_test.go +++ b/hack/benchmark/internal/core/gongt/option_test.go @@ -17,7 +17,11 @@ // Package gongt provides gongt package gongt -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithIndexPath(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithIndexPath(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithObjectType(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -319,6 +325,7 @@ func TestWithDimension(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/core/ngt/ngt_test.go b/hack/benchmark/internal/core/ngt/ngt_test.go index 51cf01d234e..fd95e0beec4 100644 --- a/hack/benchmark/internal/core/ngt/ngt_test.go +++ b/hack/benchmark/internal/core/ngt/ngt_test.go @@ -24,6 +24,8 @@ import ( icore "github.com/vdaas/vald/hack/benchmark/internal/core" "github.com/vdaas/vald/internal/core/ngt" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -81,6 +83,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -186,6 +189,7 @@ func Test_core_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -271,6 +275,7 @@ func Test_core_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/hack/benchmark/internal/core/ngt/option_test.go b/hack/benchmark/internal/core/ngt/option_test.go index 4a8bbdca1dd..d1c982595c4 100644 --- a/hack/benchmark/internal/core/ngt/option_test.go +++ b/hack/benchmark/internal/core/ngt/option_test.go @@ -17,7 +17,11 @@ // Package ngt provides ngt package ngt -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithIndexPath(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithIndexPath(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithObjectType(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -319,6 +325,7 @@ func TestWithDimension(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/e2e/option_test.go b/hack/benchmark/internal/e2e/option_test.go index d748fc4ddbb..d473ca1aafe 100644 --- a/hack/benchmark/internal/e2e/option_test.go +++ b/hack/benchmark/internal/e2e/option_test.go @@ -23,6 +23,8 @@ import ( "github.com/vdaas/vald/hack/benchmark/internal/assets" "github.com/vdaas/vald/internal/client" + + "go.uber.org/goleak" ) func TestWithName(t *testing.T) { @@ -101,6 +103,7 @@ func TestWithName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -213,6 +216,7 @@ func TestWithClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -325,6 +329,7 @@ func TestWithStrategy(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -437,6 +442,7 @@ func TestWithServerStarter(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/e2e/strategy/create_index_option_test.go b/hack/benchmark/internal/e2e/strategy/create_index_option_test.go index 56547ec8c15..560216aa556 100644 --- a/hack/benchmark/internal/e2e/strategy/create_index_option_test.go +++ b/hack/benchmark/internal/e2e/strategy/create_index_option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/client" + + "go.uber.org/goleak" ) func TestWithCreateIndexPoolSize(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithCreateIndexPoolSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithCreateIndexClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/e2e/strategy/insert_option_test.go b/hack/benchmark/internal/e2e/strategy/insert_option_test.go index d607393bc17..216214bd653 100644 --- a/hack/benchmark/internal/e2e/strategy/insert_option_test.go +++ b/hack/benchmark/internal/e2e/strategy/insert_option_test.go @@ -17,7 +17,11 @@ // Package strategy provides strategy for e2e testing functions package strategy -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithParallelInsert(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithParallelInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/e2e/strategy/remove_option_test.go b/hack/benchmark/internal/e2e/strategy/remove_option_test.go index e181dd27e69..42bf51c72d9 100644 --- a/hack/benchmark/internal/e2e/strategy/remove_option_test.go +++ b/hack/benchmark/internal/e2e/strategy/remove_option_test.go @@ -17,7 +17,11 @@ // Package strategy provides strategy for e2e testing functions package strategy -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithParallelRemove(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithParallelRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/e2e/strategy/search_option_test.go b/hack/benchmark/internal/e2e/strategy/search_option_test.go index 20b715688a2..7e1809e305e 100644 --- a/hack/benchmark/internal/e2e/strategy/search_option_test.go +++ b/hack/benchmark/internal/e2e/strategy/search_option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/client" + + "go.uber.org/goleak" ) func TestWithSearchParallel(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithSearchParallel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithSearchConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/e2e/strategy/stream_insert_test.go b/hack/benchmark/internal/e2e/strategy/stream_insert_test.go index db9b02273bb..f831b5a3c4c 100644 --- a/hack/benchmark/internal/e2e/strategy/stream_insert_test.go +++ b/hack/benchmark/internal/e2e/strategy/stream_insert_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/hack/benchmark/internal/e2e" "github.com/vdaas/vald/internal/client" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNewStreamInsert(t *testing.T) { @@ -79,6 +81,7 @@ func TestNewStreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -156,6 +159,7 @@ func Test_streamInsert_dataProvider(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -233,6 +237,7 @@ func Test_streamInsert_Run(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/e2e/strategy/stream_remove_test.go b/hack/benchmark/internal/e2e/strategy/stream_remove_test.go index 37dd79dbe82..0b626b2369a 100644 --- a/hack/benchmark/internal/e2e/strategy/stream_remove_test.go +++ b/hack/benchmark/internal/e2e/strategy/stream_remove_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/hack/benchmark/internal/e2e" "github.com/vdaas/vald/internal/client" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNewStreamRemove(t *testing.T) { @@ -79,6 +81,7 @@ func TestNewStreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -156,6 +159,7 @@ func Test_streamRemove_dataProvider(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -233,6 +237,7 @@ func Test_streamRemove_Run(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/e2e/strategy/stream_search_option_test.go b/hack/benchmark/internal/e2e/strategy/stream_search_option_test.go index 1eea98530ae..427fe6ca2d2 100644 --- a/hack/benchmark/internal/e2e/strategy/stream_search_option_test.go +++ b/hack/benchmark/internal/e2e/strategy/stream_search_option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/client" + + "go.uber.org/goleak" ) func TestWithStreamSearchConfig(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithStreamSearchConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/e2e/strategy/stream_search_test.go b/hack/benchmark/internal/e2e/strategy/stream_search_test.go index 10a574b4c6a..caa432b673c 100644 --- a/hack/benchmark/internal/e2e/strategy/stream_search_test.go +++ b/hack/benchmark/internal/e2e/strategy/stream_search_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/hack/benchmark/internal/e2e" "github.com/vdaas/vald/internal/client" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNewStreamSearch(t *testing.T) { @@ -79,6 +81,7 @@ func TestNewStreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -165,6 +168,7 @@ func Test_streamSearch_dataProvider(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -253,6 +257,7 @@ func Test_streamSearch_Run(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/starter/agent/ngt/ngt_test.go b/hack/benchmark/internal/starter/agent/ngt/ngt_test.go index e2131e70b12..15e95c8a96d 100644 --- a/hack/benchmark/internal/starter/agent/ngt/ngt_test.go +++ b/hack/benchmark/internal/starter/agent/ngt/ngt_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/hack/benchmark/internal/starter" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/agent/ngt/config" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -78,6 +80,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -161,6 +164,7 @@ func Test_server_Run(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/starter/agent/ngt/option_test.go b/hack/benchmark/internal/starter/agent/ngt/option_test.go index 2bc422631ed..9a38bdbcad0 100644 --- a/hack/benchmark/internal/starter/agent/ngt/option_test.go +++ b/hack/benchmark/internal/starter/agent/ngt/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/agent/ngt/config" + + "go.uber.org/goleak" ) func TestWithConfig(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithDimentaion(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithDistanceType(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -435,6 +440,7 @@ func TestWithObjectType(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/benchmark/internal/starter/external/ngtd/ngtd_test.go b/hack/benchmark/internal/starter/external/ngtd/ngtd_test.go index 02a1d81e15c..2deac100bd7 100644 --- a/hack/benchmark/internal/starter/external/ngtd/ngtd_test.go +++ b/hack/benchmark/internal/starter/external/ngtd/ngtd_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/hack/benchmark/internal/starter" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -169,6 +172,7 @@ func Test_server_Run(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_server_createIndexDir(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -339,6 +344,7 @@ func Test_server_clearIndexDir(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/hack/benchmark/internal/starter/external/ngtd/option_test.go b/hack/benchmark/internal/starter/external/ngtd/option_test.go index d49183ca4aa..e0fc5e9d10b 100644 --- a/hack/benchmark/internal/starter/external/ngtd/option_test.go +++ b/hack/benchmark/internal/starter/external/ngtd/option_test.go @@ -17,7 +17,11 @@ // Package ngtd provides ngtd starter functionality package ngtd -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithDimentaion(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithDimentaion(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithServerType(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -319,6 +325,7 @@ func TestWithIndexDir(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -431,6 +438,7 @@ func TestWithPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/license/gen/main_test.go b/hack/license/gen/main_test.go index 271179ccb7e..2e15acf7165 100644 --- a/hack/license/gen/main_test.go +++ b/hack/license/gen/main_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func Test_main(t *testing.T) { @@ -60,6 +62,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -129,6 +132,7 @@ func Test_dirwalk(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -199,6 +203,7 @@ func Test_readAndRewrite(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/swagger/main_test.go b/hack/swagger/main_test.go index 6f93b2facdc..f1d94748ef3 100644 --- a/hack/swagger/main_test.go +++ b/hack/swagger/main_test.go @@ -20,6 +20,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestParse(t *testing.T) { @@ -73,6 +75,7 @@ func TestParse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/hack/tools/config/agent/ngt/main_test.go b/hack/tools/config/agent/ngt/main_test.go index 8833ba6fe52..4d0f6075cbe 100644 --- a/hack/tools/config/agent/ngt/main_test.go +++ b/hack/tools/config/agent/ngt/main_test.go @@ -16,7 +16,11 @@ package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -55,6 +59,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/hack/tools/config/discoverer/k8s/main_test.go b/hack/tools/config/discoverer/k8s/main_test.go index 8833ba6fe52..4d0f6075cbe 100644 --- a/hack/tools/config/discoverer/k8s/main_test.go +++ b/hack/tools/config/discoverer/k8s/main_test.go @@ -16,7 +16,11 @@ package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -55,6 +59,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/hack/tools/config/gateway/vald/main_test.go b/hack/tools/config/gateway/vald/main_test.go index 8833ba6fe52..4d0f6075cbe 100644 --- a/hack/tools/config/gateway/vald/main_test.go +++ b/hack/tools/config/gateway/vald/main_test.go @@ -16,7 +16,11 @@ package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -55,6 +59,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/hack/tools/config/manager/backup/mysql/main_test.go b/hack/tools/config/manager/backup/mysql/main_test.go index 8833ba6fe52..4d0f6075cbe 100644 --- a/hack/tools/config/manager/backup/mysql/main_test.go +++ b/hack/tools/config/manager/backup/mysql/main_test.go @@ -16,7 +16,11 @@ package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -55,6 +59,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/hack/tools/config/meta/redis/main_test.go b/hack/tools/config/meta/redis/main_test.go index 8833ba6fe52..4d0f6075cbe 100644 --- a/hack/tools/config/meta/redis/main_test.go +++ b/hack/tools/config/meta/redis/main_test.go @@ -16,7 +16,11 @@ package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -55,6 +59,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/hack/tools/metrics/main_test.go b/hack/tools/metrics/main_test.go index 03b6bd8d63c..92dce22eac1 100644 --- a/hack/tools/metrics/main_test.go +++ b/hack/tools/metrics/main_test.go @@ -15,7 +15,11 @@ // package main -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func Test_main(t *testing.T) { type want struct { @@ -54,6 +58,7 @@ func Test_main(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/backoff/backoff_test.go b/internal/backoff/backoff_test.go index f78d28b1e1b..64fc45bb717 100644 --- a/internal/backoff/backoff_test.go +++ b/internal/backoff/backoff_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -394,6 +396,7 @@ func Test_backoff_Do(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -513,6 +516,7 @@ func Test_backoff_addJitter(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -618,6 +622,7 @@ func Test_backoff_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/backoff/option_test.go b/internal/backoff/option_test.go index a4f28cf054c..9e624e97bcc 100644 --- a/internal/backoff/option_test.go +++ b/internal/backoff/option_test.go @@ -20,6 +20,8 @@ import ( "time" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestWithInitialDuration(t *testing.T) { @@ -484,6 +486,7 @@ func TestWithEnableErrorLog(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/cache/cache_test.go b/internal/cache/cache_test.go index a93416e30ad..1e37531b4d5 100644 --- a/internal/cache/cache_test.go +++ b/internal/cache/cache_test.go @@ -22,6 +22,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -79,6 +81,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/cache/gache/option_test.go b/internal/cache/gache/option_test.go index a1739c0d506..1f4d6438b88 100644 --- a/internal/cache/gache/option_test.go +++ b/internal/cache/gache/option_test.go @@ -23,6 +23,8 @@ import ( "time" "github.com/kpango/gache" + + "go.uber.org/goleak" ) func TestWithGache(t *testing.T) { @@ -101,6 +103,7 @@ func TestWithGache(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -213,6 +216,7 @@ func TestWithExpiredHook(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -325,6 +329,7 @@ func TestWithExpireDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -437,6 +442,7 @@ func TestWithExpireCheckDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/cache/option_test.go b/internal/cache/option_test.go index a9514cce9c2..3aced282abb 100644 --- a/internal/cache/option_test.go +++ b/internal/cache/option_test.go @@ -20,6 +20,8 @@ package cache import ( "context" "testing" + + "go.uber.org/goleak" ) func TestWithExpiredHook(t *testing.T) { @@ -98,6 +100,7 @@ func TestWithExpiredHook(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -210,6 +213,7 @@ func TestWithType(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -322,6 +326,7 @@ func TestWithExpireDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +439,7 @@ func TestWithExpireCheckDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/agent/ngt/grpc/client_test.go b/internal/client/agent/ngt/grpc/client_test.go index 8eec540b75a..10a7932962c 100644 --- a/internal/client/agent/ngt/grpc/client_test.go +++ b/internal/client/agent/ngt/grpc/client_test.go @@ -22,9 +22,11 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/client" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -178,6 +181,7 @@ func Test_agentClient_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -276,6 +280,7 @@ func Test_agentClient_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -374,6 +379,7 @@ func Test_agentClient_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -471,6 +477,7 @@ func Test_agentClient_StreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -568,6 +575,7 @@ func Test_agentClient_StreamSearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -662,6 +670,7 @@ func Test_agentClient_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -759,6 +768,7 @@ func Test_agentClient_StreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -853,6 +863,7 @@ func Test_agentClient_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -947,6 +958,7 @@ func Test_agentClient_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1044,6 +1056,7 @@ func Test_agentClient_StreamUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1138,6 +1151,7 @@ func Test_agentClient_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1232,6 +1246,7 @@ func Test_agentClient_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1329,6 +1344,7 @@ func Test_agentClient_StreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1423,6 +1439,7 @@ func Test_agentClient_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1521,6 +1538,7 @@ func Test_agentClient_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1618,6 +1636,7 @@ func Test_agentClient_StreamGetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1712,6 +1731,7 @@ func Test_agentClient_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1803,6 +1823,7 @@ func Test_agentClient_SaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1897,6 +1918,7 @@ func Test_agentClient_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1992,6 +2014,7 @@ func Test_agentClient_IndexInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2073,6 +2096,7 @@ func Test_streamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2149,6 +2173,7 @@ func Test_stream(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/agent/ngt/grpc/option_test.go b/internal/client/agent/ngt/grpc/option_test.go index 8e9b9b3fa89..fe98d463e93 100644 --- a/internal/client/agent/ngt/grpc/option_test.go +++ b/internal/client/agent/ngt/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestWithAddr(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithGRPCClientOption(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/agent/ngt/rest/client_test.go b/internal/client/agent/ngt/rest/client_test.go index ece94c21fe7..8ed55630a4a 100644 --- a/internal/client/agent/ngt/rest/client_test.go +++ b/internal/client/agent/ngt/rest/client_test.go @@ -24,6 +24,8 @@ import ( "github.com/vdaas/vald/internal/client" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -80,6 +82,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -167,6 +170,7 @@ func Test_agentClient_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -257,6 +261,7 @@ func Test_agentClient_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -347,6 +352,7 @@ func Test_agentClient_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +442,7 @@ func Test_agentClient_StreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -525,6 +532,7 @@ func Test_agentClient_StreamSearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -611,6 +619,7 @@ func Test_agentClient_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -700,6 +709,7 @@ func Test_agentClient_StreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -786,6 +796,7 @@ func Test_agentClient_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -872,6 +883,7 @@ func Test_agentClient_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -961,6 +973,7 @@ func Test_agentClient_StreamUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1047,6 +1060,7 @@ func Test_agentClient_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1133,6 +1147,7 @@ func Test_agentClient_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1222,6 +1237,7 @@ func Test_agentClient_StreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1308,6 +1324,7 @@ func Test_agentClient_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1398,6 +1415,7 @@ func Test_agentClient_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1487,6 +1505,7 @@ func Test_agentClient_StreamGetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1573,6 +1592,7 @@ func Test_agentClient_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1656,6 +1676,7 @@ func Test_agentClient_SaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1742,6 +1763,7 @@ func Test_agentClient_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1829,6 +1851,7 @@ func Test_agentClient_IndexInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/agent/ngt/rest/option_test.go b/internal/client/agent/ngt/rest/option_test.go index 4a5a5cf9673..fce759c5fb6 100644 --- a/internal/client/agent/ngt/rest/option_test.go +++ b/internal/client/agent/ngt/rest/option_test.go @@ -17,7 +17,11 @@ // Package rest provides agent ngt REST client functions package rest -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithAddr(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/compressor/client_test.go b/internal/client/compressor/client_test.go index e37ecb989b9..db576499b6a 100644 --- a/internal/client/compressor/client_test.go +++ b/internal/client/compressor/client_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/apis/grpc/payload" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -82,6 +84,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -169,6 +172,7 @@ func Test_client_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -263,6 +267,7 @@ func Test_client_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -357,6 +362,7 @@ func Test_client_GetLocation(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -447,6 +453,7 @@ func Test_client_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -537,6 +544,7 @@ func Test_client_RegisterMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -627,6 +635,7 @@ func Test_client_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -717,6 +726,7 @@ func Test_client_RemoveMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -807,6 +817,7 @@ func Test_client_RegisterIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -897,6 +908,7 @@ func Test_client_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/compressor/option_test.go b/internal/client/compressor/option_test.go index d3923768125..1f9b16e64a7 100644 --- a/internal/client/compressor/option_test.go +++ b/internal/client/compressor/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestWithAddr(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/discoverer/discover_test.go b/internal/client/discoverer/discover_test.go index 61cfe921336..b732d70cb30 100644 --- a/internal/client/discoverer/discover_test.go +++ b/internal/client/discoverer/discover_test.go @@ -27,6 +27,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -84,6 +86,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -213,6 +216,7 @@ func Test_client_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -356,6 +360,7 @@ func Test_client_GetAddrs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -489,6 +494,7 @@ func Test_client_GetClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -635,6 +641,7 @@ func Test_client_connect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -781,6 +788,7 @@ func Test_client_disconnect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -931,6 +939,7 @@ func Test_client_dnsDiscovery(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1077,6 +1086,7 @@ func Test_client_discover(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/discoverer/option_test.go b/internal/client/discoverer/option_test.go index 9767c16a670..774ba2f9d97 100644 --- a/internal/client/discoverer/option_test.go +++ b/internal/client/discoverer/option_test.go @@ -23,6 +23,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestWithOnDiscoverFunc(t *testing.T) { @@ -101,6 +103,7 @@ func TestWithOnDiscoverFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -213,6 +216,7 @@ func TestWithOnConnectFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -325,6 +329,7 @@ func TestWithOnDisconnectFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -437,6 +442,7 @@ func TestWithDiscovererClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -549,6 +555,7 @@ func TestWithDiscovererAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -664,6 +671,7 @@ func TestWithDiscovererHostPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -776,6 +784,7 @@ func TestWithDiscoverDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -888,6 +897,7 @@ func TestWithOptions(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1000,6 +1010,7 @@ func TestWithAutoConnect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1112,6 +1123,7 @@ func TestWithName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1224,6 +1236,7 @@ func TestWithNamespace(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1336,6 +1349,7 @@ func TestWithPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1448,6 +1462,7 @@ func TestWithServiceDNSARecord(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1560,6 +1575,7 @@ func TestWithNodeName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1672,6 +1688,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/gateway/vald/grpc/client_test.go b/internal/client/gateway/vald/grpc/client_test.go index fdebb6b08dc..7c0ea6c23e3 100644 --- a/internal/client/gateway/vald/grpc/client_test.go +++ b/internal/client/gateway/vald/grpc/client_test.go @@ -22,11 +22,13 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/client" "github.com/vdaas/vald/internal/config" + "github.com/vdaas/vald/internal/errors" igrpc "github.com/vdaas/vald/internal/net/grpc" "google.golang.org/grpc" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -87,6 +89,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -180,6 +183,7 @@ func Test_gatewayClient_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -278,6 +282,7 @@ func Test_gatewayClient_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -376,6 +381,7 @@ func Test_gatewayClient_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -473,6 +479,7 @@ func Test_gatewayClient_StreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -570,6 +577,7 @@ func Test_gatewayClient_StreamSearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -664,6 +672,7 @@ func Test_gatewayClient_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -761,6 +770,7 @@ func Test_gatewayClient_StreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -855,6 +865,7 @@ func Test_gatewayClient_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -949,6 +960,7 @@ func Test_gatewayClient_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1046,6 +1058,7 @@ func Test_gatewayClient_StreamUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1140,6 +1153,7 @@ func Test_gatewayClient_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1234,6 +1248,7 @@ func Test_gatewayClient_Upsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1328,6 +1343,7 @@ func Test_gatewayClient_MultiUpsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1425,6 +1441,7 @@ func Test_gatewayClient_StreamUpsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1519,6 +1536,7 @@ func Test_gatewayClient_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1616,6 +1634,7 @@ func Test_gatewayClient_StreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1710,6 +1729,7 @@ func Test_gatewayClient_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1808,6 +1828,7 @@ func Test_gatewayClient_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1905,6 +1926,7 @@ func Test_gatewayClient_StreamGetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1986,6 +2008,7 @@ func Test_streamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2062,6 +2085,7 @@ func Test_stream(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/gateway/vald/grpc/option_test.go b/internal/client/gateway/vald/grpc/option_test.go index 4b3f8bb10e3..73c829d46ee 100644 --- a/internal/client/gateway/vald/grpc/option_test.go +++ b/internal/client/gateway/vald/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/config" + + "go.uber.org/goleak" ) func TestWithAddr(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithGRPCClientConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/gateway/vald/rest/client_test.go b/internal/client/gateway/vald/rest/client_test.go index 450804e5587..c2ba19d3d37 100644 --- a/internal/client/gateway/vald/rest/client_test.go +++ b/internal/client/gateway/vald/rest/client_test.go @@ -24,6 +24,8 @@ import ( "github.com/vdaas/vald/internal/client" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_gatewayClient_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_gatewayClient_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_gatewayClient_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -433,6 +439,7 @@ func Test_gatewayClient_StreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -522,6 +529,7 @@ func Test_gatewayClient_StreamSearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -608,6 +616,7 @@ func Test_gatewayClient_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -697,6 +706,7 @@ func Test_gatewayClient_StreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -783,6 +793,7 @@ func Test_gatewayClient_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -869,6 +880,7 @@ func Test_gatewayClient_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -958,6 +970,7 @@ func Test_gatewayClient_StreamUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1044,6 +1057,7 @@ func Test_gatewayClient_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1130,6 +1144,7 @@ func Test_gatewayClient_Upsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1216,6 +1231,7 @@ func Test_gatewayClient_MultiUpsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1305,6 +1321,7 @@ func Test_gatewayClient_StreamUpsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1391,6 +1408,7 @@ func Test_gatewayClient_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1480,6 +1498,7 @@ func Test_gatewayClient_StreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1566,6 +1585,7 @@ func Test_gatewayClient_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1656,6 +1676,7 @@ func Test_gatewayClient_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1745,6 +1766,7 @@ func Test_gatewayClient_StreamGetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/client/gateway/vald/rest/option_test.go b/internal/client/gateway/vald/rest/option_test.go index b40996f235c..3ce17243d20 100644 --- a/internal/client/gateway/vald/rest/option_test.go +++ b/internal/client/gateway/vald/rest/option_test.go @@ -17,7 +17,11 @@ // Package rest provides vald REST client functions package rest -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithAddr(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/compress/gob_test.go b/internal/compress/gob_test.go index 926e13227f7..4cd6e6f95dd 100644 --- a/internal/compress/gob_test.go +++ b/internal/compress/gob_test.go @@ -22,6 +22,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestGobCompressVector(t *testing.T) { @@ -118,6 +120,7 @@ func TestNewGob(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -193,6 +196,7 @@ func Test_gobCompressor_CompressVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -269,6 +273,7 @@ func Test_gobCompressor_DecompressVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/compress/gzip_option_test.go b/internal/compress/gzip_option_test.go index 74d8b8c4ab3..60d9e15c302 100644 --- a/internal/compress/gzip_option_test.go +++ b/internal/compress/gzip_option_test.go @@ -17,7 +17,11 @@ // Package compress provides compress functions package compress -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithGzipGob(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithGzipGob(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithGzipCompressionLevel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/compress/gzip_test.go b/internal/compress/gzip_test.go index 91a9d870ca7..806323071d7 100644 --- a/internal/compress/gzip_test.go +++ b/internal/compress/gzip_test.go @@ -22,6 +22,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestGzipCompressVector(t *testing.T) { @@ -118,6 +120,7 @@ func TestNewGzip(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -205,6 +208,7 @@ func Test_gzipCompressor_CompressVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -296,6 +300,7 @@ func Test_gzipCompressor_DecompressVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/compress/lz4_option_test.go b/internal/compress/lz4_option_test.go index 9a6fd235197..6d6f10334c8 100644 --- a/internal/compress/lz4_option_test.go +++ b/internal/compress/lz4_option_test.go @@ -17,7 +17,11 @@ // Package compress provides compress functions package compress -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithLZ4Gob(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithLZ4Gob(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithLZ4CompressionLevel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/compress/lz4_test.go b/internal/compress/lz4_test.go index 30f863271d8..11d8e5d23f9 100644 --- a/internal/compress/lz4_test.go +++ b/internal/compress/lz4_test.go @@ -22,6 +22,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestLZ4CompressVector(t *testing.T) { @@ -118,6 +120,7 @@ func TestNewLZ4(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -205,6 +208,7 @@ func Test_lz4Compressor_CompressVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -296,6 +300,7 @@ func Test_lz4Compressor_DecompressVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/compress/zstd_option_test.go b/internal/compress/zstd_option_test.go index a1a0f509b29..87c7f4aea9c 100644 --- a/internal/compress/zstd_option_test.go +++ b/internal/compress/zstd_option_test.go @@ -17,7 +17,11 @@ // Package compress provides compress functions package compress -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithZstdGob(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithZstdGob(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithZstdCompressionLevel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/compress/zstd_test.go b/internal/compress/zstd_test.go index 1447fcb4958..760e5edcbc5 100644 --- a/internal/compress/zstd_test.go +++ b/internal/compress/zstd_test.go @@ -23,6 +23,8 @@ import ( "github.com/klauspost/compress/zstd" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestZstdCompressVector(t *testing.T) { @@ -119,6 +121,7 @@ func TestNewZstd(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -206,6 +209,7 @@ func Test_zstdCompressor_CompressVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -297,6 +301,7 @@ func Test_zstdCompressor_DecompressVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index fa690d34cec..50c7791b184 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestGlobalConfig_Bind(t *testing.T) { @@ -81,6 +82,7 @@ func TestGlobalConfig_Bind(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -172,6 +174,7 @@ func TestGlobalConfig_UnmarshalJSON(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -250,6 +253,7 @@ func TestRead(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -320,6 +324,7 @@ func TestGetActualValue(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -390,6 +395,7 @@ func TestGetActualValues(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -466,6 +472,7 @@ func Test_checkPrefixAndSuffix(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -536,6 +543,7 @@ func TestToRawYaml(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/core/converter/tensorflow/option_test.go b/internal/core/converter/tensorflow/option_test.go index 83ae6a84b97..580e3176d3f 100644 --- a/internal/core/converter/tensorflow/option_test.go +++ b/internal/core/converter/tensorflow/option_test.go @@ -17,7 +17,11 @@ // Package tensorflow provides implementation of Go API for extract data to vector package tensorflow -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithSessionOptions(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithSessionOptions(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithSessionTarget(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -319,6 +325,7 @@ func TestWithSessionConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -431,6 +438,7 @@ func TestWithOperations(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -543,6 +551,7 @@ func TestWithExportPath(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -655,6 +664,7 @@ func TestWithTags(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -770,6 +780,7 @@ func TestWithFeed(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -885,6 +896,7 @@ func TestWithFeeds(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1000,6 +1012,7 @@ func TestWithFetch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1115,6 +1128,7 @@ func TestWithFetches(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1227,6 +1241,7 @@ func TestWithNdim(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/core/converter/tensorflow/tensorflow_test.go b/internal/core/converter/tensorflow/tensorflow_test.go index 8a5813d5bbb..58b9f671183 100644 --- a/internal/core/converter/tensorflow/tensorflow_test.go +++ b/internal/core/converter/tensorflow/tensorflow_test.go @@ -23,6 +23,8 @@ import ( tf "github.com/tensorflow/tensorflow/tensorflow/go" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -80,6 +82,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -180,6 +183,7 @@ func Test_tensorflow_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -307,6 +311,7 @@ func Test_tensorflow_run(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +439,7 @@ func Test_tensorflow_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -561,6 +567,7 @@ func Test_tensorflow_GetValue(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -688,6 +695,7 @@ func Test_tensorflow_GetValues(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/db/kvs/redis/option_test.go b/internal/db/kvs/redis/option_test.go index f711ed5289f..ba9e5284aab 100644 --- a/internal/db/kvs/redis/option_test.go +++ b/internal/db/kvs/redis/option_test.go @@ -24,6 +24,8 @@ import ( redis "github.com/go-redis/redis/v7" "github.com/vdaas/vald/internal/net" + + "go.uber.org/goleak" ) func TestWithDialer(t *testing.T) { @@ -102,6 +104,7 @@ func TestWithDialer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -214,6 +217,7 @@ func TestWithAddrs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -326,6 +330,7 @@ func TestWithDB(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -438,6 +443,7 @@ func TestWithClusterSlots(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -550,6 +556,7 @@ func TestWithDialTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -662,6 +669,7 @@ func TestWithIdleCheckFrequency(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -774,6 +782,7 @@ func TestWithIdleTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -886,6 +895,7 @@ func TestWithKeyPrefix(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -998,6 +1008,7 @@ func TestWithMaximumConnectionAge(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1110,6 +1121,7 @@ func TestWithRedirectLimit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1222,6 +1234,7 @@ func TestWithRetryLimit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1334,6 +1347,7 @@ func TestWithMaximumRetryBackoff(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1446,6 +1460,7 @@ func TestWithMinimumIdleConnection(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1558,6 +1573,7 @@ func TestWithMinimumRetryBackoff(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1670,6 +1686,7 @@ func TestWithOnConnectFunction(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1782,6 +1799,7 @@ func TestWithOnNewNodeFunction(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1894,6 +1912,7 @@ func TestWithPassword(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2006,6 +2025,7 @@ func TestWithPoolSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2118,6 +2138,7 @@ func TestWithPoolTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2230,6 +2251,7 @@ func TestWithReadOnlyFlag(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2342,6 +2364,7 @@ func TestWithReadTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2454,6 +2477,7 @@ func TestWithRouteByLatencyFlag(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2566,6 +2590,7 @@ func TestWithRouteRandomlyFlag(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2678,6 +2703,7 @@ func TestWithTLSConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2790,6 +2816,7 @@ func TestWithWriteTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2902,6 +2929,7 @@ func TestWithInitialPingTimeLimit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -3014,6 +3042,7 @@ func TestWithInitialPingDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/db/kvs/redis/redis_test.go b/internal/db/kvs/redis/redis_test.go index 255a719de33..7025b1e2096 100644 --- a/internal/db/kvs/redis/redis_test.go +++ b/internal/db/kvs/redis/redis_test.go @@ -22,6 +22,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -82,6 +84,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/db/nosql/cassandra/option_test.go b/internal/db/nosql/cassandra/option_test.go index f6c8fb76dbc..79f435b9431 100644 --- a/internal/db/nosql/cassandra/option_test.go +++ b/internal/db/nosql/cassandra/option_test.go @@ -23,6 +23,8 @@ import ( "github.com/gocql/gocql" "go.uber.org/goleak" + + "go.uber.org/goleak" ) func TestWithHosts(t *testing.T) { @@ -5109,3 +5111,342 @@ func TestWithTokenAwareHostPolicy(t *testing.T) { }) } } + +func TestWithHostFilter(t *testing.T) { + type T = interface{} + type args struct { + flg bool + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(args) + afterFunc func(args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got = %v, want %v", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return fmt.Errorf("got = %v, want %v", obj, w.c) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + flg: false, + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + flg: false, + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + got := WithHostFilter(test.args.flg) + obj := new(T) + if err := test.checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option returns an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithHostFilter(test.args.flg) + obj := new(T) + got(obj) + if err := test.checkFunc(tt.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithDCHostFilter(t *testing.T) { + type T = interface{} + type args struct { + dc string + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(args) + afterFunc func(args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got = %v, want %v", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return fmt.Errorf("got = %v, want %v", obj, w.c) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + dc: "", + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + dc: "", + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + got := WithDCHostFilter(test.args.dc) + obj := new(T) + if err := test.checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option returns an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithDCHostFilter(test.args.dc) + obj := new(T) + got(obj) + if err := test.checkFunc(tt.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithWhiteListHostFilter(t *testing.T) { + type T = interface{} + type args struct { + list []string + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(args) + afterFunc func(args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got = %v, want %v", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return fmt.Errorf("got = %v, want %v", obj, w.c) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + list: nil, + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + list: nil, + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + got := WithWhiteListHostFilter(test.args.list) + obj := new(T) + if err := test.checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option returns an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithWhiteListHostFilter(test.args.list) + obj := new(T) + got(obj) + if err := test.checkFunc(tt.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} diff --git a/internal/db/rdb/mysql/mysql_test.go b/internal/db/rdb/mysql/mysql_test.go index 94d573b67a4..24fa2357d0f 100644 --- a/internal/db/rdb/mysql/mysql_test.go +++ b/internal/db/rdb/mysql/mysql_test.go @@ -27,6 +27,8 @@ import ( dbr "github.com/gocraft/dbr/v2" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -84,6 +86,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func Test_mySQLClient_Open(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -359,6 +363,7 @@ func Test_mySQLClient_Ping(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -506,6 +511,7 @@ func Test_mySQLClient_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -660,6 +666,7 @@ func Test_mySQLClient_GetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -814,6 +821,7 @@ func Test_mySQLClient_GetIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -903,6 +911,7 @@ func Test_validateMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1034,6 +1043,7 @@ func Test_mySQLClient_SetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1184,6 +1194,7 @@ func Test_mySQLClient_SetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1279,6 +1290,7 @@ func Test_deleteMetaWithTx(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1410,6 +1422,7 @@ func Test_mySQLClient_DeleteMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1560,6 +1573,7 @@ func Test_mySQLClient_DeleteMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1713,6 +1727,7 @@ func Test_mySQLClient_SetIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1863,6 +1878,7 @@ func Test_mySQLClient_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/db/rdb/mysql/option_test.go b/internal/db/rdb/mysql/option_test.go index 017c4090d8f..3a2092f9099 100644 --- a/internal/db/rdb/mysql/option_test.go +++ b/internal/db/rdb/mysql/option_test.go @@ -22,6 +22,8 @@ import ( "testing" "github.com/vdaas/vald/internal/net" + + "go.uber.org/goleak" ) func TestWithTimezone(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithTimezone(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithCharset(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithDB(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +441,7 @@ func TestWithHost(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -548,6 +554,7 @@ func TestWithPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -660,6 +667,7 @@ func TestWithUser(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -772,6 +780,7 @@ func TestWithPass(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -884,6 +893,7 @@ func TestWithName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -996,6 +1006,7 @@ func TestWithInitialPingTimeLimit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1108,6 +1119,7 @@ func TestWithInitialPingDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1220,6 +1232,7 @@ func TestWithConnectionLifeTimeLimit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1332,6 +1345,7 @@ func TestWithMaxIdleConns(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1444,6 +1458,7 @@ func TestWithMaxOpenConns(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1556,6 +1571,7 @@ func TestWithTLSConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1668,6 +1684,7 @@ func TestWithDialer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/errgroup/group_test.go b/internal/errgroup/group_test.go index 4a57f48baba..f7dca013a69 100644 --- a/internal/errgroup/group_test.go +++ b/internal/errgroup/group_test.go @@ -25,6 +25,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -82,6 +84,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -152,6 +155,7 @@ func TestInit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +216,7 @@ func TestGet(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -278,6 +283,7 @@ func TestGo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -380,6 +386,7 @@ func Test_group_Limitation(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -494,6 +501,7 @@ func Test_group_Go(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -598,6 +606,7 @@ func Test_group_doCancel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -669,6 +678,7 @@ func TestWait(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -766,6 +776,7 @@ func Test_group_Wait(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/hack/benchmark/internal/errors/benchmark.go b/internal/errors/benchmark.go similarity index 86% rename from hack/benchmark/internal/errors/benchmark.go rename to internal/errors/benchmark.go index 39e800930ee..afba087e2e8 100644 --- a/hack/benchmark/internal/errors/benchmark.go +++ b/internal/errors/benchmark.go @@ -17,10 +17,6 @@ // Package errors provides benchmark error package errors -import ( - "github.com/vdaas/vald/internal/errors" -) - var ( - ErrInvalidCoreMode = errors.New("invalid core mode") + ErrInvalidCoreMode = New("invalid core mode") ) diff --git a/internal/errors/cassandra_test.go b/internal/errors/cassandra_test.go index 89ffdf8a386..3c0edeb23bc 100644 --- a/internal/errors/cassandra_test.go +++ b/internal/errors/cassandra_test.go @@ -20,8 +20,6 @@ package errors import ( "reflect" "testing" - - "github.com/vdaas/vald/internal/errors" ) func TestErrCassandraNotFoundIdentity_Error(t *testing.T) { @@ -41,7 +39,7 @@ func TestErrCassandraNotFoundIdentity_Error(t *testing.T) { } defaultCheckFunc := func(w want, got string) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } @@ -114,7 +112,7 @@ func TestIsErrCassandraNotFound(t *testing.T) { } defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } @@ -184,7 +182,7 @@ func TestErrCassandraUnavailableIdentity_Error(t *testing.T) { } defaultCheckFunc := func(w want, got string) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } @@ -257,7 +255,7 @@ func TestIsErrCassandraUnavailable(t *testing.T) { } defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } diff --git a/hack/benchmark/internal/errors/gongt.go b/internal/errors/gongt.go similarity index 86% rename from hack/benchmark/internal/errors/gongt.go rename to internal/errors/gongt.go index 5d2a3ecdd13..f5d0d1bd9e8 100644 --- a/hack/benchmark/internal/errors/gongt.go +++ b/internal/errors/gongt.go @@ -17,8 +17,6 @@ // Package errors provides benchmark error package errors -import "github.com/vdaas/vald/internal/errors" - var ( - ErrGoNGTNotSupportedMethod = errors.New("not supported method") + ErrGoNGTNotSupportedMethod = New("not supported method") ) diff --git a/internal/errors/mysql_test.go b/internal/errors/mysql_test.go index 6d62296ff67..0ae3d6043df 100644 --- a/internal/errors/mysql_test.go +++ b/internal/errors/mysql_test.go @@ -20,8 +20,6 @@ package errors import ( "reflect" "testing" - - "github.com/vdaas/vald/internal/errors" ) func TestErrMySQLNotFoundIdentity_Error(t *testing.T) { @@ -41,7 +39,7 @@ func TestErrMySQLNotFoundIdentity_Error(t *testing.T) { } defaultCheckFunc := func(w want, got string) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } @@ -114,7 +112,7 @@ func TestIsErrMySQLNotFound(t *testing.T) { } defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } @@ -184,7 +182,7 @@ func TestErrMySQLInvalidArgumentIdentity_Error(t *testing.T) { } defaultCheckFunc := func(w want, got string) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } @@ -257,7 +255,7 @@ func TestIsErrMySQLInvalidArgument(t *testing.T) { } defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } diff --git a/internal/errors/redis_test.go b/internal/errors/redis_test.go index 4be9aa48570..18a0e12b30f 100644 --- a/internal/errors/redis_test.go +++ b/internal/errors/redis_test.go @@ -20,8 +20,6 @@ package errors import ( "reflect" "testing" - - "github.com/vdaas/vald/internal/errors" ) func TestErrRedisNotFoundIdentity_Error(t *testing.T) { @@ -41,7 +39,7 @@ func TestErrRedisNotFoundIdentity_Error(t *testing.T) { } defaultCheckFunc := func(w want, got string) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } @@ -114,7 +112,7 @@ func TestIsErrRedisNotFound(t *testing.T) { } defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + return Errorf("got = %v, want %v", got, w.want) } return nil } diff --git a/internal/k8s/metrics/node/node_test.go b/internal/k8s/metrics/node/node_test.go index 1534aab1038..0308df85cbd 100644 --- a/internal/k8s/metrics/node/node_test.go +++ b/internal/k8s/metrics/node/node_test.go @@ -28,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -81,6 +83,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_reconciler_Reconcile(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -266,6 +270,7 @@ func Test_reconciler_GetName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -368,6 +373,7 @@ func Test_reconciler_NewReconciler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -457,6 +463,7 @@ func Test_reconciler_For(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -546,6 +553,7 @@ func Test_reconciler_Owns(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -639,6 +647,7 @@ func Test_reconciler_Watches(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/k8s/metrics/node/option_test.go b/internal/k8s/metrics/node/option_test.go index 15da8134377..fd1c6d97ec2 100644 --- a/internal/k8s/metrics/node/option_test.go +++ b/internal/k8s/metrics/node/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "sigs.k8s.io/controller-runtime/pkg/manager" + + "go.uber.org/goleak" ) func TestWithControllerName(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithControllerName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithManager(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithOnErrorFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -435,6 +440,7 @@ func TestWithOnReconcileFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/k8s/metrics/pod/option_test.go b/internal/k8s/metrics/pod/option_test.go index e1918a836a6..c4bc9dc201f 100644 --- a/internal/k8s/metrics/pod/option_test.go +++ b/internal/k8s/metrics/pod/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "sigs.k8s.io/controller-runtime/pkg/manager" + + "go.uber.org/goleak" ) func TestWithControllerName(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithControllerName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithManager(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithOnErrorFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -435,6 +440,7 @@ func TestWithOnReconcileFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/k8s/metrics/pod/pod_test.go b/internal/k8s/metrics/pod/pod_test.go index 2168dd58000..e0e78962b23 100644 --- a/internal/k8s/metrics/pod/pod_test.go +++ b/internal/k8s/metrics/pod/pod_test.go @@ -22,12 +22,14 @@ import ( "reflect" "testing" - "k8s.io/apimachinery/pkg/api/errors" + "github.com/vdaas/vald/internal/errors" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -81,6 +83,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_reconciler_Reconcile(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -266,6 +270,7 @@ func Test_reconciler_GetName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -368,6 +373,7 @@ func Test_reconciler_NewReconciler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -457,6 +463,7 @@ func Test_reconciler_For(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -546,6 +553,7 @@ func Test_reconciler_Owns(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -639,6 +647,7 @@ func Test_reconciler_Watches(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/k8s/node/node_test.go b/internal/k8s/node/node_test.go index d57aab5a261..cb843f6f41a 100644 --- a/internal/k8s/node/node_test.go +++ b/internal/k8s/node/node_test.go @@ -29,6 +29,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -82,6 +84,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -181,6 +184,7 @@ func Test_reconciler_Reconcile(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -274,6 +278,7 @@ func Test_reconciler_GetName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -380,6 +385,7 @@ func Test_reconciler_NewReconciler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -473,6 +479,7 @@ func Test_reconciler_For(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -566,6 +573,7 @@ func Test_reconciler_Owns(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -663,6 +671,7 @@ func Test_reconciler_Watches(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/k8s/node/option_test.go b/internal/k8s/node/option_test.go index 9c8364d3237..9919501d7cd 100644 --- a/internal/k8s/node/option_test.go +++ b/internal/k8s/node/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "sigs.k8s.io/controller-runtime/pkg/manager" + + "go.uber.org/goleak" ) func TestWithControllerName(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithControllerName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithManager(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithOnErrorFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -435,6 +440,7 @@ func TestWithOnReconcileFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/k8s/option_test.go b/internal/k8s/option_test.go index 697988e705c..238fb73a9a8 100644 --- a/internal/k8s/option_test.go +++ b/internal/k8s/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "sigs.k8s.io/controller-runtime/pkg/manager" + + "go.uber.org/goleak" ) func TestWithErrGroup(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithControllerName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithResourceController(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +441,7 @@ func TestWithManager(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -548,6 +554,7 @@ func TestWithMetricsAddress(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -650,6 +657,7 @@ func TestWithEnableLeaderElection(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -752,6 +760,7 @@ func TestWithDisableLeaderElection(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/k8s/pod/option_test.go b/internal/k8s/pod/option_test.go index 508e7ff88a3..aa679968f2f 100644 --- a/internal/k8s/pod/option_test.go +++ b/internal/k8s/pod/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "sigs.k8s.io/controller-runtime/pkg/manager" + + "go.uber.org/goleak" ) func TestWithControllerName(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithControllerName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithManager(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithOnErrorFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -435,6 +440,7 @@ func TestWithOnReconcileFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/k8s/pod/pod_test.go b/internal/k8s/pod/pod_test.go index 4df04eff980..abf22841d7b 100644 --- a/internal/k8s/pod/pod_test.go +++ b/internal/k8s/pod/pod_test.go @@ -28,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -81,6 +83,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -180,6 +183,7 @@ func Test_reconciler_Reconcile(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -273,6 +277,7 @@ func Test_reconciler_GetName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -379,6 +384,7 @@ func Test_reconciler_NewReconciler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -472,6 +478,7 @@ func Test_reconciler_For(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -565,6 +572,7 @@ func Test_reconciler_Owns(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -662,6 +670,7 @@ func Test_reconciler_Watches(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/k8s/reconciler_test.go b/internal/k8s/reconciler_test.go index f51ee24a96d..dcc40fd0012 100644 --- a/internal/k8s/reconciler_test.go +++ b/internal/k8s/reconciler_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "sigs.k8s.io/controller-runtime/pkg/manager" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -82,6 +84,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -181,6 +184,7 @@ func Test_controller_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/log/format/format_test.go b/internal/log/format/format_test.go index 8d87e73ca3f..661a887b85c 100644 --- a/internal/log/format/format_test.go +++ b/internal/log/format/format_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestString(t *testing.T) { @@ -168,6 +169,7 @@ func TestFormat_String(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/log/glg/glg_test.go b/internal/log/glg/glg_test.go index f7964f57025..31978bd034b 100644 --- a/internal/log/glg/glg_test.go +++ b/internal/log/glg/glg_test.go @@ -27,6 +27,8 @@ import ( "github.com/vdaas/vald/internal/log/level" "github.com/vdaas/vald/internal/log/mock" "github.com/vdaas/vald/internal/log/retry" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -982,6 +984,7 @@ func Test_logger_setLevelMode(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1077,6 +1080,7 @@ func Test_logger_setLogFormat(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1168,6 +1172,7 @@ func Test_logger_Info(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1261,6 +1266,7 @@ func Test_logger_Infof(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1351,6 +1357,7 @@ func Test_logger_Debug(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1444,6 +1451,7 @@ func Test_logger_Debugf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1534,6 +1542,7 @@ func Test_logger_Warn(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1627,6 +1636,7 @@ func Test_logger_Warnf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1717,6 +1727,7 @@ func Test_logger_Error(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1810,6 +1821,7 @@ func Test_logger_Errorf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1900,6 +1912,7 @@ func Test_logger_Fatal(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1993,6 +2006,7 @@ func Test_logger_Fatalf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/log/level/level_test.go b/internal/log/level/level_test.go index 17c19557469..05c189a878b 100644 --- a/internal/log/level/level_test.go +++ b/internal/log/level/level_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestString(t *testing.T) { @@ -216,6 +217,7 @@ func TestLevel_String(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/log/log_test.go b/internal/log/log_test.go index b7eaf7ceff9..4f04329e13c 100644 --- a/internal/log/log_test.go +++ b/internal/log/log_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/log/level" logger "github.com/vdaas/vald/internal/log/logger" "github.com/vdaas/vald/internal/log/mock" + + "go.uber.org/goleak" ) func TestInit(t *testing.T) { @@ -858,6 +860,7 @@ func Test_getLogger(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/log/logger/type_test.go b/internal/log/logger/type_test.go index fdc18235b31..973ac48948d 100644 --- a/internal/log/logger/type_test.go +++ b/internal/log/logger/type_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestString(t *testing.T) { @@ -204,6 +205,7 @@ func TestType_String(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/log/mock/logger_test.go b/internal/log/mock/logger_test.go index 81022c4550d..2291fe50112 100644 --- a/internal/log/mock/logger_test.go +++ b/internal/log/mock/logger_test.go @@ -15,7 +15,11 @@ // package mock -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestLogger_Debug(t *testing.T) { type args struct { @@ -101,6 +105,7 @@ func TestLogger_Debug(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -218,6 +223,7 @@ func TestLogger_Debugf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -332,6 +338,7 @@ func TestLogger_Info(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -449,6 +456,7 @@ func TestLogger_Infof(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -563,6 +571,7 @@ func TestLogger_Warn(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -680,6 +689,7 @@ func TestLogger_Warnf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -794,6 +804,7 @@ func TestLogger_Error(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -911,6 +922,7 @@ func TestLogger_Errorf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1025,6 +1037,7 @@ func TestLogger_Fatal(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1142,6 +1155,7 @@ func TestLogger_Fatalf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/log/mock/retry_test.go b/internal/log/mock/retry_test.go index a55bb92993a..1716716ad46 100644 --- a/internal/log/mock/retry_test.go +++ b/internal/log/mock/retry_test.go @@ -15,7 +15,11 @@ // package mock -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestRetry_Out(t *testing.T) { type args struct { @@ -80,6 +84,7 @@ func TestRetry_Out(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -168,6 +173,7 @@ func TestRetry_Outf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/log/retry/retry_test.go b/internal/log/retry/retry_test.go index 71c13d12917..6e3b02ac382 100644 --- a/internal/log/retry/retry_test.go +++ b/internal/log/retry/retry_test.go @@ -20,6 +20,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -412,6 +414,7 @@ func Test_retry_Out(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -500,6 +503,7 @@ func Test_retry_Outf(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/client_test.go b/internal/net/grpc/client_test.go index 51818df4a35..0b67fe6fc79 100644 --- a/internal/net/grpc/client_test.go +++ b/internal/net/grpc/client_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/backoff" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -79,6 +81,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -196,6 +199,7 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -326,6 +330,7 @@ func Test_gRPCClient_Range(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -459,6 +464,7 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -592,6 +598,7 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -728,6 +735,7 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -865,6 +873,7 @@ func Test_gRPCClient_Do(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -982,6 +991,7 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1099,6 +1109,7 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1232,6 +1243,7 @@ func Test_gRPCClient_Connect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1359,6 +1371,7 @@ func Test_gRPCClient_Disconnect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1476,6 +1489,7 @@ func Test_gRPCClient_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/net/grpc/option_test.go b/internal/net/grpc/option_test.go index 1b099ea3e4d..857dc2a4691 100644 --- a/internal/net/grpc/option_test.go +++ b/internal/net/grpc/option_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/net/tcp" "google.golang.org/grpc" + + "go.uber.org/goleak" ) func TestWithAddrs(t *testing.T) { @@ -103,6 +105,7 @@ func TestWithAddrs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -215,6 +218,7 @@ func TestWithHealthCheckDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -327,6 +331,7 @@ func TestWithConnectionPoolRebalanceDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -439,6 +444,7 @@ func TestWithEnableConnectionPoolRebalance(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -551,6 +557,7 @@ func TestWithConnectionPoolSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -663,6 +670,7 @@ func TestWithDialOptions(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -775,6 +783,7 @@ func TestWithMaxBackoffDelay(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -887,6 +896,7 @@ func TestWithCallOptions(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -999,6 +1009,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1111,6 +1122,7 @@ func TestWithBackoff(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1223,6 +1235,7 @@ func TestWithWaitForReady(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1335,6 +1348,7 @@ func TestWithMaxRetryRPCBufferSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1447,6 +1461,7 @@ func TestWithMaxRecvMsgSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1559,6 +1574,7 @@ func TestWithMaxSendMsgSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1671,6 +1687,7 @@ func TestWithWriteBufferSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1783,6 +1800,7 @@ func TestWithReadBufferSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1895,6 +1913,7 @@ func TestWithInitialWindowSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2007,6 +2026,7 @@ func TestWithInitialConnectionWindowSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2119,6 +2139,7 @@ func TestWithMaxMsgSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2231,6 +2252,7 @@ func TestWithInsecure(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2343,6 +2365,7 @@ func TestWithDialTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2461,6 +2484,7 @@ func TestWithKeepaliveParams(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2573,6 +2597,7 @@ func TestWithDialer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2685,6 +2710,7 @@ func TestWithTLSConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2797,6 +2823,7 @@ func TestWithOldConnCloseDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/pool/option_test.go b/internal/net/grpc/pool/option_test.go index ec4d37d4b12..42f76a7d711 100644 --- a/internal/net/grpc/pool/option_test.go +++ b/internal/net/grpc/pool/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/backoff" + + "go.uber.org/goleak" ) func TestWithAddr(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithHost(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -435,6 +440,7 @@ func TestWithStartPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -547,6 +553,7 @@ func TestWithEndPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -659,6 +666,7 @@ func TestWithBackoff(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -771,6 +779,7 @@ func TestWithSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -883,6 +892,7 @@ func TestWithDialOptions(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -995,6 +1005,7 @@ func TestWithDialTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1107,6 +1118,7 @@ func TestWithOldConnCloseDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/pool/pool_test.go b/internal/net/grpc/pool/pool_test.go index cef3de47cd3..24a5d0163b6 100644 --- a/internal/net/grpc/pool/pool_test.go +++ b/internal/net/grpc/pool/pool_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/backoff" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -86,6 +88,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func Test_pool_Connect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -355,6 +359,7 @@ func Test_pool_load(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -498,6 +503,7 @@ func Test_pool_connect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -627,6 +633,7 @@ func Test_pool_Disconnect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -773,6 +780,7 @@ func Test_pool_dial(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -912,6 +920,7 @@ func Test_pool_IsHealthy(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1051,6 +1060,7 @@ func Test_pool_Do(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1184,6 +1194,7 @@ func Test_pool_Get(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1327,6 +1338,7 @@ func Test_pool_get(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1456,6 +1468,7 @@ func Test_pool_Len(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1585,6 +1598,7 @@ func Test_pool_Size(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1728,6 +1742,7 @@ func Test_pool_lookupIPAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1874,6 +1889,7 @@ func Test_pool_Reconnect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2013,6 +2029,7 @@ func Test_pool_scanGRPCPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2106,6 +2123,7 @@ func Test_isGRPCPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2176,6 +2194,7 @@ func Test_isHealthy(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/status/status_test.go b/internal/net/grpc/status/status_test.go index 1950c9ded59..33360039878 100644 --- a/internal/net/grpc/status/status_test.go +++ b/internal/net/grpc/status/status_test.go @@ -21,10 +21,12 @@ import ( "reflect" "testing" - grpcerr "github.com/vdaas/vald/apis/grpc/errors" + gerrors "github.com/vdaas/vald/apis/grpc/errors" "github.com/vdaas/vald/internal/errors" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "go.uber.org/goleak" ) func Test_newStatus(t *testing.T) { @@ -87,6 +89,7 @@ func Test_newStatus(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -163,6 +166,7 @@ func TestWrapWithCanceled(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -239,6 +243,7 @@ func TestWrapWithUnknown(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -315,6 +320,7 @@ func TestWrapWithInvalidArgument(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -391,6 +397,7 @@ func TestWrapWithDeadlineExceeded(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -467,6 +474,7 @@ func TestWrapWithNotFound(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -543,6 +551,7 @@ func TestWrapWithAlreadyExists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -619,6 +628,7 @@ func TestWrapWithPermissionDenied(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -695,6 +705,7 @@ func TestWrapWithResourceExhausted(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -771,6 +782,7 @@ func TestWrapWithFailedPrecondition(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -847,6 +859,7 @@ func TestWrapWithAborted(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -923,6 +936,7 @@ func TestWrapWithOutOfRange(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -999,6 +1013,7 @@ func TestWrapWithUnimplemented(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1075,6 +1090,7 @@ func TestWrapWithInternal(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1151,6 +1167,7 @@ func TestWrapWithUnavailable(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1227,6 +1244,7 @@ func TestWrapWithDataLoss(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1303,6 +1321,7 @@ func TestWrapWithUnauthenticated(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1327,17 +1346,17 @@ func TestFromError(t *testing.T) { err error } type want struct { - want *grpcerr.Errors_RPC + want *gerrors.Errors_RPC } type test struct { name string args args want want - checkFunc func(want, *grpcerr.Errors_RPC) error + checkFunc func(want, *gerrors.Errors_RPC) error beforeFunc func(args) afterFunc func(args) } - defaultCheckFunc := func(w want, got *grpcerr.Errors_RPC) error { + defaultCheckFunc := func(w want, got *gerrors.Errors_RPC) error { if !reflect.DeepEqual(got, w.want) { return errors.Errorf("got = %v, want %v", got, w.want) } @@ -1373,6 +1392,7 @@ func TestFromError(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/stream_test.go b/internal/net/grpc/stream_test.go index 80cf4e32f16..b9329928289 100644 --- a/internal/net/grpc/stream_test.go +++ b/internal/net/grpc/stream_test.go @@ -23,6 +23,8 @@ import ( "github.com/vdaas/vald/internal/errors" "google.golang.org/grpc" + + "go.uber.org/goleak" ) func TestBidirectionalStream(t *testing.T) { @@ -88,6 +90,7 @@ func TestBidirectionalStream(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -167,6 +170,7 @@ func TestBidirectionalStreamClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/http/json/json_test.go b/internal/net/http/json/json_test.go index 876d18d42da..8d9d48feb05 100644 --- a/internal/net/http/json/json_test.go +++ b/internal/net/http/json/json_test.go @@ -27,6 +27,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/http/rest" + + "go.uber.org/goleak" ) func TestEncode(t *testing.T) { @@ -661,6 +663,7 @@ func TestUnmarshal(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -734,6 +737,7 @@ func TestDecodeResponse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -810,6 +814,7 @@ func TestEncodeRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -892,6 +897,7 @@ func TestRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/http/middleware/timeout_test.go b/internal/net/http/middleware/timeout_test.go index 62c00232942..84db985b2f6 100644 --- a/internal/net/http/middleware/timeout_test.go +++ b/internal/net/http/middleware/timeout_test.go @@ -27,6 +27,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/http/rest" + + "go.uber.org/goleak" ) func TestNewTimeout(t *testing.T) { @@ -262,6 +264,7 @@ func Test_timeout_Wrap(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/http/routing/router_test.go b/internal/net/http/routing/router_test.go index 2fc645e84ed..e5c075813e6 100644 --- a/internal/net/http/routing/router_test.go +++ b/internal/net/http/routing/router_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/http/middleware" "github.com/vdaas/vald/internal/net/http/rest" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -251,6 +253,7 @@ func Test_router_routing(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/http/transport/roundtrip_test.go b/internal/net/http/transport/roundtrip_test.go index 192e60c5ee0..3b07b8283d6 100644 --- a/internal/net/http/transport/roundtrip_test.go +++ b/internal/net/http/transport/roundtrip_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/backoff" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNewExpBackoff(t *testing.T) { @@ -299,6 +301,7 @@ func Test_ert_RoundTrip(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -390,6 +393,7 @@ func Test_ert_roundTrip(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/net_test.go b/internal/net/net_test.go index ce2e8851241..a6219ca5611 100644 --- a/internal/net/net_test.go +++ b/internal/net/net_test.go @@ -22,7 +22,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestListen(t *testing.T) { @@ -83,6 +84,7 @@ func TestListen(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -153,6 +155,7 @@ func TestIsLocal(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -230,6 +233,7 @@ func TestDial(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -312,6 +316,7 @@ func TestParse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -382,6 +387,7 @@ func TestIsIPv6(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -452,6 +458,7 @@ func TestIsIPv4(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -530,6 +537,7 @@ func TestSplitHostPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -613,6 +621,7 @@ func TestScanPorts(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/tcp/control_darwin_test.go b/internal/net/tcp/control_darwin_test.go index 78d3a11a038..5458a81dd55 100644 --- a/internal/net/tcp/control_darwin_test.go +++ b/internal/net/tcp/control_darwin_test.go @@ -24,6 +24,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestControl(t *testing.T) { @@ -83,6 +85,7 @@ func TestControl(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/tcp/control_other_test.go b/internal/net/tcp/control_other_test.go index 61c144ea77f..8b2b11001d5 100644 --- a/internal/net/tcp/control_other_test.go +++ b/internal/net/tcp/control_other_test.go @@ -23,7 +23,8 @@ import ( "syscall" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestControl(t *testing.T) { @@ -83,6 +84,7 @@ func TestControl(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/tcp/control_unix_test.go b/internal/net/tcp/control_unix_test.go index d7a1ce61a55..06b689b8bbc 100644 --- a/internal/net/tcp/control_unix_test.go +++ b/internal/net/tcp/control_unix_test.go @@ -24,6 +24,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestControl(t *testing.T) { @@ -83,6 +85,7 @@ func TestControl(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/tcp/control_windows_test.go b/internal/net/tcp/control_windows_test.go index e3eda8bbcf0..b9b6533eac7 100644 --- a/internal/net/tcp/control_windows_test.go +++ b/internal/net/tcp/control_windows_test.go @@ -23,7 +23,8 @@ import ( "syscall" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestControl(t *testing.T) { @@ -83,6 +84,7 @@ func TestControl(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/tcp/dialer_test.go b/internal/net/tcp/dialer_test.go index 7a49c5e75ec..4fe99a34a41 100644 --- a/internal/net/tcp/dialer_test.go +++ b/internal/net/tcp/dialer_test.go @@ -27,6 +27,8 @@ import ( "github.com/vdaas/vald/internal/cache" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net" + + "go.uber.org/goleak" ) func TestNewDialer(t *testing.T) { @@ -84,6 +86,7 @@ func TestNewDialer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -187,6 +190,7 @@ func Test_dialer_GetDialer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -321,6 +325,7 @@ func Test_dialer_lookup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -444,6 +449,7 @@ func Test_dialer_StartDialerCache(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -580,6 +586,7 @@ func Test_dialer_DialContext(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -717,6 +724,7 @@ func Test_dialer_cachedDialer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/collector/collector_option_test.go b/internal/observability/collector/collector_option_test.go index 189b94d3a34..8359cc7d152 100644 --- a/internal/observability/collector/collector_option_test.go +++ b/internal/observability/collector/collector_option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/observability/metrics" + + "go.uber.org/goleak" ) func TestWithErrGroup(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithMetrics(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +441,7 @@ func TestWithVersionInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -548,6 +554,7 @@ func TestWithMemoryMetrics(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -660,6 +667,7 @@ func TestWithGoroutineMetrics(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -772,6 +780,7 @@ func TestWithCGOMetrics(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/collector/collector_test.go b/internal/observability/collector/collector_test.go index 22dfeb74359..9899f3d12f8 100644 --- a/internal/observability/collector/collector_test.go +++ b/internal/observability/collector/collector_test.go @@ -23,9 +23,11 @@ import ( "testing" "time" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability/metrics" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -83,6 +85,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -169,6 +172,7 @@ func Test_collector_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -260,6 +264,7 @@ func Test_collector_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -347,6 +352,7 @@ func Test_collector_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -437,6 +443,7 @@ func Test_collector_collect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/exporter/jaeger/jaeger_option_test.go b/internal/observability/exporter/jaeger/jaeger_option_test.go index d78e7b68ef9..1459b829790 100644 --- a/internal/observability/exporter/jaeger/jaeger_option_test.go +++ b/internal/observability/exporter/jaeger/jaeger_option_test.go @@ -17,7 +17,11 @@ // Package jaeger provides a jaeger exporter. package jaeger -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithCollectorEndpoint(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithCollectorEndpoint(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithAgentEndpoint(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -319,6 +325,7 @@ func TestWithUsername(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -431,6 +438,7 @@ func TestWithPassword(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -543,6 +551,7 @@ func TestWithServiceName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -655,6 +664,7 @@ func TestWithBufferMaxCount(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -767,6 +777,7 @@ func TestWithOnErrorFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/exporter/jaeger/jaeger_test.go b/internal/observability/exporter/jaeger/jaeger_test.go index c4333b634d4..244ad0efa82 100644 --- a/internal/observability/exporter/jaeger/jaeger_test.go +++ b/internal/observability/exporter/jaeger/jaeger_test.go @@ -23,7 +23,9 @@ import ( "testing" "contrib.go.opencensus.io/exporter/jaeger" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -81,6 +83,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_exporter_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -247,6 +251,7 @@ func Test_exporter_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +328,7 @@ func Test_exporter_Exporter(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/observability/exporter/prometheus/prometheus_option_test.go b/internal/observability/exporter/prometheus/prometheus_option_test.go index 3ba2a67ee2f..97a7069681c 100644 --- a/internal/observability/exporter/prometheus/prometheus_option_test.go +++ b/internal/observability/exporter/prometheus/prometheus_option_test.go @@ -17,7 +17,11 @@ // Package prometheus provides a prometheus exporter. package prometheus -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithEndpoint(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithEndpoint(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithNamespace(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -319,6 +325,7 @@ func TestWithOnErrorFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/exporter/prometheus/prometheus_test.go b/internal/observability/exporter/prometheus/prometheus_test.go index a0af57eba7f..3d8c4aea48d 100644 --- a/internal/observability/exporter/prometheus/prometheus_test.go +++ b/internal/observability/exporter/prometheus/prometheus_test.go @@ -24,7 +24,9 @@ import ( "testing" "contrib.go.opencensus.io/exporter/prometheus" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -82,6 +84,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -165,6 +168,7 @@ func Test_exporter_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -248,6 +252,7 @@ func Test_exporter_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +329,7 @@ func Test_exporter_Exporter(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -401,6 +407,7 @@ func Test_exporter_NewHTTPHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -469,6 +476,7 @@ func TestExporter(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/observability/metrics/agent/ngt/ngt_test.go b/internal/observability/metrics/agent/ngt/ngt_test.go index f7e6f558de2..e5aed2d095e 100644 --- a/internal/observability/metrics/agent/ngt/ngt_test.go +++ b/internal/observability/metrics/agent/ngt/ngt_test.go @@ -22,9 +22,11 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability/metrics" "github.com/vdaas/vald/pkg/agent/ngt/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -78,6 +80,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_ngtMetrics_Measurement(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -284,6 +288,7 @@ func Test_ngtMetrics_MeasurementWithTags(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -377,6 +382,7 @@ func Test_ngtMetrics_View(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/observability/metrics/manager/compressor/compressor_test.go b/internal/observability/metrics/manager/compressor/compressor_test.go index 488ae5b7984..64ea569d71f 100644 --- a/internal/observability/metrics/manager/compressor/compressor_test.go +++ b/internal/observability/metrics/manager/compressor/compressor_test.go @@ -22,9 +22,11 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability/metrics" "github.com/vdaas/vald/pkg/manager/compressor/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -81,6 +83,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -186,6 +189,7 @@ func Test_compressorMetrics_Measurement(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -301,6 +305,7 @@ func Test_compressorMetrics_MeasurementWithTags(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -402,6 +407,7 @@ func Test_compressorMetrics_View(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/observability/metrics/mem/mem_test.go b/internal/observability/metrics/mem/mem_test.go index 722ffb8b503..1edd1545ba9 100644 --- a/internal/observability/metrics/mem/mem_test.go +++ b/internal/observability/metrics/mem/mem_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability/metrics" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -67,6 +69,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -190,6 +193,7 @@ func Test_memory_Measurement(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -329,6 +333,7 @@ func Test_memory_MeasurementWithTags(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -454,6 +459,7 @@ func Test_memory_View(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/observability/metrics/metrics_test.go b/internal/observability/metrics/metrics_test.go index 43929644498..b79eaea8eea 100644 --- a/internal/observability/metrics/metrics_test.go +++ b/internal/observability/metrics/metrics_test.go @@ -23,6 +23,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestRegisterView(t *testing.T) { @@ -76,6 +78,7 @@ func TestRegisterView(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -145,6 +148,7 @@ func TestRecord(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -217,6 +221,7 @@ func TestRecordWithTags(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -287,6 +292,7 @@ func TestMeasurementsCount(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/metrics/runtime/cgo/cgo_test.go b/internal/observability/metrics/runtime/cgo/cgo_test.go index dc2f69a96fe..795734a6572 100644 --- a/internal/observability/metrics/runtime/cgo/cgo_test.go +++ b/internal/observability/metrics/runtime/cgo/cgo_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability/metrics" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -67,6 +69,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -151,6 +154,7 @@ func Test_cgo_Measurement(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -238,6 +242,7 @@ func Test_cgo_MeasurementWithTags(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -311,6 +316,7 @@ func Test_cgo_View(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/observability/metrics/runtime/goroutine/goroutine_test.go b/internal/observability/metrics/runtime/goroutine/goroutine_test.go index d52d9a3c8b2..ad034ffcec7 100644 --- a/internal/observability/metrics/runtime/goroutine/goroutine_test.go +++ b/internal/observability/metrics/runtime/goroutine/goroutine_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability/metrics" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -67,6 +69,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -151,6 +154,7 @@ func Test_goroutines_Measurement(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -238,6 +242,7 @@ func Test_goroutines_MeasurementWithTags(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -311,6 +316,7 @@ func Test_goroutines_View(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/observability/metrics/version/version_test.go b/internal/observability/metrics/version/version_test.go index 65590e44b79..6a3e9486f5a 100644 --- a/internal/observability/metrics/version/version_test.go +++ b/internal/observability/metrics/version/version_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability/metrics" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -71,6 +73,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -135,6 +138,7 @@ func Test_labelKVs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -222,6 +226,7 @@ func Test_version_Measurement(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -313,6 +318,7 @@ func Test_version_MeasurementWithTags(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -390,6 +396,7 @@ func Test_version_View(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/observability/observability_option_test.go b/internal/observability/observability_option_test.go index 90811950883..8ec1461f3b2 100644 --- a/internal/observability/observability_option_test.go +++ b/internal/observability/observability_option_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/internal/observability/exporter/jaeger" "github.com/vdaas/vald/internal/observability/exporter/prometheus" "github.com/vdaas/vald/internal/observability/trace" + + "go.uber.org/goleak" ) func TestWithErrGroup(t *testing.T) { @@ -103,6 +105,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -215,6 +218,7 @@ func TestWithCollector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -327,6 +331,7 @@ func TestWithTracer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -439,6 +444,7 @@ func TestWithPrometheus(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -551,6 +557,7 @@ func TestWithJaeger(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/observability_test.go b/internal/observability/observability_test.go index 6d83dd7d83e..270c118d196 100644 --- a/internal/observability/observability_test.go +++ b/internal/observability/observability_test.go @@ -30,6 +30,8 @@ import ( "github.com/vdaas/vald/internal/observability/exporter/prometheus" "github.com/vdaas/vald/internal/observability/metrics" "github.com/vdaas/vald/internal/observability/trace" + + "go.uber.org/goleak" ) func TestNewWithConfig(t *testing.T) { @@ -90,6 +92,7 @@ func TestNewWithConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -256,6 +260,7 @@ func Test_observability_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -355,6 +360,7 @@ func Test_observability_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -450,6 +456,7 @@ func Test_observability_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/trace/trace_option_test.go b/internal/observability/trace/trace_option_test.go index 719274ac8c0..27086cc2856 100644 --- a/internal/observability/trace/trace_option_test.go +++ b/internal/observability/trace/trace_option_test.go @@ -17,7 +17,11 @@ // Package trace provides trace function. package trace -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithSamplingRate(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithSamplingRate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/params/option_test.go b/internal/params/option_test.go index 9e6971fa4c6..19166adcca7 100644 --- a/internal/params/option_test.go +++ b/internal/params/option_test.go @@ -17,7 +17,11 @@ // Package params provides implementation of Go API for argument parser package params -import "testing" +import ( + "testing" + + "go.uber.org/goleak" +) func TestWithConfigFilePathKeys(t *testing.T) { type T = interface{} @@ -95,6 +99,7 @@ func TestWithConfigFilePathKeys(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -207,6 +212,7 @@ func TestWithConfigFilePathDefault(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -319,6 +325,7 @@ func TestWithConfigFileDescription(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -431,6 +438,7 @@ func TestWithVersionKeys(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -543,6 +551,7 @@ func TestWithVersionFlagDefault(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -655,6 +664,7 @@ func TestWithVersionDescription(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/params/params_test.go b/internal/params/params_test.go index bdbf0b3687f..50b3e4ba947 100644 --- a/internal/params/params_test.go +++ b/internal/params/params_test.go @@ -22,6 +22,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -75,6 +77,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_parser_Parse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -241,6 +245,7 @@ func Test_data_ConfigFilePath(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -318,6 +323,7 @@ func Test_data_ShowVersion(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/runner/option_test.go b/internal/runner/option_test.go index 7232ea9acd5..c59d6ef2654 100644 --- a/internal/runner/option_test.go +++ b/internal/runner/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/config" + + "go.uber.org/goleak" ) func TestWithName(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -217,6 +220,7 @@ func TestWithVersion(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -329,6 +333,7 @@ func TestWithConfigLoader(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -441,6 +446,7 @@ func TestWithDaemonInitializer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/runner/runner_test.go b/internal/runner/runner_test.go index d811ae459c7..c84c91fb328 100644 --- a/internal/runner/runner_test.go +++ b/internal/runner/runner_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestDo(t *testing.T) { @@ -77,6 +79,7 @@ func TestDo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -153,6 +156,7 @@ func TestRun(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/servers/server/option_test.go b/internal/servers/server/option_test.go index 083b53c3c68..24f5fdba567 100644 --- a/internal/servers/server/option_test.go +++ b/internal/servers/server/option_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net" "google.golang.org/grpc" + + "go.uber.org/goleak" ) func TestWithHost(t *testing.T) { @@ -2391,6 +2393,7 @@ func TestWithPreStopFunction(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/servers/server/server_test.go b/internal/servers/server/server_test.go index 1101e1818d2..83f0c0a6a3e 100644 --- a/internal/servers/server/server_test.go +++ b/internal/servers/server/server_test.go @@ -31,6 +31,8 @@ import ( "github.com/vdaas/vald/internal/net" "github.com/vdaas/vald/internal/net/tcp" "google.golang.org/grpc" + + "go.uber.org/goleak" ) func TestString(t *testing.T) { @@ -707,6 +709,7 @@ func Test_mode_String(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -849,6 +852,7 @@ func Test_server_IsRunning(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1015,6 +1019,7 @@ func Test_server_Name(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1194,6 +1199,7 @@ func Test_server_ListenAndServe(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1370,6 +1376,7 @@ func Test_server_Shutdown(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/servers/servers_test.go b/internal/servers/servers_test.go index 314c54010d5..41750fc3d21 100644 --- a/internal/servers/servers_test.go +++ b/internal/servers/servers_test.go @@ -24,6 +24,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/servers/server" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -430,6 +432,7 @@ func Test_listener_ListenAndServe(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -529,6 +532,7 @@ func Test_listener_Shutdown(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/servers/starter/starter_test.go b/internal/servers/starter/starter_test.go index a8fdd5e9965..594daf468b9 100644 --- a/internal/servers/starter/starter_test.go +++ b/internal/servers/starter/starter_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/servers" "github.com/vdaas/vald/internal/servers/server" "github.com/vdaas/vald/internal/tls" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -544,6 +546,7 @@ func Test_srvs_setupAPIs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -651,6 +654,7 @@ func Test_srvs_setupHealthCheck(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -758,6 +762,7 @@ func Test_srvs_setupMetrics(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/singleflight/singleflight.go b/internal/singleflight/singleflight.go index ea9f9d0f098..b63326e1f7d 100644 --- a/internal/singleflight/singleflight.go +++ b/internal/singleflight/singleflight.go @@ -30,7 +30,7 @@ type call struct { } type Group interface { - Do(ctx context.Context, key string, fn func() (interface{}, error)) (v interface{}, err error, shared bool) + Do(ctx context.Context, key string, fn func() (interface{}, error)) (v interface{}, shared bool, err error) } type group struct { @@ -47,13 +47,13 @@ func New(size int) Group { } } -func (g *group) Do(ctx context.Context, key string, fn func() (interface{}, error)) (v interface{}, err error, shared bool) { +func (g *group) Do(ctx context.Context, key string, fn func() (interface{}, error)) (v interface{}, shared bool, err error) { g.mu.RLock() if c, ok := g.m[key]; ok { g.mu.RUnlock() c.dups++ c.wg.Wait() - return c.val, c.err, true + return c.val, true, c.err } g.mu.RUnlock() @@ -71,5 +71,5 @@ func (g *group) Do(ctx context.Context, key string, fn func() (interface{}, erro delete(g.m, key) g.mu.Unlock() - return c.val, c.err, c.dups > 0 + return c.val, c.dups > 0, c.err } diff --git a/internal/singleflight/singleflight_test.go b/internal/singleflight/singleflight_test.go index 0b4bc1ba01d..dfd54ed3d25 100644 --- a/internal/singleflight/singleflight_test.go +++ b/internal/singleflight/singleflight_test.go @@ -23,7 +23,8 @@ import ( "sync" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +78,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -174,6 +176,7 @@ func Test_group_Do(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -188,8 +191,7 @@ func Test_group_Do(t *testing.T) { m: test.fields.m, } - // TODO: refactor singleflight.Do - gotV, err, gotShared := g.Do(test.args.ctx, test.args.key, test.args.fn) + gotV, gotShared, err := g.Do(test.args.ctx, test.args.key, test.args.fn) if err := test.checkFunc(test.want, gotV, gotShared, err); err != nil { tt.Errorf("error = %v", err) } diff --git a/internal/tls/option_test.go b/internal/tls/option_test.go index c39eae7808e..73b2cc41fc0 100644 --- a/internal/tls/option_test.go +++ b/internal/tls/option_test.go @@ -20,6 +20,8 @@ package tls import ( "crypto/tls" "testing" + + "go.uber.org/goleak" ) func TestWithCert(t *testing.T) { @@ -98,6 +100,7 @@ func TestWithCert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -210,6 +213,7 @@ func TestWithKey(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -322,6 +326,7 @@ func TestWithCa(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +439,7 @@ func TestWithTLSConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/tls/tls_test.go b/internal/tls/tls_test.go index f876b9ebb2d..2cc29007b8f 100644 --- a/internal/tls/tls_test.go +++ b/internal/tls/tls_test.go @@ -23,6 +23,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -80,6 +82,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -154,6 +157,7 @@ func TestNewClientConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -228,6 +232,7 @@ func TestNewX509CertPool(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/worker/queue_option_test.go b/internal/worker/queue_option_test.go index 9e576645956..f3707a52323 100644 --- a/internal/worker/queue_option_test.go +++ b/internal/worker/queue_option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errgroup" + + "go.uber.org/goleak" ) func TestWithQueueBuffer(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithQueueBuffer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithQueueErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithQueueCheckDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/worker/queue_test.go b/internal/worker/queue_test.go index 33481614d53..c06b5eee7ce 100644 --- a/internal/worker/queue_test.go +++ b/internal/worker/queue_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNewQueue(t *testing.T) { @@ -83,6 +85,7 @@ func TestNewQueue(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -185,6 +188,7 @@ func Test_queue_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -282,6 +286,7 @@ func Test_queue_isRunning(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -392,6 +397,7 @@ func Test_queue_Push(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -503,6 +509,7 @@ func Test_queue_Pop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -617,6 +624,7 @@ func Test_queue_pop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -714,6 +722,7 @@ func Test_queue_Len(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/worker/worker_option_test.go b/internal/worker/worker_option_test.go index 38ce98ced9c..7b13d1280fb 100644 --- a/internal/worker/worker_option_test.go +++ b/internal/worker/worker_option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errgroup" + + "go.uber.org/goleak" ) func TestWithName(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithLimitation(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -435,6 +440,7 @@ func TestWithQueueOption(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/worker/worker_test.go b/internal/worker/worker_test.go index a1526e9e661..ae5b8c477d7 100644 --- a/internal/worker/worker_test.go +++ b/internal/worker/worker_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -82,6 +84,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -187,6 +190,7 @@ func Test_worker_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -298,6 +302,7 @@ func Test_worker_startJobLoop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -395,6 +400,7 @@ func Test_worker_Pause(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -491,6 +497,7 @@ func Test_worker_Resume(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -591,6 +598,7 @@ func Test_worker_IsRunning(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -692,6 +700,7 @@ func Test_worker_Name(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -793,6 +802,7 @@ func Test_worker_Len(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -894,6 +904,7 @@ func Test_worker_TotalRequested(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -995,6 +1006,7 @@ func Test_worker_TotalCompleted(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1109,6 +1121,7 @@ func Test_worker_Dispatch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/ngt/config/config_test.go b/pkg/agent/ngt/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/agent/ngt/config/config_test.go +++ b/pkg/agent/ngt/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/ngt/handler/grpc/handler_test.go b/pkg/agent/ngt/handler/grpc/handler_test.go index b192325ba1d..339d15a56de 100644 --- a/pkg/agent/ngt/handler/grpc/handler_test.go +++ b/pkg/agent/ngt/handler/grpc/handler_test.go @@ -27,6 +27,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/agent/ngt/model" "github.com/vdaas/vald/pkg/agent/ngt/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -80,6 +82,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -170,6 +173,7 @@ func Test_server_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -264,6 +268,7 @@ func Test_server_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -358,6 +363,7 @@ func Test_server_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -439,6 +445,7 @@ func Test_toSearchResponse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -522,6 +529,7 @@ func Test_server_StreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -609,6 +617,7 @@ func Test_server_StreamSearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -703,6 +712,7 @@ func Test_server_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -790,6 +800,7 @@ func Test_server_StreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -884,6 +895,7 @@ func Test_server_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -978,6 +990,7 @@ func Test_server_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1065,6 +1078,7 @@ func Test_server_StreamUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1159,6 +1173,7 @@ func Test_server_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1253,6 +1268,7 @@ func Test_server_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1340,6 +1356,7 @@ func Test_server_StreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1434,6 +1451,7 @@ func Test_server_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1528,6 +1546,7 @@ func Test_server_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1615,6 +1634,7 @@ func Test_server_StreamGetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1709,6 +1729,7 @@ func Test_server_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1803,6 +1824,7 @@ func Test_server_SaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1897,6 +1919,7 @@ func Test_server_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1991,6 +2014,7 @@ func Test_server_IndexInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/ngt/handler/grpc/option_test.go b/pkg/agent/ngt/handler/grpc/option_test.go index c4ca17ae4c2..0217e8f4aae 100644 --- a/pkg/agent/ngt/handler/grpc/option_test.go +++ b/pkg/agent/ngt/handler/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/agent/ngt/service" + + "go.uber.org/goleak" ) func TestWithNGT(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithNGT(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithStreamConcurrency(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/ngt/handler/rest/handler_test.go b/pkg/agent/ngt/handler/rest/handler_test.go index 603457a1ec9..2246525d1b4 100644 --- a/pkg/agent/ngt/handler/rest/handler_test.go +++ b/pkg/agent/ngt/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/agent" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_Index(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_handler_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +440,7 @@ func Test_handler_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -524,6 +531,7 @@ func Test_handler_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +622,7 @@ func Test_handler_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -704,6 +713,7 @@ func Test_handler_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -794,6 +804,7 @@ func Test_handler_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -884,6 +895,7 @@ func Test_handler_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -974,6 +986,7 @@ func Test_handler_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1064,6 +1077,7 @@ func Test_handler_SaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1154,6 +1168,7 @@ func Test_handler_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1244,6 +1259,7 @@ func Test_handler_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1334,6 +1350,7 @@ func Test_handler_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/ngt/handler/rest/option_test.go b/pkg/agent/ngt/handler/rest/option_test.go index 3104daa007e..d3404e97acf 100644 --- a/pkg/agent/ngt/handler/rest/option_test.go +++ b/pkg/agent/ngt/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/agent" + + "go.uber.org/goleak" ) func TestWithAgent(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithAgent(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/ngt/router/option_test.go b/pkg/agent/ngt/router/option_test.go index f3b4965d230..1e9ddcfb0bc 100644 --- a/pkg/agent/ngt/router/option_test.go +++ b/pkg/agent/ngt/router/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/agent/ngt/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/ngt/service/ngt_test.go b/pkg/agent/ngt/service/ngt_test.go index 459c190035b..7592722ebe2 100644 --- a/pkg/agent/ngt/service/ngt_test.go +++ b/pkg/agent/ngt/service/ngt_test.go @@ -30,6 +30,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/agent/ngt/model" "github.com/vdaas/vald/pkg/agent/ngt/service/kvs" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -87,6 +89,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -203,6 +206,7 @@ func Test_ngt_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -347,6 +351,7 @@ func Test_ngt_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -491,6 +496,7 @@ func Test_ngt_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -625,6 +631,7 @@ func Test_ngt_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -765,6 +772,7 @@ func Test_ngt_insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -896,6 +904,7 @@ func Test_ngt_InsertMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1030,6 +1039,7 @@ func Test_ngt_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1161,6 +1171,7 @@ func Test_ngt_UpdateMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1292,6 +1303,7 @@ func Test_ngt_Delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1426,6 +1438,7 @@ func Test_ngt_delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1557,6 +1570,7 @@ func Test_ngt_DeleteMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1692,6 +1706,7 @@ func Test_ngt_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1823,6 +1838,7 @@ func Test_ngt_CreateIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1944,6 +1960,7 @@ func Test_ngt_SaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -2075,6 +2092,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2192,6 +2210,7 @@ func Test_ngt_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -2326,6 +2345,7 @@ func Test_ngt_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2461,6 +2481,7 @@ func Test_ngt_insertCache(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2582,6 +2603,7 @@ func Test_ngt_IsIndexing(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -2713,6 +2735,7 @@ func Test_ngt_UUIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2834,6 +2857,7 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -2955,6 +2979,7 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -3076,6 +3101,7 @@ func Test_ngt_Len(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -3197,6 +3223,7 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -3318,6 +3345,7 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/pkg/agent/ngt/usecase/agentd_test.go b/pkg/agent/ngt/usecase/agentd_test.go index 60c8c8d301b..4e609e9f8d9 100644 --- a/pkg/agent/ngt/usecase/agentd_test.go +++ b/pkg/agent/ngt/usecase/agentd_test.go @@ -21,13 +21,15 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability" "github.com/vdaas/vald/internal/runner" "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/agent/ngt/config" "github.com/vdaas/vald/pkg/agent/ngt/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -280,6 +284,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -379,6 +384,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -478,6 +484,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -577,6 +584,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/discoverer/k8s/config/config_test.go b/pkg/discoverer/k8s/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/discoverer/k8s/config/config_test.go +++ b/pkg/discoverer/k8s/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/discoverer/k8s/handler/grpc/handler.go b/pkg/discoverer/k8s/handler/grpc/handler.go index 21913d0625f..fcbe1f07e00 100644 --- a/pkg/discoverer/k8s/handler/grpc/handler.go +++ b/pkg/discoverer/k8s/handler/grpc/handler.go @@ -74,7 +74,7 @@ func (s *server) Pods(ctx context.Context, req *payload.Discoverer_Request) (*pa span.End() } }() - res, err, _ := s.group.Do(ctx, singleflightKey(podPrefix, req), func() (interface{}, error) { + res, _, err := s.group.Do(ctx, singleflightKey(podPrefix, req), func() (interface{}, error) { return s.dsc.GetPods(req) }) if err != nil { @@ -94,7 +94,7 @@ func (s *server) Nodes(ctx context.Context, req *payload.Discoverer_Request) (*p span.End() } }() - res, err, _ := s.group.Do(ctx, singleflightKey(nodePrefix, req), func() (interface{}, error) { + res, _, err := s.group.Do(ctx, singleflightKey(nodePrefix, req), func() (interface{}, error) { return s.dsc.GetNodes(req) }) if err != nil { diff --git a/pkg/discoverer/k8s/handler/grpc/handler_test.go b/pkg/discoverer/k8s/handler/grpc/handler_test.go index b9637b73102..a1707df5678 100644 --- a/pkg/discoverer/k8s/handler/grpc/handler_test.go +++ b/pkg/discoverer/k8s/handler/grpc/handler_test.go @@ -22,10 +22,12 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/payload" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/singleflight" "github.com/vdaas/vald/pkg/discoverer/k8s/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -83,6 +85,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -162,6 +165,7 @@ func Test_server_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -255,6 +259,7 @@ func Test_server_Pods(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -349,6 +354,7 @@ func Test_server_Nodes(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -426,6 +432,7 @@ func Test_singleflightKey(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/discoverer/k8s/handler/grpc/option_test.go b/pkg/discoverer/k8s/handler/grpc/option_test.go index 6c4a94a5285..91fe8a44e42 100644 --- a/pkg/discoverer/k8s/handler/grpc/option_test.go +++ b/pkg/discoverer/k8s/handler/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/discoverer/k8s/service" + + "go.uber.org/goleak" ) func TestWithDiscoverer(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithDiscoverer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/discoverer/k8s/handler/rest/handler_test.go b/pkg/discoverer/k8s/handler/rest/handler_test.go index f18632f73de..3d13930f8f8 100644 --- a/pkg/discoverer/k8s/handler/rest/handler_test.go +++ b/pkg/discoverer/k8s/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/discoverer" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_Index(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_Pods(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_handler_Nodes(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/discoverer/k8s/handler/rest/option_test.go b/pkg/discoverer/k8s/handler/rest/option_test.go index a3191bad051..3125c33244f 100644 --- a/pkg/discoverer/k8s/handler/rest/option_test.go +++ b/pkg/discoverer/k8s/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/discoverer" + + "go.uber.org/goleak" ) func TestWithDiscoverer(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithDiscoverer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/discoverer/k8s/router/option_test.go b/pkg/discoverer/k8s/router/option_test.go index 03db83b7253..a4f38b10ea7 100644 --- a/pkg/discoverer/k8s/router/option_test.go +++ b/pkg/discoverer/k8s/router/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/discoverer/k8s/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/discoverer/k8s/service/discover_test.go b/pkg/discoverer/k8s/service/discover_test.go index 470895c638a..8326e3343f4 100644 --- a/pkg/discoverer/k8s/service/discover_test.go +++ b/pkg/discoverer/k8s/service/discover_test.go @@ -28,6 +28,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/k8s" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -208,6 +211,7 @@ func Test_discoverer_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -347,6 +351,7 @@ func Test_discoverer_GetPods(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -486,6 +491,7 @@ func Test_discoverer_GetNodes(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/discoverer/k8s/service/option_test.go b/pkg/discoverer/k8s/service/option_test.go index 5d144c275c0..7395c179713 100644 --- a/pkg/discoverer/k8s/service/option_test.go +++ b/pkg/discoverer/k8s/service/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errgroup" + + "go.uber.org/goleak" ) func TestWithName(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithNamespace(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithDiscoverDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -435,6 +440,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/discoverer/k8s/usecase/discovered_test.go b/pkg/discoverer/k8s/usecase/discovered_test.go index cb5173d2b42..351f0093c24 100644 --- a/pkg/discoverer/k8s/usecase/discovered_test.go +++ b/pkg/discoverer/k8s/usecase/discovered_test.go @@ -21,14 +21,16 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability" "github.com/vdaas/vald/internal/runner" "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/discoverer/k8s/config" handler "github.com/vdaas/vald/pkg/discoverer/k8s/handler/grpc" "github.com/vdaas/vald/pkg/discoverer/k8s/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -86,6 +88,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -181,6 +184,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -288,6 +292,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -391,6 +396,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -494,6 +500,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -597,6 +604,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/config/config_test.go b/pkg/gateway/vald/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/gateway/vald/config/config_test.go +++ b/pkg/gateway/vald/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/handler/grpc/handler_test.go b/pkg/gateway/vald/handler/grpc/handler_test.go index bd5193e4134..b811a0b3ca0 100644 --- a/pkg/gateway/vald/handler/grpc/handler_test.go +++ b/pkg/gateway/vald/handler/grpc/handler_test.go @@ -30,6 +30,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" "github.com/vdaas/vald/pkg/gateway/vald/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -83,6 +85,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -191,6 +194,7 @@ func Test_server_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -309,6 +313,7 @@ func Test_server_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -427,6 +432,7 @@ func Test_server_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -548,6 +554,7 @@ func Test_server_search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -659,6 +666,7 @@ func Test_server_StreamSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -770,6 +778,7 @@ func Test_server_StreamSearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -888,6 +897,7 @@ func Test_server_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -999,6 +1009,7 @@ func Test_server_StreamInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1117,6 +1128,7 @@ func Test_server_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1235,6 +1247,7 @@ func Test_server_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1346,6 +1359,7 @@ func Test_server_StreamUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1464,6 +1478,7 @@ func Test_server_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1582,6 +1597,7 @@ func Test_server_Upsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1693,6 +1709,7 @@ func Test_server_StreamUpsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1811,6 +1828,7 @@ func Test_server_MultiUpsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1929,6 +1947,7 @@ func Test_server_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2040,6 +2059,7 @@ func Test_server_StreamRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2158,6 +2178,7 @@ func Test_server_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2276,6 +2297,7 @@ func Test_server_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2387,6 +2409,7 @@ func Test_server_StreamGetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/handler/grpc/option_test.go b/pkg/gateway/vald/handler/grpc/option_test.go index c9bd859c1a8..60ea050efeb 100644 --- a/pkg/gateway/vald/handler/grpc/option_test.go +++ b/pkg/gateway/vald/handler/grpc/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/gateway/vald/service" + + "go.uber.org/goleak" ) func TestWithGateway(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithGateway(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithBackup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +441,7 @@ func TestWithFilters(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -548,6 +554,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -660,6 +667,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -772,6 +780,7 @@ func TestWithReplicationCount(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -884,6 +893,7 @@ func TestWithStreamConcurrency(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/handler/rest/handler_test.go b/pkg/gateway/vald/handler/rest/handler_test.go index 3a7c0915205..37fee9c24f7 100644 --- a/pkg/gateway/vald/handler/rest/handler_test.go +++ b/pkg/gateway/vald/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/gateway/vald" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_Index(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_Search(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_handler_SearchByID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +440,7 @@ func Test_handler_Insert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -524,6 +531,7 @@ func Test_handler_MultiInsert(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +622,7 @@ func Test_handler_Update(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -704,6 +713,7 @@ func Test_handler_MultiUpdate(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -794,6 +804,7 @@ func Test_handler_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -884,6 +895,7 @@ func Test_handler_MultiRemove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -974,6 +986,7 @@ func Test_handler_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1064,6 +1077,7 @@ func Test_handler_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/handler/rest/option_test.go b/pkg/gateway/vald/handler/rest/option_test.go index ccdce7bd5d4..d8fe7692d7f 100644 --- a/pkg/gateway/vald/handler/rest/option_test.go +++ b/pkg/gateway/vald/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/gateway/vald" + + "go.uber.org/goleak" ) func TestWithVald(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithVald(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/router/option_test.go b/pkg/gateway/vald/router/option_test.go index 63d6e061a83..b9fd88836fc 100644 --- a/pkg/gateway/vald/router/option_test.go +++ b/pkg/gateway/vald/router/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/gateway/vald/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/service/backup_option_test.go b/pkg/gateway/vald/service/backup_option_test.go index 0a0b541b8dc..72c4ceaf3aa 100644 --- a/pkg/gateway/vald/service/backup_option_test.go +++ b/pkg/gateway/vald/service/backup_option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestWithBackupAddr(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithBackupAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithBackupClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/service/backup_test.go b/pkg/gateway/vald/service/backup_test.go index faa636ddce4..2d6c262f692 100644 --- a/pkg/gateway/vald/service/backup_test.go +++ b/pkg/gateway/vald/service/backup_test.go @@ -24,6 +24,8 @@ import ( "github.com/vdaas/vald/apis/grpc/payload" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestNewBackup(t *testing.T) { @@ -81,6 +83,7 @@ func TestNewBackup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -168,6 +171,7 @@ func Test_backup_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -262,6 +266,7 @@ func Test_backup_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -356,6 +361,7 @@ func Test_backup_GetLocation(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -446,6 +452,7 @@ func Test_backup_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -536,6 +543,7 @@ func Test_backup_RegisterMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -626,6 +634,7 @@ func Test_backup_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -716,6 +725,7 @@ func Test_backup_RemoveMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/service/filter_option_test.go b/pkg/gateway/vald/service/filter_option_test.go index 229f7750be9..dfed870d60d 100644 --- a/pkg/gateway/vald/service/filter_option_test.go +++ b/pkg/gateway/vald/service/filter_option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestWithFilterClient(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithFilterClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/service/filter_test.go b/pkg/gateway/vald/service/filter_test.go index 2e085ba0d07..e03f77c8214 100644 --- a/pkg/gateway/vald/service/filter_test.go +++ b/pkg/gateway/vald/service/filter_test.go @@ -24,6 +24,8 @@ import ( "github.com/vdaas/vald/apis/grpc/payload" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestNewFilter(t *testing.T) { @@ -81,6 +83,7 @@ func TestNewFilter(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -165,6 +168,7 @@ func Test_filter_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -255,6 +259,7 @@ func Test_filter_FilterSearch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/service/gateway_option_test.go b/pkg/gateway/vald/service/gateway_option_test.go index a52c1e293c3..7440c530318 100644 --- a/pkg/gateway/vald/service/gateway_option_test.go +++ b/pkg/gateway/vald/service/gateway_option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/client/discoverer" "github.com/vdaas/vald/internal/errgroup" + + "go.uber.org/goleak" ) func TestWithDiscoverer(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithDiscoverer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/service/gateway_test.go b/pkg/gateway/vald/service/gateway_test.go index 73589a327b9..e1e87f6b321 100644 --- a/pkg/gateway/vald/service/gateway_test.go +++ b/pkg/gateway/vald/service/gateway_test.go @@ -27,6 +27,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestNewGateway(t *testing.T) { @@ -84,6 +86,7 @@ func TestNewGateway(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -171,6 +174,7 @@ func Test_gateway_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -261,6 +265,7 @@ func Test_gateway_BroadCast(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -351,6 +356,7 @@ func Test_gateway_Do(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -444,6 +450,7 @@ func Test_gateway_DoMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -531,6 +538,7 @@ func Test_gateway_GetAgentCount(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/service/meta_option_test.go b/pkg/gateway/vald/service/meta_option_test.go index fbc9e220af6..f00fc245c46 100644 --- a/pkg/gateway/vald/service/meta_option_test.go +++ b/pkg/gateway/vald/service/meta_option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/cache" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestWithMetaAddr(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithMetaAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -215,6 +218,7 @@ func TestWithMetaHostPort(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -327,6 +331,7 @@ func TestWithMetaClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -439,6 +444,7 @@ func TestWithMetaCacheEnabled(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -551,6 +557,7 @@ func TestWithMetaCache(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -663,6 +670,7 @@ func TestWithMetaCacheExpireDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -775,6 +783,7 @@ func TestWithMetaCacheExpiredCheckDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/service/meta_test.go b/pkg/gateway/vald/service/meta_test.go index 213fce425be..c2d0835a8ac 100644 --- a/pkg/gateway/vald/service/meta_test.go +++ b/pkg/gateway/vald/service/meta_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/internal/cache" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestNewMeta(t *testing.T) { @@ -82,6 +84,7 @@ func TestNewMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -181,6 +184,7 @@ func Test_meta_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -291,6 +295,7 @@ func Test_meta_Exists(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -401,6 +406,7 @@ func Test_meta_GetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -511,6 +517,7 @@ func Test_meta_GetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -621,6 +628,7 @@ func Test_meta_GetUUID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -731,6 +739,7 @@ func Test_meta_GetUUIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -840,6 +849,7 @@ func Test_meta_SetUUIDandMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -946,6 +956,7 @@ func Test_meta_SetUUIDandMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1056,6 +1067,7 @@ func Test_meta_DeleteMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1166,6 +1178,7 @@ func Test_meta_DeleteMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1276,6 +1289,7 @@ func Test_meta_DeleteUUID(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1386,6 +1400,7 @@ func Test_meta_DeleteUUIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/gateway/vald/usecase/vald_test.go b/pkg/gateway/vald/usecase/vald_test.go index f8d6f0dfc62..542bbff2a99 100644 --- a/pkg/gateway/vald/usecase/vald_test.go +++ b/pkg/gateway/vald/usecase/vald_test.go @@ -28,6 +28,8 @@ import ( "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/gateway/vald/config" "github.com/vdaas/vald/pkg/gateway/vald/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -186,6 +189,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -301,6 +305,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -412,6 +417,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -523,6 +529,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -634,6 +641,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/cassandra/config/config_test.go b/pkg/manager/backup/cassandra/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/manager/backup/cassandra/config/config_test.go +++ b/pkg/manager/backup/cassandra/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/cassandra/handler/grpc/handler_test.go b/pkg/manager/backup/cassandra/handler/grpc/handler_test.go index 30d30643ac4..456f2137712 100644 --- a/pkg/manager/backup/cassandra/handler/grpc/handler_test.go +++ b/pkg/manager/backup/cassandra/handler/grpc/handler_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/manager/backup/cassandra/model" "github.com/vdaas/vald/pkg/manager/backup/cassandra/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -79,6 +81,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -166,6 +169,7 @@ func Test_server_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -256,6 +260,7 @@ func Test_server_Locations(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -346,6 +351,7 @@ func Test_server_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +442,7 @@ func Test_server_RegisterMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -526,6 +533,7 @@ func Test_server_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -616,6 +624,7 @@ func Test_server_RemoveMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -706,6 +715,7 @@ func Test_server_RegisterIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -796,6 +806,7 @@ func Test_server_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -873,6 +884,7 @@ func Test_toBackupMetaVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -947,6 +959,7 @@ func Test_toModelMetaVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/cassandra/handler/grpc/option_test.go b/pkg/manager/backup/cassandra/handler/grpc/option_test.go index d8721a3b876..f5a69df4715 100644 --- a/pkg/manager/backup/cassandra/handler/grpc/option_test.go +++ b/pkg/manager/backup/cassandra/handler/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/manager/backup/cassandra/service" + + "go.uber.org/goleak" ) func TestWithCassandra(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithCassandra(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/cassandra/handler/rest/handler_test.go b/pkg/manager/backup/cassandra/handler/rest/handler_test.go index 33892cd7892..02c6cbd3b27 100644 --- a/pkg/manager/backup/cassandra/handler/rest/handler_test.go +++ b/pkg/manager/backup/cassandra/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/manager/backup" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_Locations(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_handler_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +440,7 @@ func Test_handler_RegisterMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -524,6 +531,7 @@ func Test_handler_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +622,7 @@ func Test_handler_RemoveMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -704,6 +713,7 @@ func Test_handler_RegisterIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -794,6 +804,7 @@ func Test_handler_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/cassandra/handler/rest/option_test.go b/pkg/manager/backup/cassandra/handler/rest/option_test.go index 605d15ec372..cb8c38c7355 100644 --- a/pkg/manager/backup/cassandra/handler/rest/option_test.go +++ b/pkg/manager/backup/cassandra/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/manager/backup" + + "go.uber.org/goleak" ) func TestWithBackup(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithBackup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/cassandra/router/option_test.go b/pkg/manager/backup/cassandra/router/option_test.go index e3211cca24d..dc5ef1d2487 100644 --- a/pkg/manager/backup/cassandra/router/option_test.go +++ b/pkg/manager/backup/cassandra/router/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/manager/backup/cassandra/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/cassandra/service/cassandra_test.go b/pkg/manager/backup/cassandra/service/cassandra_test.go index 1243563e4de..d4d622db0fa 100644 --- a/pkg/manager/backup/cassandra/service/cassandra_test.go +++ b/pkg/manager/backup/cassandra/service/cassandra_test.go @@ -21,10 +21,12 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/config" "github.com/vdaas/vald/internal/db/nosql/cassandra" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/manager/backup/cassandra/model" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -82,6 +84,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -165,6 +168,7 @@ func Test_client_Connect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -252,6 +256,7 @@ func Test_client_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -346,6 +351,7 @@ func Test_client_getMetaVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -440,6 +446,7 @@ func Test_client_GetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -534,6 +541,7 @@ func Test_client_GetIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -624,6 +632,7 @@ func Test_client_SetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -714,6 +723,7 @@ func Test_client_SetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -804,6 +814,7 @@ func Test_client_DeleteMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -894,6 +905,7 @@ func Test_client_DeleteMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -987,6 +999,7 @@ func Test_client_SetIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1077,6 +1090,7 @@ func Test_client_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/cassandra/usecase/backupd_test.go b/pkg/manager/backup/cassandra/usecase/backupd_test.go index 2702743244e..1267815ef27 100644 --- a/pkg/manager/backup/cassandra/usecase/backupd_test.go +++ b/pkg/manager/backup/cassandra/usecase/backupd_test.go @@ -21,13 +21,15 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability" "github.com/vdaas/vald/internal/runner" "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/manager/backup/cassandra/config" "github.com/vdaas/vald/pkg/manager/backup/cassandra/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -280,6 +284,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -379,6 +384,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -478,6 +484,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -577,6 +584,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/mysql/config/config_test.go b/pkg/manager/backup/mysql/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/manager/backup/mysql/config/config_test.go +++ b/pkg/manager/backup/mysql/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/mysql/handler/grpc/handler_test.go b/pkg/manager/backup/mysql/handler/grpc/handler_test.go index 96fa8660c92..230c9c9c27b 100644 --- a/pkg/manager/backup/mysql/handler/grpc/handler_test.go +++ b/pkg/manager/backup/mysql/handler/grpc/handler_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/manager/backup/mysql/model" "github.com/vdaas/vald/pkg/manager/backup/mysql/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -79,6 +81,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -166,6 +169,7 @@ func Test_server_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -256,6 +260,7 @@ func Test_server_Locations(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -346,6 +351,7 @@ func Test_server_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +442,7 @@ func Test_server_RegisterMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -526,6 +533,7 @@ func Test_server_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -616,6 +624,7 @@ func Test_server_RemoveMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -706,6 +715,7 @@ func Test_server_RegisterIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -796,6 +806,7 @@ func Test_server_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -873,6 +884,7 @@ func Test_toBackupMetaVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -947,6 +959,7 @@ func Test_toModelMetaVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/mysql/handler/grpc/option_test.go b/pkg/manager/backup/mysql/handler/grpc/option_test.go index 497d9b29427..ae8d5512b54 100644 --- a/pkg/manager/backup/mysql/handler/grpc/option_test.go +++ b/pkg/manager/backup/mysql/handler/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/manager/backup/mysql/service" + + "go.uber.org/goleak" ) func TestWithMySQL(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithMySQL(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/mysql/handler/rest/handler_test.go b/pkg/manager/backup/mysql/handler/rest/handler_test.go index 33892cd7892..02c6cbd3b27 100644 --- a/pkg/manager/backup/mysql/handler/rest/handler_test.go +++ b/pkg/manager/backup/mysql/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/manager/backup" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_Locations(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_handler_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +440,7 @@ func Test_handler_RegisterMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -524,6 +531,7 @@ func Test_handler_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +622,7 @@ func Test_handler_RemoveMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -704,6 +713,7 @@ func Test_handler_RegisterIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -794,6 +804,7 @@ func Test_handler_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/mysql/handler/rest/option_test.go b/pkg/manager/backup/mysql/handler/rest/option_test.go index 605d15ec372..cb8c38c7355 100644 --- a/pkg/manager/backup/mysql/handler/rest/option_test.go +++ b/pkg/manager/backup/mysql/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/manager/backup" + + "go.uber.org/goleak" ) func TestWithBackup(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithBackup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/mysql/router/option_test.go b/pkg/manager/backup/mysql/router/option_test.go index 4974e0761ed..098fa9c6121 100644 --- a/pkg/manager/backup/mysql/router/option_test.go +++ b/pkg/manager/backup/mysql/router/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/manager/backup/mysql/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/mysql/service/mysql_test.go b/pkg/manager/backup/mysql/service/mysql_test.go index 410aecc0733..99a977b7176 100644 --- a/pkg/manager/backup/mysql/service/mysql_test.go +++ b/pkg/manager/backup/mysql/service/mysql_test.go @@ -21,11 +21,13 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/config" "github.com/vdaas/vald/internal/db/rdb/mysql" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/tcp" "github.com/vdaas/vald/pkg/manager/backup/mysql/model" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -83,6 +85,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -166,6 +169,7 @@ func Test_client_Connect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -253,6 +257,7 @@ func Test_client_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -347,6 +352,7 @@ func Test_client_GetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -441,6 +447,7 @@ func Test_client_GetIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -531,6 +538,7 @@ func Test_client_SetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -621,6 +629,7 @@ func Test_client_SetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -711,6 +720,7 @@ func Test_client_DeleteMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -801,6 +811,7 @@ func Test_client_DeleteMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -894,6 +905,7 @@ func Test_client_SetIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -984,6 +996,7 @@ func Test_client_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/backup/mysql/usecase/backupd_test.go b/pkg/manager/backup/mysql/usecase/backupd_test.go index 884e51485e2..5268dab084c 100644 --- a/pkg/manager/backup/mysql/usecase/backupd_test.go +++ b/pkg/manager/backup/mysql/usecase/backupd_test.go @@ -21,13 +21,15 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability" "github.com/vdaas/vald/internal/runner" "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/manager/backup/mysql/config" "github.com/vdaas/vald/pkg/manager/backup/mysql/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -280,6 +284,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -379,6 +384,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -478,6 +484,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -577,6 +584,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/config/config_test.go b/pkg/manager/compressor/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/manager/compressor/config/config_test.go +++ b/pkg/manager/compressor/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/handler/grpc/handler_test.go b/pkg/manager/compressor/handler/grpc/handler_test.go index a3486a88d33..f316dc30f3f 100644 --- a/pkg/manager/compressor/handler/grpc/handler_test.go +++ b/pkg/manager/compressor/handler/grpc/handler_test.go @@ -22,9 +22,11 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/payload" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/manager/compressor/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -78,6 +80,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -171,6 +174,7 @@ func Test_server_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -269,6 +273,7 @@ func Test_server_Locations(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -367,6 +372,7 @@ func Test_server_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -465,6 +471,7 @@ func Test_server_RegisterMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -563,6 +570,7 @@ func Test_server_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -661,6 +669,7 @@ func Test_server_RemoveMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -759,6 +768,7 @@ func Test_server_RegisterIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -857,6 +867,7 @@ func Test_server_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/handler/grpc/option_test.go b/pkg/manager/compressor/handler/grpc/option_test.go index eb4313d6866..ef7945ebfc7 100644 --- a/pkg/manager/compressor/handler/grpc/option_test.go +++ b/pkg/manager/compressor/handler/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/manager/compressor/service" + + "go.uber.org/goleak" ) func TestWithCompressor(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithCompressor(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithBackup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithRegisterer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/handler/rest/handler_test.go b/pkg/manager/compressor/handler/rest/handler_test.go index d454e1040a6..3fae2ad60dc 100644 --- a/pkg/manager/compressor/handler/rest/handler_test.go +++ b/pkg/manager/compressor/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/manager/compressor" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_Locations(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_handler_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +440,7 @@ func Test_handler_RegisterMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -524,6 +531,7 @@ func Test_handler_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +622,7 @@ func Test_handler_RemoveMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -704,6 +713,7 @@ func Test_handler_RegisterIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -794,6 +804,7 @@ func Test_handler_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/handler/rest/option_test.go b/pkg/manager/compressor/handler/rest/option_test.go index 81ca16c1d78..9694543e9ea 100644 --- a/pkg/manager/compressor/handler/rest/option_test.go +++ b/pkg/manager/compressor/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/manager/compressor" + + "go.uber.org/goleak" ) func TestWithBackup(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithBackup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/router/option_test.go b/pkg/manager/compressor/router/option_test.go index 27323dd4395..c5bd1555304 100644 --- a/pkg/manager/compressor/router/option_test.go +++ b/pkg/manager/compressor/router/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/manager/compressor/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/service/backup_option_test.go b/pkg/manager/compressor/service/backup_option_test.go index 0a0b541b8dc..72c4ceaf3aa 100644 --- a/pkg/manager/compressor/service/backup_option_test.go +++ b/pkg/manager/compressor/service/backup_option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestWithBackupAddr(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithBackupAddr(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithBackupClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/service/backup_test.go b/pkg/manager/compressor/service/backup_test.go index 5fcfddc4451..a064bdb6b39 100644 --- a/pkg/manager/compressor/service/backup_test.go +++ b/pkg/manager/compressor/service/backup_test.go @@ -24,6 +24,8 @@ import ( "github.com/vdaas/vald/apis/grpc/payload" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestNewBackup(t *testing.T) { @@ -81,6 +83,7 @@ func TestNewBackup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -168,6 +171,7 @@ func Test_backup_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -262,6 +266,7 @@ func Test_backup_GetObject(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -356,6 +361,7 @@ func Test_backup_GetLocation(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -446,6 +452,7 @@ func Test_backup_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -536,6 +543,7 @@ func Test_backup_RegisterMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -626,6 +634,7 @@ func Test_backup_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -716,6 +725,7 @@ func Test_backup_RemoveMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -809,6 +819,7 @@ func Test_backup_RegisterIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -899,6 +910,7 @@ func Test_backup_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/service/compress_option_test.go b/pkg/manager/compressor/service/compress_option_test.go index 4d89097779a..178b006c89f 100644 --- a/pkg/manager/compressor/service/compress_option_test.go +++ b/pkg/manager/compressor/service/compress_option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/worker" + + "go.uber.org/goleak" ) func TestWithCompressAlgorithm(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithCompressAlgorithm(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithCompressionLevel(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithCompressorWorker(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +441,7 @@ func TestWithCompressorErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/service/compress_test.go b/pkg/manager/compressor/service/compress_test.go index 06a0cb09a88..ad28e8f39b8 100644 --- a/pkg/manager/compressor/service/compress_test.go +++ b/pkg/manager/compressor/service/compress_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/worker" + + "go.uber.org/goleak" ) func TestNewCompressor(t *testing.T) { @@ -82,6 +84,7 @@ func TestNewCompressor(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_compressor_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -284,6 +288,7 @@ func Test_compressor_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -394,6 +399,7 @@ func Test_compressor_dispatchCompress(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -504,6 +510,7 @@ func Test_compressor_dispatchDecompress(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +621,7 @@ func Test_compressor_Compress(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -724,6 +732,7 @@ func Test_compressor_Decompress(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -834,6 +843,7 @@ func Test_compressor_MultiCompress(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -944,6 +954,7 @@ func Test_compressor_MultiDecompress(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1037,6 +1048,7 @@ func Test_compressor_Len(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1130,6 +1142,7 @@ func Test_compressor_TotalRequested(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1223,6 +1236,7 @@ func Test_compressor_TotalCompleted(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/pkg/manager/compressor/service/registerer_option_test.go b/pkg/manager/compressor/service/registerer_option_test.go index 037a3f75dc7..46259262392 100644 --- a/pkg/manager/compressor/service/registerer_option_test.go +++ b/pkg/manager/compressor/service/registerer_option_test.go @@ -23,6 +23,8 @@ import ( client "github.com/vdaas/vald/internal/client/compressor" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/worker" + + "go.uber.org/goleak" ) func TestWithRegistererWorker(t *testing.T) { @@ -101,6 +103,7 @@ func TestWithRegistererWorker(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -213,6 +216,7 @@ func TestWithRegistererErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -325,6 +329,7 @@ func TestWithRegistererBackup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -437,6 +442,7 @@ func TestWithRegistererCompressor(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -549,6 +555,7 @@ func TestWithRegistererClient(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/service/registerer_test.go b/pkg/manager/compressor/service/registerer_test.go index eb7e76d6cf0..03baf420490 100644 --- a/pkg/manager/compressor/service/registerer_test.go +++ b/pkg/manager/compressor/service/registerer_test.go @@ -27,6 +27,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/worker" + + "go.uber.org/goleak" ) func TestNewRegisterer(t *testing.T) { @@ -84,6 +86,7 @@ func TestNewRegisterer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -185,6 +188,7 @@ func Test_registerer_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -300,6 +304,7 @@ func Test_registerer_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -411,6 +416,7 @@ func Test_registerer_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -525,6 +531,7 @@ func Test_registerer_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -639,6 +646,7 @@ func Test_registerer_RegisterMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -740,6 +748,7 @@ func Test_registerer_Len(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -841,6 +850,7 @@ func Test_registerer_TotalRequested(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -942,6 +952,7 @@ func Test_registerer_TotalCompleted(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -1056,6 +1067,7 @@ func Test_registerer_dispatch(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1167,6 +1179,7 @@ func Test_registerer_registerProcessFunc(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1278,6 +1291,7 @@ func Test_registerer_forwardMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/compressor/usecase/compressord_test.go b/pkg/manager/compressor/usecase/compressord_test.go index f7048841d1d..acf0425cf46 100644 --- a/pkg/manager/compressor/usecase/compressord_test.go +++ b/pkg/manager/compressor/usecase/compressord_test.go @@ -28,6 +28,8 @@ import ( "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/manager/compressor/config" "github.com/vdaas/vald/pkg/manager/compressor/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -183,6 +186,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -294,6 +298,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -401,6 +406,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -508,6 +514,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -615,6 +622,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/index/config/config_test.go b/pkg/manager/index/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/manager/index/config/config_test.go +++ b/pkg/manager/index/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/index/handler/grpc/handler_test.go b/pkg/manager/index/handler/grpc/handler_test.go index be20c238c73..6931e288626 100644 --- a/pkg/manager/index/handler/grpc/handler_test.go +++ b/pkg/manager/index/handler/grpc/handler_test.go @@ -22,10 +22,12 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/manager/index" "github.com/vdaas/vald/apis/grpc/payload" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/manager/index/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -79,6 +81,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -166,6 +169,7 @@ func Test_server_IndexInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/index/handler/grpc/option_test.go b/pkg/manager/index/handler/grpc/option_test.go index a203a95d815..81d914eb230 100644 --- a/pkg/manager/index/handler/grpc/option_test.go +++ b/pkg/manager/index/handler/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/manager/index/service" + + "go.uber.org/goleak" ) func TestWithIndexer(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithIndexer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/index/handler/rest/handler_test.go b/pkg/manager/index/handler/rest/handler_test.go index d1abef82992..5f89220f1c4 100644 --- a/pkg/manager/index/handler/rest/handler_test.go +++ b/pkg/manager/index/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/manager/index" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_Index(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_IndexInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/index/handler/rest/option_test.go b/pkg/manager/index/handler/rest/option_test.go index 2fee34cbd08..42689be6d6a 100644 --- a/pkg/manager/index/handler/rest/option_test.go +++ b/pkg/manager/index/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/manager/index" + + "go.uber.org/goleak" ) func TestWithIndexer(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithIndexer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/index/router/option_test.go b/pkg/manager/index/router/option_test.go index 0daf962a02c..466a925aa7c 100644 --- a/pkg/manager/index/router/option_test.go +++ b/pkg/manager/index/router/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/manager/index/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/index/service/indexer_test.go b/pkg/manager/index/service/indexer_test.go index 053a47fcc55..abacbdbfa1a 100644 --- a/pkg/manager/index/service/indexer_test.go +++ b/pkg/manager/index/service/indexer_test.go @@ -27,6 +27,8 @@ import ( "github.com/vdaas/vald/internal/client/discoverer" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -84,6 +86,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -204,6 +207,7 @@ func Test_index_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -338,6 +342,7 @@ func Test_index_execute(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -469,6 +474,7 @@ func Test_index_loadInfos(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -590,6 +596,7 @@ func Test_index_IsIndexing(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -711,6 +718,7 @@ func Test_index_NumberOfUUIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -832,6 +840,7 @@ func Test_index_NumberOfUncommittedUUIDs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/pkg/manager/index/service/option_test.go b/pkg/manager/index/service/option_test.go index 782eb587a3f..6247a8371b3 100644 --- a/pkg/manager/index/service/option_test.go +++ b/pkg/manager/index/service/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/client/discoverer" "github.com/vdaas/vald/internal/errgroup" + + "go.uber.org/goleak" ) func TestWithIndexingConcurrency(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithIndexingConcurrency(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithIndexingDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithIndexingDurationLimit(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +441,7 @@ func TestWithMinUncommitted(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -548,6 +554,7 @@ func TestWithCreationPoolSize(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -660,6 +667,7 @@ func TestWithDiscoverer(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -772,6 +780,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/index/usecase/indexer_test.go b/pkg/manager/index/usecase/indexer_test.go index 709a6971f21..ce4317761e8 100644 --- a/pkg/manager/index/usecase/indexer_test.go +++ b/pkg/manager/index/usecase/indexer_test.go @@ -21,13 +21,15 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability" "github.com/vdaas/vald/internal/runner" "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/manager/index/config" "github.com/vdaas/vald/pkg/manager/index/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -280,6 +284,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -379,6 +384,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -478,6 +484,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -577,6 +584,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/agent/config/config_test.go b/pkg/manager/replication/agent/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/manager/replication/agent/config/config_test.go +++ b/pkg/manager/replication/agent/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/agent/handler/grpc/handler_test.go b/pkg/manager/replication/agent/handler/grpc/handler_test.go index c7b943f3100..2d546912042 100644 --- a/pkg/manager/replication/agent/handler/grpc/handler_test.go +++ b/pkg/manager/replication/agent/handler/grpc/handler_test.go @@ -22,9 +22,11 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/payload" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/manager/replication/agent/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -78,6 +80,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -168,6 +171,7 @@ func Test_server_Recover(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -262,6 +266,7 @@ func Test_server_Rebalance(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -356,6 +361,7 @@ func Test_server_AgentInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/agent/handler/rest/handler_test.go b/pkg/manager/replication/agent/handler/rest/handler_test.go index 33892cd7892..02c6cbd3b27 100644 --- a/pkg/manager/replication/agent/handler/rest/handler_test.go +++ b/pkg/manager/replication/agent/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/manager/backup" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_GetVector(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_Locations(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_handler_Register(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +440,7 @@ func Test_handler_RegisterMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -524,6 +531,7 @@ func Test_handler_Remove(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +622,7 @@ func Test_handler_RemoveMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -704,6 +713,7 @@ func Test_handler_RegisterIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -794,6 +804,7 @@ func Test_handler_RemoveIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/agent/handler/rest/option_test.go b/pkg/manager/replication/agent/handler/rest/option_test.go index 605d15ec372..cb8c38c7355 100644 --- a/pkg/manager/replication/agent/handler/rest/option_test.go +++ b/pkg/manager/replication/agent/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/manager/backup" + + "go.uber.org/goleak" ) func TestWithBackup(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithBackup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/agent/router/option_test.go b/pkg/manager/replication/agent/router/option_test.go index fad39d4452c..04bbfbb4066 100644 --- a/pkg/manager/replication/agent/router/option_test.go +++ b/pkg/manager/replication/agent/router/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/manager/replication/agent/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/agent/usecase/backupd_test.go b/pkg/manager/replication/agent/usecase/backupd_test.go index dce57ce598c..9ac5bac2fc0 100644 --- a/pkg/manager/replication/agent/usecase/backupd_test.go +++ b/pkg/manager/replication/agent/usecase/backupd_test.go @@ -21,13 +21,15 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability" "github.com/vdaas/vald/internal/runner" "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/manager/replication/agent/config" "github.com/vdaas/vald/pkg/manager/replication/agent/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -280,6 +284,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -379,6 +384,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -478,6 +484,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -577,6 +584,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/controller/config/config_test.go b/pkg/manager/replication/controller/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/manager/replication/controller/config/config_test.go +++ b/pkg/manager/replication/controller/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/controller/handler/grpc/handler_test.go b/pkg/manager/replication/controller/handler/grpc/handler_test.go index c70957d5239..bb3f1fbe052 100644 --- a/pkg/manager/replication/controller/handler/grpc/handler_test.go +++ b/pkg/manager/replication/controller/handler/grpc/handler_test.go @@ -22,10 +22,12 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/manager/replication/controller" "github.com/vdaas/vald/apis/grpc/payload" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/manager/replication/controller/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -79,6 +81,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -166,6 +169,7 @@ func Test_server_ReplicationInfo(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/controller/handler/grpc/option_test.go b/pkg/manager/replication/controller/handler/grpc/option_test.go index 113ae5c51be..5a4d0f204b3 100644 --- a/pkg/manager/replication/controller/handler/grpc/option_test.go +++ b/pkg/manager/replication/controller/handler/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/manager/replication/controller/service" + + "go.uber.org/goleak" ) func TestWithReplicator(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithReplicator(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/controller/handler/rest/handler_test.go b/pkg/manager/replication/controller/handler/rest/handler_test.go index 2b1c3d63514..40e699aad3b 100644 --- a/pkg/manager/replication/controller/handler/rest/handler_test.go +++ b/pkg/manager/replication/controller/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/manager/replication/controller" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_Index(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/controller/handler/rest/option_test.go b/pkg/manager/replication/controller/handler/rest/option_test.go index 005e0c349ec..65cbe15b3e8 100644 --- a/pkg/manager/replication/controller/handler/rest/option_test.go +++ b/pkg/manager/replication/controller/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/manager/replication/controller" + + "go.uber.org/goleak" ) func TestWithReplicator(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithReplicator(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/controller/router/option_test.go b/pkg/manager/replication/controller/router/option_test.go index c7f76d86892..277dee1a9e0 100644 --- a/pkg/manager/replication/controller/router/option_test.go +++ b/pkg/manager/replication/controller/router/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/manager/replication/controller/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/controller/service/discover_test.go b/pkg/manager/replication/controller/service/discover_test.go index 7b889795d78..78053e1cf0d 100644 --- a/pkg/manager/replication/controller/service/discover_test.go +++ b/pkg/manager/replication/controller/service/discover_test.go @@ -29,6 +29,8 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/k8s" "github.com/vdaas/vald/internal/net/grpc" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -86,6 +88,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -191,6 +194,7 @@ func Test_replicator_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -296,6 +300,7 @@ func Test_replicator_GetCurrentPodIPs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -407,6 +412,7 @@ func Test_replicator_SendRecoveryRequest(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/controller/service/option_test.go b/pkg/manager/replication/controller/service/option_test.go index 4ec1d58c99c..f5a7d21d8b6 100644 --- a/pkg/manager/replication/controller/service/option_test.go +++ b/pkg/manager/replication/controller/service/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/internal/errgroup" + + "go.uber.org/goleak" ) func TestWithName(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithName(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -211,6 +214,7 @@ func TestWithNamespace(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -323,6 +327,7 @@ func TestWithRecoverCheckDuration(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -435,6 +440,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/manager/replication/controller/usecase/discovered_test.go b/pkg/manager/replication/controller/usecase/discovered_test.go index 928f4eb3edb..ef16f551620 100644 --- a/pkg/manager/replication/controller/usecase/discovered_test.go +++ b/pkg/manager/replication/controller/usecase/discovered_test.go @@ -21,13 +21,15 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability" "github.com/vdaas/vald/internal/runner" "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/manager/replication/controller/config" "github.com/vdaas/vald/pkg/manager/replication/controller/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -280,6 +284,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -379,6 +384,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -478,6 +484,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -577,6 +584,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/cassandra/config/config_test.go b/pkg/meta/cassandra/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/meta/cassandra/config/config_test.go +++ b/pkg/meta/cassandra/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/cassandra/handler/grpc/handler_test.go b/pkg/meta/cassandra/handler/grpc/handler_test.go index 9ef700e17ae..b38159ffc07 100644 --- a/pkg/meta/cassandra/handler/grpc/handler_test.go +++ b/pkg/meta/cassandra/handler/grpc/handler_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/apis/grpc/payload" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/meta/cassandra/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -79,6 +81,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -166,6 +169,7 @@ func Test_server_GetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -256,6 +260,7 @@ func Test_server_GetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -346,6 +351,7 @@ func Test_server_GetMetaInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +442,7 @@ func Test_server_GetMetasInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -526,6 +533,7 @@ func Test_server_SetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -616,6 +624,7 @@ func Test_server_SetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -706,6 +715,7 @@ func Test_server_DeleteMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -796,6 +806,7 @@ func Test_server_DeleteMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -886,6 +897,7 @@ func Test_server_DeleteMetaInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -976,6 +988,7 @@ func Test_server_DeleteMetasInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/cassandra/handler/grpc/option_test.go b/pkg/meta/cassandra/handler/grpc/option_test.go index bf9915bbf38..c6369e43451 100644 --- a/pkg/meta/cassandra/handler/grpc/option_test.go +++ b/pkg/meta/cassandra/handler/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/meta/cassandra/service" + + "go.uber.org/goleak" ) func TestWithCassandra(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithCassandra(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/cassandra/handler/rest/handler_test.go b/pkg/meta/cassandra/handler/rest/handler_test.go index e5df11d8de5..9ed6532f524 100644 --- a/pkg/meta/cassandra/handler/rest/handler_test.go +++ b/pkg/meta/cassandra/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/meta" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_Index(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_GetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_handler_GetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +440,7 @@ func Test_handler_GetMetaInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -524,6 +531,7 @@ func Test_handler_GetMetasInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +622,7 @@ func Test_handler_SetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -704,6 +713,7 @@ func Test_handler_SetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -794,6 +804,7 @@ func Test_handler_DeleteMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -884,6 +895,7 @@ func Test_handler_DeleteMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -974,6 +986,7 @@ func Test_handler_DeleteMetaInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1064,6 +1077,7 @@ func Test_handler_DeleteMetasInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/cassandra/handler/rest/option_test.go b/pkg/meta/cassandra/handler/rest/option_test.go index 626ea914786..64cbcbfdf94 100644 --- a/pkg/meta/cassandra/handler/rest/option_test.go +++ b/pkg/meta/cassandra/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/meta" + + "go.uber.org/goleak" ) func TestWithMeta(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/cassandra/router/option_test.go b/pkg/meta/cassandra/router/option_test.go index 5f922ab68c2..3934edae8ae 100644 --- a/pkg/meta/cassandra/router/option_test.go +++ b/pkg/meta/cassandra/router/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/meta/cassandra/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/cassandra/service/cassandra_test.go b/pkg/meta/cassandra/service/cassandra_test.go index 440ccf22ad4..36c459dce9c 100644 --- a/pkg/meta/cassandra/service/cassandra_test.go +++ b/pkg/meta/cassandra/service/cassandra_test.go @@ -25,6 +25,8 @@ import ( "github.com/vdaas/vald/internal/config" "github.com/vdaas/vald/internal/db/nosql/cassandra" "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -82,6 +84,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -168,6 +171,7 @@ func Test_client_Connect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -259,6 +263,7 @@ func Test_client_Close(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -354,6 +359,7 @@ func Test_client_Get(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -449,6 +455,7 @@ func Test_client_GetMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -544,6 +551,7 @@ func Test_client_GetInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -639,6 +647,7 @@ func Test_client_GetInverseMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -733,6 +742,7 @@ func Test_client_Set(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -824,6 +834,7 @@ func Test_client_SetMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -919,6 +930,7 @@ func Test_client_deleteByKeys(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1014,6 +1026,7 @@ func Test_client_Delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1109,6 +1122,7 @@ func Test_client_DeleteMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1204,6 +1218,7 @@ func Test_client_deleteByValues(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1299,6 +1314,7 @@ func Test_client_DeleteInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1394,6 +1410,7 @@ func Test_client_DeleteInverseMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/cassandra/usecase/meta_test.go b/pkg/meta/cassandra/usecase/meta_test.go index 59c49b0089e..b503e9b8e9e 100644 --- a/pkg/meta/cassandra/usecase/meta_test.go +++ b/pkg/meta/cassandra/usecase/meta_test.go @@ -21,13 +21,15 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability" "github.com/vdaas/vald/internal/runner" "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/meta/cassandra/config" "github.com/vdaas/vald/pkg/meta/cassandra/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -280,6 +284,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -379,6 +384,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -478,6 +484,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -577,6 +584,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/redis/config/config_test.go b/pkg/meta/redis/config/config_test.go index 03100fbcef1..e8090717ead 100644 --- a/pkg/meta/redis/config/config_test.go +++ b/pkg/meta/redis/config/config_test.go @@ -21,7 +21,8 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" ) func TestNewConfig(t *testing.T) { @@ -79,6 +80,7 @@ func TestNewConfig(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/redis/handler/grpc/handler_test.go b/pkg/meta/redis/handler/grpc/handler_test.go index 127f07ceaf1..0ccf46a78fe 100644 --- a/pkg/meta/redis/handler/grpc/handler_test.go +++ b/pkg/meta/redis/handler/grpc/handler_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/apis/grpc/payload" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/pkg/meta/redis/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -79,6 +81,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -166,6 +169,7 @@ func Test_server_GetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -256,6 +260,7 @@ func Test_server_GetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -346,6 +351,7 @@ func Test_server_GetMetaInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -436,6 +442,7 @@ func Test_server_GetMetasInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -526,6 +533,7 @@ func Test_server_SetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -616,6 +624,7 @@ func Test_server_SetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -706,6 +715,7 @@ func Test_server_DeleteMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -796,6 +806,7 @@ func Test_server_DeleteMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -886,6 +897,7 @@ func Test_server_DeleteMetaInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -976,6 +988,7 @@ func Test_server_DeleteMetasInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/redis/handler/grpc/option_test.go b/pkg/meta/redis/handler/grpc/option_test.go index 5cd7d499362..5f70cec213f 100644 --- a/pkg/meta/redis/handler/grpc/option_test.go +++ b/pkg/meta/redis/handler/grpc/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/pkg/meta/redis/service" + + "go.uber.org/goleak" ) func TestWithRedis(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithRedis(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/redis/handler/rest/handler_test.go b/pkg/meta/redis/handler/rest/handler_test.go index e5df11d8de5..9ed6532f524 100644 --- a/pkg/meta/redis/handler/rest/handler_test.go +++ b/pkg/meta/redis/handler/rest/handler_test.go @@ -22,8 +22,10 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/apis/grpc/meta" + "github.com/vdaas/vald/internal/errors" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -77,6 +79,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -164,6 +167,7 @@ func Test_handler_Index(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -254,6 +258,7 @@ func Test_handler_GetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -344,6 +349,7 @@ func Test_handler_GetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -434,6 +440,7 @@ func Test_handler_GetMetaInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -524,6 +531,7 @@ func Test_handler_GetMetasInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +622,7 @@ func Test_handler_SetMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -704,6 +713,7 @@ func Test_handler_SetMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -794,6 +804,7 @@ func Test_handler_DeleteMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -884,6 +895,7 @@ func Test_handler_DeleteMetas(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -974,6 +986,7 @@ func Test_handler_DeleteMetaInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1064,6 +1077,7 @@ func Test_handler_DeleteMetasInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/redis/handler/rest/option_test.go b/pkg/meta/redis/handler/rest/option_test.go index 626ea914786..64cbcbfdf94 100644 --- a/pkg/meta/redis/handler/rest/option_test.go +++ b/pkg/meta/redis/handler/rest/option_test.go @@ -21,6 +21,8 @@ import ( "testing" "github.com/vdaas/vald/apis/grpc/meta" + + "go.uber.org/goleak" ) func TestWithMeta(t *testing.T) { @@ -99,6 +101,7 @@ func TestWithMeta(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/redis/router/option_test.go b/pkg/meta/redis/router/option_test.go index d077420185b..62a3f92cb0d 100644 --- a/pkg/meta/redis/router/option_test.go +++ b/pkg/meta/redis/router/option_test.go @@ -22,6 +22,8 @@ import ( "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/pkg/meta/redis/handler/rest" + + "go.uber.org/goleak" ) func TestWithHandler(t *testing.T) { @@ -100,6 +102,7 @@ func TestWithHandler(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +215,7 @@ func TestWithTimeout(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -324,6 +328,7 @@ func TestWithErrGroup(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/redis/service/redis_test.go b/pkg/meta/redis/service/redis_test.go index 1b707399c70..11c4ad5ea55 100644 --- a/pkg/meta/redis/service/redis_test.go +++ b/pkg/meta/redis/service/redis_test.go @@ -26,6 +26,8 @@ import ( "github.com/vdaas/vald/internal/db/kvs/redis" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/tcp" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -83,6 +85,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -168,6 +171,7 @@ func Test_client_Disconnect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc() } @@ -271,6 +275,7 @@ func Test_client_Connect(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -378,6 +383,7 @@ func Test_client_Get(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -485,6 +491,7 @@ func Test_client_GetMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -592,6 +599,7 @@ func Test_client_GetInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -699,6 +707,7 @@ func Test_client_GetInverseMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -805,6 +814,7 @@ func Test_client_appendPrefix(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -915,6 +925,7 @@ func Test_client_get(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1025,6 +1036,7 @@ func Test_client_getMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1131,6 +1143,7 @@ func Test_client_Set(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1234,6 +1247,7 @@ func Test_client_SetMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1341,6 +1355,7 @@ func Test_client_Delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1448,6 +1463,7 @@ func Test_client_DeleteMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1555,6 +1571,7 @@ func Test_client_DeleteInverse(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1662,6 +1679,7 @@ func Test_client_DeleteInverseMultiple(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1775,6 +1793,7 @@ func Test_client_delete(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1888,6 +1907,7 @@ func Test_client_deleteMulti(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/meta/redis/usecase/meta_test.go b/pkg/meta/redis/usecase/meta_test.go index 4900896ffcb..9852250655d 100644 --- a/pkg/meta/redis/usecase/meta_test.go +++ b/pkg/meta/redis/usecase/meta_test.go @@ -21,13 +21,15 @@ import ( "reflect" "testing" - "github.com/cockroachdb/errors" "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability" "github.com/vdaas/vald/internal/runner" "github.com/vdaas/vald/internal/servers/starter" "github.com/vdaas/vald/pkg/meta/redis/config" "github.com/vdaas/vald/pkg/meta/redis/service" + + "go.uber.org/goleak" ) func TestNew(t *testing.T) { @@ -85,6 +87,7 @@ func TestNew(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -177,6 +180,7 @@ func Test_run_PreStart(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -280,6 +284,7 @@ func Test_run_Start(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -379,6 +384,7 @@ func Test_run_PreStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -478,6 +484,7 @@ func Test_run_Stop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -577,6 +584,7 @@ func Test_run_PostStop(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/tools/cli/loadtest/config/config_test.go b/pkg/tools/cli/loadtest/config/config_test.go new file mode 100644 index 00000000000..e8090717ead --- /dev/null +++ b/pkg/tools/cli/loadtest/config/config_test.go @@ -0,0 +1,101 @@ +// +// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Package setting stores all server application settings +package config + +import ( + "reflect" + "testing" + + "github.com/vdaas/vald/internal/errors" + "go.uber.org/goleak" +) + +func TestNewConfig(t *testing.T) { + type args struct { + path string + } + type want struct { + wantCfg *Data + err error + } + type test struct { + name string + args args + want want + checkFunc func(want, *Data, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, gotCfg *Data, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + if !reflect.DeepEqual(gotCfg, w.wantCfg) { + return errors.Errorf("got = %v, want %v", gotCfg, w.wantCfg) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + path: "", + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + path: "", + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + gotCfg, err := NewConfig(test.args.path) + if err := test.checkFunc(test.want, gotCfg, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} diff --git a/pkg/tools/cli/loadtest/usecase/load_test.go b/pkg/tools/cli/loadtest/usecase/load_test.go new file mode 100644 index 00000000000..8b14dad49fd --- /dev/null +++ b/pkg/tools/cli/loadtest/usecase/load_test.go @@ -0,0 +1,549 @@ +// +// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package usecase + +import ( + "context" + "reflect" + "testing" + + "github.com/vdaas/vald/internal/errgroup" + "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/runner" + "github.com/vdaas/vald/pkg/agent/ngt/config" + + "go.uber.org/goleak" +) + +func TestNew(t *testing.T) { + type args struct { + cfg *config.Data + } + type want struct { + wantR runner.Runner + err error + } + type test struct { + name string + args args + want want + checkFunc func(want, runner.Runner, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, gotR runner.Runner, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + if !reflect.DeepEqual(gotR, w.wantR) { + return errors.Errorf("got = %v, want %v", gotR, w.wantR) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + + gotR, err := New(test.args.cfg) + if err := test.checkFunc(test.want, gotR, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_run_PreStart(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + eg errgroup.Group + cfg *config.Data + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + r := &run{ + eg: test.fields.eg, + cfg: test.fields.cfg, + } + + err := r.PreStart(test.args.ctx) + if err := test.checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_run_Start(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + eg errgroup.Group + cfg *config.Data + } + type want struct { + want <-chan error + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, <-chan error, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, got <-chan error, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got = %v, want %v", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + r := &run{ + eg: test.fields.eg, + cfg: test.fields.cfg, + } + + got, err := r.Start(test.args.ctx) + if err := test.checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_run_PreStop(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + eg errgroup.Group + cfg *config.Data + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + r := &run{ + eg: test.fields.eg, + cfg: test.fields.cfg, + } + + err := r.PreStop(test.args.ctx) + if err := test.checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_run_Stop(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + eg errgroup.Group + cfg *config.Data + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + r := &run{ + eg: test.fields.eg, + cfg: test.fields.cfg, + } + + err := r.Stop(test.args.ctx) + if err := test.checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +} + +func Test_run_PostStop(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + eg errgroup.Group + cfg *config.Data + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + eg: nil, + cfg: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, test := range tests { + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(t) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + r := &run{ + eg: test.fields.eg, + cfg: test.fields.cfg, + } + + err := r.PostStop(test.args.ctx) + if err := test.checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + + }) + } +}