From 1b6a344e55117c2f1435191e3301eda472cac3dd Mon Sep 17 00:00:00 2001 From: Yusuke Kato Date: Thu, 8 Sep 2022 15:12:08 +0900 Subject: [PATCH] refactor internal package (net, file, logger) (#1768) * refactor internal packages Signed-off-by: kpango * fix Signed-off-by: kpango Signed-off-by: kpango --- Makefile.d/test.mk | 4 +- apis/docs/v1/docs.md | 142 +- charts/vald/README.md | 57 +- charts/vald/values.go | 97 +- example/client/go.mod | 4 +- example/client/go.sum | 8 +- go.mod | 148 +- go.sum | 350 ++--- hack/go.mod.default | 23 +- internal/backoff/backoff_test.go | 6 +- internal/backoff/option_test.go | 3 +- internal/cache/cache_test.go | 3 +- internal/cache/cacher/cacher_test.go | 6 +- internal/cache/gache/gache_test.go | 18 +- internal/cache/gache/option_test.go | 18 +- internal/cache/option_test.go | 12 +- internal/compress/compress_test.go | 30 + internal/compress/gob_test.go | 30 +- internal/compress/gzip_option_test.go | 11 +- internal/compress/gzip_test.go | 41 +- internal/compress/lz4_option_test.go | 10 +- internal/compress/lz4_test.go | 41 +- internal/compress/zstd_option_test.go | 6 +- internal/compress/zstd_test.go | 30 +- internal/config/blob_test.go | 12 +- internal/config/compress_test.go | 15 +- internal/config/config_test.go | 18 +- internal/config/discoverer.go | 70 + internal/config/discoverer_test.go | 867 +++++++++- internal/config/log_test.go | 3 +- internal/config/mysql_test.go | 3 +- internal/config/ngt_test.go | 3 +- internal/config/tls_test.go | 6 +- internal/db/kvs/redis/option_test.go | 84 +- internal/db/kvs/redis/redis_test.go | 18 +- internal/db/nosql/cassandra/cassandra_test.go | 39 +- .../db/nosql/cassandra/conviction_test.go | 9 +- internal/db/nosql/cassandra/option_test.go | 156 +- internal/db/rdb/mysql/model_test.go | 9 +- internal/db/rdb/mysql/mysql_test.go | 42 +- internal/db/rdb/mysql/option_test.go | 51 +- internal/db/storage/blob/s3/option_test.go | 27 +- .../db/storage/blob/s3/reader/option_test.go | 18 +- .../db/storage/blob/s3/reader/reader_test.go | 18 +- internal/db/storage/blob/s3/s3_test.go | 15 +- .../s3/sdk/s3/s3manager/s3manager_test.go | 6 +- .../db/storage/blob/s3/session/option_test.go | 51 +- .../storage/blob/s3/session/session_test.go | 6 +- .../db/storage/blob/s3/writer/option_test.go | 15 +- .../db/storage/blob/s3/writer/writer_test.go | 15 +- internal/encoding/json/json_test.go | 6 +- internal/errgroup/group_test.go | 44 +- internal/errors/blob_test.go | 24 +- internal/errors/cassandra_test.go | 48 +- internal/errors/compressor_test.go | 12 +- internal/errors/discoverer_test.go | 15 +- internal/errors/errors_test.go | 48 +- internal/errors/file_test.go | 12 +- internal/errors/filter_test.go | 3 +- internal/errors/grpc_test.go | 24 +- internal/errors/http_test.go | 24 +- internal/errors/info_test.go | 6 +- internal/errors/io_test.go | 9 +- internal/errors/mysql_test.go | 42 +- internal/errors/net_test.go | 12 +- internal/errors/ngt_test.go | 66 +- internal/errors/redis_test.go | 36 +- internal/errors/tls.go | 4 + internal/errors/unit_test.go | 3 +- internal/errors/vald_test.go | 6 +- internal/file/file.go | 20 +- internal/file/file_test.go | 6 +- internal/file/watch/option_test.go | 27 +- internal/file/watch/watch_test.go | 18 +- internal/info/info.go | 35 +- internal/info/info_test.go | 119 +- internal/info/option_test.go | 9 +- internal/log/format/format_test.go | 6 +- internal/log/glg/glg_test.go | 72 +- internal/log/level/level_test.go | 6 +- internal/log/log_test.go | 39 +- internal/log/logger/type_test.go | 6 +- internal/log/mock/logger_test.go | 30 +- internal/log/mock/retry_test.go | 6 +- internal/log/option_test.go | 12 +- internal/log/retry/option_test.go | 6 +- internal/log/retry/retry_test.go | 9 +- internal/log/zap/option_test.go | 9 +- internal/log/zap/zap_test.go | 42 +- internal/net/control/control_test.go | 10 +- internal/net/dialer.go | 219 ++- internal/net/dialer_test.go | 1399 +++++++++-------- internal/net/grpc/addrs_test.go | 8 - internal/net/grpc/client_test.go | 512 ++++-- internal/net/grpc/codec_test.go | 7 +- internal/net/grpc/context_test.go | 5 +- .../net/grpc/credentials/credentials_test.go | 5 +- .../net/grpc/errdetails/errdetails_test.go | 4 + internal/net/grpc/grpcconns_test.go | 14 - internal/net/grpc/health/health_test.go | 6 +- .../server/logging/accesslog_test.go | 7 +- .../server/recover/recover_test.go | 6 +- .../interceptor/server/trace/payload_test.go | 10 +- internal/net/grpc/logger/logger_test.go | 29 +- internal/net/grpc/metric/client_test.go | 2 - internal/net/grpc/metric/server_test.go | 5 +- internal/net/grpc/option_test.go | 32 - internal/net/grpc/pool/option_test.go | 13 - internal/net/grpc/pool/pool.go | 27 +- internal/net/grpc/pool/pool_test.go | 23 +- internal/net/grpc/proto/proto_test.go | 11 +- internal/net/grpc/server_test.go | 18 +- internal/net/grpc/status/status_test.go | 31 +- internal/net/grpc/stream_test.go | 3 - internal/net/http/client/client_test.go | 9 +- internal/net/http/client/option_test.go | 103 +- internal/net/http/dump/dump_test.go | 16 +- internal/net/http/json/json_test.go | 195 ++- .../net/http/middleware/middleware_test.go | 24 + internal/net/http/middleware/option_test.go | 25 +- internal/net/http/middleware/timeout_test.go | 213 +-- internal/net/http/rest/rest_test.go | 16 +- internal/net/http/routing/option_test.go | 48 +- internal/net/http/routing/router_test.go | 80 +- internal/net/http/transport/option_test.go | 18 +- internal/net/http/transport/roundtrip_test.go | 33 +- internal/net/net.go | 16 +- internal/net/net_test.go | 437 ++--- internal/net/option.go | 13 +- internal/net/option_test.go | 80 +- .../client/google/option_test.go | 1289 +++++++++++++++ .../collector/collector_option_test.go | 21 +- .../observability/collector/collector_test.go | 30 +- .../prometheus/prometheus_option_test.go | 9 +- .../exporter/prometheus/prometheus_test.go | 15 +- .../metrics/agent/sidecar/sidecar_test.go | 18 +- .../metrics/manager/index/index_test.go | 12 +- .../observability/metrics/mem/mem_test.go | 12 +- .../observability/metrics/metrics_test.go | 12 +- .../metrics/runtime/cgo/cgo_test.go | 12 +- .../runtime/goroutine/goroutine_test.go | 12 +- .../metrics/version/version_test.go | 15 +- .../observability_option_test.go | 12 +- internal/observability/observability_test.go | 15 +- .../observability/trace/trace_option_test.go | 6 +- internal/params/option_test.go | 18 +- internal/params/params_test.go | 12 +- internal/runner/option_test.go | 12 +- internal/runner/runner_race_test.go | 3 +- internal/runner/runner_test.go | 3 +- internal/safety/safety_bench_test.go | 6 +- internal/safety/safety_test.go | 9 +- internal/servers/starter/starter_test.go | 18 +- internal/singleflight/singleflight_test.go | 6 +- internal/strings/strings.go | 1 + internal/test/data/backup/100index/grp | Bin 12 -> 0 bytes internal/test/data/backup/100index/obj | Bin 8 -> 0 bytes internal/test/data/backup/100index/prf | 26 - internal/test/data/backup/100index/tre | Bin 28 -> 0 bytes internal/test/goleak/goleak.go | 10 +- internal/test/goleak/goleak_test.go | 76 +- internal/test/testdata_test.go | 6 +- internal/timeutil/time_bench_test.go | 6 +- internal/timeutil/time_test.go | 3 +- internal/tls/tls.go | 7 +- internal/tls/tls_test.go | 9 +- internal/unit/unit_test.go | 3 +- internal/worker/queue_option_test.go | 9 +- internal/worker/queue_test.go | 21 +- internal/worker/worker_option_test.go | 24 +- internal/worker/worker_test.go | 33 +- k8s/agent/configmap.yaml | 2 +- k8s/discoverer/configmap.yaml | 2 +- k8s/discoverer/deployment.yaml | 2 +- k8s/gateway/lb/configmap.yaml | 2 +- k8s/gateway/lb/deployment.yaml | 2 +- k8s/manager/index/configmap.yaml | 2 +- k8s/manager/index/deployment.yaml | 2 +- .../core/ngt/handler/grpc/handler_test.go | 6 +- pkg/agent/core/ngt/handler/grpc/index_test.go | 109 +- .../core/ngt/handler/grpc/insert_test.go | 782 ++++----- .../ngt/handler/grpc/linear_search_test.go | 13 +- .../core/ngt/handler/grpc/object_test.go | 257 +-- .../core/ngt/handler/grpc/option_test.go | 6 - .../core/ngt/handler/grpc/remove_test.go | 41 +- .../core/ngt/handler/grpc/search_test.go | 58 +- .../core/ngt/handler/grpc/update_test.go | 71 +- .../core/ngt/handler/grpc/upsert_test.go | 6 +- pkg/agent/core/ngt/service/kvs/kvs_test.go | 13 +- pkg/agent/core/ngt/service/option_test.go | 7 +- pkg/discoverer/k8s/service/discover.go | 16 +- tests/chaos/chart/README.md | 2 +- versions/GO_VERSION | 2 +- 193 files changed, 6764 insertions(+), 3777 deletions(-) create mode 100644 internal/compress/compress_test.go create mode 100644 internal/net/http/middleware/middleware_test.go create mode 100644 internal/observability/client/google/option_test.go delete mode 100644 internal/test/data/backup/100index/grp delete mode 100644 internal/test/data/backup/100index/obj delete mode 100644 internal/test/data/backup/100index/prf delete mode 100644 internal/test/data/backup/100index/tre diff --git a/Makefile.d/test.mk b/Makefile.d/test.mk index 29b110916b..ed04dc11cb 100644 --- a/Makefile.d/test.mk +++ b/Makefile.d/test.mk @@ -17,12 +17,12 @@ .PHONY: test ## run tests for cmd, internal, pkg test: - go test -shuffle=on -race -mod=readonly -cover ./cmd/... ./internal/... ./pkg/... + go test -shuffle=on -race -mod=readonly -cover -timeout=30m ./cmd/... ./internal/... ./pkg/... .PHONY: test/tparse ## run tests for cmd, internal, pkg and show table test/tparse: - go test -shuffle=on -race -mod=readonly -json -cover ./cmd/... ./internal/... ./pkg/... | tparse -notests + go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./cmd/... ./internal/... ./pkg/... | tparse -notests .PHONY: test/cmd ## run tests for cmd diff --git a/apis/docs/v1/docs.md b/apis/docs/v1/docs.md index 92dc01a59c..4cedbc6796 100644 --- a/apis/docs/v1/docs.md +++ b/apis/docs/v1/docs.md @@ -92,6 +92,12 @@ - [Upsert.ObjectRequest](#payload-v1-Upsert-ObjectRequest) - [Upsert.Request](#payload-v1-Upsert-Request) +- [apis/proto/v1/vald/filter.proto](#apis_proto_v1_vald_filter-proto) + - [Filter](#vald-v1-Filter) + +- [apis/proto/v1/vald/insert.proto](#apis_proto_v1_vald_insert-proto) + - [Insert](#vald-v1-Insert) + - [apis/proto/v1/vald/object.proto](#apis_proto_v1_vald_object-proto) - [Object](#vald-v1-Object) @@ -107,12 +113,6 @@ - [apis/proto/v1/vald/upsert.proto](#apis_proto_v1_vald_upsert-proto) - [Upsert](#vald-v1-Upsert) -- [apis/proto/v1/vald/filter.proto](#apis_proto_v1_vald_filter-proto) - - [Filter](#vald-v1-Filter) - -- [apis/proto/v1/vald/insert.proto](#apis_proto_v1_vald_insert-proto) - - [Insert](#vald-v1-Insert) - - [Scalar Value Types](#scalar-value-types) @@ -1326,6 +1326,71 @@ Represent the upsert request. + +

Top

+ +## apis/proto/v1/vald/filter.proto + + + + + + + + + + + +### Filter +Filter service provides ways to connect to Vald through filter. + +| Method Name | Request Type | Response Type | Description | +| ----------- | ------------ | ------------- | ------------| +| SearchObject | [.payload.v1.Search.ObjectRequest](#payload-v1-Search-ObjectRequest) | [.payload.v1.Search.Response](#payload-v1-Search-Response) | A method to search object. | +| MultiSearchObject | [.payload.v1.Search.MultiObjectRequest](#payload-v1-Search-MultiObjectRequest) | [.payload.v1.Search.Responses](#payload-v1-Search-Responses) | A method to search multiple objects. | +| StreamSearchObject | [.payload.v1.Search.ObjectRequest](#payload-v1-Search-ObjectRequest) stream | [.payload.v1.Search.StreamResponse](#payload-v1-Search-StreamResponse) stream | A method to search object by bidirectional streaming. | +| InsertObject | [.payload.v1.Insert.ObjectRequest](#payload-v1-Insert-ObjectRequest) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method insert object. | +| StreamInsertObject | [.payload.v1.Insert.ObjectRequest](#payload-v1-Insert-ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | Represent the streaming RPC to insert object by bidirectional streaming. | +| MultiInsertObject | [.payload.v1.Insert.MultiObjectRequest](#payload-v1-Insert-MultiObjectRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to insert multiple objects. | +| UpdateObject | [.payload.v1.Update.ObjectRequest](#payload-v1-Update-ObjectRequest) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to update object. | +| StreamUpdateObject | [.payload.v1.Update.ObjectRequest](#payload-v1-Update-ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to update object by bidirectional streaming. | +| MultiUpdateObject | [.payload.v1.Update.MultiObjectRequest](#payload-v1-Update-MultiObjectRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to update multiple objects. | +| UpsertObject | [.payload.v1.Upsert.ObjectRequest](#payload-v1-Upsert-ObjectRequest) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to upsert object. | +| StreamUpsertObject | [.payload.v1.Upsert.ObjectRequest](#payload-v1-Upsert-ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to upsert object by bidirectional streaming. | +| MultiUpsertObject | [.payload.v1.Upsert.MultiObjectRequest](#payload-v1-Upsert-MultiObjectRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to upsert multiple objects. | + + + + + + +

Top

+ +## apis/proto/v1/vald/insert.proto + + + + + + + + + + + +### Insert +Insert service provides ways to add new vectors. + +| Method Name | Request Type | Response Type | Description | +| ----------- | ------------ | ------------- | ------------| +| Insert | [.payload.v1.Insert.Request](#payload-v1-Insert-Request) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to add a new single vector. | +| StreamInsert | [.payload.v1.Insert.Request](#payload-v1-Insert-Request) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to add new multiple vectors by bidirectional streaming. | +| MultiInsert | [.payload.v1.Insert.MultiRequest](#payload-v1-Insert-MultiRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to add new multiple vectors in a single request. | + + + + +

Top

@@ -1475,71 +1540,6 @@ Upsert service provides ways to insert/update vectors. - -

Top

- -## apis/proto/v1/vald/filter.proto - - - - - - - - - - - -### Filter -Filter service provides ways to connect to Vald through filter. - -| Method Name | Request Type | Response Type | Description | -| ----------- | ------------ | ------------- | ------------| -| SearchObject | [.payload.v1.Search.ObjectRequest](#payload-v1-Search-ObjectRequest) | [.payload.v1.Search.Response](#payload-v1-Search-Response) | A method to search object. | -| MultiSearchObject | [.payload.v1.Search.MultiObjectRequest](#payload-v1-Search-MultiObjectRequest) | [.payload.v1.Search.Responses](#payload-v1-Search-Responses) | A method to search multiple objects. | -| StreamSearchObject | [.payload.v1.Search.ObjectRequest](#payload-v1-Search-ObjectRequest) stream | [.payload.v1.Search.StreamResponse](#payload-v1-Search-StreamResponse) stream | A method to search object by bidirectional streaming. | -| InsertObject | [.payload.v1.Insert.ObjectRequest](#payload-v1-Insert-ObjectRequest) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method insert object. | -| StreamInsertObject | [.payload.v1.Insert.ObjectRequest](#payload-v1-Insert-ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | Represent the streaming RPC to insert object by bidirectional streaming. | -| MultiInsertObject | [.payload.v1.Insert.MultiObjectRequest](#payload-v1-Insert-MultiObjectRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to insert multiple objects. | -| UpdateObject | [.payload.v1.Update.ObjectRequest](#payload-v1-Update-ObjectRequest) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to update object. | -| StreamUpdateObject | [.payload.v1.Update.ObjectRequest](#payload-v1-Update-ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to update object by bidirectional streaming. | -| MultiUpdateObject | [.payload.v1.Update.MultiObjectRequest](#payload-v1-Update-MultiObjectRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to update multiple objects. | -| UpsertObject | [.payload.v1.Upsert.ObjectRequest](#payload-v1-Upsert-ObjectRequest) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to upsert object. | -| StreamUpsertObject | [.payload.v1.Upsert.ObjectRequest](#payload-v1-Upsert-ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to upsert object by bidirectional streaming. | -| MultiUpsertObject | [.payload.v1.Upsert.MultiObjectRequest](#payload-v1-Upsert-MultiObjectRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to upsert multiple objects. | - - - - - - -

Top

- -## apis/proto/v1/vald/insert.proto - - - - - - - - - - - -### Insert -Insert service provides ways to add new vectors. - -| Method Name | Request Type | Response Type | Description | -| ----------- | ------------ | ------------- | ------------| -| Insert | [.payload.v1.Insert.Request](#payload-v1-Insert-Request) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to add a new single vector. | -| StreamInsert | [.payload.v1.Insert.Request](#payload-v1-Insert-Request) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to add new multiple vectors by bidirectional streaming. | -| MultiInsert | [.payload.v1.Insert.MultiRequest](#payload-v1-Insert-MultiRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to add new multiple vectors in a single request. | - - - - - ## Scalar Value Types | .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | diff --git a/charts/vald/README.md b/charts/vald/README.md index 1025df969b..0a0c4ea7ff 100644 --- a/charts/vald/README.md +++ b/charts/vald/README.md @@ -99,7 +99,7 @@ Configuration | agent.ngt.vqueue.insert_buffer_pool_size | int | `10000` | insert slice pool buffer size | | agent.nodeName | string | `""` | node name | | agent.nodeSelector | object | `{}` | node selector | -| agent.observability | object | `{"jaeger":{"service_name":"vald-agent-ngt"},"stackdriver":{"profiler":{"service":"vald-agent-ngt"}}}` | observability config (overrides defaults.observability) | +| agent.observability | object | `{"jaeger":{"service_name":"vald-agent-ngt"}}` | observability config (overrides defaults.observability) | | agent.persistentVolume.accessMode | string | `"ReadWriteOncePod"` | agent pod storage accessMode | | agent.persistentVolume.enabled | bool | `false` | enables PVC. It is required to enable if agent pod's file store functionality is enabled with non in-memory mode | | agent.persistentVolume.mountPropagation | string | `"None"` | agent pod storage mountPropagation | @@ -212,7 +212,7 @@ Configuration | agent.sidecar.initContainerEnabled | bool | `false` | sidecar on initContainer mode enabled. | | agent.sidecar.logging | object | `{}` | logging config (overrides defaults.logging) | | agent.sidecar.name | string | `"vald-agent-sidecar"` | name of agent sidecar | -| agent.sidecar.observability | object | `{"jaeger":{"service_name":"vald-agent-sidecar"},"stackdriver":{"profiler":{"service":"vald-agent-sidecar"}}}` | observability config (overrides defaults.observability) | +| agent.sidecar.observability | object | `{"jaeger":{"service_name":"vald-agent-sidecar"}}` | observability config (overrides defaults.observability) | | agent.sidecar.resources | object | `{"requests":{"cpu":"100m","memory":"100Mi"}}` | compute resources. | | agent.sidecar.server_config | object | `{"healths":{"liveness":{"enabled":false,"port":13000,"servicePort":13000},"readiness":{"enabled":false,"port":13001,"servicePort":13001},"startup":{"enabled":false,"port":13001}},"metrics":{"pprof":{"port":16060,"servicePort":16060},"prometheus":{"port":16061,"servicePort":16061}},"servers":{"grpc":{"enabled":false,"port":18081,"servicePort":18081},"rest":{"enabled":false,"port":18080,"servicePort":18080}}}` | server config (overrides defaults.server_config) | | agent.sidecar.service.annotations | object | `{}` | agent sidecar service annotations | @@ -241,6 +241,11 @@ Configuration | defaults.grpc.client.call_option.max_retry_rpc_buffer_size | int | `0` | gRPC client call option max retry rpc buffer size | | defaults.grpc.client.call_option.max_send_msg_size | int | `0` | gRPC client call option max send message size | | defaults.grpc.client.call_option.wait_for_ready | bool | `true` | gRPC client call option wait for ready | +| defaults.grpc.client.circuit_breaker.closed_error_rate | float | `0.7` | gRPC client circuitbreaker closed error rate | +| defaults.grpc.client.circuit_breaker.closed_refresh_timeout | string | `"10s"` | gRPC client circuitbreaker closed refresh timeout | +| defaults.grpc.client.circuit_breaker.half_open_error_rate | float | `0.5` | gRPC client circuitbreaker half-open error rate | +| defaults.grpc.client.circuit_breaker.min_samples | int | `1000` | gRPC client circuitbreaker minimum sampling count | +| defaults.grpc.client.circuit_breaker.open_timeout | string | `"1s"` | gRPC client circuitbreaker open timeout | | defaults.grpc.client.connection_pool.enable_dns_resolver | bool | `true` | enables gRPC client connection pool dns resolver, when enabled vald uses ip handshake exclude dns discovery which improves network performance | | defaults.grpc.client.connection_pool.enable_rebalance | bool | `true` | enables gRPC client connection pool rebalance | | defaults.grpc.client.connection_pool.old_conn_close_duration | string | `"2m"` | makes delay before gRPC client connection closing during connection pool rebalance | @@ -299,8 +304,8 @@ Configuration | defaults.observability.collector.metrics.enable_version_info | bool | `true` | version info metrics enabled | | defaults.observability.collector.metrics.version_info_labels | list | `["vald_version","server_name","git_commit","build_time","go_version","go_os","go_arch","ngt_version"]` | enabled label names of version info | | defaults.observability.enabled | bool | `false` | observability features enabled | -| defaults.observability.jaeger.agent_endpoint | string | `"jaeger-agent.default.svc.cluster.local:6831"` | Jaeger agent endpoint | -| defaults.observability.jaeger.buffer_max_count | int | `10` | Jaeger buffer max count | +| defaults.observability.jaeger.agent_endpoint | string | `""` | Jaeger agent endpoint | +| defaults.observability.jaeger.buffer_max_count | int | `65000` | Jaeger buffer max count | | defaults.observability.jaeger.collector_endpoint | string | `""` | Jaeger collector endpoint | | defaults.observability.jaeger.enabled | bool | `false` | Jaeger exporter enabled | | defaults.observability.jaeger.password | string | `""` | Jaeger password | @@ -309,42 +314,6 @@ Configuration | defaults.observability.prometheus.enabled | bool | `false` | Prometheus exporter enabled | | defaults.observability.prometheus.endpoint | string | `"/metrics"` | Prometheus exporter endpoint | | defaults.observability.prometheus.namespace | string | `"vald"` | prefix of exported metrics name | -| defaults.observability.stackdriver.client.api_key | string | `""` | API key to be used as the basis for authentication. | -| defaults.observability.stackdriver.client.audiences | list | `[]` | to be used as the audience field ("aud") for the JWT token authentication. | -| defaults.observability.stackdriver.client.authentication_enabled | bool | `true` | enables authentication. | -| defaults.observability.stackdriver.client.credentials_file | string | `""` | service account or refresh token JSON credentials file. | -| defaults.observability.stackdriver.client.credentials_json | string | `""` | service account or refresh token JSON credentials. | -| defaults.observability.stackdriver.client.endpoint | string | `""` | overrides the default endpoint to be used for a service. | -| defaults.observability.stackdriver.client.quota_project | string | `""` | the project used for quota and billing purposes. | -| defaults.observability.stackdriver.client.request_reason | string | `""` | a reason for making the request, which is intended to be recorded in audit logging. | -| defaults.observability.stackdriver.client.scopes | list | `[]` | overrides the default OAuth2 scopes to be used for a service. | -| defaults.observability.stackdriver.client.telemetry_enabled | bool | `true` | enables default telemetry settings on gRPC and HTTP clients. | -| defaults.observability.stackdriver.client.user_agent | string | `""` | sets the User-Agent. | -| defaults.observability.stackdriver.exporter.bundle_count_threshold | int | `0` | how many view data events or trace spans can be buffered. | -| defaults.observability.stackdriver.exporter.bundle_delay_threshold | string | `"0"` | the max amount of time the exporter can wait before uploading data. | -| defaults.observability.stackdriver.exporter.location | string | `""` | identifier of the GCP or AWS cloud region/zone the data is stored. | -| defaults.observability.stackdriver.exporter.metric_prefix | string | `"vald.vdaas.org"` | the prefix of a stackdriver metric names. | -| defaults.observability.stackdriver.exporter.monitoring_enabled | bool | `false` | stackdriver monitoring enabled | -| defaults.observability.stackdriver.exporter.number_of_workers | int | `1` | number of workers | -| defaults.observability.stackdriver.exporter.reporting_interval | string | `"1m"` | interval between reporting metrics | -| defaults.observability.stackdriver.exporter.skip_cmd | bool | `false` | skip all the CreateMetricDescriptor calls | -| defaults.observability.stackdriver.exporter.timeout | string | `"5s"` | timeout for all API calls | -| defaults.observability.stackdriver.exporter.trace_spans_buffer_max_bytes | int | `0` | maximum size of spans that will be buffered. | -| defaults.observability.stackdriver.exporter.tracing_enabled | bool | `false` | stackdriver tracing enabled | -| defaults.observability.stackdriver.profiler.alloc_force_gc | bool | `false` | forces GC before the collection of each heap profile. | -| defaults.observability.stackdriver.profiler.alloc_profiling | bool | `true` | enables allocation profiling. | -| defaults.observability.stackdriver.profiler.api_addr | string | `""` | HTTP endpoint to use to connect to the profiler agent API. | -| defaults.observability.stackdriver.profiler.cpu_profiling | bool | `true` | enables CPU profiling. | -| defaults.observability.stackdriver.profiler.debug_logging | bool | `false` | enables detailed logging from profiler. | -| defaults.observability.stackdriver.profiler.enabled | bool | `false` | stackdriver profiler enabled. | -| defaults.observability.stackdriver.profiler.goroutine_profiling | bool | `true` | enables goroutine profiling. | -| defaults.observability.stackdriver.profiler.heap_profiling | bool | `true` | enables heap profiling. | -| defaults.observability.stackdriver.profiler.instance | string | `""` | the name of Compute Engine instance. This is normally determined from the Compute Engine metadata server and doesn't need to be initialized. | -| defaults.observability.stackdriver.profiler.mutex_profiling | bool | `true` | enables mutex profiling. | -| defaults.observability.stackdriver.profiler.service | string | `""` | the name of the service. | -| defaults.observability.stackdriver.profiler.service_version | string | `""` | the version of the service. | -| defaults.observability.stackdriver.profiler.zone | string | `""` | the zone of Compute Engine instance. This is normally determined from the Compute Engine metadata server and doesn't need to be initialized. | -| defaults.observability.stackdriver.project_id | string | `""` | project id for uploading the stats data | | defaults.observability.trace.enabled | bool | `false` | trace enabled | | defaults.observability.trace.sampling_rate | float | `1` | trace sampling rate. must be between 0.0 to 1.0. | | defaults.server_config.full_shutdown_duration | string | `"600s"` | server full shutdown duration | @@ -597,7 +566,7 @@ Configuration | discoverer.name | string | `"vald-discoverer"` | name of discoverer deployment | | discoverer.nodeName | string | `""` | node name | | discoverer.nodeSelector | object | `{}` | node selector | -| discoverer.observability | object | `{"jaeger":{"service_name":"vald-discoverer"},"stackdriver":{"profiler":{"service":"vald-discoverer"}}}` | observability config (overrides defaults.observability) | +| discoverer.observability | object | `{"jaeger":{"service_name":"vald-discoverer"}}` | observability config (overrides defaults.observability) | | discoverer.podAnnotations | object | `{}` | pod annotations | | discoverer.podPriority.enabled | bool | `true` | discoverer pod PriorityClass enabled | | discoverer.podPriority.value | int | `1000000` | discoverer pod PriorityClass value | @@ -663,7 +632,7 @@ Configuration | gateway.filter.name | string | `"vald-filter-gateway"` | name of filter gateway deployment | | gateway.filter.nodeName | string | `""` | node name | | gateway.filter.nodeSelector | object | `{}` | node selector | -| gateway.filter.observability | object | `{"jaeger":{"service_name":"vald-filter-gateway"},"stackdriver":{"profiler":{"service":"vald-filter-gateway"}}}` | observability config (overrides defaults.observability) | +| gateway.filter.observability | object | `{"jaeger":{"service_name":"vald-filter-gateway"}}` | observability config (overrides defaults.observability) | | gateway.filter.podAnnotations | object | `{}` | pod annotations | | gateway.filter.podPriority.enabled | bool | `true` | gateway pod PriorityClass enabled | | gateway.filter.podPriority.value | int | `1000000` | gateway pod PriorityClass value | @@ -721,7 +690,7 @@ Configuration | gateway.lb.name | string | `"vald-lb-gateway"` | name of gateway deployment | | gateway.lb.nodeName | string | `""` | node name | | gateway.lb.nodeSelector | object | `{}` | node selector | -| gateway.lb.observability | object | `{"jaeger":{"service_name":"vald-lb-gateway"},"stackdriver":{"profiler":{"service":"vald-lb-gateway"}}}` | observability config (overrides defaults.observability) | +| gateway.lb.observability | object | `{"jaeger":{"service_name":"vald-lb-gateway"}}` | observability config (overrides defaults.observability) | | gateway.lb.podAnnotations | object | `{}` | pod annotations | | gateway.lb.podPriority.enabled | bool | `true` | gateway pod PriorityClass enabled | | gateway.lb.podPriority.value | int | `1000000` | gateway pod PriorityClass value | @@ -775,7 +744,7 @@ Configuration | manager.index.name | string | `"vald-manager-index"` | name of index manager deployment | | manager.index.nodeName | string | `""` | node name | | manager.index.nodeSelector | object | `{}` | node selector | -| manager.index.observability | object | `{"jaeger":{"service_name":"vald-manager-index"},"stackdriver":{"profiler":{"service":"vald-manager-index"}}}` | observability config (overrides defaults.observability) | +| manager.index.observability | object | `{"jaeger":{"service_name":"vald-manager-index"}}` | observability config (overrides defaults.observability) | | manager.index.podAnnotations | object | `{}` | pod annotations | | manager.index.podPriority.enabled | bool | `true` | index manager pod PriorityClass enabled | | manager.index.podPriority.value | int | `1000000` | index manager pod PriorityClass value | diff --git a/charts/vald/values.go b/charts/vald/values.go index 5a234c510d..bc51e8652a 100644 --- a/charts/vald/values.go +++ b/charts/vald/values.go @@ -283,42 +283,6 @@ type EgressFilter struct { // EnvItems type EnvItems struct{} -// Exporter -type Exporter struct { - // how many view data events or trace spans can be buffered. - BundleCountThreshold int `json:"bundle_count_threshold,omitempty"` - - // the max amount of time the exporter can wait before uploading data. - BundleDelayThreshold string `json:"bundle_delay_threshold,omitempty"` - - // identifier of the GCP or AWS cloud region/zone the data is stored. - Location string `json:"location,omitempty"` - - // the prefix of a stackdriver metric names. - MetricPrefix string `json:"metric_prefix,omitempty"` - - // stackdriver monitoring enabled - MonitoringEnabled bool `json:"monitoring_enabled,omitempty"` - - // number of workers - NumberOfWorkers int `json:"number_of_workers,omitempty"` - - // interval between reporting metrics - ReportingInterval string `json:"reporting_interval,omitempty"` - - // skip all the CreateMetricDescriptor calls - SkipCmd bool `json:"skip_cmd,omitempty"` - - // timeout for all API calls - Timeout string `json:"timeout,omitempty"` - - // maximum size of spans that will be buffered. - TraceSpansBufferMaxBytes int `json:"trace_spans_buffer_max_bytes,omitempty"` - - // stackdriver tracing enabled - TracingEnabled bool `json:"tracing_enabled,omitempty"` -} - // Fields k8s field selectors for pod discovery type Fields struct{} @@ -924,11 +888,10 @@ type Observability struct { Collector *Collector `json:"collector,omitempty"` // observability features enabled - Enabled bool `json:"enabled,omitempty"` - Jaeger *Jaeger `json:"jaeger,omitempty"` - Prometheus *Prometheus `json:"prometheus,omitempty"` - Stackdriver *Stackdriver `json:"stackdriver,omitempty"` - Trace *Trace `json:"trace,omitempty"` + Enabled bool `json:"enabled,omitempty"` + Jaeger *Jaeger `json:"jaeger,omitempty"` + Prometheus *Prometheus `json:"prometheus,omitempty"` + Trace *Trace `json:"trace,omitempty"` } // PersistentVolume @@ -1016,48 +979,6 @@ type Pprof struct { // PreferredDuringSchedulingIgnoredDuringExecutionItems type PreferredDuringSchedulingIgnoredDuringExecutionItems struct{} -// Profiler -type Profiler struct { - // forces GC before the collection of each heap profile. - AllocForceGc bool `json:"alloc_force_gc,omitempty"` - - // enables allocation profiling. - AllocProfiling bool `json:"alloc_profiling,omitempty"` - - // HTTP endpoint to use to connect to the profiler agent API. - ApiAddr string `json:"api_addr,omitempty"` - - // enables CPU profiling. - CpuProfiling bool `json:"cpu_profiling,omitempty"` - - // enables detailed logging from profiler. - DebugLogging bool `json:"debug_logging,omitempty"` - - // stackdriver profiler enabled. - Enabled bool `json:"enabled,omitempty"` - - // enables goroutine profiling. - GoroutineProfiling bool `json:"goroutine_profiling,omitempty"` - - // enables heap profiling. - HeapProfiling bool `json:"heap_profiling,omitempty"` - - // the name of Compute Engine instance. This is normally determined from the Compute Engine metadata server and doesn't need to be initialized. - Instance string `json:"instance,omitempty"` - - // enables mutex profiling. - MutexProfiling bool `json:"mutex_profiling,omitempty"` - - // the name of the service. - Service string `json:"service,omitempty"` - - // the version of the service. - ServiceVersion string `json:"service_version,omitempty"` - - // the zone of Compute Engine instance. This is normally determined from the Compute Engine metadata server and doesn't need to be initialized. - Zone string `json:"zone,omitempty"` -} - // Prometheus type Prometheus struct { // Prometheus exporter enabled @@ -1307,16 +1228,6 @@ type Sidecar struct { Version string `json:"version,omitempty"` } -// Stackdriver -type Stackdriver struct { - Client *config.GRPCClient `json:"client,omitempty"` - Exporter *Exporter `json:"exporter,omitempty"` - Profiler *Profiler `json:"profiler,omitempty"` - - // project id for uploading the stats data - ProjectId string `json:"project_id,omitempty"` -} - // Startup type Startup struct { // startup server enabled diff --git a/example/client/go.mod b/example/client/go.mod index 86c916d99b..49e84241ac 100644 --- a/example/client/go.mod +++ b/example/client/go.mod @@ -9,9 +9,9 @@ replace ( github.com/kpango/glg => github.com/kpango/glg v1.6.13 github.com/pkg/sftp => github.com/pkg/sftp v1.13.5 golang.org/x/crypto => golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 - golang.org/x/net => golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b + golang.org/x/net => golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 golang.org/x/text => golang.org/x/text v0.3.7 - google.golang.org/genproto => google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf + google.golang.org/genproto => google.golang.org/genproto v0.0.0-20220902135211-223410557253 google.golang.org/grpc => google.golang.org/grpc v1.49.0 google.golang.org/protobuf => google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.4.0 diff --git a/example/client/go.sum b/example/client/go.sum index 57fa3917e0..4d2fdf4a44 100644 --- a/example/client/go.sum +++ b/example/client/go.sum @@ -38,8 +38,8 @@ golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY= -golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 h1:1WGATo9HAhkWMbfyuVU0tEFP88OIkUvwaHFveQPvzCQ= +golang.org/x/net v0.0.0-20220907135653-1e95f45603a7/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -64,8 +64,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1N golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 h1:vJpL69PeUullhJyKtTjHjENEmZU3BkO4e+fod7nKzgM= gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946/go.mod h1:BQUWDHIAygjdt1HnUPQ0eWqLN2n5FwJycrpYUVUOx2I= -google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf h1:Q5xNKbTSFwkuaaGaR7CMcXEM5sy19KYdUU8iF8/iRC0= -google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= +google.golang.org/genproto v0.0.0-20220902135211-223410557253 h1:vXJMM8Shg7TGaYxZsQ++A/FOSlbDmDtWhS/o+3w/hj4= +google.golang.org/genproto v0.0.0-20220902135211-223410557253/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= diff --git a/go.mod b/go.mod index c8f6af5a12..358ac35313 100755 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace ( cloud.google.com/go/compute => cloud.google.com/go/compute v1.9.0 cloud.google.com/go/datastore => cloud.google.com/go/datastore v1.8.0 cloud.google.com/go/firestore => cloud.google.com/go/firestore v1.6.1 - cloud.google.com/go/iam => cloud.google.com/go/iam v0.3.0 + cloud.google.com/go/iam => cloud.google.com/go/iam v0.4.0 cloud.google.com/go/kms => cloud.google.com/go/kms v1.4.0 cloud.google.com/go/monitoring => cloud.google.com/go/monitoring v1.6.0 cloud.google.com/go/profiler => cloud.google.com/go/profiler v0.3.0 @@ -21,7 +21,7 @@ replace ( contrib.go.opencensus.io/exporter/prometheus => contrib.go.opencensus.io/exporter/prometheus v0.4.2 contrib.go.opencensus.io/integrations/ocsql => contrib.go.opencensus.io/integrations/ocsql v0.1.7 git.sr.ht/~sbinet/gg => git.sr.ht/~sbinet/gg v0.3.1 - github.com/AdaLogics/go-fuzz-headers => github.com/AdaLogics/go-fuzz-headers v0.0.0-20220824214621-3c06a36a6952 + github.com/AdaLogics/go-fuzz-headers => github.com/AdaLogics/go-fuzz-headers v0.0.0-20220903154154-e8044f6e4c72 github.com/Azure/azure-amqp-common-go/v3 => github.com/Azure/azure-amqp-common-go/v3 v3.2.3 github.com/Azure/azure-pipeline-go => github.com/Azure/azure-pipeline-go v0.2.3 github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v66.0.0+incompatible @@ -57,35 +57,35 @@ replace ( github.com/alecthomas/units => github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 github.com/alexflint/go-filemutex => github.com/alexflint/go-filemutex v1.2.0 github.com/antihax/optional => github.com/antihax/optional v1.0.0 - github.com/antlr/antlr4/runtime/Go/antlr => github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220826213629-cd8f367ca010 + github.com/antlr/antlr4/runtime/Go/antlr => github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/armon/circbuf => github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2 github.com/armon/go-metrics => github.com/armon/go-metrics v0.4.0 github.com/armon/go-radix => github.com/armon/go-radix v1.0.0 github.com/armon/go-socks5 => github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 github.com/asaskevich/govalidator => github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d - github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.44.90 - github.com/aws/aws-sdk-go-v2 => github.com/aws/aws-sdk-go-v2 v1.16.13 - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream => github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.6 - github.com/aws/aws-sdk-go-v2/config => github.com/aws/aws-sdk-go-v2/config v1.17.4 - github.com/aws/aws-sdk-go-v2/credentials => github.com/aws/aws-sdk-go-v2/credentials v1.12.17 - github.com/aws/aws-sdk-go-v2/feature/ec2/imds => github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.14 - github.com/aws/aws-sdk-go-v2/feature/s3/manager => github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.30 - github.com/aws/aws-sdk-go-v2/internal/configsources => github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.20 - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 => github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.14 - github.com/aws/aws-sdk-go-v2/internal/ini => github.com/aws/aws-sdk-go-v2/internal/ini v1.3.21 - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding => github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.7 - github.com/aws/aws-sdk-go-v2/service/internal/checksum => github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.15 - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url => github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.14 - github.com/aws/aws-sdk-go-v2/service/internal/s3shared => github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.14 - github.com/aws/aws-sdk-go-v2/service/kms => github.com/aws/aws-sdk-go-v2/service/kms v1.18.8 - github.com/aws/aws-sdk-go-v2/service/s3 => github.com/aws/aws-sdk-go-v2/service/s3 v1.27.8 - github.com/aws/aws-sdk-go-v2/service/secretsmanager => github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.15.21 - github.com/aws/aws-sdk-go-v2/service/sns => github.com/aws/aws-sdk-go-v2/service/sns v1.17.16 - github.com/aws/aws-sdk-go-v2/service/sqs => github.com/aws/aws-sdk-go-v2/service/sqs v1.19.7 - github.com/aws/aws-sdk-go-v2/service/ssm => github.com/aws/aws-sdk-go-v2/service/ssm v1.27.12 - github.com/aws/aws-sdk-go-v2/service/sso => github.com/aws/aws-sdk-go-v2/service/sso v1.11.20 - github.com/aws/aws-sdk-go-v2/service/sts => github.com/aws/aws-sdk-go-v2/service/sts v1.16.16 - github.com/aws/smithy-go => github.com/aws/smithy-go v1.13.1 + github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.44.93 + github.com/aws/aws-sdk-go-v2 => github.com/aws/aws-sdk-go-v2 v1.16.14 + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream => github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.7 + github.com/aws/aws-sdk-go-v2/config => github.com/aws/aws-sdk-go-v2/config v1.17.5 + github.com/aws/aws-sdk-go-v2/credentials => github.com/aws/aws-sdk-go-v2/credentials v1.12.18 + github.com/aws/aws-sdk-go-v2/feature/ec2/imds => github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.15 + github.com/aws/aws-sdk-go-v2/feature/s3/manager => github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.31 + github.com/aws/aws-sdk-go-v2/internal/configsources => github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.21 + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 => github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.15 + github.com/aws/aws-sdk-go-v2/internal/ini => github.com/aws/aws-sdk-go-v2/internal/ini v1.3.22 + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding => github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.8 + github.com/aws/aws-sdk-go-v2/service/internal/checksum => github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.16 + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url => github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.15 + github.com/aws/aws-sdk-go-v2/service/internal/s3shared => github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.15 + github.com/aws/aws-sdk-go-v2/service/kms => github.com/aws/aws-sdk-go-v2/service/kms v1.18.9 + github.com/aws/aws-sdk-go-v2/service/s3 => github.com/aws/aws-sdk-go-v2/service/s3 v1.27.9 + github.com/aws/aws-sdk-go-v2/service/secretsmanager => github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.15.22 + github.com/aws/aws-sdk-go-v2/service/sns => github.com/aws/aws-sdk-go-v2/service/sns v1.17.17 + github.com/aws/aws-sdk-go-v2/service/sqs => github.com/aws/aws-sdk-go-v2/service/sqs v1.19.8 + github.com/aws/aws-sdk-go-v2/service/ssm => github.com/aws/aws-sdk-go-v2/service/ssm v1.27.13 + github.com/aws/aws-sdk-go-v2/service/sso => github.com/aws/aws-sdk-go-v2/service/sso v1.11.21 + github.com/aws/aws-sdk-go-v2/service/sts => github.com/aws/aws-sdk-go-v2/service/sts v1.16.17 + github.com/aws/smithy-go => github.com/aws/smithy-go v1.13.2 github.com/benbjohnson/clock => github.com/benbjohnson/clock v1.3.0 github.com/beorn7/perks => github.com/beorn7/perks v1.0.1 github.com/bgentry/speakeasy => github.com/bgentry/speakeasy v0.1.0 @@ -201,7 +201,7 @@ replace ( github.com/go-openapi/swag => github.com/go-openapi/swag v0.22.3 github.com/go-openapi/validate => github.com/go-openapi/validate v0.22.0 github.com/go-pdf/fpdf => github.com/go-pdf/fpdf v1.4.3 - github.com/go-playground/assert/v2 => github.com/go-playground/assert/v2 v2.0.1 + github.com/go-playground/assert/v2 => github.com/go-playground/assert/v2 v2.2.0 github.com/go-playground/locales => github.com/go-playground/locales v0.14.0 github.com/go-playground/universal-translator => github.com/go-playground/universal-translator v0.18.0 github.com/go-playground/validator/v10 => github.com/go-playground/validator/v10 v10.11.0 @@ -219,7 +219,7 @@ replace ( github.com/gobwas/ws => github.com/gobwas/ws v1.1.0 github.com/goccy/go-json => github.com/goccy/go-json v0.9.11 github.com/goccy/go-yaml => github.com/goccy/go-yaml v1.9.5 - github.com/gocql/gocql => github.com/gocql/gocql v1.2.0 + github.com/gocql/gocql => github.com/gocql/gocql v1.2.1 github.com/gocraft/dbr/v2 => github.com/gocraft/dbr/v2 v2.7.3 github.com/godbus/dbus/v5 => github.com/godbus/dbus/v5 v5.1.0 github.com/gofrs/uuid => github.com/gofrs/uuid v4.2.0+incompatible @@ -299,7 +299,7 @@ replace ( github.com/jackc/pgproto3/v2 => github.com/jackc/pgproto3/v2 v2.3.1 github.com/jackc/pgservicefile => github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b github.com/jackc/pgtype => github.com/jackc/pgtype v1.12.0 - github.com/jackc/pgx/v4 => github.com/jackc/pgx/v4 v4.17.1 + github.com/jackc/pgx/v4 => github.com/jackc/pgx/v4 v4.17.2 github.com/jackc/puddle => github.com/jackc/puddle v1.3.0 github.com/jessevdk/go-flags => github.com/jessevdk/go-flags v1.5.0 github.com/jmespath/go-jmespath => github.com/jmespath/go-jmespath v0.4.0 @@ -314,7 +314,7 @@ replace ( github.com/julienschmidt/httprouter => github.com/julienschmidt/httprouter v1.3.0 github.com/kisielk/errcheck => github.com/kisielk/errcheck v1.6.2 github.com/kisielk/gotool => github.com/kisielk/gotool v1.0.0 - github.com/klauspost/compress => github.com/klauspost/compress v1.15.10-0.20220829133349-1481365fd7f6 + github.com/klauspost/compress => github.com/klauspost/compress v1.15.10-0.20220907083105-a63f67b75f97 github.com/klauspost/cpuid/v2 => github.com/klauspost/cpuid/v2 v2.1.1 github.com/kolo/xmlrpc => github.com/kolo/xmlrpc v0.0.0-20201022064351-38db28db192b github.com/kpango/fastime => github.com/kpango/fastime v1.1.4 @@ -327,7 +327,7 @@ replace ( github.com/kylelemons/godebug => github.com/kylelemons/godebug v1.1.0 github.com/leanovate/gopter => github.com/leanovate/gopter v0.2.9 github.com/leodido/go-urn => github.com/leodido/go-urn v1.2.1 - github.com/lib/pq => github.com/lib/pq v1.10.6 + github.com/lib/pq => github.com/lib/pq v1.10.7 github.com/liggitt/tabwriter => github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de github.com/linode/linodego => github.com/linode/linodego v1.9.1 github.com/linuxkit/virtsock => github.com/linuxkit/virtsock v0.0.0-20220523201153-1a23e78aa7a2 @@ -346,7 +346,6 @@ replace ( github.com/mitchellh/cli => github.com/mitchellh/cli v1.1.4 github.com/mitchellh/colorstring => github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db github.com/mitchellh/go-homedir => github.com/mitchellh/go-homedir v1.1.0 - github.com/mitchellh/go-testing-interface => github.com/mitchellh/go-testing-interface v1.14.1 github.com/mitchellh/go-wordwrap => github.com/mitchellh/go-wordwrap v1.0.1 github.com/mitchellh/mapstructure => github.com/mitchellh/mapstructure v1.5.0 github.com/moby/locker => github.com/moby/locker v1.0.1 @@ -445,7 +444,7 @@ replace ( github.com/tv42/httpunix => github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c github.com/ugorji/go => github.com/ugorji/go v1.2.7 github.com/ugorji/go/codec => github.com/ugorji/go/codec v1.2.7 - github.com/urfave/cli => github.com/urfave/cli v1.22.9 + github.com/urfave/cli => github.com/urfave/cli v1.22.10 github.com/vdaas/vald-client-go => github.com/vdaas/vald-client-go v1.5.6 github.com/vishvananda/netlink => github.com/vishvananda/netlink v1.1.0 github.com/vishvananda/netns => github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 @@ -458,7 +457,7 @@ replace ( github.com/xiang90/probing => github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 github.com/xlab/treeprint => github.com/xlab/treeprint v1.1.0 github.com/youmark/pkcs8 => github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a - github.com/yuin/goldmark => github.com/yuin/goldmark v1.4.13 + github.com/yuin/goldmark => github.com/yuin/goldmark v1.4.14 github.com/zeebo/assert => github.com/zeebo/assert v1.3.1 github.com/zeebo/xxh3 => github.com/zeebo/xxh3 v1.0.2 go.etcd.io/bbolt => go.etcd.io/bbolt v1.3.6 @@ -469,7 +468,7 @@ replace ( go.etcd.io/etcd/pkg/v3 => go.etcd.io/etcd/pkg/v3 v3.5.4 go.etcd.io/etcd/raft/v3 => go.etcd.io/etcd/raft/v3 v3.5.4 go.etcd.io/etcd/server/v3 => go.etcd.io/etcd/server/v3 v3.5.4 - go.mongodb.org/mongo-driver => go.mongodb.org/mongo-driver v1.10.1 + go.mongodb.org/mongo-driver => go.mongodb.org/mongo-driver v1.10.2 go.mozilla.org/pkcs7 => go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 go.opencensus.io => go.opencensus.io v0.23.0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc => go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.34.0 @@ -490,34 +489,34 @@ replace ( go.starlark.net => go.starlark.net v0.0.0-20220817180228-f738f5508c12 go.uber.org/atomic => go.uber.org/atomic v1.10.0 go.uber.org/automaxprocs => go.uber.org/automaxprocs v1.5.1 - go.uber.org/goleak => go.uber.org/goleak v1.1.12 + go.uber.org/goleak => go.uber.org/goleak v1.2.0 go.uber.org/multierr => go.uber.org/multierr v1.8.0 go.uber.org/zap => go.uber.org/zap v1.23.0 go4.org/intern => go4.org/intern v0.0.0-20220617035311-6925f38cc365 go4.org/unsafe/assume-no-moving-gc => go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 gocloud.dev => gocloud.dev v0.26.0 golang.org/x/crypto => golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 - golang.org/x/exp => golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 - golang.org/x/exp/typeparams => golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 - golang.org/x/image => golang.org/x/image v0.0.0-20220722155232-062f8c9fd539 + golang.org/x/exp => golang.org/x/exp v0.0.0-20220907003533-145caa8ea1d0 + golang.org/x/exp/typeparams => golang.org/x/exp/typeparams v0.0.0-20220907003533-145caa8ea1d0 + golang.org/x/image => golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 golang.org/x/lint => golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 golang.org/x/mod => golang.org/x/mod v0.5.1 - golang.org/x/net => golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b + golang.org/x/net => golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 golang.org/x/oauth2 => golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094 - golang.org/x/sync => golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde - golang.org/x/sys => golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 + golang.org/x/sync => golang.org/x/sync v0.0.0-20220907140024-f12130a52804 + golang.org/x/sys => golang.org/x/sys v0.0.0-20220907062415-87db552b00fd golang.org/x/term => golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 golang.org/x/text => golang.org/x/text v0.3.7 golang.org/x/time => golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 golang.org/x/tools => golang.org/x/tools v0.1.12 - golang.org/x/xerrors => golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f + golang.org/x/xerrors => golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 gomodules.xyz/jsonpatch/v2 => gomodules.xyz/jsonpatch/v2 v2.2.0 - gonum.org/v1/gonum => gonum.org/v1/gonum v0.11.0 + gonum.org/v1/gonum => gonum.org/v1/gonum v0.12.0 gonum.org/v1/hdf5 => gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 - gonum.org/v1/plot => gonum.org/v1/plot v0.11.0 - google.golang.org/api => google.golang.org/api v0.94.0 + gonum.org/v1/plot => gonum.org/v1/plot v0.12.0 + google.golang.org/api => google.golang.org/api v0.95.0 google.golang.org/appengine => google.golang.org/appengine v1.6.7 - google.golang.org/genproto => google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf + google.golang.org/genproto => google.golang.org/genproto v0.0.0-20220902135211-223410557253 google.golang.org/grpc => google.golang.org/grpc v1.49.0 google.golang.org/grpc/cmd/protoc-gen-go-grpc => google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0 google.golang.org/protobuf => google.golang.org/protobuf v1.28.1 @@ -536,25 +535,25 @@ replace ( gotest.tools/v3 => gotest.tools/v3 v3.3.0 honnef.co/go/tools => honnef.co/go/tools v0.3.3 inet.af/netaddr => inet.af/netaddr v0.0.0-20220811202034-502d2d690317 - k8s.io/api => k8s.io/api v0.24.2 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.24.2 - k8s.io/apimachinery => k8s.io/apimachinery v0.24.2 - k8s.io/apiserver => k8s.io/apiserver v0.24.2 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.24.2 - k8s.io/client-go => k8s.io/client-go v0.24.2 - k8s.io/code-generator => k8s.io/code-generator v0.24.2 - k8s.io/component-base => k8s.io/component-base v0.24.2 - k8s.io/cri-api => k8s.io/cri-api v0.24.2 - k8s.io/gengo => k8s.io/gengo v0.0.0-20220613173612-397b4ae3bce7 + k8s.io/api => k8s.io/api v0.25.0 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.25.0 + k8s.io/apimachinery => k8s.io/apimachinery v0.25.0 + k8s.io/apiserver => k8s.io/apiserver v0.25.0 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.25.0 + k8s.io/client-go => k8s.io/client-go v0.25.0 + k8s.io/code-generator => k8s.io/code-generator v0.25.0 + k8s.io/component-base => k8s.io/component-base v0.25.0 + k8s.io/cri-api => k8s.io/cri-api v0.25.0 + k8s.io/gengo => k8s.io/gengo v0.0.0-20220902162205-c0856e24416d k8s.io/klog => k8s.io/klog v1.0.0 k8s.io/klog/v2 => k8s.io/klog/v2 v2.80.0 k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea - k8s.io/metrics => k8s.io/metrics v0.24.2 + k8s.io/metrics => k8s.io/metrics v0.25.0 k8s.io/utils => k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 nhooyr.io/websocket => nhooyr.io/websocket v1.8.7 rsc.io/pdf => rsc.io/pdf v0.1.1 sigs.k8s.io/apiserver-network-proxy/konnectivity-client => sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.32 - sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.12.2 + sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.13.0 sigs.k8s.io/json => sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.12.1 sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.13.9 @@ -568,14 +567,14 @@ require ( contrib.go.opencensus.io/exporter/prometheus v0.0.0-00010101000000-000000000000 github.com/aws/aws-sdk-go v1.43.31 github.com/envoyproxy/protoc-gen-validate v0.6.7 - github.com/fsnotify/fsnotify v1.5.1 + github.com/fsnotify/fsnotify v1.5.4 github.com/go-redis/redis/v8 v8.0.0-00010101000000-000000000000 github.com/go-sql-driver/mysql v1.6.0 github.com/goccy/go-json v0.9.11 github.com/gocql/gocql v0.0.0-20200131111108-92af2e088537 github.com/gocraft/dbr/v2 v2.0.0-00010101000000-000000000000 github.com/google/go-cmp v0.5.8 - github.com/gorilla/mux v1.8.0 + github.com/gorilla/mux v0.0.0-00010101000000-000000000000 github.com/hashicorp/go-version v0.0.0-00010101000000-000000000000 github.com/klauspost/compress v1.15.1 github.com/kpango/fastime v1.1.4 @@ -606,16 +605,16 @@ require ( golang.org/x/text v0.3.7 golang.org/x/tools v0.1.12 gonum.org/v1/hdf5 v0.0.0-00010101000000-000000000000 - gonum.org/v1/plot v0.10.1 + gonum.org/v1/plot v0.0.0-00010101000000-000000000000 google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc google.golang.org/grpc v1.48.0 google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v2 v2.4.0 inet.af/netaddr v0.0.0-00010101000000-000000000000 - k8s.io/api v0.24.2 - k8s.io/apimachinery v0.24.2 + k8s.io/api v0.25.0 + k8s.io/apimachinery v0.25.0 k8s.io/cli-runtime v0.0.0-00010101000000-000000000000 - k8s.io/client-go v0.24.2 + k8s.io/client-go v0.25.0 k8s.io/metrics v0.0.0-00010101000000-000000000000 sigs.k8s.io/controller-runtime v0.0.0-00010101000000-000000000000 ) @@ -630,8 +629,9 @@ require ( github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/emicklei/go-restful/v3 v3.9.0 // indirect + github.com/emicklei/go-restful/v3 v3.8.0 // indirect github.com/evanphx/json-patch v4.12.0+incompatible // indirect + github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/go-errors/errors v1.0.1 // indirect github.com/go-fonts/liberation v0.2.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -693,7 +693,7 @@ require ( go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect - golang.org/x/image v0.0.0-20220302094943-723b81ca9867 // indirect + golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect @@ -703,13 +703,13 @@ require ( google.golang.org/appengine v1.6.7 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.24.2 // indirect - k8s.io/component-base v0.24.2 // indirect - k8s.io/klog/v2 v2.60.1 // indirect - k8s.io/kube-openapi v0.0.0-20220401212409-b28bf2818661 // indirect - k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect - sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect - sigs.k8s.io/kustomize/api v0.11.4 // indirect + k8s.io/apiextensions-apiserver v0.25.0 // indirect + k8s.io/component-base v0.25.0 // indirect + k8s.io/klog/v2 v2.70.1 // indirect + k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect + k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect + sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect + sigs.k8s.io/kustomize/api v0.12.1 // indirect sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/go.sum b/go.sum index 7ccba10cba..3e0f22deb8 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ cloud.google.com/go/compute v1.9.0/go.mod h1:lWv1h/zUWTm/LozzfTJhBSkd6ShQq8la8Ve cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0= cloud.google.com/go/datastore v1.8.0/go.mod h1:q1CpHVByTlXppdqTcu4LIhCsTn3fhtZ5R7+TajciO+M= cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= -cloud.google.com/go/iam v0.3.0 h1:exkAomrVUuzx9kWFI1wm3KI0uoDeUFPB4kKGzx6x+Gc= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= +cloud.google.com/go/iam v0.4.0 h1:YBYU00SCDzZJdHqVc4I5d6lsklcYIjQZa1YmEz4jlSE= +cloud.google.com/go/iam v0.4.0/go.mod h1:cbaZxyScUhxl7ZAkNWiALgihfP75wS/fUsVNaa1r3vA= cloud.google.com/go/kms v1.4.0/go.mod h1:fajBHndQ+6ubNw6Ss2sSd+SWvjL26RNo/dr7uxsnnOA= cloud.google.com/go/monitoring v1.6.0/go.mod h1:w+OY1TYCk4MtvY7WfEHlIp5mP8SV/gDSqOsvGhVa2KM= cloud.google.com/go/pubsub v1.25.1/go.mod h1:bY6l7rF8kCcwz6V3RaQ6kK4p5g7qc7PqjRoE9wDOqOU= @@ -25,7 +25,6 @@ contrib.go.opencensus.io/integrations/ocsql v0.1.7/go.mod h1:8DsSdjz3F+APR+0z0Wk eliasnaur.com/font v0.0.0-20220124212145-832bb8fc08c3/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA= fyne.io/fyne v1.4.3/go.mod h1:8kiPBNSDmuplxs9WnKCkaWYqbcXFy0DeAzwa6PBO9Z8= fyne.io/fyne/v2 v2.1.4/go.mod h1:p+E/Dh+wPW8JwR2DVcsZ9iXgR9ZKde80+Y+40Is54AQ= -gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= gioui.org v0.0.0-20220517073035-79f037f983a7/go.mod h1:WHoHbUjH91BJS2xkfps2AhKxji+9o3xwfsphGsCBfnM= gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= @@ -43,7 +42,6 @@ github.com/Azure/azure-service-bus-go v0.11.5/go.mod h1:MI6ge2CuQWBVq+ly456MY7Xq github.com/Azure/azure-storage-blob-go v0.15.0 h1:rXtgp8tN1p29GvpGgfJetavIG0V7OgcSXPpwp3tx6qk= github.com/Azure/azure-storage-blob-go v0.15.0/go.mod h1:vbjsVbX0dlxnRc4FFMPsS9BsJWPcne7GB7onqlPvz58= github.com/Azure/go-amqp v0.17.5/go.mod h1:9YJ3RhxRT1gquYnzpZO1vcYMMpAdJT+QEg6fwmw9Zlg= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v14.2.1-0.20220808173745-2fa44cb18b83+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.29-0.20220808173745-2fa44cb18b83/go.mod h1:MrkzG3Y3AH668QyF9KRk5neJnGgmhQ6krbhR8Q5eMvA= github.com/Azure/go-autorest/autorest/adal v0.9.21/go.mod h1:zua7mBUaCc5YnSLKYgGJR/w5ePdMDA6H56upLsHzA9U= @@ -58,22 +56,9 @@ github.com/Azure/go-autorest/tracing v0.6.1-0.20220808173745-2fa44cb18b83/go.mod github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/GoogleCloudPlatform/cloudsql-proxy v1.31.2/go.mod h1:qR6jVnZTKDCW3j+fC9mOEPHm++1nKDMkqbbkD6KNsfo= -github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= -github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I= -github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig/v3 v3.2.0/go.mod h1:tWhwTbUTndesPNeF0C900vKoq283u6zp4APT9vaF3SI= -github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/ajstarks/deck v0.0.0-20220708113203-4c766a8e1850/go.mod h1:8XEdKkD+Bk7YhhX9FS9Nz2eghb+Hh58w9U4OL28zd14= github.com/ajstarks/deck/generate v0.0.0-20220708113203-4c766a8e1850/go.mod h1:u04DhpZIpzaPnAUmhhjibCj450/2ITtLTEnvhaM49as= github.com/ajstarks/fc v0.0.0-20220317125603-4129c66e12c7/go.mod h1:lKzlLfZDk7F4FgB15Bc5vnZI094gxuX6X0pyt56BNMk= @@ -85,59 +70,52 @@ github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkK github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220826213629-cd8f367ca010/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= -github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.4.0/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/aws/aws-sdk-go v1.44.90 h1:5g93WPWhh8EL2HhQ7HOYapWj/gY6/K6rGYSx1RTyD1M= -github.com/aws/aws-sdk-go v1.44.90/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go-v2 v1.16.13 h1:HgF7OX2q0gSZtcXoo9DMEA8A2Qk/GCxmWyM0RI7Yz2Y= -github.com/aws/aws-sdk-go-v2 v1.16.13/go.mod h1:xSyvSnzh0KLs5H4HJGeIEsNYemUWdNIl0b/rP6SIsLU= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.6 h1:PPefqpze5qW/eqdgK5RqtOTQi5GhXpSxitbGqImAQ1I= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.6/go.mod h1:bcLsAUI2iDC8zC52XQvczR/zpaC1q/wP32p3wwvqGVo= -github.com/aws/aws-sdk-go-v2/config v1.17.4 h1:9HY1wbShqObySCHP2Z07blfrSWVX+nVxCZmUuLZKcG8= -github.com/aws/aws-sdk-go-v2/config v1.17.4/go.mod h1:ul+ru+huVpfduF9XRmGUq82T8T3K+nIFQuF6F+L+548= -github.com/aws/aws-sdk-go-v2/credentials v1.12.17 h1:htUjIJOQcvIUR0jC4eLkdis1DfaLL4EUbIKUFqh2WFA= -github.com/aws/aws-sdk-go-v2/credentials v1.12.17/go.mod h1:jd1mvJulXY7ccHvcSiJceYhv06yWIIRkJnwWEA4IX+g= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.14 h1:NZwZFtxXGOEIiCd8jWN55lexakug543CaO68bTpoLwg= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.14/go.mod h1:5CU57SyF5jZLSIw4OOll0PG83ThXwNdkRFOc0EltD/0= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.30 h1:Rtd+R7uWtQg5+bZ72x1g1ENjQykhFKnayo6Lv/QpxFU= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.30/go.mod h1:Fbi0PULkPycJg44P9rwhQUGknk8Fl6DUTXcCaSZ6FeI= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.20 h1:Rk8eqZSdFovt8Id+O+i2qT0c3CY13DPn2SfGOEVlxNs= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.20/go.mod h1:gdZ5gRUaxThXIZyZQ8MTtgYBk2jbHgp05BO3GcD9Cwc= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.14 h1:6Yxuq9yrkoLYab5JXqJnto9tdRuIcYVdR+eiKjsJYWU= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.14/go.mod h1:GEV9jaDPIgayiU+uevxwozcvUOjc+P4aHE2BeSjm2vE= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.21 h1:lpwSbLKYTuABo6SyUoC25xAmfO3/TehGS2SmD1EtOL0= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.21/go.mod h1:Q0pktZjvRZk77TBto6yAvUAi7fcse1bdcMctBDVGgBw= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.11 h1:zFriLANEIFWl/TQvPqhRASnU8Xr9fzshPL0OY7e1DpM= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.11/go.mod h1:EAtoA46xWR2I0fROMCsb0lgC4kYfgaK9EBrCv9hIHYM= -github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.7 h1:f0l2kujaZ0UyqwfKdtPaYQs8vzFmLbtPhWDNYeEY4ho= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.7/go.mod h1:aGaU7sKr91r4yZCi+4fWpsDepAzy8A6u/1enpD3K6mM= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.15 h1:xw0EMeNfAdmiFX3Ix9OOdqW/S2GPeV3WAYKHr2qR/W4= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.15/go.mod h1:SvmZIJp6fx7Yua+4hhigLm5kVRDWo56Cj+j8FvVl6M8= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.14 h1:c5hJNN2DkK1gAytcKp7LkiKNDJeevFSboPezEHAM4Ro= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.14/go.mod h1:8qOLjqMzY/S1kh3myDXA1yxK5eD4uN8aOJgKpgvc4OM= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.14 h1:sGFyMilgKmgg8TsGMUXApIvIrbc9SZs2sFrbdugL21c= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.14/go.mod h1:QWqlQbLB0GYO6hDDUwPKr2VKr7C6lpCdOzs92IVYQmk= -github.com/aws/aws-sdk-go-v2/service/kms v1.18.8/go.mod h1:NjgXnn0pk5rLSWZIgtx0BCwoCugRXzKZ7cDNsl98W7U= -github.com/aws/aws-sdk-go-v2/service/s3 v1.27.8 h1:zYpocIndjdPRURWkq/Rschy8WpC+vL0f74z+lJhEpJk= -github.com/aws/aws-sdk-go-v2/service/s3 v1.27.8/go.mod h1:aljgUlqAplymnhQNEcyx/fjUmQtOXCsS6Ry+ySpCcA8= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.15.21/go.mod h1:6JkZkiwXG3TLJh9O+WysncUbD1hTrsKiSTO1kbYM/MQ= -github.com/aws/aws-sdk-go-v2/service/sns v1.17.16/go.mod h1:4WxvZBlY3vIqs/zNL7IJpP5SPf5rf2wncX8z9iJGRps= -github.com/aws/aws-sdk-go-v2/service/sqs v1.19.7/go.mod h1:vMdSMmI0ajtCjxN4pTocddojOpPSQWBH6L0VsuQbLyQ= -github.com/aws/aws-sdk-go-v2/service/ssm v1.27.12/go.mod h1:YKSwltOXNDEOzMLcr9vaiFnfZbB6l6Etf94ViogY/Bk= -github.com/aws/aws-sdk-go-v2/service/sso v1.11.20 h1:3raP0UC9rvRyY4/cc4o4F3jTrNo94AYiarNUGNnq6dU= -github.com/aws/aws-sdk-go-v2/service/sso v1.11.20/go.mod h1:hPsROgDdgY/NQ1gPt7VJWG0GjSnalDC0DkkMfGEw2gc= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.2 h1:/SYpdjjAtraymql+/r719OgjxezdanAQiLb/NMxDb04= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.2/go.mod h1:5cxfDYtY2mDOlmesy4yycb6lwyy1U/iAUOHKhQLKw/E= -github.com/aws/aws-sdk-go-v2/service/sts v1.16.16 h1:otZvq9r+xjPL7qU/luX2QdBamiN+oSZURRi4sAKymO8= -github.com/aws/aws-sdk-go-v2/service/sts v1.16.16/go.mod h1:Y9iBgT1w2vHtYzJEkwD6FqILjDSsvbxcW/+wIYxyse4= -github.com/aws/smithy-go v1.13.1 h1:q09BdpUiaqpothcv393ACfWJJHzlzjB5HaNL1XHKmoQ= -github.com/aws/smithy-go v1.13.1/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/aws-sdk-go v1.44.93 h1:hAgd9fuaptBatSft27/5eBMdcA8+cIMqo96/tZ6rKl8= +github.com/aws/aws-sdk-go v1.44.93/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= +github.com/aws/aws-sdk-go-v2 v1.16.14 h1:db6GvO4Z2UqHt5gvT0lr6J5x5P+oQ7bdRzczVaRekMU= +github.com/aws/aws-sdk-go-v2 v1.16.14/go.mod h1:s/G+UV29dECbF5rf+RNj1xhlmvoNurGSr+McVSRj59w= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.7 h1:/kxQjtZc7j67TMW/aFJfpsrlvFhsq3lNbX41qN5Tro4= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.7/go.mod h1:KvHyNlxCjo9Y1Fsz+6Ex9OaN2jKijvMxzROxpW5Vctc= +github.com/aws/aws-sdk-go-v2/config v1.17.5 h1:+NS1BWvprx7nHcIk5o32LrZgifs/7Pm1V2nWjQgZ2H0= +github.com/aws/aws-sdk-go-v2/config v1.17.5/go.mod h1:H0cvPNDO3uExWts/9PDhD/0ne2esu1uaIulwn1vkwxM= +github.com/aws/aws-sdk-go-v2/credentials v1.12.18 h1:HF62tbhARhgLfvmfwUbL9qZ+dkbZYzbFdxBb3l5gr7Q= +github.com/aws/aws-sdk-go-v2/credentials v1.12.18/go.mod h1:O7n/CPagQ33rfG6h7vR/W02ammuc5CrsSM22cNZp9so= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.15 h1:nkQ+aI0OCeYfzrBipL6ja/6VEbUnHQoZHBHtoK+Nzxw= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.15/go.mod h1:Oz2/qWINxIgSmoZT9adpxJy2UhpcOAI3TIyWgYMVSz0= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.31 h1:Ggf7rvFS1s3/Nauv2mokAY+RfKsCAHvfiiZJoYd0lV0= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.31/go.mod h1:Iv2xOFdy8aFIxVKEdzo9puLXFaGNnjx5xzGYIlGzhuY= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.21 h1:gRIXnmAVNyoRQywdNtpAkgY+f30QNzgF53Q5OobNZZs= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.21/go.mod h1:XsmHMV9c512xgsW01q7H0ut+UQQQpWX8QsFbdLHDwaU= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.15 h1:noAhOo2mMDyYhTx99aYPvQw16T3fQ/DiKAv9fzpIKH8= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.15/go.mod h1:kjJ4CyD9M3Wq88GYg3IPfj67Rs0Uvz8aXK7MJ8BvE4I= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.22 h1:nF+E8HfYpOMw6M5oA9efB602VC00IHNQnB5CmFvZPvA= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.22/go.mod h1:tltHVGy977LrSOgRR5aV9+miyno/Gul/uJNPKS7FzP4= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.12 h1:i0Tig01XGhXo/ki1BZUbRMhusGVCScEvaWdlFRWxAKk= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.12/go.mod h1:QPoxYMISvteeDH4A89gGWWlCA/Bz6oUDF7hGdPdOPuE= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.8 h1:NpixDFjwr1BZg2459mX07NZnVYGGp62Lb6AtVGOLNlo= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.8/go.mod h1:MJUgrBPfGB4yk2uWoImVqd9cklry1hATyJV/7gJ6JTk= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.16 h1:kHc3TqW5kJ9Vfd9YEwywrNrL87DItpvAohlP+OuzABY= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.16/go.mod h1:U/9ZCgIx6x6NTdFRt60qO3gxUxBx4gRi+S/Yc/n+7vc= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.15 h1:xlf0J6DUgAj/ocvKQxCmad8Bu1lJuRbt5Wu+4G1xw1g= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.15/go.mod h1:ZVJ7ejRl4+tkWMuCwjXoy0jd8fF5u3RCyWjSVjUIvQE= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.15 h1:v9f7NY7D19ssE2EM+m9yT1m5zdWHuRAsZaFh24GAkOk= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.15/go.mod h1:gXfPo3nMoCbJKTZKDxv3rUhcYJjYT/K++jEqcWHjD/Q= +github.com/aws/aws-sdk-go-v2/service/kms v1.18.9/go.mod h1:8sR6O18d56mlJf0VkYD7mOtrBoM//8eym7FcfG1t9Sc= +github.com/aws/aws-sdk-go-v2/service/s3 v1.27.9 h1:imVonvre+AHMcDc3B9bPHHy5ZgjIkkYc/jyDBK8FHFw= +github.com/aws/aws-sdk-go-v2/service/s3 v1.27.9/go.mod h1:0Gfmg8gjPhVPy/IXkLAmyKZbAue+2s11BWKH+oXggmg= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.15.22/go.mod h1:zT2j7Ndi+FcBX+zfYLDppqODSgSdKlquB3LPLPVDAts= +github.com/aws/aws-sdk-go-v2/service/sns v1.17.17/go.mod h1:hygPv9etah0QZWMe7TEE+PCPe1VL+1tfwYvJZz478uc= +github.com/aws/aws-sdk-go-v2/service/sqs v1.19.8/go.mod h1:nMu/p558phDp5xa1USWHcofcWvoaat4Dr46w7ruM1XQ= +github.com/aws/aws-sdk-go-v2/service/ssm v1.27.13/go.mod h1:DLGkJX+FzEhluRGOTf9eejrDPu1gZ+1GuNkgLYdnPFM= +github.com/aws/aws-sdk-go-v2/service/sso v1.11.21 h1:7jUFr+7F4MzIjCZzy7ygRtXFQcQ0kAbT0gUvtUeAdyU= +github.com/aws/aws-sdk-go-v2/service/sso v1.11.21/go.mod h1:q8nYq51W3gpZempYsAD83fPRlrOTMCwN+Ahg4BKFTXQ= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.3 h1:UTTPNP3/WzZa7hoHP3Szb/Yl0bM3NoBrf5ABy1OArUM= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.3/go.mod h1:+IF75RMJh0+zqTGXGshyEGRsU2ImqWv6UuHGkHl6kEo= +github.com/aws/aws-sdk-go-v2/service/sts v1.16.17 h1:LVM2jzEQ8mhb2dhrFl4PJ3sa5+KcKT01dsMk2Ma9/FU= +github.com/aws/aws-sdk-go-v2/service/sts v1.16.17/go.mod h1:bQujK1n0V1D1Gz5uII1jaB1WDvhj4/T3tElsJnVXCR0= +github.com/aws/smithy-go v1.13.2 h1:TBLKyeJfXTrTXRHmsv4qWt9IQGYyWThLYaJWSahTOGE= +github.com/aws/smithy-go v1.13.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benoitkugler/pstokenizer v1.0.0/go.mod h1:l1G2Voirz0q/jj0TQfabNxVsa8HZXh/VMxFSRALWTiE= @@ -146,31 +124,20 @@ github.com/benoitkugler/textlayout v0.1.1/go.mod h1:o+1hFV+JSHBC9qNLIuwVoLedERU7 github.com/benoitkugler/textlayout-testdata v0.1.1/go.mod h1:i/qZl09BbUOtd7Bu/W1CAubRwTWrEXWq6JwMkw8wYxo= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bitly/go-hostpool v0.1.0/go.mod h1:4gOCgp6+NZnVqlKyZ/iBZFTAJKembaVENUpMkpg42fw= -github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= -github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:po7NpZ/QiTKzBKyrsEAxwnTamCoh8uDk/egRpQ7siIc= github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20220520190051-1e77728a1eaa/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= -github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/coreos/go-oidc v2.2.1+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= @@ -185,41 +152,26 @@ github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/ github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dvyukov/go-fuzz v0.0.0-20220726122315-1d375ef9f9f6/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= -github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= -github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q= github.com/elazarl/goproxy v0.0.0-20220901064549-fbd10ff4f5a1 h1:ecIiM5NYeEOhy5trm8xel6wpUhYH+QWteUKnwcbCMl4= -github.com/elazarl/goproxy v0.0.0-20220901064549-fbd10ff4f5a1/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= -github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= -github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful/v3 v3.8.0 h1:eCZ8ulSerjdAiaNpF7GxXIE7ZCMo1moN1qX+S609eVw= github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE= -github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.10.3/go.mod h1:fJJn/j26vwOu972OllsvAgJJM//w9BV6Fxbg2LuVd34= github.com/envoyproxy/protoc-gen-validate v0.6.7 h1:qcZcULcd/abmQg6dwigimCNEyi4gg31M/xaciQlDml8= github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k= github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= +github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/form3tech-oss/jwt-go v3.2.5+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo= -github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3/go.mod h1:CzM2G82Q9BDUvMTGHnXf/6OExw/Dz2ivDj48nVg7Lg8= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fyne-io/mobile v0.1.2/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY= -github.com/getkin/kin-openapi v0.100.0/go.mod h1:w4lRPHiyOdwGbOkLIyk+P0qCwlu7TXPCHD/64nSXzgE= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/gioui/uax v0.2.1-0.20220325163150-e3d987515a12/go.mod h1:kDhBRTA/i3H46PVdhqcw26TdGSIj42TOKNWKY+Kipnw= @@ -234,7 +186,6 @@ github.com/go-fonts/liberation v0.2.0/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2H github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY= github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220806181222-55e207c401ad/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81 h1:6zl3BbBhdnMkpSj2YY30qV3gDcVBGtFgVsV3+/i+mKQ= @@ -246,7 +197,6 @@ github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= -github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= @@ -256,7 +206,7 @@ github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/ github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-pdf/fpdf v1.4.3 h1:0ZbUVyy3URshI6fCIaCD/iTVW33dqA8zbUHuGynxAPA= github.com/go-pdf/fpdf v1.4.3/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= @@ -264,7 +214,6 @@ github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v2.20.0+incompatible/go.mod h1:N/mhXZITr/EQAOErEHciKvO1bFei2Lld2Ym6h96pdy0= github.com/go-text/typesetting v0.0.0-20220411150340-35994bc27a7b/go.mod h1:ZNYu5saGoMOqtkVH5T8onTwhzenDUVszI+5WFHJRaxQ= github.com/go-toolsmith/astcopy v1.0.2 h1:YnWf5Rnh1hUudj11kei53kI57quN/VH6Hp1n+erozn0= @@ -273,14 +222,13 @@ github.com/go-toolsmith/astequal v1.0.3 h1:+LVdyRatFS+XO78SGV4I3TCEA0AC7fKEGma+f github.com/go-toolsmith/astequal v1.0.3/go.mod h1:9Ai4UglvtR+4up+bAD4+hCj7iTo4m/OXVTSLnCyTAx4= github.com/go-toolsmith/strparse v1.0.0 h1:Vcw78DnpCAKlM20kSbAyO4mPfJn/lyYA4BJUDxe2Jb4= github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8= -github.com/go-zookeeper/zk v1.0.3/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.1.0/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0= github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/gocql/gocql v1.2.0 h1:TZhsCd7fRuye4VyHr3WCvWwIQaZUmjsqnSIXK9FcVCE= -github.com/gocql/gocql v1.2.0/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8= +github.com/gocql/gocql v1.2.1 h1:G/STxUzD6pGvRHzG0Fi7S04SXejMKBbRZb7pwre1edU= +github.com/gocql/gocql v1.2.1/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8= github.com/gocraft/dbr/v2 v2.7.3 h1:5/PTRiBkdD2FoHpnrCMoEUw5Wf/Cl3l3PjJ02Wm+pwM= github.com/gocraft/dbr/v2 v2.7.3/go.mod h1:8IH98S8M8J0JSEiYk0MPH26ZDUKemiQ/GvmXL5jo+Uw= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -300,14 +248,12 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/cel-go v0.12.5/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= @@ -336,50 +282,22 @@ github.com/googleapis/gax-go/v2 v2.5.1 h1:kBRZU0PSuI7PspsSb/ChWoVResUcwNVIdpB049 github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/hanwen/go-fuse v1.0.0/go.mod h1:unqXarDXqzAk0rt98O2tVndEPIpUgLD9+rwFisZH3Ok= github.com/hanwen/go-fuse/v2 v2.1.0/go.mod h1:oRyA5eK+pvJyv5otpO/DgccS8y/RvYMaO00GgRLGryc= -github.com/hashicorp/consul/api v1.14.0/go.mod h1:bcaw5CSZ7NE9qfOfKCI1xb7ZKjzu/MyvQkCLTfqLqxQ= -github.com/hashicorp/consul/sdk v0.11.0/go.mod h1:yPkX5Q6CsxTFMjQQDJwzeNmUUF5NUGGbrDsv9wTb8cw= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v1.3.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.5/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.4.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0= -github.com/hashicorp/serf v0.10.0/go.mod h1:bXN03oZc5xlH46k/K1qTrpXb9ERKyY1/i/N5mxvgrZw= -github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20220517205856-0058ec4f073c/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= @@ -388,7 +306,7 @@ github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5ey github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgx/v4 v4.17.1/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw= +github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw= github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackmordaunt/icns v0.0.0-20181231085925-4f16af745526/go.mod h1:UQkeMHVoNcyXYq9otUupF7/h/2tmHlhrS2zw7ZVvUqc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -398,7 +316,6 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= -github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josephspurrier/goversioninfo v0.0.0-20200309025242-14b0ab84c6ca/go.mod h1:eJTEwMjXb7kZ633hO3Ln9mBUCOjX2+FlTljvpl9SYdE= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= @@ -406,12 +323,11 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v1.0.0/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.6.2/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.15.10-0.20220829133349-1481365fd7f6 h1:XvRQFsgUiUur2+46prtn50vffdMrgZL9rff9228HYhw= -github.com/klauspost/compress v1.15.10-0.20220829133349-1481365fd7f6/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.15.10-0.20220907083105-a63f67b75f97 h1:IqNP9Vb1P7Cx/iHsh2a8jOXPGZtABKcWQxNcRuSdhZ0= +github.com/klauspost/compress v1.15.10-0.20220907083105-a63f67b75f97/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/cpuid/v2 v2.1.1 h1:t0wUqjowdm8ezddV5k0tLWVklVuvLJpoHeb4WBdydm0= github.com/klauspost/cpuid/v2 v2.1.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kpango/fastime v1.1.4 h1:pus9JgJBg/8Jie3ozayA4yNIV67BUPhbq0wMZY3CtYo= @@ -433,8 +349,8 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= -github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= +github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= @@ -451,19 +367,11 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= -github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= -github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= -github.com/mitchellh/cli v1.1.4/go.mod h1:vTLESy5mRhKOs9KDp0/RATawxP1UqBmdrpVRMnpcvKQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= -github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= @@ -475,51 +383,31 @@ github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q= -github.com/nats-io/jwt/v2 v2.0.3/go.mod h1:VRP+deawSXyhNjXmxPCHskrR6Mq50BqpEI5SEcNiGlY= -github.com/nats-io/nats-server/v2 v2.5.0/go.mod h1:Kj86UtrXAL6LwYRA6H4RqzkHhK0Vcv2ZnKD5WbQ1t3g= -github.com/nats-io/nats.go v1.12.1/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w= -github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s= -github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= -github.com/neelance/sourcemap v0.0.0-20200213170602-2833bce08e4c/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/ginkgo/v2 v2.1.6 h1:Fx2POJZfKRQcM1pH49qSZiYeu319wji004qX+GDovrU= github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= github.com/onsi/gomega v1.20.2 h1:8uQq0zMgLEfa0vRrrBgaJF2gyW9Da9BmfGV+OyUzfkY= github.com/onsi/gomega v1.20.2/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/pierrec/cmdflag v0.0.2/go.mod h1:a3zKGZ3cdQUfxjd0RGMLZr8xI3nvpJOB+m6o/1X5BmU= -github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4/v3 v3.3.5 h1:JzKda6jLXZpQK5/ulrEfT1I66tsKiGlw6sjKssFpwt8= github.com/pierrec/lz4/v3 v3.3.5/go.mod h1:280XNCGS8jAcG++AHdd6SeWnzyJ1w9oow2vbORyey8Q= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pkg/sftp v1.13.5/go.mod h1:wHDZ0IZX6JcBYRK1TH9bcVq8G7TLpVHYIGJRFnmPfxg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/pquerna/cachecontrol v0.1.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= @@ -539,9 +427,7 @@ github.com/quasilyte/gogrep v0.0.0-20220828223005-86e4605de09f h1:6Gtn2i04RD0gVy github.com/quasilyte/gogrep v0.0.0-20220828223005-86e4605de09f/go.mod h1:Cm9lpz9NZjEoL1tgZ2OgeUKPIxL1meE7eo60Z6Sk+Ng= github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs= github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= @@ -549,28 +435,17 @@ github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= -github.com/ryanuber/columnize v2.1.2+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/schollz/progressbar/v2 v2.15.0/go.mod h1:UdPq3prGkfQ7MOzZKlDRpYKcFqEMczbD7YmbPgpzKMI= github.com/scylladb/go-reflectx v1.0.1 h1:b917wZM7189pZdlND9PbIJ6NQxfDPfBvUaQ7cjj1iZQ= github.com/scylladb/go-reflectx v1.0.1/go.mod h1:rWnOfDIRWBGN0miMLIcoPt/Dhi2doCMZqwMCJ3KupFc= github.com/scylladb/gocqlx v1.5.0 h1:p7NEqRaCMAtW2nvq62iyUNXmIYP29373YOC7D2Xd7Qg= github.com/scylladb/gocqlx v1.5.0/go.mod h1:QarZcw5kpYh31MXfxiN2JWWvF1cgZbYqfTfXwmwhpEQ= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= -github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= -github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= -github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/smartystreets/assertions v1.13.0/go.mod h1:wDmR7qL282YbGsPy6H/yAsesrxfxaaSlJazyFLYVFx8= -github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= -github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= -github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -581,16 +456,11 @@ github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9/go.mod h1:mvWM0+15 github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780/go.mod h1:mvWM0+15UqyrFKqdRjY6LuAVJR0HOVhJlEgZ5JWtSWU= github.com/srwiley/rasterx v0.0.0-20220128185129-2efea2b9ea41/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= -github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk= -github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= @@ -599,35 +469,20 @@ github.com/vdaas/vald-client-go v1.5.6/go.mod h1:JT0mLVsJYMs/ZkUxHPviWYl9Uz6QCQt github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk= github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.4.14/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zeebo/assert v1.3.1 h1:vukIABvugfNMZMQO1ABsyQDJDTVQbn+LWSMy1ol1h6A= github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= -go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= -go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/v2 v2.305.4/go.mod h1:Ud+VUwIi9/uQHOMA+4ekToJ12lTxlv0zB/+DHwTGEbU= -go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY= -go.etcd.io/etcd/pkg/v3 v3.5.4/go.mod h1:OI+TtO+Aa3nhQSppMbwE4ld3uF1/fqqwbpfndbbrEe0= -go.etcd.io/etcd/raft/v3 v3.5.4/go.mod h1:SCuunjYvZFC0fBX0vxMSPjuZmpcSk+XaAcMrD6Do03w= -go.etcd.io/etcd/server/v3 v3.5.4/go.mod h1:S5/YTU15KxymM5l3T6b09sNOHPXqGYIZStpuuGbb65c= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.34.0/go.mod h1:fk1+icoN47ytLSgkoWHLJrtVTSQ+HgmkNgPTKrk/Nsc= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0/go.mod h1:548ZsYzmT4PL4zWKRd8q/N4z0Wxzn/ZxUE+lkEpwWQA= go.opentelemetry.io/otel v1.9.0 h1:8WZNQFIB2a71LnANS9JeyidJKKGOOremcUtb/OtHISw= go.opentelemetry.io/otel v1.9.0/go.mod h1:np4EoPGzoPs3O67xUVNoPPcmSvsfOxNlNA4F4AC+0Eo= go.opentelemetry.io/otel/exporters/jaeger v1.9.0 h1:gAEgEVGDWwFjcis9jJTOJqZNxDzoZfR12WNIxr7g9Ww= go.opentelemetry.io/otel/exporters/jaeger v1.9.0/go.mod h1:hquezOLVAybNW6vanIxkdLXTXvzlj2Vn3wevSP15RYs= -go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= -go.opentelemetry.io/otel/metric v0.31.0/go.mod h1:ohmwj9KTSIeBnDBm/ZwH2PSZxZzoOaG2xZeekTRzL5A= go.opentelemetry.io/otel/sdk v1.9.0 h1:LNXp1vrr83fNXTHgU8eO89mhzxb/bbWAsHG6fNf3qWo= go.opentelemetry.io/otel/sdk v1.9.0/go.mod h1:AEZc8nt5bd2F7BC24J5R0mrjYnpEgYHyTcM/vrSple4= -go.opentelemetry.io/otel/sdk/export/metric v0.28.0/go.mod h1:2HTuv+l3ia7NquArnWavCoKhXi9yBJPpKqMHr1trKa0= -go.opentelemetry.io/otel/sdk/metric v0.31.0/go.mod h1:fl0SmNnX9mN9xgU6OLYLMBMrNAsaZQi7qBwprwO3abk= go.opentelemetry.io/otel/trace v1.9.0 h1:oZaCNJUjWcg60VXWee8lJKlqhPbXAPB51URuR47pQYc= go.opentelemetry.io/otel/trace v1.9.0/go.mod h1:2737Q0MuG8q1uILYm2YYVkAyLtOofiTNGg6VODnOiPo= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= @@ -637,8 +492,8 @@ go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/automaxprocs v1.5.1 h1:e1YG66Lrk73dn4qhg8WFSvhF0JuFQF0ERIp4rpuV8Qk= go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= -go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= -go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= @@ -651,24 +506,24 @@ gocloud.dev v0.26.0 h1:4rM/SVL0lLs+rhC0Gmc+gt/82DBpb7nbpIZKXXnfMXg= gocloud.dev v0.26.0/go.mod h1:mkUgejbnbLotorqDyvedJO20XcZNTynmSeVSQS9btVg= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 h1:tnebWN09GYg9OLPss1KXj8txwZc6X6uMr6VFdcGNbHw= -golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 h1:Ic/qN6TEifvObMGQy72k0n1LlJr7DjWWEi+MOsDOiSk= -golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/image v0.0.0-20220722155232-062f8c9fd539 h1:/eM0PCrQI2xd471rI+snWuu251/+/jpBpZqir2mPdnU= -golang.org/x/image v0.0.0-20220722155232-062f8c9fd539/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY= +golang.org/x/exp v0.0.0-20220907003533-145caa8ea1d0 h1:17k44ji3KFYG94XS5QEFC8pyuOlMh3IoR+vkmTZmJJs= +golang.org/x/exp v0.0.0-20220907003533-145caa8ea1d0/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= +golang.org/x/exp/typeparams v0.0.0-20220907003533-145caa8ea1d0 h1:/w0J1vuLHutJv6sFrxOtCXQs2XiC9awfGYSYAUygcMk= +golang.org/x/exp/typeparams v0.0.0-20220907003533-145caa8ea1d0/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= +golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 h1:Lj6HJGCSn5AjxRAH2+r35Mir4icalbqku+CLUtjnvXY= +golang.org/x/image v0.0.0-20220902085622-e7cb96979f69/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY= -golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 h1:1WGATo9HAhkWMbfyuVU0tEFP88OIkUvwaHFveQPvzCQ= +golang.org/x/net v0.0.0-20220907135653-1e95f45603a7/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094 h1:2o1E+E8TpNLklK9nHiPiK1uzIYrIHt+cQx3ynCwq9V8= golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc= -golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A= +golang.org/x/sync v0.0.0-20220907140024-f12130a52804/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20220907062415-87db552b00fd h1:AZeIEzg+8RCELJYq8w+ODLVxFgLMMigSwO/ffKPEd9U= +golang.org/x/sys v0.0.0-20220907062415-87db552b00fd/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= @@ -677,22 +532,21 @@ golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 h1:ftMN5LMiBFjbzleLqtoBZk7K golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f h1:uF6paiQQebLeSXkrTqHqz0MXhXXS1KgF41eUdBNvxK0= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY= gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY= -gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E= -gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA= +gonum.org/v1/gonum v0.12.0 h1:xKuo6hzt+gMav00meVPUlXwSdoEJP46BR+wdxQEFK2o= gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 h1:vJpL69PeUullhJyKtTjHjENEmZU3BkO4e+fod7nKzgM= gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946/go.mod h1:BQUWDHIAygjdt1HnUPQ0eWqLN2n5FwJycrpYUVUOx2I= -gonum.org/v1/plot v0.11.0 h1:z2ZkgNqW34d0oYUzd80RRlc0L9kWtenqK4kflZG1lGc= -gonum.org/v1/plot v0.11.0/go.mod h1:fH9YnKnDKax0u5EzHVXvhN5HJwtMFWIOLNuhgUahbCQ= -google.golang.org/api v0.94.0 h1:KtKM9ru3nzQioV1HLlUf1cR7vMYJIpgls5VhAYQXIwA= -google.golang.org/api v0.94.0/go.mod h1:eADj+UBuxkh5zlrSntJghuNeg8HwQ1w5lTKkuqaETEI= +gonum.org/v1/plot v0.12.0 h1:y1ZNmfz/xHuHvtgFe8USZVyykQo5ERXPnspQNVK15Og= +gonum.org/v1/plot v0.12.0/go.mod h1:PgiMf9+3A3PnZdJIciIXmyN1FwdAA6rXELSN761oQkw= +google.golang.org/api v0.95.0 h1:d1c24AAS01DYqXreBeuVV7ewY/U8Mnhh47pwtsgVtYg= +google.golang.org/api v0.95.0/go.mod h1:eADj+UBuxkh5zlrSntJghuNeg8HwQ1w5lTKkuqaETEI= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf h1:Q5xNKbTSFwkuaaGaR7CMcXEM5sy19KYdUU8iF8/iRC0= -google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= +google.golang.org/genproto v0.0.0-20220902135211-223410557253 h1:vXJMM8Shg7TGaYxZsQ++A/FOSlbDmDtWhS/o+3w/hj4= +google.golang.org/genproto v0.0.0-20220902135211-223410557253/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY= @@ -701,52 +555,42 @@ google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/inconshreveable/log15.v2 v2.0.0-20200109203555-b30bc20e4fd1/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= -gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw= inet.af/netaddr v0.0.0-20220811202034-502d2d690317 h1:U2fwK6P2EqmopP/hFLTOAjWTki0qgd4GMJn5X8wOleU= inet.af/netaddr v0.0.0-20220811202034-502d2d690317/go.mod h1:OIezDfdzOgFhuw4HuWapWq2e9l0H9tK4F1j+ETRtF3k= -k8s.io/api v0.24.2 h1:g518dPU/L7VRLxWfcadQn2OnsiGWVOadTLpdnqgY2OI= -k8s.io/api v0.24.2/go.mod h1:AHqbSkTm6YrQ0ObxjO3Pmp/ubFF/KuM7jU+3khoBsOg= -k8s.io/apiextensions-apiserver v0.24.2 h1:/4NEQHKlEz1MlaK/wHT5KMKC9UKYz6NZz6JE6ov4G6k= -k8s.io/apiextensions-apiserver v0.24.2/go.mod h1:e5t2GMFVngUEHUd0wuCJzw8YDwZoqZfJiGOW6mm2hLQ= -k8s.io/apimachinery v0.24.2 h1:5QlH9SL2C8KMcrNJPor+LbXVTaZRReml7svPEh4OKDM= -k8s.io/apimachinery v0.24.2/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM= -k8s.io/apiserver v0.24.2/go.mod h1:pSuKzr3zV+L+MWqsEo0kHHYwCo77AT5qXbFXP2jbvFI= -k8s.io/cli-runtime v0.24.2 h1:KxY6tSgPGsahA6c1/dmR3uF5jOxXPx2QQY6C5ZrLmtE= -k8s.io/cli-runtime v0.24.2/go.mod h1:1LIhKL2RblkhfG4v5lZEt7FtgFG5mVb8wqv5lE9m5qY= -k8s.io/client-go v0.24.2 h1:CoXFSf8if+bLEbinDqN9ePIDGzcLtqhfd6jpfnwGOFA= -k8s.io/client-go v0.24.2/go.mod h1:zg4Xaoo+umDsfCWr4fCnmLEtQXyCNXCvJuSsglNcV30= -k8s.io/code-generator v0.24.2/go.mod h1:dpVhs00hTuTdTY6jvVxvTFCk6gSMrtfRydbhZwHI15w= -k8s.io/component-base v0.24.2 h1:kwpQdoSfbcH+8MPN4tALtajLDfSfYxBDYlXobNWI6OU= -k8s.io/component-base v0.24.2/go.mod h1:ucHwW76dajvQ9B7+zecZAP3BVqvrHoOxm8olHEg0nmM= -k8s.io/gengo v0.0.0-20220613173612-397b4ae3bce7/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= +k8s.io/api v0.25.0 h1:H+Q4ma2U/ww0iGB78ijZx6DRByPz6/733jIuFpX70e0= +k8s.io/api v0.25.0/go.mod h1:ttceV1GyV1i1rnmvzT3BST08N6nGt+dudGrquzVQWPk= +k8s.io/apiextensions-apiserver v0.25.0 h1:CJ9zlyXAbq0FIW8CD7HHyozCMBpDSiH7EdrSTCZcZFY= +k8s.io/apiextensions-apiserver v0.25.0/go.mod h1:3pAjZiN4zw7R8aZC5gR0y3/vCkGlAjCazcg1me8iB/E= +k8s.io/apimachinery v0.25.0 h1:MlP0r6+3XbkUG2itd6vp3oxbtdQLQI94fD5gCS+gnoU= +k8s.io/apimachinery v0.25.0/go.mod h1:qMx9eAk0sZQGsXGu86fab8tZdffHbwUfsvzqKn4mfB0= +k8s.io/cli-runtime v0.25.0 h1:XBnTc2Fi+w818jcJGzhiJKQuXl8479sZ4FhtV5hVJ1Q= +k8s.io/cli-runtime v0.25.0/go.mod h1:bHOI5ZZInRHhbq12OdUiYZQN8ml8aKZLwQgt9QlLINw= +k8s.io/client-go v0.25.0 h1:CVWIaCETLMBNiTUta3d5nzRbXvY5Hy9Dpl+VvREpu5E= +k8s.io/client-go v0.25.0/go.mod h1:lxykvypVfKilxhTklov0wz1FoaUZ8X4EwbhS6rpRfN8= +k8s.io/component-base v0.25.0 h1:haVKlLkPCFZhkcqB6WCvpVxftrg6+FK5x1ZuaIDaQ5Y= +k8s.io/component-base v0.25.0/go.mod h1:F2Sumv9CnbBlqrpdf7rKZTmmd2meJq0HizeyY/yAFxk= k8s.io/klog/v2 v2.80.0 h1:lyJt0TWMPaGoODa8B8bUuxgHS3W/m/bNr2cca3brA/g= k8s.io/klog/v2 v2.80.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea h1:3QOH5+2fGsY8e1qf+GIFpg+zw/JGNrgyZRQR7/m6uWg= k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea/go.mod h1:C/N6wCaBHeBHkHUesQOQy2/MZqGgMAFPqGsGQLdbZBU= -k8s.io/metrics v0.24.2 h1:3lgEq973VGPWAEaT9VI/p0XmI0R5kJgb/r9Ufr5fz8k= -k8s.io/metrics v0.24.2/go.mod h1:5NWURxZ6Lz5gj8TFU83+vdWIVASx7W8lwPpHYCqopMo= +k8s.io/metrics v0.25.0 h1:z/tyqXUCxvmFsKIO7GH6ulvogYvGp+pDmlz5ANSQVPE= +k8s.io/metrics v0.25.0/go.mod h1:HZZrbhuRX+fsDcRc3u59o2FbrKhqD67IGnoFECNmovc= k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 h1:H9TCJUUx+2VA0ZiD9lvtaX8fthFsMoD+Izn93E/hm8U= k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.32/go.mod h1:fEO7lRTdivWO2qYVCVG7dEADOMo/MLDCVr8So2g88Uw= -sigs.k8s.io/controller-runtime v0.12.2 h1:nqV02cvhbAj7tbt21bpPpTByrXGn2INHRsi39lXy9sE= -sigs.k8s.io/controller-runtime v0.12.2/go.mod h1:qKsk4WE6zW2Hfj0G4v10EnNB2jMG1C+NTb8h+DwCoU0= +sigs.k8s.io/controller-runtime v0.13.0 h1:iqa5RNciy7ADWnIc8QxCbOX5FEKVR3uxVxKHRMc2WIQ= +sigs.k8s.io/controller-runtime v0.13.0/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/kustomize/api v0.12.1 h1:7YM7gW3kYBwtKvoY216ZzY+8hM+lV53LUayghNRJ0vM= diff --git a/hack/go.mod.default b/hack/go.mod.default index 81cfbc4c69..d7376b1d58 100755 --- a/hack/go.mod.default +++ b/hack/go.mod.default @@ -346,7 +346,6 @@ replace ( github.com/mitchellh/cli => github.com/mitchellh/cli latest github.com/mitchellh/colorstring => github.com/mitchellh/colorstring latest github.com/mitchellh/go-homedir => github.com/mitchellh/go-homedir latest - github.com/mitchellh/go-testing-interface => github.com/mitchellh/go-testing-interface latest github.com/mitchellh/go-wordwrap => github.com/mitchellh/go-wordwrap latest github.com/mitchellh/mapstructure => github.com/mitchellh/mapstructure latest github.com/moby/locker => github.com/moby/locker latest @@ -536,25 +535,25 @@ replace ( gotest.tools/v3 => gotest.tools/v3 latest honnef.co/go/tools => honnef.co/go/tools latest inet.af/netaddr => inet.af/netaddr latest - k8s.io/api => k8s.io/api v0.24.2 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.24.2 - k8s.io/apimachinery => k8s.io/apimachinery v0.24.2 - k8s.io/apiserver => k8s.io/apiserver v0.24.2 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.24.2 - k8s.io/client-go => k8s.io/client-go v0.24.2 - k8s.io/code-generator => k8s.io/code-generator v0.24.2 - k8s.io/component-base => k8s.io/component-base v0.24.2 - k8s.io/cri-api => k8s.io/cri-api v0.24.2 + k8s.io/api => k8s.io/api v0.25.0 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.25.0 + k8s.io/apimachinery => k8s.io/apimachinery v0.25.0 + k8s.io/apiserver => k8s.io/apiserver v0.25.0 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.25.0 + k8s.io/client-go => k8s.io/client-go v0.25.0 + k8s.io/code-generator => k8s.io/code-generator v0.25.0 + k8s.io/component-base => k8s.io/component-base v0.25.0 + k8s.io/cri-api => k8s.io/cri-api v0.25.0 k8s.io/gengo => k8s.io/gengo latest k8s.io/klog => k8s.io/klog latest k8s.io/klog/v2 => k8s.io/klog/v2 latest k8s.io/kube-openapi => k8s.io/kube-openapi latest - k8s.io/metrics => k8s.io/metrics v0.24.2 + k8s.io/metrics => k8s.io/metrics v0.25.0 k8s.io/utils => k8s.io/utils latest nhooyr.io/websocket => nhooyr.io/websocket latest rsc.io/pdf => rsc.io/pdf latest sigs.k8s.io/apiserver-network-proxy/konnectivity-client => sigs.k8s.io/apiserver-network-proxy/konnectivity-client latest - sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.12.2 + sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.13.0 sigs.k8s.io/json => sigs.k8s.io/json latest sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api latest sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml latest diff --git a/internal/backoff/backoff_test.go b/internal/backoff/backoff_test.go index 491f321274..fd73fe2893 100644 --- a/internal/backoff/backoff_test.go +++ b/internal/backoff/backoff_test.go @@ -565,14 +565,14 @@ func Test_backoff_Do(t *testing.T) { }, fields: fields{ wg: sync.WaitGroup{}, - backoffFactor: 0, - initialDuration: 0, + backoffFactor: 1.1, + initialDuration: float64(time.Millisecond * 5), jittedInitialDuration: 0, jitterLimit: 0, durationLimit: 10, maxDuration: 0, maxRetryCount: 1, - backoffTimeLimit: 50 * time.Microsecond, + backoffTimeLimit: 30 * time.Microsecond, errLog: true, }, want: want{ diff --git a/internal/backoff/option_test.go b/internal/backoff/option_test.go index cac866a363..3d50764297 100644 --- a/internal/backoff/option_test.go +++ b/internal/backoff/option_test.go @@ -423,7 +423,8 @@ func TestWithEnableErrorLog(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/cache/cache_test.go b/internal/cache/cache_test.go index fc67ba5eb2..16e8460506 100644 --- a/internal/cache/cache_test.go +++ b/internal/cache/cache_test.go @@ -108,7 +108,8 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/cache/cacher/cacher_test.go b/internal/cache/cacher/cacher_test.go index 78ccab2574..74f1d81d8c 100644 --- a/internal/cache/cacher/cacher_test.go +++ b/internal/cache/cacher/cacher_test.go @@ -66,7 +66,8 @@ func TestType_String(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -156,7 +157,8 @@ func TestToType(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) diff --git a/internal/cache/gache/gache_test.go b/internal/cache/gache/gache_test.go index 528b30f9d9..f667e91f35 100644 --- a/internal/cache/gache/gache_test.go +++ b/internal/cache/gache/gache_test.go @@ -103,7 +103,8 @@ func TestNew(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -166,7 +167,8 @@ func Test_cache_Start(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -263,7 +265,8 @@ func Test_cache_Get(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) c := &cache{ @@ -346,7 +349,8 @@ func Test_cache_Set(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -448,7 +452,8 @@ func Test_cache_Delete(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) c := &cache{ @@ -546,7 +551,8 @@ func Test_cache_GetAndDelete(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) c := &cache{ diff --git a/internal/cache/gache/option_test.go b/internal/cache/gache/option_test.go index 7e836821cd..8cb75799d3 100644 --- a/internal/cache/gache/option_test.go +++ b/internal/cache/gache/option_test.go @@ -68,7 +68,8 @@ func TestDefaultOptions(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -141,7 +142,8 @@ func TestWithGache(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -219,7 +221,8 @@ func TestWithExpiredHook(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -289,7 +292,8 @@ func TestWithExpireDuration(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -359,7 +363,8 @@ func TestWithExpireCheckDuration(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -448,7 +453,8 @@ func Test_defaultOptions(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/cache/option_test.go b/internal/cache/option_test.go index ab4db63603..f2c3437efb 100644 --- a/internal/cache/option_test.go +++ b/internal/cache/option_test.go @@ -77,7 +77,8 @@ func TestWithExpiredHook(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -147,7 +148,8 @@ func TestWithType(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -230,7 +232,8 @@ func TestWithExpireDuration(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -313,7 +316,8 @@ func TestWithExpireCheckDuration(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/compress/compress_test.go b/internal/compress/compress_test.go new file mode 100644 index 0000000000..c2e2f755ba --- /dev/null +++ b/internal/compress/compress_test.go @@ -0,0 +1,30 @@ +// +// Copyright (C) 2019-2022 vdaas.org vald team +// +// 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 compress + +import ( + "testing" + + "github.com/vdaas/vald/internal/log" + "github.com/vdaas/vald/internal/log/logger" + "github.com/vdaas/vald/internal/test/goleak" +) + +func TestMain(m *testing.M) { + log.Init(log.WithLoggerType(logger.NOP.String())) + goleak.VerifyTestMain(m) +} diff --git a/internal/compress/gob_test.go b/internal/compress/gob_test.go index 54e0431375..443f05b5bc 100644 --- a/internal/compress/gob_test.go +++ b/internal/compress/gob_test.go @@ -81,7 +81,8 @@ func TestNewGob(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -183,7 +184,8 @@ func Test_gobCompressor_CompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -250,7 +252,8 @@ func Test_E2E_gobCompressor_CompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -357,7 +360,8 @@ func Test_gobCompressor_DecompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -438,7 +442,8 @@ func Test_gobCompressor_Reader(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -519,7 +524,8 @@ func Test_gobCompressor_Writer(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -613,7 +619,8 @@ func Test_gobReader_Read(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -676,7 +683,8 @@ func Test_gobReader_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -770,7 +778,8 @@ func Test_gobWriter_Write(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -833,7 +842,8 @@ func Test_gobWriter_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/compress/gzip_option_test.go b/internal/compress/gzip_option_test.go index 3cde7da05f..fa508c14f8 100644 --- a/internal/compress/gzip_option_test.go +++ b/internal/compress/gzip_option_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" ) func TestWithGzipGob(t *testing.T) { @@ -70,9 +69,10 @@ func TestWithGzipGob(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -148,9 +148,10 @@ func TestWithGzipCompressionLevel(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/compress/gzip_test.go b/internal/compress/gzip_test.go index 13ccca98dc..d5319987d7 100644 --- a/internal/compress/gzip_test.go +++ b/internal/compress/gzip_test.go @@ -24,7 +24,6 @@ import ( "github.com/vdaas/vald/internal/compress/gzip" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/io" - "github.com/vdaas/vald/internal/test/goleak" ) func TestNewGzip(t *testing.T) { @@ -86,9 +85,9 @@ func TestNewGzip(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -272,9 +271,9 @@ func Test_gzipCompressor_CompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -346,9 +345,9 @@ func Test_E2E_gzipCompressor_CompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -487,9 +486,9 @@ func Test_gzipCompressor_DecompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -591,9 +590,9 @@ func Test_gzipCompressor_Reader(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -695,9 +694,9 @@ func Test_gzipCompressor_Writer(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -771,9 +770,9 @@ func Test_gzipReader_Read(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -897,9 +896,9 @@ func Test_gzipReader_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -973,9 +972,9 @@ func Test_gzipWriter_Write(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1099,9 +1098,9 @@ func Test_gzipWriter_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/compress/lz4_option_test.go b/internal/compress/lz4_option_test.go index 214f0dcefa..88a317d805 100644 --- a/internal/compress/lz4_option_test.go +++ b/internal/compress/lz4_option_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" ) func TestWithLZ4Gob(t *testing.T) { @@ -70,9 +69,9 @@ func TestWithLZ4Gob(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -151,9 +150,10 @@ func TestWithLZ4CompressionLevel(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/compress/lz4_test.go b/internal/compress/lz4_test.go index a6265a986a..53805768f9 100644 --- a/internal/compress/lz4_test.go +++ b/internal/compress/lz4_test.go @@ -24,7 +24,6 @@ import ( "github.com/vdaas/vald/internal/compress/lz4" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/io" - "github.com/vdaas/vald/internal/test/goleak" ) func TestNewLZ4(t *testing.T) { @@ -103,9 +102,9 @@ func TestNewLZ4(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -298,9 +297,9 @@ func Test_lz4Compressor_CompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -366,9 +365,9 @@ func Test_E2E_lz4Compressor_CompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -503,9 +502,9 @@ func Test_lz4Compressor_DecompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -589,9 +588,9 @@ func Test_lz4Compressor_Reader(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -675,9 +674,9 @@ func Test_lz4Compressor_Writer(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -752,9 +751,9 @@ func Test_lz4Reader_Read(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -821,9 +820,9 @@ func Test_lz4Reader_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -897,9 +896,9 @@ func Test_lz4Writer_Write(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -984,9 +983,9 @@ func Test_lz4Writer_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/compress/zstd_option_test.go b/internal/compress/zstd_option_test.go index 543a49da18..ca60e716f0 100644 --- a/internal/compress/zstd_option_test.go +++ b/internal/compress/zstd_option_test.go @@ -72,7 +72,8 @@ func TestWithZstdGob(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -149,7 +150,8 @@ func TestWithZstdCompressionLevel(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/compress/zstd_test.go b/internal/compress/zstd_test.go index 8479b2aaa2..62d4c03324 100644 --- a/internal/compress/zstd_test.go +++ b/internal/compress/zstd_test.go @@ -121,7 +121,8 @@ func TestNewZstd(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -304,7 +305,8 @@ func Test_zstdCompressor_CompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -373,7 +375,8 @@ func Test_E2E_zstdCompressor_CompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -545,7 +548,8 @@ func Test_zstdCompressor_DecompressVector(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -653,7 +657,8 @@ func Test_zstdCompressor_Reader(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -762,7 +767,8 @@ func Test_zstdCompressor_Writer(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -855,7 +861,8 @@ func Test_zstdReader_Read(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -932,7 +939,8 @@ func Test_zstdReader_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -1024,7 +1032,8 @@ func Test_zstdWriter_Write(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -1147,7 +1156,8 @@ func Test_zstdWriter_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/config/blob_test.go b/internal/config/blob_test.go index 4a5058d812..5b0da85f80 100644 --- a/internal/config/blob_test.go +++ b/internal/config/blob_test.go @@ -73,7 +73,8 @@ func TestBlobStorageType_String(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -170,7 +171,8 @@ func TestAtoBST(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -292,7 +294,8 @@ func TestBlob_Bind(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -450,7 +453,8 @@ func TestS3Config_Bind(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/config/compress_test.go b/internal/config/compress_test.go index a1677229d3..c92cc4090c 100644 --- a/internal/config/compress_test.go +++ b/internal/config/compress_test.go @@ -87,7 +87,8 @@ func Test_compressAlgorithm_String(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -211,7 +212,8 @@ func TestCompressAlgorithm(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -332,7 +334,8 @@ func TestCompressCore_Bind(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -421,7 +424,8 @@ func TestCompressor_Bind(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -532,7 +536,8 @@ func TestCompressorRegisterer_Bind(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 1b456f7457..ce15eee1bd 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -240,7 +240,8 @@ func TestGlobalConfig_Bind(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -868,7 +869,8 @@ func TestRead(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1003,7 +1005,8 @@ func TestGetActualValue(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1110,7 +1113,8 @@ func TestGetActualValues(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1279,7 +1283,8 @@ func Test_checkPrefixAndSuffix(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1402,7 +1407,8 @@ func TestToRawYaml(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/config/discoverer.go b/internal/config/discoverer.go index e6768d1e85..e24c671468 100644 --- a/internal/config/discoverer.go +++ b/internal/config/discoverer.go @@ -33,11 +33,81 @@ type Selectors struct { PodMetrics *Selector `json:"pod_metrics,omitempty" yaml:"pod_metrics"` } +func (s *Selectors) GetPodFields() map[string]string { + if s == nil { + return nil + } + return s.Pod.GetFields() +} + +func (s *Selectors) GetPodLabels() map[string]string { + if s == nil { + return nil + } + return s.Pod.GetLabels() +} + +func (s *Selectors) GetNodeFields() map[string]string { + if s == nil { + return nil + } + return s.Node.GetFields() +} + +func (s *Selectors) GetNodeLabels() map[string]string { + if s == nil { + return nil + } + return s.Node.GetLabels() +} + +func (s *Selectors) GetPodMetricsFields() map[string]string { + if s == nil { + return nil + } + return s.PodMetrics.GetFields() +} + +func (s *Selectors) GetPodMetricsLabels() map[string]string { + if s == nil { + return nil + } + return s.PodMetrics.GetLabels() +} + +func (s *Selectors) GetNodeMetricsFields() map[string]string { + if s == nil { + return nil + } + return s.NodeMetrics.GetFields() +} + +func (s *Selectors) GetNodeMetricsLabels() map[string]string { + if s == nil { + return nil + } + return s.NodeMetrics.GetLabels() +} + type Selector struct { Labels map[string]string `json:"labels,omitempty" yaml:"labels"` Fields map[string]string `json:"fields,omitempty" yaml:"fields"` } +func (s *Selector) GetLabels() map[string]string { + if s == nil { + return nil + } + return s.Labels +} + +func (s *Selector) GetFields() map[string]string { + if s == nil { + return nil + } + return s.Fields +} + // Bind binds the actual data from the Discoverer receiver field. func (d *Discoverer) Bind() *Discoverer { d.Name = GetActualValue(d.Name) diff --git a/internal/config/discoverer_test.go b/internal/config/discoverer_test.go index 776cc6b57a..7b4b7ee885 100644 --- a/internal/config/discoverer_test.go +++ b/internal/config/discoverer_test.go @@ -258,7 +258,8 @@ func TestDiscovererClient_Bind(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { @@ -450,3 +451,867 @@ func TestSelector_Bind(t *testing.T) { }) } } + +func TestSelectors_GetPodFields(t *testing.T) { + type fields struct { + Pod *Selector + Node *Selector + NodeMetrics *Selector + PodMetrics *Selector + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selectors{ + Pod: test.fields.Pod, + Node: test.fields.Node, + NodeMetrics: test.fields.NodeMetrics, + PodMetrics: test.fields.PodMetrics, + } + + got := s.GetPodFields() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func TestSelectors_GetPodLabels(t *testing.T) { + type fields struct { + Pod *Selector + Node *Selector + NodeMetrics *Selector + PodMetrics *Selector + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selectors{ + Pod: test.fields.Pod, + Node: test.fields.Node, + NodeMetrics: test.fields.NodeMetrics, + PodMetrics: test.fields.PodMetrics, + } + + got := s.GetPodLabels() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func TestSelectors_GetNodeFields(t *testing.T) { + type fields struct { + Pod *Selector + Node *Selector + NodeMetrics *Selector + PodMetrics *Selector + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selectors{ + Pod: test.fields.Pod, + Node: test.fields.Node, + NodeMetrics: test.fields.NodeMetrics, + PodMetrics: test.fields.PodMetrics, + } + + got := s.GetNodeFields() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func TestSelectors_GetNodeLabels(t *testing.T) { + type fields struct { + Pod *Selector + Node *Selector + NodeMetrics *Selector + PodMetrics *Selector + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selectors{ + Pod: test.fields.Pod, + Node: test.fields.Node, + NodeMetrics: test.fields.NodeMetrics, + PodMetrics: test.fields.PodMetrics, + } + + got := s.GetNodeLabels() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func TestSelectors_GetPodMetricsFields(t *testing.T) { + type fields struct { + Pod *Selector + Node *Selector + NodeMetrics *Selector + PodMetrics *Selector + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selectors{ + Pod: test.fields.Pod, + Node: test.fields.Node, + NodeMetrics: test.fields.NodeMetrics, + PodMetrics: test.fields.PodMetrics, + } + + got := s.GetPodMetricsFields() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func TestSelectors_GetPodMetricsLabels(t *testing.T) { + type fields struct { + Pod *Selector + Node *Selector + NodeMetrics *Selector + PodMetrics *Selector + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selectors{ + Pod: test.fields.Pod, + Node: test.fields.Node, + NodeMetrics: test.fields.NodeMetrics, + PodMetrics: test.fields.PodMetrics, + } + + got := s.GetPodMetricsLabels() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func TestSelectors_GetNodeMetricsFields(t *testing.T) { + type fields struct { + Pod *Selector + Node *Selector + NodeMetrics *Selector + PodMetrics *Selector + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selectors{ + Pod: test.fields.Pod, + Node: test.fields.Node, + NodeMetrics: test.fields.NodeMetrics, + PodMetrics: test.fields.PodMetrics, + } + + got := s.GetNodeMetricsFields() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func TestSelectors_GetNodeMetricsLabels(t *testing.T) { + type fields struct { + Pod *Selector + Node *Selector + NodeMetrics *Selector + PodMetrics *Selector + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Pod: Selector{}, + Node: Selector{}, + NodeMetrics: Selector{}, + PodMetrics: Selector{}, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selectors{ + Pod: test.fields.Pod, + Node: test.fields.Node, + NodeMetrics: test.fields.NodeMetrics, + PodMetrics: test.fields.PodMetrics, + } + + got := s.GetNodeMetricsLabels() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func TestSelector_GetLabels(t *testing.T) { + type fields struct { + Labels map[string]string + Fields map[string]string + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Labels: nil, + Fields: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Labels: nil, + Fields: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selector{ + Labels: test.fields.Labels, + Fields: test.fields.Fields, + } + + got := s.GetLabels() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func TestSelector_GetFields(t *testing.T) { + type fields struct { + Labels map[string]string + Fields map[string]string + } + type want struct { + want map[string]string + } + type test struct { + name string + fields fields + want want + checkFunc func(want, map[string]string) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got map[string]string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + Labels: nil, + Fields: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + Labels: nil, + Fields: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + s := &Selector{ + Labels: test.fields.Labels, + Fields: test.fields.Fields, + } + + got := s.GetFields() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} diff --git a/internal/config/log_test.go b/internal/config/log_test.go index d750c7edcb..e997be2c4a 100644 --- a/internal/config/log_test.go +++ b/internal/config/log_test.go @@ -91,7 +91,8 @@ func TestLogging_Bind(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/config/mysql_test.go b/internal/config/mysql_test.go index 6d850c3aa0..fc0a254d90 100644 --- a/internal/config/mysql_test.go +++ b/internal/config/mysql_test.go @@ -205,7 +205,8 @@ func TestMySQL_Bind(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/config/ngt_test.go b/internal/config/ngt_test.go index 3e2468413b..7318bc769f 100644 --- a/internal/config/ngt_test.go +++ b/internal/config/ngt_test.go @@ -158,7 +158,8 @@ func TestNGT_Bind(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/config/tls_test.go b/internal/config/tls_test.go index a578164524..0de31c9442 100644 --- a/internal/config/tls_test.go +++ b/internal/config/tls_test.go @@ -97,7 +97,8 @@ func TestTLS_Bind(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -179,7 +180,8 @@ func TestTLS_Opts(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/db/kvs/redis/option_test.go b/internal/db/kvs/redis/option_test.go index bdf6725e33..c77d15bdca 100644 --- a/internal/db/kvs/redis/option_test.go +++ b/internal/db/kvs/redis/option_test.go @@ -97,7 +97,8 @@ func TestWithDialer(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -180,7 +181,8 @@ func TestWithDialerFunc(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -290,7 +292,8 @@ func TestWithAddrs(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -358,7 +361,8 @@ func TestWithDB(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -443,7 +447,8 @@ func TestWithClusterSlots(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -531,7 +536,8 @@ func TestWithDialTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -619,7 +625,8 @@ func TestWithIdleCheckFrequency(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -707,7 +714,8 @@ func TestWithIdleTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -783,7 +791,8 @@ func TestWithKeyPrefix(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -869,7 +878,8 @@ func TestWithMaximumConnectionAge(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -935,7 +945,8 @@ func TestWithRedirectLimit(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1001,7 +1012,8 @@ func TestWithRetryLimit(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1089,7 +1101,8 @@ func TestWithMaximumRetryBackoff(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1155,7 +1168,8 @@ func TestWithMinimumIdleConnection(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1243,7 +1257,8 @@ func TestWithMinimumRetryBackoff(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1326,7 +1341,8 @@ func TestWithOnConnectFunction(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1402,7 +1418,8 @@ func TestWithPassword(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1468,7 +1485,8 @@ func TestWithPoolSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1556,7 +1574,8 @@ func TestWithPoolTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1622,7 +1641,8 @@ func TestWithReadOnlyFlag(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1710,7 +1730,8 @@ func TestWithReadTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1776,7 +1797,8 @@ func TestWithRouteByLatencyFlag(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1842,7 +1864,8 @@ func TestWithRouteRandomlyFlag(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1923,7 +1946,8 @@ func TestWithTLSConfig(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2011,7 +2035,8 @@ func TestWithWriteTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2099,7 +2124,8 @@ func TestWithInitialPingTimeLimit(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2187,7 +2213,8 @@ func TestWithInitialPingDuration(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2306,7 +2333,8 @@ func TestWithHooks(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/kvs/redis/redis_test.go b/internal/db/kvs/redis/redis_test.go index 8f95e9434d..9d96a396f2 100644 --- a/internal/db/kvs/redis/redis_test.go +++ b/internal/db/kvs/redis/redis_test.go @@ -114,7 +114,8 @@ func TestNew(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -221,7 +222,8 @@ func Test_redisClient_ping(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -370,7 +372,8 @@ func Test_redisClient_setClient(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -589,7 +592,8 @@ func Test_redisClient_newClient(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -838,7 +842,8 @@ func Test_redisClient_newClusterClient(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -995,7 +1000,8 @@ func Test_redisClient_Connect(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/nosql/cassandra/cassandra_test.go b/internal/db/nosql/cassandra/cassandra_test.go index 0252f44f82..17451ee944 100644 --- a/internal/db/nosql/cassandra/cassandra_test.go +++ b/internal/db/nosql/cassandra/cassandra_test.go @@ -1136,7 +1136,8 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1287,7 +1288,8 @@ func Test_client_Open(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, append(goleakIgnoreOptions, goleak.IgnoreTopFunction("github.com/gocql/gocql.(*eventDebouncer).flusher"))...) if test.beforeFunc != nil { @@ -1447,7 +1449,8 @@ func Test_client_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1624,7 +1627,8 @@ func Test_client_Query(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1749,7 +1753,8 @@ func TestSelect(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1821,7 +1826,8 @@ func TestDelete(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1878,7 +1884,8 @@ func TestInsert(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1933,7 +1940,8 @@ func TestUpdate(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1981,7 +1989,8 @@ func TestBatch(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2036,7 +2045,8 @@ func TestEq(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2091,7 +2101,8 @@ func TestIn(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2146,7 +2157,8 @@ func TestContains(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2320,7 +2332,8 @@ func TestWrapErrorWithKeys(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/nosql/cassandra/conviction_test.go b/internal/db/nosql/cassandra/conviction_test.go index a341af4895..3c171a06ab 100644 --- a/internal/db/nosql/cassandra/conviction_test.go +++ b/internal/db/nosql/cassandra/conviction_test.go @@ -52,7 +52,8 @@ func TestNewConvictionPolicy(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -114,7 +115,8 @@ func Test_convictionPolicy_AddFailure(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -167,7 +169,8 @@ func Test_convictionPolicy_Reset(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/nosql/cassandra/option_test.go b/internal/db/nosql/cassandra/option_test.go index cc870aaeaa..e2eb9c77a8 100644 --- a/internal/db/nosql/cassandra/option_test.go +++ b/internal/db/nosql/cassandra/option_test.go @@ -123,7 +123,8 @@ func TestWithHosts(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.afterFunc != nil { @@ -201,7 +202,8 @@ func TestWithDialer(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -285,7 +287,8 @@ func TestWithCQLVersion(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -371,7 +374,8 @@ func TestWithProtoVersion(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -459,7 +463,8 @@ func TestWithTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -545,7 +550,8 @@ func TestWithConnectTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -670,7 +676,8 @@ func TestWithPort(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -756,7 +763,8 @@ func TestWithKeyspace(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -856,7 +864,8 @@ func TestWithNumConns(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -954,7 +963,8 @@ func TestWithConsistency(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1051,7 +1061,8 @@ func TestWithSerialConsistency(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1124,7 +1135,8 @@ func TestWithCompressor(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1199,7 +1211,8 @@ func TestWithUsername(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1274,7 +1287,8 @@ func TestWithPassword(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1352,7 +1366,8 @@ func TestWithAuthProvider(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1429,7 +1444,8 @@ func TestWithRetryPolicyNumRetries(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1521,7 +1537,8 @@ func TestWithRetryPolicyMinDuration(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1612,7 +1629,8 @@ func TestWithRetryPolicyMaxDuration(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1703,7 +1721,8 @@ func TestWithReconnectionPolicyInitialInterval(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1780,7 +1799,8 @@ func TestWithReconnectionPolicyMaxRetries(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1864,7 +1884,8 @@ func TestWithSocketKeepalive(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1939,7 +1960,8 @@ func TestWithMaxPreparedStmts(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2014,7 +2036,8 @@ func TestWithMaxRoutingKeyInfo(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2089,7 +2112,8 @@ func TestWithPageSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2166,7 +2190,8 @@ func TestWithTLS(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2241,7 +2266,8 @@ func TestWithTLSCertPath(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2316,7 +2342,8 @@ func TestWithTLSKeyPath(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2391,7 +2418,8 @@ func TestWithTLSCAPath(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2456,7 +2484,8 @@ func TestWithEnableHostVerification(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2520,7 +2549,8 @@ func TestWithDefaultTimestamp(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2597,7 +2627,8 @@ func TestWithDC(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2664,7 +2695,8 @@ func TestWithDCAwareRouting(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2731,7 +2763,8 @@ func TestWithNonLocalReplicasFallback(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2798,7 +2831,8 @@ func TestWithShuffleReplicas(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2865,7 +2899,8 @@ func TestWithTokenAwareHostPolicy(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2954,7 +2989,8 @@ func TestWithMaxWaitSchemaAgreement(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3039,7 +3075,8 @@ func TestWithReconnectInterval(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3104,7 +3141,8 @@ func TestWithIgnorePeerAddr(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3169,7 +3207,8 @@ func TestWithDisableInitialHostLookup(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3234,7 +3273,8 @@ func TestWithDisableNodeStatusEvents(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3299,7 +3339,8 @@ func TestWithDisableTopologyEvents(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3364,7 +3405,8 @@ func TestWithDisableSchemaEvents(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3429,7 +3471,8 @@ func TestWithDisableSkipMetadata(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3504,7 +3547,8 @@ func TestWithQueryObserver(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3579,7 +3623,8 @@ func TestWithBatchObserver(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3654,7 +3699,8 @@ func TestWithConnectObserver(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3728,7 +3774,8 @@ func TestWithFrameHeaderObserver(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3793,7 +3840,8 @@ func TestWithDefaultIdempotence(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3878,7 +3926,8 @@ func TestWithWriteCoalesceWaitTime(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3945,7 +3994,8 @@ func TestWithHostFilter(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -4023,7 +4073,8 @@ func TestWithDCHostFilter(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -4101,7 +4152,8 @@ func TestWithWhiteListHostFilter(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/rdb/mysql/model_test.go b/internal/db/rdb/mysql/model_test.go index 4746cad67c..d5889c5673 100644 --- a/internal/db/rdb/mysql/model_test.go +++ b/internal/db/rdb/mysql/model_test.go @@ -70,7 +70,8 @@ func Test_vector_GetUUID(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -141,7 +142,8 @@ func Test_vector_GetVector(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -217,7 +219,8 @@ func Test_vector_GetIPs(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/rdb/mysql/mysql_test.go b/internal/db/rdb/mysql/mysql_test.go index 017b055aa4..412e8af00b 100644 --- a/internal/db/rdb/mysql/mysql_test.go +++ b/internal/db/rdb/mysql/mysql_test.go @@ -114,7 +114,8 @@ func TestNew(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -402,7 +403,8 @@ func Test_mySQLClient_Open(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -575,7 +577,8 @@ func Test_mySQLClient_Ping(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -681,7 +684,8 @@ func Test_mySQLClient_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -988,7 +992,8 @@ func Test_mySQLClient_GetVector(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1310,7 +1315,8 @@ func Test_mySQLClient_GetIPs(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1384,7 +1390,8 @@ func Test_validateVector(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2060,7 +2067,8 @@ func Test_mySQLClient_SetVector(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -2757,7 +2765,8 @@ func Test_mySQLClient_SetVectors(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3207,7 +3216,8 @@ func Test_mySQLClient_deleteVector(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3393,7 +3403,8 @@ func Test_mySQLClient_DeleteVector(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3582,7 +3593,8 @@ func Test_mySQLClient_DeleteVectors(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -3975,7 +3987,8 @@ func Test_mySQLClient_SetIPs(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -4194,7 +4207,8 @@ func Test_mySQLClient_RemoveIPs(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/rdb/mysql/option_test.go b/internal/db/rdb/mysql/option_test.go index 2f734a3f81..521ba296cd 100644 --- a/internal/db/rdb/mysql/option_test.go +++ b/internal/db/rdb/mysql/option_test.go @@ -82,7 +82,8 @@ func TestWithTimezone(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -153,7 +154,8 @@ func TestWithCharset(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -225,7 +227,8 @@ func TestWithDB(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -297,7 +300,8 @@ func TestWithHost(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -369,7 +373,8 @@ func TestWithPort(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -444,7 +449,8 @@ func TestWithUser(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -516,7 +522,8 @@ func TestWithPass(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -588,7 +595,8 @@ func TestWithName(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -671,7 +679,8 @@ func TestWithInitialPingTimeLimit(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -754,7 +763,8 @@ func TestWithInitialPingDuration(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -837,7 +847,8 @@ func TestWithConnectionLifeTimeLimit(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -909,7 +920,8 @@ func TestWithMaxIdleConns(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -981,7 +993,8 @@ func TestWithMaxOpenConns(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1058,7 +1071,8 @@ func TestWithTLSConfig(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1137,7 +1151,8 @@ func TestWithDialerFunc(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1216,7 +1231,8 @@ func TestWithDialer(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1292,7 +1308,8 @@ func TestWithEventReceiver(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/storage/blob/s3/option_test.go b/internal/db/storage/blob/s3/option_test.go index 6af53cc9de..db593796b9 100644 --- a/internal/db/storage/blob/s3/option_test.go +++ b/internal/db/storage/blob/s3/option_test.go @@ -90,7 +90,8 @@ func TestWithErrGroup(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -173,7 +174,8 @@ func TestWithSession(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -249,7 +251,8 @@ func TestWithBucket(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -344,7 +347,8 @@ func TestWithMaxPartSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -441,7 +445,8 @@ func TestWithMaxChunkSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -507,7 +512,8 @@ func TestWithReaderBackoff(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -628,7 +634,8 @@ func TestWithReaderBackoffOpts(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -711,7 +718,8 @@ func TestWithReader(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -792,7 +800,8 @@ func TestWithWriter(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/storage/blob/s3/reader/option_test.go b/internal/db/storage/blob/s3/reader/option_test.go index cbf7cb188c..a79591a460 100644 --- a/internal/db/storage/blob/s3/reader/option_test.go +++ b/internal/db/storage/blob/s3/reader/option_test.go @@ -78,7 +78,8 @@ func TestWithErrGroup(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -145,7 +146,8 @@ func TestWithService(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -213,7 +215,8 @@ func TestWithBucket(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -289,7 +292,8 @@ func TestWithMaxChunkSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -355,7 +359,8 @@ func TestWithBackoff(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -460,7 +465,8 @@ func TestWithBackoffOpts(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) obj := new(T) diff --git a/internal/db/storage/blob/s3/reader/reader_test.go b/internal/db/storage/blob/s3/reader/reader_test.go index 38ef419cc7..1337a0524e 100644 --- a/internal/db/storage/blob/s3/reader/reader_test.go +++ b/internal/db/storage/blob/s3/reader/reader_test.go @@ -104,7 +104,8 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -449,7 +450,8 @@ func Test_reader_Open(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -551,7 +553,8 @@ func Test_reader_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -662,7 +665,8 @@ func Test_reader_Read(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -795,7 +799,8 @@ func Test_reader_getObjectWithBackoff(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1090,7 +1095,8 @@ func Test_reader_getObject(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/storage/blob/s3/s3_test.go b/internal/db/storage/blob/s3/s3_test.go index 3164239146..f05dea2f46 100644 --- a/internal/db/storage/blob/s3/s3_test.go +++ b/internal/db/storage/blob/s3/s3_test.go @@ -268,7 +268,8 @@ func TestNew(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -331,7 +332,8 @@ func Test_client_Open(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -394,7 +396,8 @@ func Test_client_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -535,7 +538,8 @@ func Test_client_Reader(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -676,7 +680,8 @@ func Test_client_Writer(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/storage/blob/s3/sdk/s3/s3manager/s3manager_test.go b/internal/db/storage/blob/s3/sdk/s3/s3manager/s3manager_test.go index 6da3e3a38f..32d9dd9b43 100644 --- a/internal/db/storage/blob/s3/sdk/s3/s3manager/s3manager_test.go +++ b/internal/db/storage/blob/s3/sdk/s3/s3manager/s3manager_test.go @@ -62,7 +62,8 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -139,7 +140,8 @@ func Test_s3mngr_NewUploaderWithClient(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) diff --git a/internal/db/storage/blob/s3/session/option_test.go b/internal/db/storage/blob/s3/session/option_test.go index b60f38c5f1..6a8f6edf3c 100644 --- a/internal/db/storage/blob/s3/session/option_test.go +++ b/internal/db/storage/blob/s3/session/option_test.go @@ -78,7 +78,8 @@ func TestWithEndpoint(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -155,7 +156,8 @@ func TestWithRegion(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -232,7 +234,8 @@ func TestWithAccessKey(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -309,7 +312,8 @@ func TestWithSecretAccessKey(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -386,7 +390,8 @@ func TestWithToken(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -452,7 +457,8 @@ func TestWithMaxRetries(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -518,7 +524,8 @@ func TestWithForcePathStyle(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -584,7 +591,8 @@ func TestWithUseAccelerate(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -650,7 +658,8 @@ func TestWithUseARNRegion(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -716,7 +725,8 @@ func TestWithUseDualStack(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -782,7 +792,8 @@ func TestWithEnableSSL(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -848,7 +859,8 @@ func TestWithEnableParamValidation(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -914,7 +926,8 @@ func TestWithEnable100Continue(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -980,7 +993,8 @@ func TestWithEnableContentMD5Validation(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1046,7 +1060,8 @@ func TestWithEnableEndpointDiscovery(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1112,7 +1127,8 @@ func TestWithEnableEndpointHostPrefix(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1194,7 +1210,8 @@ func TestWithHTTPClient(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/storage/blob/s3/session/session_test.go b/internal/db/storage/blob/s3/session/session_test.go index 1dfdc6b4e7..a53e2bdf4b 100644 --- a/internal/db/storage/blob/s3/session/session_test.go +++ b/internal/db/storage/blob/s3/session/session_test.go @@ -165,7 +165,8 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -651,7 +652,8 @@ func Test_sess_Session(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/storage/blob/s3/writer/option_test.go b/internal/db/storage/blob/s3/writer/option_test.go index 83438d9ecb..dc33af0c52 100644 --- a/internal/db/storage/blob/s3/writer/option_test.go +++ b/internal/db/storage/blob/s3/writer/option_test.go @@ -93,7 +93,8 @@ func TestWithErrGroup(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -187,7 +188,8 @@ func TestWithService(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -265,7 +267,8 @@ func TestWithBucket(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -341,7 +344,8 @@ func TestWithMaxPartSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -417,7 +421,8 @@ func TestWithContentType(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/db/storage/blob/s3/writer/writer_test.go b/internal/db/storage/blob/s3/writer/writer_test.go index 46bc8cb9a0..7a07f0a043 100644 --- a/internal/db/storage/blob/s3/writer/writer_test.go +++ b/internal/db/storage/blob/s3/writer/writer_test.go @@ -114,7 +114,8 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -195,7 +196,8 @@ func Test_writer_Open(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -293,7 +295,8 @@ func Test_writer_Close(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -407,7 +410,8 @@ func Test_writer_Write(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -546,7 +550,8 @@ func Test_writer_upload(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/encoding/json/json_test.go b/internal/encoding/json/json_test.go index 155c2015cc..83da4e2186 100644 --- a/internal/encoding/json/json_test.go +++ b/internal/encoding/json/json_test.go @@ -281,7 +281,8 @@ func TestUnmarshal(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -356,7 +357,8 @@ func TestMarshal(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/errgroup/group_test.go b/internal/errgroup/group_test.go index c612a77991..6cee962776 100644 --- a/internal/errgroup/group_test.go +++ b/internal/errgroup/group_test.go @@ -27,9 +27,16 @@ import ( "time" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/log" + "github.com/vdaas/vald/internal/log/logger" "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + log.Init(log.WithLoggerType(logger.NOP.String())) + goleak.VerifyTestMain(m) +} + func TestNew(t *testing.T) { type args struct { ctx context.Context @@ -83,9 +90,9 @@ func TestNew(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -153,9 +160,9 @@ func TestInit(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc == nil { test.beforeFunc = defaultBeforeFunc } @@ -236,9 +243,9 @@ func TestGet(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc == nil { test.beforeFunc = defaultBeforeFunc } @@ -307,9 +314,9 @@ func TestGo(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -396,9 +403,9 @@ func Test_group_Limitation(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -543,9 +550,9 @@ func Test_group_Go(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.afterFunc != nil { defer test.afterFunc(test.args) } @@ -609,9 +616,9 @@ func Test_group_doCancel(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc() } @@ -663,9 +670,10 @@ func TestWait(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc() } @@ -753,9 +761,9 @@ func Test_group_Wait(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt) if test.afterFunc != nil { defer test.afterFunc() } diff --git a/internal/errors/blob_test.go b/internal/errors/blob_test.go index ca711b9d48..f6eb9cda31 100644 --- a/internal/errors/blob_test.go +++ b/internal/errors/blob_test.go @@ -76,7 +76,8 @@ func TestNewErrBlobNoSuchBucket(t *testing.T) { }, }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -149,7 +150,8 @@ func TestNewErrBlobNoSuchKey(t *testing.T) { }, }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -203,7 +205,8 @@ func TestErrBlobNoSuchBucket_Error(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -279,7 +282,8 @@ func TestIsErrBlobNoSuchBucket(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -334,7 +338,8 @@ func TestErrBlobNoSuchKey_Error(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -410,7 +415,8 @@ func TestIsErrBlobNoSuchKey(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -477,7 +483,8 @@ func TestErrBlobNoSuchBucket_Unwrap(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -547,7 +554,8 @@ func TestErrBlobNoSuchKey_Unwrap(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/errors/cassandra_test.go b/internal/errors/cassandra_test.go index 469aa00cbc..6cc4f08bff 100644 --- a/internal/errors/cassandra_test.go +++ b/internal/errors/cassandra_test.go @@ -66,7 +66,8 @@ func TestErrCassandraInvalidConsistencyType(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -115,7 +116,8 @@ func TestNewErrCassandraNotFoundIdentity(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -164,7 +166,8 @@ func TestNewErrCassandraUnavailableIdentity(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -213,7 +216,8 @@ func TestErrCassandraUnavailable(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -299,7 +303,8 @@ func TestErrCassandraNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -385,7 +390,8 @@ func TestErrCassandraGetOperationFailed(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -471,7 +477,8 @@ func TestErrCassandraSetOperationFailed(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -557,7 +564,8 @@ func TestErrCassandraDeleteOperationFailed(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -643,7 +651,8 @@ func TestErrCassandraHostDownDetected(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -766,7 +775,8 @@ func TestErrCassandraFailedToCreateSession(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -820,7 +830,8 @@ func TestErrCassandraNotFoundIdentity_Error(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -897,7 +908,8 @@ func TestErrCassandraNotFoundIdentity_Unwrap(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -964,7 +976,8 @@ func TestIsErrCassandraNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1018,7 +1031,8 @@ func TestErrCassandraUnavailableIdentity_Error(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -1095,7 +1109,8 @@ func TestErrCassandraUnavailableIdentity_Unwrap(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -1162,7 +1177,8 @@ func TestIsErrCassandraUnavailable(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) diff --git a/internal/errors/compressor_test.go b/internal/errors/compressor_test.go index 5f4a07203c..cdb655ab7f 100644 --- a/internal/errors/compressor_test.go +++ b/internal/errors/compressor_test.go @@ -78,7 +78,8 @@ func TestErrInvalidCompressionLevel(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -141,7 +142,8 @@ func TestErrCompressorNameNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -188,7 +190,8 @@ func TestErrCompressorRegistererIsNotRunning(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -235,7 +238,8 @@ func TestErrCompressorRegistererChannelIsFull(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/errors/discoverer_test.go b/internal/errors/discoverer_test.go index c4c384a89c..141789661b 100644 --- a/internal/errors/discoverer_test.go +++ b/internal/errors/discoverer_test.go @@ -80,7 +80,8 @@ func TestErrAddrCouldNotDiscover(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -143,7 +144,8 @@ func TestErrNodeNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -206,7 +208,8 @@ func TestErrNamespaceNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -269,7 +272,8 @@ func TestErrPodNameNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -316,7 +320,8 @@ func TestErrInvalidDiscoveryCache(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/errors/errors_test.go b/internal/errors/errors_test.go index 94c0e11db8..90f2cbf70a 100644 --- a/internal/errors/errors_test.go +++ b/internal/errors/errors_test.go @@ -68,7 +68,8 @@ func TestErrTimeoutParseFailed(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -137,7 +138,8 @@ func TestErrServerNotFound(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -238,7 +240,8 @@ func TestErrOptionFailed(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -305,7 +308,8 @@ func TestErrArgumentPraseFailed(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -372,7 +376,8 @@ func TestErrBackoffTimeout(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -473,7 +478,8 @@ func TestErrInvalidTypeConversion(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -574,7 +580,8 @@ func TestErrLoggingRetry(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -675,7 +682,8 @@ func TestErrLoggingFailed(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -739,7 +747,8 @@ func TestNew(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -829,7 +838,8 @@ func TestWrap(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1030,7 +1040,8 @@ func TestWrapf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1094,7 +1105,8 @@ func TestCause(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1159,7 +1171,8 @@ func TestUnwarp(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1278,7 +1291,8 @@ func TestErrorf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1489,7 +1503,8 @@ func TestIs(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1544,7 +1559,8 @@ func TestAs(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) diff --git a/internal/errors/file_test.go b/internal/errors/file_test.go index 000c75d9ed..4678e420fe 100644 --- a/internal/errors/file_test.go +++ b/internal/errors/file_test.go @@ -47,7 +47,8 @@ func TestErrWatchDirNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -110,7 +111,8 @@ func TestErrFileAlreadyExists(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -157,7 +159,8 @@ func TestErrPathNotSpecified(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -220,7 +223,8 @@ func TestErrPathNotAllowed(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) diff --git a/internal/errors/filter_test.go b/internal/errors/filter_test.go index e66d7cb57c..e368e03f8b 100644 --- a/internal/errors/filter_test.go +++ b/internal/errors/filter_test.go @@ -61,7 +61,8 @@ func TestErrTargetFilterNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) diff --git a/internal/errors/grpc_test.go b/internal/errors/grpc_test.go index 4d3b3a25c5..afd44fed4f 100644 --- a/internal/errors/grpc_test.go +++ b/internal/errors/grpc_test.go @@ -83,7 +83,8 @@ func TestErrGRPCClientConnectionClose(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -207,7 +208,8 @@ func TestErrInvalidGRPCPort(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -270,7 +272,8 @@ func TestErrInvalidGRPCClientConn(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -333,7 +336,8 @@ func TestErrGRPCLookupIPAddrNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -380,7 +384,8 @@ func TestErrGRPCClientNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -443,7 +448,8 @@ func TestErrGRPCClientConnNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -529,7 +535,8 @@ func TestErrRPCCallFailed(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -576,7 +583,8 @@ func TestErrGRPCTargetAddrNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/errors/http_test.go b/internal/errors/http_test.go index 23cfb6bd97..4d0f0c17e4 100644 --- a/internal/errors/http_test.go +++ b/internal/errors/http_test.go @@ -45,7 +45,8 @@ func TestErrInvalidAPIConfig(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -92,7 +93,8 @@ func TestErrInvalidRequest(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -155,7 +157,8 @@ func TestErrHandler(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -261,7 +264,8 @@ func TestErrHandlerTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -324,7 +328,8 @@ func TestErrRequestBodyCloseAndFlush(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -387,7 +392,8 @@ func TestErrRequestBodyClose(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -450,7 +456,8 @@ func TestErrRequestBodyFlush(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -497,7 +504,8 @@ func TestErrTransportRetryable(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/errors/info_test.go b/internal/errors/info_test.go index f1cfbc25af..54f1ff25b0 100644 --- a/internal/errors/info_test.go +++ b/internal/errors/info_test.go @@ -61,7 +61,8 @@ func TestErrFailedToInitInfo(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -108,7 +109,8 @@ func TestErrRuntimeFuncNil(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/errors/io_test.go b/internal/errors/io_test.go index f2eb41f702..ce4671a482 100644 --- a/internal/errors/io_test.go +++ b/internal/errors/io_test.go @@ -41,7 +41,8 @@ func TestNewErrContextNotProvided(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -88,7 +89,8 @@ func TestNewErrReaderNotProvided(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -135,7 +137,8 @@ func TestNewErrWriterNotProvided(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() diff --git a/internal/errors/mysql_test.go b/internal/errors/mysql_test.go index 17c25b9b44..920c7850c9 100644 --- a/internal/errors/mysql_test.go +++ b/internal/errors/mysql_test.go @@ -50,7 +50,8 @@ func TestErrMySQLConnectionPingFailed(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -101,7 +102,8 @@ func TestNewErrMySQLNotFoundIdentity(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -150,7 +152,8 @@ func TestErrMySQLConnectionClosed(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -199,7 +202,8 @@ func TestErrMySQLTransactionNotCreated(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -268,7 +272,8 @@ func TestErrRequiredElementNotFoundByUUID(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -319,7 +324,8 @@ func TestNewErrMySQLInvalidArgumentIdentity(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -388,7 +394,8 @@ func TestErrRequiredMemberNotFilled(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { @@ -436,7 +443,8 @@ func TestErrMySQLSessionNil(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -492,7 +500,8 @@ func TestErrMySQLNotFoundIdentity_Error(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -560,7 +569,8 @@ func TestErrMySQLNotFoundIdentity_Unwrap(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -637,7 +647,8 @@ func TestIsErrMySQLNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -693,7 +704,8 @@ func TestErrMySQLInvalidArgumentIdentity_Error(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -761,7 +773,8 @@ func TestErrMySQLInvalidArgumentIdentity_Unwrap(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) @@ -838,7 +851,8 @@ func TestIsErrMySQLInvalidArgument(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) diff --git a/internal/errors/net_test.go b/internal/errors/net_test.go index d8a72021e3..dc7b82c6fd 100644 --- a/internal/errors/net_test.go +++ b/internal/errors/net_test.go @@ -45,7 +45,8 @@ func TestErrFailedInitDialer(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -146,7 +147,8 @@ func TestErrInvalidDNSConfig(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -241,7 +243,8 @@ func TestErrNoPortAvailable(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -302,7 +305,8 @@ func TestErrLookupIPAddrNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) diff --git a/internal/errors/ngt_test.go b/internal/errors/ngt_test.go index 48e0d0d4a4..b8ffe4b2a2 100644 --- a/internal/errors/ngt_test.go +++ b/internal/errors/ngt_test.go @@ -67,7 +67,8 @@ func TestErrCreateProperty(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -114,7 +115,8 @@ func TestErrIndexNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -161,7 +163,8 @@ func TestErrIndexLoadTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -267,7 +270,8 @@ func TestErrInvalidDimensionSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -330,7 +334,8 @@ func TestErrInvalidUUID(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -417,7 +422,8 @@ func TestErrDimensionLimitExceed(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -491,7 +497,8 @@ func TestErrIncompatibleDimensionSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -538,7 +545,8 @@ func TestErrUnsupportedObjectType(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -585,7 +593,8 @@ func TestErrUnsupportedDistanceType(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -671,7 +680,8 @@ func TestErrFailedToSetDistanceType(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -757,7 +767,8 @@ func TestErrFailedToSetObjectType(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -820,7 +831,8 @@ func TestErrFailedToSetDimension(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -883,7 +895,8 @@ func TestErrFailedToSetCreationEdgeSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -946,7 +959,8 @@ func TestErrFailedToSetSearchEdgeSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1019,7 +1033,8 @@ func TestErrUncommittedIndexExists(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1066,7 +1081,8 @@ func TestErrUncommittedIndexNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -1113,7 +1129,8 @@ func TestErrCAPINotImplemented(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -1176,7 +1193,8 @@ func TestErrUUIDAlreadyExists(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1248,7 +1266,8 @@ func TestErrUUIDNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1311,7 +1330,8 @@ func TestErrObjectIDNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1397,7 +1417,8 @@ func TestErrObjectNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -1469,7 +1490,8 @@ func TestErrRemoveRequestedBeforeIndexing(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) diff --git a/internal/errors/redis_test.go b/internal/errors/redis_test.go index 69b99453ca..3af6e5207c 100644 --- a/internal/errors/redis_test.go +++ b/internal/errors/redis_test.go @@ -93,7 +93,8 @@ func TestErrRedisInvalidKVVKPrefic(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -144,7 +145,8 @@ func TestNewErrRedisNotFoundIdentity(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -205,7 +207,8 @@ func TestErrRdisNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -252,7 +255,8 @@ func TestErrRedisInvalidOption(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -343,7 +347,8 @@ func TestErrRedisGetOperationFailed(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -434,7 +439,8 @@ func TestErrRedisSetOperationFailed(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -525,7 +531,8 @@ func TestErrRedisDeleteOperationFailed(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -616,7 +623,8 @@ func TestErrInvalidConfigVersion(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -663,7 +671,8 @@ func TestErrRedisAddrsNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -710,7 +719,8 @@ func TestErrRedisConnectionPingFailed(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -771,7 +781,8 @@ func TestErrRedisNotFoundIdentity_Error(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -907,7 +918,8 @@ func TestIsErrRedisNotFound(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) diff --git a/internal/errors/tls.go b/internal/errors/tls.go index 2af78abe56..d98360c0cf 100644 --- a/internal/errors/tls.go +++ b/internal/errors/tls.go @@ -27,4 +27,8 @@ var ( ErrTLSCertOrKeyNotFound = New("cert or key file path not found") ErrCertificationFailed = New("certification failed") + + ErrFailedToHandshakeTLSConnection = func(network, addr string) error { + return Errorf("failed to handshake connection to %s:%s", network, addr) + } ) diff --git a/internal/errors/unit_test.go b/internal/errors/unit_test.go index c6460fbb0b..6b11b2091c 100644 --- a/internal/errors/unit_test.go +++ b/internal/errors/unit_test.go @@ -56,7 +56,8 @@ func TestErrParseUnitFailed(t *testing.T) { }, }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) diff --git a/internal/errors/vald_test.go b/internal/errors/vald_test.go index 70dc04b5c2..6cf15f5e9d 100644 --- a/internal/errors/vald_test.go +++ b/internal/errors/vald_test.go @@ -58,7 +58,8 @@ func TestErrMetaDataAlreadyExists(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() if test.beforeFunc != nil { @@ -107,7 +108,8 @@ func TestErrMetadataCannotFetch(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() if test.beforeFunc != nil { diff --git a/internal/file/file.go b/internal/file/file.go index ef310faf2c..8fdfd08a85 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -97,7 +97,7 @@ func moveDir(ctx context.Context, src, dst string, rollback bool) (err error) { return nil } exits, fi, err := exists(src) - if !exits || !fi.IsDir() || err != nil { + if !exits || fi == nil || !fi.IsDir() || err != nil { return errors.ErrDirectoryNotFound(err, src, fi) } @@ -132,7 +132,7 @@ func moveDir(ctx context.Context, src, dst string, rollback bool) (err error) { log.Debugf("directory %s successfully moved to tmp location %s", dst, tmpPath) } exits, fi, err = exists(src) - if exits && fi.IsDir() && err == nil { + if exits && fi != nil && fi.IsDir() && err == nil { err = os.Rename(src, dst) if err != nil { log.Debugf("err: %v\t now trying to move file with I/O copy and Remove old index", errors.ErrFailedToRenameDir(err, src, dst, fi, nil)) @@ -152,6 +152,8 @@ func moveDir(ctx context.Context, src, dst string, rollback bool) (err error) { return err } } + } else { + return errors.ErrDirectoryNotFound(err, src, fi) } } log.Infof("directory %s successfully moved to destination directory %s", src, dst) @@ -236,7 +238,7 @@ func CopyFileWithPerm(ctx context.Context, src, dst string, perm fs.FileMode) (n flg := os.O_RDONLY | os.O_SYNC sf, err := Open(src, flg, perm) if err != nil || sf == nil { - err = errors.ErrFailedToCopyDir(errors.ErrFailedToOpenFile(err, src, flg, perm), src, dst, fi, nil) + err = errors.ErrFailedToCopyFile(errors.ErrFailedToOpenFile(err, src, flg, perm), src, dst, fi, nil) return 0, err } defer func() { @@ -247,11 +249,7 @@ func CopyFileWithPerm(ctx context.Context, src, dst string, perm fs.FileMode) (n } } }() - sr, err := io.NewReaderWithContext(ctx, sf) - if err != nil { - return 0, err - } - n, err = OverWriteFile(ctx, dst, sr, perm) + n, err = OverWriteFile(ctx, dst, sf, perm) if err != nil && !errors.Is(err, io.EOF) { err = errors.ErrFailedToCopyFile(err, src, dst, fi, nil) return 0, err @@ -309,7 +307,11 @@ func writeFile(ctx context.Context, target string, r io.Reader, flg int, perm fs if err != nil { return 0, err } - n, err = io.Copy(w, r) + cr, err := io.NewReaderWithContext(ctx, r) + if err != nil { + return 0, err + } + n, err = io.Copy(w, cr) if err != nil && !errors.Is(err, io.EOF) { return 0, err } diff --git a/internal/file/file_test.go b/internal/file/file_test.go index 73f8737798..8fc0d3b674 100644 --- a/internal/file/file_test.go +++ b/internal/file/file_test.go @@ -203,7 +203,8 @@ func TestOpen(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -377,7 +378,8 @@ func TestExists(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { diff --git a/internal/file/watch/option_test.go b/internal/file/watch/option_test.go index db7b03f4e5..054fae01f4 100644 --- a/internal/file/watch/option_test.go +++ b/internal/file/watch/option_test.go @@ -75,7 +75,8 @@ func TestWithErrGroup(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -180,7 +181,8 @@ func TestWithDirs(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -260,7 +262,8 @@ func TestWithOnChange(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -338,7 +341,8 @@ func TestWithOnCreate(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -416,7 +420,8 @@ func TestWithOnChmod(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -494,7 +499,8 @@ func TestWithOnRename(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -572,7 +578,8 @@ func TestWithOnDelete(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -650,7 +657,8 @@ func TestWithOnWrite(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -728,7 +736,8 @@ func TestWithOnError(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/file/watch/watch_test.go b/internal/file/watch/watch_test.go index 297109dbf0..ce1cd73f4e 100644 --- a/internal/file/watch/watch_test.go +++ b/internal/file/watch/watch_test.go @@ -112,7 +112,8 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -264,7 +265,8 @@ func Test_watch_init(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -628,7 +630,8 @@ func Test_watch_Start(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -789,7 +792,8 @@ func Test_watch_Add(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc == nil { @@ -962,7 +966,8 @@ func Test_watch_Remove(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc == nil { @@ -1108,7 +1113,8 @@ func Test_watch_Stop(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc == nil { diff --git a/internal/info/info.go b/internal/info/info.go index fce3888d9d..d78a7f4d68 100644 --- a/internal/info/info.go +++ b/internal/info/info.go @@ -110,6 +110,13 @@ var ( valdRepo = fmt.Sprintf("github.com/%s/%s", Organization, Repository) ) +const ( + goSrc = "go/src/" + goSrcLen = len(goSrc) + goMod = "go/pkg/mod/" + goModLen = len(goMod) +) + // Init initializes Detail object only once. func Init(name string) { once.Do(func() { @@ -252,7 +259,10 @@ func (d Detail) String() string { // Get returns parased Detail object. func (i *info) Get() Detail { i.prepare() + return i.get() +} +func (i info) get() Detail { i.detail.StackTrace = make([]StackTrace, 0, 10) for j := 2; ; j++ { pc, file, line, ok := i.rtCaller(j) @@ -264,25 +274,32 @@ func (i *info) Get() Detail { break } url := i.baseURL + var idx int switch { case strings.HasPrefix(file, i.detail.GoRoot+"/src"): url = "https://github.com/golang/go/blob/" + i.detail.GoVersion + strings.TrimPrefix(file, i.detail.GoRoot) + "#L" + strconv.Itoa(line) - case strings.Contains(file, "go/pkg/mod/"): + case func() bool { + idx = strings.Index(file, goMod) + return idx >= 0 + }(): url = "https:/" - for _, path := range strings.Split(strings.SplitN(file, "go/pkg/mod/", 2)[1], "/") { - if strings.Contains(path, "@") { - sv := strings.SplitN(path, "@", 2) - if strings.Count(sv[1], "-") > 2 { - path = sv[0] + "/blob/main" + for _, path := range strings.Split(file[idx+goModLen:], "/") { + left, right, ok := strings.Cut(path, "@") + if ok { + if strings.Count(right, "-") > 2 { + path = left + "/blob/main" } else { - path = sv[0] + "/blob/" + sv[1] + path = left + "/blob/" + right } } url += "/" + path } url += "#L" + strconv.Itoa(line) - case strings.Contains(file, "go/src/") && strings.Contains(file, valdRepo): - url = strings.Replace(strings.SplitN(file, "go/src/", 2)[1]+"#L"+strconv.Itoa(line), valdRepo, "https://"+valdRepo+"/blob/"+i.detail.GitCommit, -1) + case func() bool { + idx = strings.Index(file, goSrc) + return idx >= 0 && strings.Index(file, valdRepo) >= 0 + }(): + url = strings.Replace(file[idx+goSrcLen:]+"#L"+strconv.Itoa(line), valdRepo, "https://"+valdRepo+"/blob/"+i.detail.GitCommit, -1) } i.detail.StackTrace = append(i.detail.StackTrace, StackTrace{ FuncName: funcName, diff --git a/internal/info/info_test.go b/internal/info/info_test.go index 60421dcea8..2a08c57f08 100644 --- a/internal/info/info_test.go +++ b/internal/info/info_test.go @@ -96,7 +96,8 @@ func TestString(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.afterFunc != nil { defer test.afterFunc() @@ -165,7 +166,8 @@ func TestGet(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc() @@ -333,7 +335,8 @@ func TestInit(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { if test.beforeFunc != nil { test.beforeFunc(test.args) @@ -542,7 +545,8 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -645,7 +649,8 @@ func Test_info_String(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -752,7 +757,8 @@ func TestDetail_String(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1115,7 +1121,8 @@ func Test_info_Get(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1464,7 +1471,8 @@ func Test_info_prepare(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1531,7 +1539,8 @@ func TestStackTrace_String(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1558,3 +1567,95 @@ func TestStackTrace_String(t *testing.T) { }) } } + +func Test_info_get(t *testing.T) { + type fields struct { + baseURL string + detail Detail + prepOnce sync.Once + rtCaller func(skip int) (pc uintptr, file string, line int, ok bool) + rtFuncForPC func(pc uintptr) *runtime.Func + } + type want struct { + want Detail + } + type test struct { + name string + fields fields + want want + checkFunc func(want, Detail) error + beforeFunc func() + afterFunc func() + } + defaultCheckFunc := func(w want, got Detail) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + baseURL: "", + detail: Detail{}, + prepOnce: sync.Once{}, + rtCaller: nil, + rtFuncForPC: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + baseURL: "", + detail: Detail{}, + prepOnce: sync.Once{}, + rtCaller: nil, + rtFuncForPC: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc() + } + if test.afterFunc != nil { + defer test.afterFunc() + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + i := info{ + baseURL: test.fields.baseURL, + detail: test.fields.detail, + prepOnce: test.fields.prepOnce, + rtCaller: test.fields.rtCaller, + rtFuncForPC: test.fields.rtFuncForPC, + } + + got := i.get() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} diff --git a/internal/info/option_test.go b/internal/info/option_test.go index 50025ef12f..e9179f503f 100644 --- a/internal/info/option_test.go +++ b/internal/info/option_test.go @@ -79,7 +79,8 @@ func TestWithServerName(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -174,7 +175,8 @@ func TestWithRuntimeCaller(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -269,7 +271,8 @@ func TestWithRuntimeFuncForPC(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/log/format/format_test.go b/internal/log/format/format_test.go index 9878e21603..84559ce3bc 100644 --- a/internal/log/format/format_test.go +++ b/internal/log/format/format_test.go @@ -73,7 +73,8 @@ func TestFormat_String(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -172,7 +173,8 @@ func TestAtof(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/log/glg/glg_test.go b/internal/log/glg/glg_test.go index dd0a93e0cc..c55e245b6e 100644 --- a/internal/log/glg/glg_test.go +++ b/internal/log/glg/glg_test.go @@ -978,9 +978,11 @@ func Test_logger_setLevelMode(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1074,9 +1076,11 @@ func Test_logger_setLogFormat(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1165,9 +1169,11 @@ func Test_logger_Info(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1259,9 +1265,11 @@ func Test_logger_Infof(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1350,9 +1358,11 @@ func Test_logger_Debug(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1444,9 +1454,11 @@ func Test_logger_Debugf(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1535,9 +1547,11 @@ func Test_logger_Warn(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1629,9 +1643,11 @@ func Test_logger_Warnf(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1720,9 +1736,11 @@ func Test_logger_Error(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1814,9 +1832,11 @@ func Test_logger_Errorf(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1905,9 +1925,11 @@ func Test_logger_Fatal(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1999,9 +2021,11 @@ func Test_logger_Fatalf(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) 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 294610d8ed..15d908bde5 100644 --- a/internal/log/level/level_test.go +++ b/internal/log/level/level_test.go @@ -178,7 +178,8 @@ func TestAtol(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -267,7 +268,8 @@ func TestLevel_String(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/log/log_test.go b/internal/log/log_test.go index 3f1bc90015..9109e9ca3c 100644 --- a/internal/log/log_test.go +++ b/internal/log/log_test.go @@ -91,7 +91,8 @@ func TestInit(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -204,7 +205,8 @@ func Test_getLogger(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -259,7 +261,8 @@ func TestBold(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -334,7 +337,8 @@ func TestDebug(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -415,7 +419,8 @@ func TestDebugf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -486,7 +491,8 @@ func TestInfo(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -567,7 +573,8 @@ func TestInfof(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -638,7 +645,8 @@ func TestWarn(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -719,7 +727,8 @@ func TestWarnf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -790,7 +799,8 @@ func TestError(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -871,7 +881,8 @@ func TestErrorf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -942,7 +953,8 @@ func TestFatal(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -1023,7 +1035,8 @@ func TestFatalf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/log/logger/type_test.go b/internal/log/logger/type_test.go index 9b6ab35e9e..93d6ded29e 100644 --- a/internal/log/logger/type_test.go +++ b/internal/log/logger/type_test.go @@ -100,7 +100,8 @@ func TestType_String(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -305,7 +306,8 @@ func TestAtot(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/log/mock/logger_test.go b/internal/log/mock/logger_test.go index 4660095f5c..4e43969029 100644 --- a/internal/log/mock/logger_test.go +++ b/internal/log/mock/logger_test.go @@ -73,7 +73,8 @@ func TestLogger_Debug(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -154,7 +155,8 @@ func TestLogger_Debugf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -232,7 +234,8 @@ func TestLogger_Info(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -313,7 +316,8 @@ func TestLogger_Infof(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -391,7 +395,8 @@ func TestLogger_Warn(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -472,7 +477,8 @@ func TestLogger_Warnf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -550,7 +556,8 @@ func TestLogger_Error(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -631,7 +638,8 @@ func TestLogger_Errorf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -709,7 +717,8 @@ func TestLogger_Fatal(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -790,7 +799,8 @@ func TestLogger_Fatalf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/log/mock/retry_test.go b/internal/log/mock/retry_test.go index 74c1f4f19b..78463398e7 100644 --- a/internal/log/mock/retry_test.go +++ b/internal/log/mock/retry_test.go @@ -83,7 +83,8 @@ func TestRetry_Out(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -177,7 +178,8 @@ func TestRetry_Outf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/log/option_test.go b/internal/log/option_test.go index 29920ce7ff..5673d0089e 100644 --- a/internal/log/option_test.go +++ b/internal/log/option_test.go @@ -76,7 +76,8 @@ func TestWithLogger(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -155,7 +156,8 @@ func TestWithLoggerType(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -233,7 +235,8 @@ func TestWithLevel(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -318,7 +321,8 @@ func TestWithFormat(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/log/retry/option_test.go b/internal/log/retry/option_test.go index 222117b75e..01d4a73d4d 100644 --- a/internal/log/retry/option_test.go +++ b/internal/log/retry/option_test.go @@ -69,7 +69,8 @@ func TestWithError(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -142,7 +143,8 @@ func TestWithWarn(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/log/retry/retry_test.go b/internal/log/retry/retry_test.go index 1c8ff5253c..ca4f275d4d 100644 --- a/internal/log/retry/retry_test.go +++ b/internal/log/retry/retry_test.go @@ -79,7 +79,8 @@ func TestNew(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -200,7 +201,8 @@ func Test_retry_Out(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -348,7 +350,8 @@ func Test_retry_Outf(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/log/zap/option_test.go b/internal/log/zap/option_test.go index 149644e816..e20a188c9e 100644 --- a/internal/log/zap/option_test.go +++ b/internal/log/zap/option_test.go @@ -70,7 +70,8 @@ func TestWithLevel(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -141,7 +142,8 @@ func TestWithFormat(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -202,7 +204,8 @@ func TestWithCaller(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/log/zap/zap_test.go b/internal/log/zap/zap_test.go index c8a6f41d10..6fabd77b0f 100644 --- a/internal/log/zap/zap_test.go +++ b/internal/log/zap/zap_test.go @@ -86,7 +86,8 @@ func TestNew(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -250,7 +251,8 @@ func Test_logger_initialize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -357,7 +359,8 @@ func Test_toZapLevel(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -440,7 +443,8 @@ func Test_toZapEncoder(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -504,7 +508,8 @@ func Test_logger_Debug(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -577,7 +582,8 @@ func Test_logger_Debugf(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -648,7 +654,8 @@ func Test_logger_Info(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -721,7 +728,8 @@ func Test_logger_Infof(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -792,7 +800,8 @@ func Test_logger_Warn(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -865,7 +874,8 @@ func Test_logger_Warnf(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -936,7 +946,8 @@ func Test_logger_Error(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -1009,7 +1020,8 @@ func Test_logger_Errorf(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -1080,7 +1092,8 @@ func Test_logger_Fatal(t *testing.T) { // }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -1153,7 +1166,8 @@ func Test_logger_Fatalf(t *testing.T) { // }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/net/control/control_test.go b/internal/net/control/control_test.go index efb461d212..b2c002f918 100644 --- a/internal/net/control/control_test.go +++ b/internal/net/control/control_test.go @@ -28,6 +28,10 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestNew(t *testing.T) { t.Parallel() type args struct { @@ -83,7 +87,6 @@ func TestNew(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -150,7 +153,6 @@ func Test_boolint(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -235,7 +237,6 @@ func Test_isTCP(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -300,7 +301,6 @@ func Test_control_GetControl(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -333,6 +333,7 @@ func Test_control_GetControl(t *testing.T) { } func Test_control_controlFunc(t *testing.T) { + t.Parallel() type args struct { network string address string @@ -480,7 +481,6 @@ func Test_control_controlFunc(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/dialer.go b/internal/net/dialer.go index a95288380f..969e7154e7 100644 --- a/internal/net/dialer.go +++ b/internal/net/dialer.go @@ -43,10 +43,11 @@ type Dialer interface { } type dialer struct { - cache cache.Cache - dnsCache bool + dnsCache cache.Cache + enableDNSCache bool dnsCachedOnce sync.Once tlsConfig *tls.Config + tmu sync.RWMutex // lock mutex for tls handshake update dnsRefreshDurationStr string dnsCacheExpirationStr string dnsRefreshDuration time.Duration @@ -113,13 +114,12 @@ func NewDialer(opts ...DialerOption) (der Dialer, err error) { } d.dialer = d.dial - - if d.dnsCache { + if d.enableDNSCache { if d.dnsRefreshDuration > d.dnsCacheExpiration { return nil, errors.ErrInvalidDNSConfig(d.dnsRefreshDuration, d.dnsCacheExpiration) } - if d.cache == nil { - if d.cache, err = cache.New( + if d.dnsCache == nil { + if d.dnsCache, err = cache.New( cache.WithExpireDuration(d.dnsCacheExpirationStr), cache.WithExpireCheckDuration(d.dnsRefreshDurationStr), cache.WithExpiredHook(d.cacheExpireHook), @@ -131,7 +131,7 @@ func NewDialer(opts ...DialerOption) (der Dialer, err error) { } d.der.Resolver = &Resolver{ - PreferGo: false, + PreferGo: true, Dial: d.dialer, } @@ -143,10 +143,15 @@ func (d *dialer) GetDialer() func(ctx context.Context, network, addr string) (Co return d.dialer } -func (d *dialer) lookup(ctx context.Context, host string) (*dialerCache, error) { - cache, ok := d.cache.Get(host) - if ok { - return cache.(*dialerCache), nil +func (d *dialer) lookup(ctx context.Context, host string) (dc *dialerCache, err error) { + if d.enableDNSCache { + dnsCache, ok := d.dnsCache.Get(host) + if ok && dnsCache != nil { + dc, ok = dnsCache.(*dialerCache) + if ok && dc != nil && len(dc.ips) > 0 { + return dc, nil + } + } } ctx, span := trace.StartSpan(ctx, apiName+"/Dialer.lookup") defer func() { @@ -155,35 +160,61 @@ func (d *dialer) lookup(ctx context.Context, host string) (*dialerCache, error) } }() - r, err := d.der.Resolver.LookupIPAddr(ctx, host) + ips, err := d.lookupIPAddrs(ctx, host) if err != nil { return nil, err } - - if len(r) == 0 { + if len(ips) == 0 { return nil, errors.ErrLookupIPAddrNotFound(host) } - dc := &dialerCache{ - ips: make([]string, 0, len(r)), + dc = &dialerCache{ + ips: ips, + } + log.Infof("lookup succeed %v", dc.ips) + if d.enableDNSCache { + d.dnsCache.Set(host, dc) } + return dc, nil +} - for _, ip := range r { - dc.ips = append(dc.ips, ip.String()) +func (d *dialer) lookupIPAddrs(ctx context.Context, host string) (ips []string, err error) { + ctx, span := trace.StartSpan(ctx, apiName+"/Dialer.lookupIPAddrs") + defer func() { + if span != nil { + span.End() + } + }() + + var rsv *net.Resolver + if d.der == nil || d.der.Resolver == nil { + rsv = DefaultResolver + } else { + rsv = d.der.Resolver } - if dc != nil && len(dc.ips) != 0 { - log.Infof("lookup succeed %v", dc.ips) - d.cache.Set(host, dc) + r, err := rsv.LookupIPAddr(ctx, host) + if err != nil { + return nil, err } - return dc, nil + + if len(r) == 0 { + return nil, errors.ErrLookupIPAddrNotFound(host) + } + + ips = make([]string, 0, len(r)) + + for _, ip := range r { + ips = append(ips, ip.String()) + } + return ips, nil } // StartDialerCache starts the dialer cache to expire the cache automatically. func (d *dialer) StartDialerCache(ctx context.Context) { - if d.dnsCache && d.cache != nil { + if d.enableDNSCache && d.dnsCache != nil { d.dnsCachedOnce.Do(func() { - d.cache.Start(ctx) + d.dnsCache.Start(ctx) }) } } @@ -195,7 +226,14 @@ func (d *dialer) DialContext(ctx context.Context, network, address string) (Conn return d.GetDialer()(ctx, network, address) } -func (d *dialer) cachedDialer(dctx context.Context, network, addr string) (conn Conn, err error) { +func (d *dialer) cachedDialer(ctx context.Context, network, addr string) (conn Conn, err error) { + ctx, span := trace.StartSpan(ctx, apiName+"/Dialer.cachedDialer") + defer func() { + if span != nil { + span.End() + } + }() + var ( host string port string @@ -207,7 +245,6 @@ func (d *dialer) cachedDialer(dctx context.Context, network, addr string) (conn var isV4, isV6 bool host, nport, _, isV4, isV6, err = Parse(addr) if err != nil { - d.addrs.Delete(addr) return nil, err } port = strconv.FormatUint(uint64(nport), 10) @@ -226,21 +263,40 @@ func (d *dialer) cachedDialer(dctx context.Context, network, addr string) (conn } } - if d.dnsCache && !isIP { - if dc, err := d.lookup(dctx, host); err == nil { - for i := uint32(0); i < dc.Len(); i++ { - // in this line we use golang's standard net packages net.JoinHostPort cuz port is string type - target := net.JoinHostPort(dc.IP(), port) - conn, err := d.dial(dctx, network, target) - if err == nil && conn != nil { - return conn, nil + if d.enableDNSCache && !isIP { + to := time.NewTimer(d.dialerTimeout) + defer to.Stop() + for { + select { + case <-to.C: + d.dnsCache.Delete(host) + return d.dial(ctx, network, addr) + default: + if dc, err := d.lookup(ctx, host); err == nil { + for i := uint32(0); i < dc.Len(); i++ { + select { + case <-to.C: + d.dnsCache.Delete(host) + return d.dial(ctx, network, addr) + default: + // in this line we use golang's standard net packages net.JoinHostPort cuz port is string type + target := net.JoinHostPort(dc.IP(), port) + conn, err := d.dial(ctx, network, target) + if err == nil && conn != nil { + return conn, nil + } + log.Warnf("failed to dial connection to %s\terror: %v", target, err) + if conn != nil { + conn.Close() + } + } + d.dnsCache.Delete(host) + } } - log.Warnf("failed to dial connection to %s\terror: %v", target, err) } - d.cache.Delete(host) } } - return d.dial(dctx, network, addr) + return d.dial(ctx, network, addr) } func (d *dialer) dial(ctx context.Context, network, addr string) (conn Conn, err error) { @@ -251,7 +307,10 @@ func (d *dialer) dial(ctx context.Context, network, addr string) (conn Conn, err } }() log.Debugf("%s connection dialing to addr %s", network, addr) - conn, err = d.der.DialContext(ctx, network, addr) + err = safety.RecoverWithoutPanicFunc(func() error { + conn, err = d.der.DialContext(ctx, network, addr) + return err + })() if err != nil { defer func(conn Conn) { if conn != nil { @@ -265,9 +324,12 @@ func (d *dialer) dial(ctx context.Context, network, addr string) (conn Conn, err return nil, err } + d.tmu.RLock() if d.tlsConfig != nil { - return d.tlsHandshake(ctx, conn, addr) + d.tmu.RUnlock() + return d.tlsHandshake(ctx, conn, network, addr) } + d.tmu.RUnlock() if conn != nil { log.Infof("connected to addr %s succeed from %s://%s to %s://%s", addr, @@ -278,22 +340,31 @@ func (d *dialer) dial(ctx context.Context, network, addr string) (conn Conn, err return conn, nil } -func (d *dialer) tlsHandshake(ctx context.Context, conn Conn, addr string) (*tls.Conn, error) { +func (d *dialer) tlsHandshake(ctx context.Context, conn Conn, network, addr string) (tconn *tls.Conn, err error) { ctx, span := trace.StartSpan(ctx, apiName+"/Dialer.tlsHandshake") defer func() { if span != nil { span.End() } }() - var err error + d.tmu.RLock() if d.tlsConfig.ServerName == "" { + d.tmu.RUnlock() var host string host, _, err = SplitHostPort(addr) - if err == nil { + if err == nil && len(host) != 0 { + d.tmu.Lock() d.tlsConfig.ServerName = host + d.tmu.Unlock() } + } else { + d.tmu.RUnlock() + } + if conn != nil { + d.tmu.RLock() + tconn = tls.Client(conn, d.tlsConfig) + d.tmu.RUnlock() } - tconn := tls.Client(conn, d.tlsConfig) var tctx context.Context if d.der.Timeout > 0 { var cancel context.CancelFunc @@ -302,18 +373,58 @@ func (d *dialer) tlsHandshake(ctx context.Context, conn Conn, addr string) (*tls } else { tctx = ctx } - err = tconn.HandshakeContext(tctx) + if tconn != nil { + err = safety.RecoverWithoutPanicFunc(func() error { + return tconn.HandshakeContext(tctx) + })() + if err == nil && !tconn.ConnectionState().HandshakeComplete { + err = errors.ErrFailedToHandshakeTLSConnection(network, addr) + } + } else { + err = errors.ErrFailedToHandshakeTLSConnection(network, addr) + } if err != nil { - defer func(conn Conn) { - if conn != nil { - if err != nil { - err = errors.Wrap(conn.Close(), err.Error()) - return - } - err = conn.Close() + tctx, tcancel := context.WithTimeout(ctx, d.der.Timeout) + defer tcancel() + err = safety.RecoverWithoutPanicFunc(func() error { + d.tmu.RLock() + tder := &tls.Dialer{ + NetDialer: d.der, + Config: d.tlsConfig, } - }(conn) - return nil, err + d.tmu.RUnlock() + conn, err = tder.DialContext(tctx, network, addr) + return err + })() + if err != nil || conn == nil { + ttctx, ttcancel := context.WithTimeout(ctx, d.der.Timeout) + defer ttcancel() + err = safety.RecoverWithoutPanicFunc(func() error { + d.tmu.RLock() + tder := &tls.Dialer{ + Config: d.tlsConfig, + } + d.tmu.RUnlock() + conn, err = tder.DialContext(ttctx, network, addr) + return err + })() + } + if err != nil || conn == nil { + defer func(conn Conn) { + if conn != nil { + if err != nil { + err = errors.Wrap(conn.Close(), err.Error()) + return + } + err = conn.Close() + } + }(conn) + return nil, err + } + tconn, ok := conn.(*tls.Conn) + if !ok || tconn == nil || !tconn.ConnectionState().HandshakeComplete { + return nil, errors.ErrFailedToHandshakeTLSConnection(network, addr) + } } if tconn != nil { log.Infof("tls handshake addr %s succeed from %s://%s to %s://%s,\tconnectionstate: [ Version:%d, ServerName: %s, HandshakeComplete: %v, DidResume: %v, NegotiatedProtocol: %s ]", @@ -335,6 +446,6 @@ func (d *dialer) cacheExpireHook(ctx context.Context, addr string) { _, err = d.lookup(ctx, addr) return })(); err != nil { - log.Errorf("dns cacheExpireHook error occurred: %v\taddr:\t%s", err, addr) + log.Errorf("dns cache expiration hook process returned error: %v\tfor addr:\t%s", err, addr) } } diff --git a/internal/net/dialer_test.go b/internal/net/dialer_test.go index 8353804201..8ae54660b8 100644 --- a/internal/net/dialer_test.go +++ b/internal/net/dialer_test.go @@ -19,8 +19,6 @@ package net import ( "context" - ctls "crypto/tls" - stderrors "errors" "fmt" "math" "net" @@ -28,8 +26,8 @@ import ( "net/http/httptest" "reflect" "strconv" + "strings" "sync" - "sync/atomic" "testing" "time" @@ -39,12 +37,12 @@ import ( "github.com/vdaas/vald/internal/cache/gache" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/io" - "github.com/vdaas/vald/internal/strings" - "github.com/vdaas/vald/internal/test/goleak" + "github.com/vdaas/vald/internal/net/control" "github.com/vdaas/vald/internal/tls" ) func Test_dialerCache_IP(t *testing.T) { + t.Parallel() type fields struct { ips []string cnt uint32 @@ -143,9 +141,10 @@ func Test_dialerCache_IP(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc() } @@ -170,6 +169,7 @@ func Test_dialerCache_IP(t *testing.T) { } func Test_dialerCache_Len(t *testing.T) { + t.Parallel() type fields struct { ips []string cnt uint32 @@ -201,9 +201,10 @@ func Test_dialerCache_Len(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc() } @@ -228,12 +229,13 @@ func Test_dialerCache_Len(t *testing.T) { } func TestNewDialer(t *testing.T) { + t.Parallel() type args struct { opts []DialerOption } type want struct { - wantDer Dialer - err error + dialer Dialer + err error } type test struct { name string @@ -248,18 +250,24 @@ func TestNewDialer(t *testing.T) { return errors.Errorf("got_error: \"%+v\",\n\t\t\t\twant: \"%+v\"", err, w.err) } - if w.wantDer == nil && gotDer == nil { + if w.dialer == nil && gotDer == nil { return nil } - if w.wantDer == nil && gotDer != nil || w.wantDer != nil && gotDer == nil { - return errors.Errorf("got: \"%+v\",\n\t\t\t\twant: \"%+v\"", gotDer, w.wantDer) + if w.dialer == nil && gotDer != nil || w.dialer != nil && gotDer == nil { + return errors.Errorf("got: \"%+v\",\n\t\t\t\twant: \"%+v\"", gotDer, w.dialer) } - want := w.wantDer.(*dialer) - got := gotDer.(*dialer) - opts := []cmp.Option{ + want, ok := w.dialer.(*dialer) + if !ok { + return errors.Errorf("want: \"%+v\" is not a dialer", w.dialer) + } + got, ok := gotDer.(*dialer) + if !ok { + return errors.Errorf("got: \"%+v\" is not a dialer", gotDer) + } + if diff := cmp.Diff(*want, *got, + cmpopts.IgnoreFields(*want, "dialer", "der", "addrs", "dnsCachedOnce", "dnsCache", "ctrl", "tmu"), cmp.AllowUnexported(*want), - cmpopts.IgnoreFields(*want, "dialer", "der", "addrs", "dnsCachedOnce", "ctrl"), cmp.Comparer(func(x, y cache.Cache) bool { if x == nil && y == nil { return true @@ -269,11 +277,10 @@ func TestNewDialer(t *testing.T) { cmp.Comparer(func(x, y *tls.Config) bool { return reflect.DeepEqual(x, y) }), - } - - if diff := cmp.Diff(*want, *got, opts...); diff != "" { + ); diff != "" { return errors.Errorf("err: %s", diff) } + if got.dialer == nil { return errors.Errorf("dialer is not initialized") } @@ -283,95 +290,58 @@ func TestNewDialer(t *testing.T) { return nil } tests := []test{ + { + name: "returns dialer when option is empty", + want: want{ + dialer: func() (der Dialer) { + der, _ = NewDialer() + return der + }(), + }, + }, func() test { - d := &net.Dialer{ - Timeout: 0, - KeepAlive: time.Second * 30, - FallbackDelay: time.Millisecond * 300, - DualStack: true, - } - d.Resolver = &Resolver{ - PreferGo: false, - Dial: d.DialContext, - } - - return test{ - name: "returns dialer when option is empty", - want: want{ - wantDer: &dialer{ - dialerKeepalive: time.Second * 30, - dialerTimeout: 0, - dialerFallbackDelay: time.Millisecond * 300, - dialerDualStack: true, - der: d, - dialer: d.DialContext, - }, - }, - } - }(), - func() test { - d := &net.Dialer{ - Timeout: time.Second * 30, - KeepAlive: time.Second * 30, - DualStack: true, - } - d.Resolver = &Resolver{ - PreferGo: false, - Dial: d.DialContext, + opts := []DialerOption{ + WithTLS(func() *tls.Config { + c, err := tls.NewClientConfig(tls.WithInsecureSkipVerify(true)) + if err != nil { + return nil + } + return c + }()), + WithEnableDNSCache(), + WithDNSRefreshDuration("5s"), + WithDNSCacheExpiration("10s"), } - tc := new(tls.Config) - c := gache.New() - return test{ name: "returns dialer when option is not empty", args: args{ - opts: []DialerOption{ - WithTLS(tc), - WithEnableDNSCache(), - WithDNSRefreshDuration("5s"), - WithDNSCacheExpiration("10s"), - }, + opts: opts, }, want: want{ - wantDer: &dialer{ - dialerKeepalive: time.Second * 30, - dialerTimeout: 0, - dialerFallbackDelay: time.Millisecond * 300, - dnsRefreshDuration: time.Second * 5, - dnsCacheExpiration: time.Second * 10, - dnsRefreshDurationStr: "5s", - dnsCacheExpirationStr: "10s", - dnsCache: true, - dialerDualStack: true, - der: d, - dialer: d.DialContext, - cache: c, - tlsConfig: tc, - }, + dialer: func() (der Dialer) { + der, _ = NewDialer(opts...) + return der + }(), }, } }(), func() test { - d := &net.Dialer{ - Timeout: time.Second * 30, - KeepAlive: time.Second * 30, - DualStack: true, - } - d.Resolver = &Resolver{ - PreferGo: false, - Dial: d.DialContext, + opts := []DialerOption{ + WithTLS(func() *tls.Config { + c, err := tls.NewClientConfig(tls.WithInsecureSkipVerify(true)) + if err != nil { + return nil + } + return c + }()), + WithEnableDNSCache(), + WithDNSRefreshDuration("50s"), + WithDNSCacheExpiration("10s"), } - tc := new(tls.Config) - return test{ name: "return error when refresh duration > cache expiration and cache enabled", args: args{ - opts: []DialerOption{ - WithTLS(tc), - WithEnableDNSCache(), - WithDNSRefreshDuration("50s"), - WithDNSCacheExpiration("10s"), - }, + opts: opts, }, want: want{ err: errors.ErrInvalidDNSConfig(50*time.Second, 10*time.Second), @@ -380,9 +350,10 @@ func TestNewDialer(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -403,6 +374,7 @@ func TestNewDialer(t *testing.T) { } func Test_dialer_GetDialer(t *testing.T) { + t.Parallel() type fields struct { dialer func(ctx context.Context, network, addr string) (Conn, error) } @@ -440,9 +412,10 @@ func Test_dialer_GetDialer(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc() } @@ -466,24 +439,10 @@ func Test_dialer_GetDialer(t *testing.T) { } func Test_dialer_lookup(t *testing.T) { + t.Parallel() type args struct { - ctx context.Context addr string } - type fields struct { - cache cache.Cache - dnsCache bool - tlsConfig *tls.Config - dnsRefreshDurationStr string - dnsCacheExpirationStr string - dnsRefreshDuration time.Duration - dnsCacheExpiration time.Duration - dialerTimeout time.Duration - dialerKeepalive time.Duration - dialerDualStack bool - der *net.Dialer - dialer func(ctx context.Context, network, addr string) (Conn, error) - } type want struct { want *dialerCache err error @@ -491,13 +450,13 @@ func Test_dialer_lookup(t *testing.T) { type test struct { name string args args - fields fields + opts []DialerOption want want - checkFunc func(want, *dialerCache, error, *dialer) error + checkFunc func(context.Context, want, *dialerCache, error, *dialer) error beforeFunc func(args) afterFunc func(args) } - defaultCheckFunc := func(w want, got *dialerCache, err error, d *dialer) error { + defaultCheckFunc := func(ctx context.Context, w want, got *dialerCache, err error, d *dialer) error { if !errors.Is(err, w.err) { return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) } @@ -510,22 +469,13 @@ func Test_dialer_lookup(t *testing.T) { { name: "return ips when lookupIpAddr returns ips", args: args{ - ctx: context.Background(), addr: "google.com", }, - fields: fields{ - cache: gache.New(), - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, - }, - }, - }, - checkFunc: func(w want, got *dialerCache, err error, d *dialer) error { + opts: []DialerOption{}, + checkFunc: func(ctx context.Context, w want, got *dialerCache, err error, d *dialer) error { if !errors.Is(err, w.err) { return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) } - if got.Len() == 0 { return errors.New("ips is empty") } @@ -535,18 +485,13 @@ func Test_dialer_lookup(t *testing.T) { { name: "return ips when lookupIpAddr returns and the cache is set", args: args{ - ctx: context.Background(), addr: "google.com", }, - fields: fields{ - cache: gache.New(), - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, - }, - }, + opts: []DialerOption{ + WithDNSCache(gache.New()), + WithDisableDialerDualStack(), }, - checkFunc: func(w want, got *dialerCache, err error, d *dialer) error { + checkFunc: func(ctx context.Context, w want, got *dialerCache, err error, d *dialer) error { if !errors.Is(err, w.err) { return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) } @@ -556,21 +501,21 @@ func Test_dialer_lookup(t *testing.T) { } // check the cache is set - if _, ok := d.cache.Get("google.com"); !ok { + if _, ok := d.dnsCache.Get("google.com"); !ok { return errors.New("cache is not set") } // execute lookup again and check the result is the same - dc1, err1 := d.lookup(context.Background(), "google.com") + dc1, err1 := d.lookup(ctx, "google.com") if err1 != nil { return err1 } if !reflect.DeepEqual(got, dc1) { - return errors.Errorf("got = %v, got1 %v", got, dc1) + return errors.Errorf("previous = %v, now %v", got, dc1) } // check the cache is set - if _, ok := d.cache.Get("google.com"); !ok { + if _, ok := d.dnsCache.Get("google.com"); !ok { return errors.New("cache is not set") } @@ -580,22 +525,17 @@ func Test_dialer_lookup(t *testing.T) { { name: "return cached ips when the cache hits", args: args{ - ctx: context.Background(), addr: "addr", }, - fields: fields{ - cache: func() cache.Cache { + opts: []DialerOption{ + WithDNSCache(func() cache.Cache { g := gache.New() g.Set("addr", &dialerCache{ ips: []string{"999.999.999.999"}, }) return g - }(), - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, - }, - }, + }()), + WithDisableDialerDualStack(), }, want: want{ want: &dialerCache{ @@ -605,9 +545,14 @@ func Test_dialer_lookup(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -619,22 +564,16 @@ func Test_dialer_lookup(t *testing.T) { checkFunc = defaultCheckFunc } - d := &dialer{ - cache: test.fields.cache, - dnsCache: test.fields.dnsCache, - tlsConfig: test.fields.tlsConfig, - dnsRefreshDurationStr: test.fields.dnsRefreshDurationStr, - dnsCacheExpirationStr: test.fields.dnsCacheExpirationStr, - dnsRefreshDuration: test.fields.dnsRefreshDuration, - dnsCacheExpiration: test.fields.dnsCacheExpiration, - dialerTimeout: test.fields.dialerTimeout, - dialerKeepalive: test.fields.dialerKeepalive, - dialerDualStack: test.fields.dialerDualStack, - der: test.fields.der, - dialer: test.fields.dialer, + der, err := NewDialer(test.opts...) + if err != nil { + tt.Errorf("failed to initialize dialer: %v", err) } - got, err := d.lookup(test.args.ctx, test.args.addr) - if err := checkFunc(test.want, got, err, d); err != nil { + d, ok := der.(*dialer) + if !ok { + tt.Errorf("NewDialer return value Dialer is not *dialer: %v", der) + } + got, err := d.lookup(ctx, test.args.addr) + if err := checkFunc(ctx, test.want, got, err, d); err != nil { tt.Errorf("error = %v", err) } }) @@ -642,28 +581,13 @@ func Test_dialer_lookup(t *testing.T) { } func Test_dialer_StartDialerCache(t *testing.T) { - type args struct { - ctx context.Context - } - type fields struct { - cache cache.Cache - dnsCache bool - tlsConfig *tls.Config - dnsRefreshDurationStr string - dnsCacheExpirationStr string - dnsRefreshDuration time.Duration - dnsCacheExpiration time.Duration - dialerTimeout time.Duration - dialerKeepalive time.Duration - dialerDualStack bool - der *net.Dialer - dialer func(ctx context.Context, network, addr string) (Conn, error) - } + t.Parallel() + type args struct{} type want struct{} type test struct { name string args args - fields fields + opts []DialerOption want want checkFunc func(*dialer) error beforeFunc func(*dialer) @@ -674,146 +598,118 @@ func Test_dialer_StartDialerCache(t *testing.T) { } tests := []test{ func() test { - addr := "google.com" - ips := []string{"0.0.0.0"} - ctx, cancel := context.WithCancel(context.Background()) + addr := "localhost" + ips := []string{} return test{ name: "cache refresh when it is expired", - args: args{ - ctx: ctx, - }, - fields: fields{ - dnsCache: true, - dnsRefreshDuration: time.Millisecond * 100, - dnsCacheExpiration: time.Millisecond * 100, + + opts: []DialerOption{ + WithEnableDNSCache(), + WithDNSRefreshDuration("100ms"), + WithDNSCacheExpiration("100ms"), + WithDisableDialerDualStack(), + WithDialerTimeout("1m"), + WithDialerKeepalive("1m"), }, beforeFunc: func(d *dialer) { - d.cache, _ = cache.New(cache.WithExpireDuration("300ms"), cache.WithExpireCheckDuration("100ms"), - cache.WithExpiredHook(d.cacheExpireHook)) - d.cache.Set(addr, &dialerCache{ips: ips}) - - d.der = &net.Dialer{ - Timeout: time.Minute, - KeepAlive: time.Minute, - DualStack: d.dialerDualStack, - Resolver: &Resolver{ - PreferGo: false, - Dial: d.dialer, - }, - } + d.dnsCache.Set(addr, &dialerCache{ + ips: ips, + }) }, checkFunc: func(d *dialer) error { - // ensure the cache exists - val, ok := d.cache.Get(addr) - if !ok { - return errors.New("cache not found") - } - if !reflect.DeepEqual(val.(*dialerCache).ips, ips) { - return errors.New("cache is not correct") + validateFn := func(ipLen int) error { + val, ok := d.dnsCache.Get(addr) + if !ok { + return errors.New("cache not found") + } + if val == nil || len(val.(*dialerCache).ips) != ipLen { + return errors.Errorf("cache is not correct, gotLen: %v, want: %v", val, ipLen) + } + return nil } - // sleep and wait the cache update - time.Sleep(500 * time.Millisecond) - - // get again and check if the cache is updated - val, ok = d.cache.Get(addr) - if !ok { - return errors.New("cache not found") + // ensure the cache exists + if err := validateFn(0); err != nil { + return errors.Errorf("invalid cache err: %e", err) } - if reflect.DeepEqual(val.(*dialerCache).ips, ips) { - return errors.New("cache is not updated") + + // check cache update until timeout + timeout := time.After(5 * time.Second) + ticker := time.Tick(20 * time.Millisecond) + for { + select { + case <-timeout: + if err := validateFn(2); err != nil { + return errors.Errorf("cache is not updated, err: %v", err) + } + case <-ticker: + if err := validateFn(2); err == nil { + return nil + } + } } - return nil - }, - afterFunc: func(args) { - cancel() }, } }(), func() test { addr := "invalid" - ips := []string{"0.0.0.0"} - ctx, cancel := context.WithCancel(context.Background()) return test{ name: "cache deleted when it is expired and the address is invalid or not available anymore", - args: args{ - ctx: ctx, - }, - fields: fields{ - dnsCache: true, - dnsRefreshDuration: time.Millisecond * 100, - dnsCacheExpiration: time.Millisecond * 100, - }, - beforeFunc: func(d *dialer) { - d.cache, _ = cache.New(cache.WithExpireDuration("300ms"), cache.WithExpireCheckDuration("100ms"), - cache.WithExpiredHook(d.cacheExpireHook)) - d.cache.Set(addr, &dialerCache{ips: ips}) - - d.der = &net.Dialer{ - Timeout: time.Minute, - KeepAlive: time.Minute, - DualStack: d.dialerDualStack, - Resolver: &Resolver{ - PreferGo: false, - Dial: d.dialer, - }, - } + + opts: []DialerOption{ + WithEnableDNSCache(), + WithDNSRefreshDuration("100ms"), + WithDNSCacheExpiration("100ms"), + WithDisableDialerDualStack(), + WithDialerTimeout("1m"), + WithDialerKeepalive("1m"), }, checkFunc: func(d *dialer) error { // ensure the cache exists - val, ok := d.cache.Get(addr) - if !ok { - return errors.New("cache not found") - } - if !reflect.DeepEqual(val.(*dialerCache).ips, ips) { - return errors.New("cache is not correct") + _, ok := d.dnsCache.Get(addr) + if ok { + return errors.New("cache found") } - // sleep and wait the cache removed time.Sleep(500 * time.Millisecond) // get again and check if the cache deleted - if _, ok := d.cache.Get(addr); ok { + if _, ok := d.dnsCache.Get(addr); ok { return errors.New("cache found") } return nil }, - afterFunc: func(args) { - cancel() - time.Sleep(500 * time.Millisecond) - }, } }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - d := &dialer{ - cache: test.fields.cache, - dnsCache: test.fields.dnsCache, - tlsConfig: test.fields.tlsConfig, - dnsRefreshDurationStr: test.fields.dnsRefreshDurationStr, - dnsCacheExpirationStr: test.fields.dnsCacheExpirationStr, - dnsRefreshDuration: test.fields.dnsRefreshDuration, - dnsCacheExpiration: test.fields.dnsCacheExpiration, - dialerTimeout: test.fields.dialerTimeout, - dialerKeepalive: test.fields.dialerKeepalive, - dialerDualStack: test.fields.dialerDualStack, - der: test.fields.der, - dialer: test.fields.dialer, + der, err := NewDialer(test.opts...) + if err != nil { + tt.Errorf("failed to initialize dialer: %v", err) + } + d, ok := der.(*dialer) + if !ok { + tt.Errorf("NewDialer return value Dialer is not *dialer: %v", der) } if test.beforeFunc != nil { test.beforeFunc(d) } - d.StartDialerCache(test.args.ctx) + d.StartDialerCache(ctx) if err := checkFunc(d); err != nil { tt.Errorf("error = %v", err) } @@ -825,8 +721,8 @@ func Test_dialer_StartDialerCache(t *testing.T) { } func Test_dialer_DialContext(t *testing.T) { + t.Parallel() type args struct { - ctx context.Context network string address string } @@ -859,7 +755,6 @@ func Test_dialer_DialContext(t *testing.T) { { name: "return non nil error", args: args{ - ctx: context.Background(), network: "dummyNetwork", address: "dummyAddress", }, @@ -874,9 +769,14 @@ func Test_dialer_DialContext(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -891,7 +791,7 @@ func Test_dialer_DialContext(t *testing.T) { dialer: test.fields.dialer, } - got, err := d.DialContext(test.args.ctx, test.args.network, test.args.address) + got, err := d.DialContext(ctx, test.args.network, test.args.address) if err := checkFunc(test.want, got, err); err != nil { tt.Errorf("error = %v", err) } @@ -900,25 +800,11 @@ func Test_dialer_DialContext(t *testing.T) { } func Test_dialer_cachedDialer(t *testing.T) { + t.Parallel() type args struct { - dctx context.Context network string addr string } - type fields struct { - cache cache.Cache - dnsCache bool - tlsConfig *tls.Config - dnsRefreshDurationStr string - dnsCacheExpirationStr string - dnsRefreshDuration time.Duration - dnsCacheExpiration time.Duration - dialerTimeout time.Duration - dialerKeepalive time.Duration - dialerDualStack bool - der *net.Dialer - dialer func(ctx context.Context, network, addr string) (Conn, error) - } type want struct { wantConn Conn err error @@ -926,13 +812,13 @@ func Test_dialer_cachedDialer(t *testing.T) { type test struct { name string args args - fields fields + opts []DialerOption want want - checkFunc func(*dialer, want, Conn, error) error - beforeFunc func(args) - afterFunc func(args) + checkFunc func(*dialer, context.Context, want, Conn, error) error + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } - defaultCheckFunc := func(d *dialer, w want, gotConn Conn, err error) error { + defaultCheckFunc := func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { if !errors.Is(err, w.err) { return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) } @@ -942,80 +828,86 @@ func Test_dialer_cachedDialer(t *testing.T) { return nil } tests := []test{ + func() test { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + })) + return test{ + name: "return conn", + args: args{ + network: TCP.String(), + addr: srv.URL[len("http://"):], + }, + opts: nil, + checkFunc: func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { + if err != nil { + return errors.Errorf("err is not nil: %v, want: %#v, got: %#v", err, w, gotConn) + } + + if gotConn == nil { + return errors.New("conn is nil") + } + return nil + }, + afterFunc: func(*testing.T) { + srv.Close() + }, + } + }(), + func() test { + srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + })) + srv.TLS.InsecureSkipVerify = true + + return test{ + name: "return tls conn", + args: args{ + network: TCP.String(), + addr: srv.URL[len("https://"):], + }, + opts: []DialerOption{ + WithTLS(func() *tls.Config { + c, err := tls.NewClientConfig(tls.WithInsecureSkipVerify(true)) + if err != nil { + return nil + } + return c + }()), + WithDialerTimeout("30s"), + }, + checkFunc: func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { + if err != nil { + return errors.Errorf("err is not nil: %v", err) + } + + if gotConn == nil { + return errors.New("conn is nil") + } + return nil + }, + afterFunc: func(t *testing.T) { + t.Helper() + srv.Close() + }, + } + }(), { - name: "return conn", + name: "returns error when missing port in address", args: args{ - dctx: context.Background(), network: TCP.String(), - addr: "google.com:80", - }, - fields: fields{ - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, - }, - }, + addr: "addr", }, - checkFunc: func(d *dialer, w want, gotConn Conn, err error) error { - if err != nil { - return errors.Errorf("err is not nil: %v, want: %#v, got: %#v", err, w, gotConn) + opts: nil, + checkFunc: func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { + if err == nil { + return errors.New("err is nil") } - if gotConn == nil { - return errors.New("conn is nil") + if gotConn != nil { + return errors.Errorf("conn is not nil: %v", gotConn) } - return nil - }, - }, - { - name: "return tls conn", - args: args{ - dctx: context.Background(), - network: TCP.String(), - addr: "google.com:443", - }, - fields: fields{ - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, - }, - }, - tlsConfig: new(tls.Config), - }, - checkFunc: func(d *dialer, w want, gotConn Conn, err error) error { - if err != nil { - return errors.Errorf("err is not nil: %v", err) - } - - if gotConn == nil { - return errors.New("conn is nil") - } - return nil - }, - }, - { - name: "returns error when missing port in address", - args: args{ - dctx: context.Background(), - network: TCP.String(), - addr: "addr", - }, - fields: fields{ - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, - }, - }, - }, - checkFunc: func(d *dialer, w want, gotConn Conn, err error) error { - if err == nil { - return errors.New("err is nil") - } - - if gotConn != nil { - return errors.Errorf("conn is not nil: %v", gotConn) - } - + return nil }, }, @@ -1024,48 +916,49 @@ func Test_dialer_cachedDialer(t *testing.T) { w.WriteHeader(200) })) - host, port, _ := SplitHostPort(strings.TrimPrefix(strings.TrimPrefix(srv.URL, "https://"), "http://")) - - addr := "invalid_ip" + c, err := cache.New() + if err != nil { + t.Error(err) + } - // set the hostname 'invalid_ip' to the host name of the cache with the test server ip address - cache, _ := cache.New() - cache.Set(addr, &dialerCache{ - ips: []string{ - host, - }, - }) + addr := srv.URL[len("http://"):] + host, _, err := SplitHostPort(addr) + if err != nil { + t.Error(err) + } return test{ name: "return cached ip connection", args: args{ - dctx: context.Background(), network: TCP.String(), - addr: addr + ":" + strconv.FormatUint(uint64(port), 10), + addr: addr, }, - fields: fields{ - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, + opts: []DialerOption{ + WithDNSCache(c), + }, + beforeFunc: func(t *testing.T) { + t.Helper() + // set the hostname 'invalid_ip' to the host name of the cache with the test server ip address + c.Set(addr, &dialerCache{ + ips: []string{ + host, }, - }, - cache: cache, - dnsCache: true, + }) }, - checkFunc: func(d *dialer, w want, gotConn Conn, err error) error { + checkFunc: func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { if err != nil { - return errors.New("err is not nil") + return errors.Errorf("err is not nil, %v", err) } if gotConn == nil { return errors.New("conn is nil") } - if _, ok := cache.Get(addr); !ok { + if _, ok := c.Get(addr); !ok { return errors.New("cache value is deleted") } return nil }, - afterFunc: func(args) { + afterFunc: func(t *testing.T) { srv.Close() }, } @@ -1074,40 +967,42 @@ func Test_dialer_cachedDialer(t *testing.T) { srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) })) - host, port, _ := SplitHostPort(strings.TrimPrefix(strings.TrimPrefix(srv.URL, "https://"), "http://")) + srv.TLS.InsecureSkipVerify = true - addr := host + ":" + strconv.FormatUint(uint64(port), 10) - // set the hostname 'invalid_ip' to the host name of the cache with the test server ip address - cache, err := cache.New() + c, err := cache.New() + if err != nil { + t.Error(err) + } + tls, err := tls.NewClientConfig(tls.WithInsecureSkipVerify(true)) + if err != nil { + t.Error(err) + } + + addr := srv.URL[len("https://"):] + host, _, err := SplitHostPort(addr) if err != nil { t.Error(err) } - cache.Set(addr, &dialerCache{ - ips: []string{ - host, - }, - }) - tcfg, _ := tls.NewClientConfig(tls.WithInsecureSkipVerify(true)) return test{ name: "return cached ip tls connection", args: args{ - dctx: context.Background(), network: TCP.String(), addr: addr, }, - fields: fields{ - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, + opts: []DialerOption{ + WithDNSCache(c), + WithTLS(tls), + }, + beforeFunc: func(t *testing.T) { + // set the hostname 'invalid_ip' to the host name of the cache with the test server ip address + c.Set(addr, &dialerCache{ + ips: []string{ + host, }, - }, - cache: cache, - dnsCache: true, - // tlsConfig: srv.Config.TLSConfig, - tlsConfig: tcfg, + }) }, - checkFunc: func(d *dialer, w want, gotConn Conn, err error) error { + checkFunc: func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { if err != nil { return errors.Wrap(err, "err is not nil") } @@ -1115,12 +1010,12 @@ func Test_dialer_cachedDialer(t *testing.T) { return errors.New("conn is nil") } - if _, ok := cache.Get(addr); !ok { + if _, ok := c.Get(addr); !ok { return errors.New("cache value is deleted") } return nil }, - afterFunc: func(args) { + afterFunc: func(t *testing.T) { srv.Close() }, } @@ -1128,30 +1023,27 @@ func Test_dialer_cachedDialer(t *testing.T) { func() test { addr := "invalid_ip" - cache, _ := cache.New() - cache.Set(addr, &dialerCache{ - ips: []string{ - addr, - }, - }) - + c, err := cache.New() + if err != nil { + t.Error(err) + } return test{ name: "remove cache when dial failed", args: args{ - dctx: context.Background(), network: TCP.String(), addr: addr + ":80", }, - fields: fields{ - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, + opts: []DialerOption{ + WithDNSCache(c), + }, + beforeFunc: func(*testing.T) { + c.Set(addr, &dialerCache{ + ips: []string{ + addr, }, - }, - cache: cache, - dnsCache: true, + }) }, - checkFunc: func(d *dialer, w want, gotConn Conn, err error) error { + checkFunc: func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { if err == nil { return errors.New("err is nil") } @@ -1159,7 +1051,7 @@ func Test_dialer_cachedDialer(t *testing.T) { return errors.New("conn is nil") } - if _, ok := cache.Get(addr); ok { + if _, ok := c.Get(addr); ok { return errors.New("cache value is not deleted") } return nil @@ -1168,31 +1060,27 @@ func Test_dialer_cachedDialer(t *testing.T) { }(), func() test { addr := "google.com" - - cache, _ := cache.New() - cache.Set(addr, &dialerCache{ - ips: []string{ - "invalid_ip", - }, - }) - + c, err := cache.New() + if err != nil { + t.Error(err) + } return test{ name: "retry when cache invalid and cache will be deleted", args: args{ - dctx: context.Background(), network: TCP.String(), addr: addr + ":80", }, - fields: fields{ - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, + opts: []DialerOption{ + WithDNSCache(c), + }, + beforeFunc: func(*testing.T) { + c.Set(addr, &dialerCache{ + ips: []string{ + "invalid_ip", }, - }, - cache: cache, - dnsCache: true, + }) }, - checkFunc: func(d *dialer, w want, gotConn Conn, err error) error { + checkFunc: func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { if err != nil { return errors.Errorf("err is not nil: %v", err) } @@ -1200,7 +1088,7 @@ func Test_dialer_cachedDialer(t *testing.T) { return errors.New("conn is nil") } - if c, ok := cache.Get(addr); ok { + if c, ok := c.Get(addr); ok { return errors.Errorf("cache value is set: %+v", c) } return nil @@ -1209,51 +1097,43 @@ func Test_dialer_cachedDialer(t *testing.T) { }(), func() test { srvNums := 20 - srvs := make([]*httptest.Server, 0, srvNums) - hosts := make([]string, 0, srvNums) - ports := make([]string, 0, srvNums) + srvs := make([]*httptest.Server, srvNums) + hosts := make([]string, srvNums) + ports := make([]uint16, srvNums) + addrs := make([]string, srvNums) - // create servers that will return the server number for i := 0; i < srvNums; i++ { content := fmt.Sprint(i) - hf := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srvs[i] = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) fmt.Fprint(w, content) - }) - srvs = append(srvs, httptest.NewServer(hf)) - h, p, _ := SplitHostPort(strings.TrimPrefix(strings.TrimPrefix(srvs[i].URL, "https://"), "http://")) - hosts = append(hosts, h) - ports = append(ports, fmt.Sprint(p)) + })) + hosts[i], ports[i], _ = SplitHostPort(strings.TrimPrefix(strings.TrimPrefix(srvs[i].URL, "https://"), "http://")) + addrs[i] = JoinHostPort(hosts[i], ports[i]) } - addr := "address" - - cache, _ := cache.New() - cache.Set(addr, &dialerCache{ - ips: hosts, - }) + c, err := cache.New() + if err != nil { + t.Error(err) + } return test{ name: "return cached ip connection in round robin order", args: args{ - dctx: context.Background(), network: TCP.String(), - addr: net.JoinHostPort(addr, ports[0]), + addr: addrs[0], }, - fields: fields{ - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, - }, - }, - cache: cache, - dnsCache: true, + opts: []DialerOption{ + WithDNSCache(c), + WithEnableDNSCache(), }, - checkFunc: func(d *dialer, w want, gotConn Conn, err error) error { - c, _ := d.cache.Get(addr) - dc := c.(*dialerCache) - - check := func(gotConn Conn, gotErr error, cnt int, port string, srvContent string) error { + beforeFunc: func(t *testing.T) { + c.Set(addrs[0], &dialerCache{ + ips: hosts, + }) + }, + checkFunc: func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { + check := func(gotConn Conn, gotErr error, port uint16, srvContent string) error { defer func() { if gotConn != nil { _ = gotConn.Close() @@ -1266,14 +1146,11 @@ func Test_dialer_cachedDialer(t *testing.T) { if gotConn == nil { return errors.New("conn is nil") } - if c := atomic.LoadUint32(&dc.cnt); c != uint32(cnt) { - return errors.Errorf("cnt not correct, %d, except: %d", c, cnt) - } - // check the connection made is the same excepted + // check the connection made on the same port _, p, _ := net.SplitHostPort(gotConn.RemoteAddr().String()) - if fmt.Sprint(p) != port { - return errors.Errorf("unexcepted port number, except: %v, got: %v", port, p) + if p != strconv.Itoa(int(port)) { + return errors.Errorf("unexcepted port number, except: %d, got: %s", port, p) } // read the output from the server and check if it is equals to the count @@ -1281,22 +1158,22 @@ func Test_dialer_cachedDialer(t *testing.T) { buf, _ := io.ReadAll(gotConn) content := strings.Split(string(buf), "\n")[5] // skip HTTP header if content != srvContent { - return errors.Errorf("excepted output from server, got: %v, want: %v", content, fmt.Sprint(cnt)) + return errors.Errorf("excepted output from server, got: %v, want: %v", content, srvContent) } return nil } // check the return of the returned connection - if err := check(gotConn, err, 1, ports[0], "0"); err != nil { - return err + if err := check(gotConn, err, ports[0], "0"); err != nil { + return errors.Errorf("check return connection, err: %v", err) } - // check all the connection + // check all remaining connection for i := 1; i < srvNums; i++ { - c, e := d.cachedDialer(context.Background(), TCP.String(), net.JoinHostPort(addr, ports[i])) + c, e := d.cachedDialer(ctx, TCP.String(), addrs[i]) srvContent := fmt.Sprint(i) - if err := check(c, e, i+1, ports[i], srvContent); err != nil { + if err := check(c, e, ports[i], srvContent); err != nil { return err } } @@ -1304,19 +1181,18 @@ func Test_dialer_cachedDialer(t *testing.T) { // check all the connections again and it should start with index 0, // and the count should not be reset for i := 0; i < srvNums; i++ { - c, e := d.cachedDialer(context.Background(), TCP.String(), net.JoinHostPort(addr, ports[i])) - cnt := srvNums + i + 1 + c, e := d.cachedDialer(ctx, TCP.String(), addrs[i]) srvContent := fmt.Sprint(i) - if err := check(c, e, cnt, ports[i], srvContent); err != nil { + if err := check(c, e, ports[i], srvContent); err != nil { return err } } return nil }, - afterFunc: func(args) { - for _, srv := range srvs { - srv.Close() + afterFunc: func(t *testing.T) { + for _, s := range srvs { + s.Close() } }, } @@ -1325,35 +1201,35 @@ func Test_dialer_cachedDialer(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) })) - host, port, _ := net.SplitHostPort(srv.URL[len("http://"):]) - addr := "invalid_ip" + addr := srv.URL[len("http://"):] + host, _, err := SplitHostPort(addr) + if err != nil { + t.Error(err) + } - cache, _ := cache.New() - cache.Set(addr, &dialerCache{ - ips: []string{ - host, host, - }, - cnt: math.MaxUint32, - }) + c, err := cache.New() + if err != nil { + t.Error(err) + } return test{ - name: "reset cache count when it is overflow", + name: "reset cache count when it is overflow", args: args{ - dctx: context.Background(), network: TCP.String(), - addr: addr + ":" + fmt.Sprint(port), + addr: addr, }, - fields: fields{ - der: &net.Dialer{ - Resolver: &Resolver{ - PreferGo: false, - }, - }, - cache: cache, - dnsCache: true, + opts: []DialerOption{ + WithDNSCache(c), + WithDialerTimeout("10s"), + }, + beforeFunc: func(t *testing.T) { + c.Set(addr, &dialerCache{ + cnt: math.MaxUint32, + ips: []string{host, host}, + }) }, - checkFunc: func(d *dialer, w want, gotConn Conn, err error) error { + checkFunc: func(d *dialer, ctx context.Context, w want, gotConn Conn, err error) error { if err != nil { return errors.Errorf("err is not nil: %v", err) } @@ -1361,59 +1237,63 @@ func Test_dialer_cachedDialer(t *testing.T) { return errors.New("conn is nil") } - c, _ := d.cache.Get(addr) + c, _ := d.dnsCache.Get(host) if dc := c.(*dialerCache); dc.cnt != 0 { return errors.Errorf("count do not reset, cnt: %v", dc.cnt) } return nil }, - afterFunc: func(args) { + afterFunc: func(t *testing.T) { srv.Close() }, } }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt) // even test is failed, ensure afterFunc is executed to avoid goleak error } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - d := &dialer{ - cache: test.fields.cache, - dnsCache: test.fields.dnsCache, - tlsConfig: test.fields.tlsConfig, - dnsRefreshDurationStr: test.fields.dnsRefreshDurationStr, - dnsCacheExpirationStr: test.fields.dnsCacheExpirationStr, - dnsRefreshDuration: test.fields.dnsRefreshDuration, - dnsCacheExpiration: test.fields.dnsCacheExpiration, - dialerTimeout: test.fields.dialerTimeout, - dialerKeepalive: test.fields.dialerKeepalive, - dialerDualStack: test.fields.dialerDualStack, - der: test.fields.der, - dialer: test.fields.dialer, + + der, err := NewDialer(test.opts...) + if err != nil { + tt.Errorf("failed to initialize dialer: %v", err) + } + d, ok := der.(*dialer) + if !ok { + tt.Errorf("NewDialer return value Dialer is not *dialer: %v", der) } - gotConn, gotErr := d.cachedDialer(test.args.dctx, test.args.network, test.args.addr) - if err := checkFunc(d, test.want, gotConn, gotErr); err != nil { + gotConn, gotErr := d.cachedDialer(ctx, test.args.network, test.args.addr) + if err := checkFunc(d, ctx, test.want, gotConn, gotErr); err != nil { tt.Errorf("error = %v", err) } + + // call without defer to ensure the server is closed before checking with goleak + if test.afterFunc != nil { + test.afterFunc(tt) + } }) } } func Test_dialer_dial(t *testing.T) { + t.Parallel() type args struct { - ctx context.Context network string addr string } @@ -1447,7 +1327,6 @@ func Test_dialer_dial(t *testing.T) { { name: "return conn", args: args{ - ctx: context.Background(), network: TCP.String(), addr: "google.com:80", }, @@ -1463,7 +1342,6 @@ func Test_dialer_dial(t *testing.T) { { name: "return tls conn", args: args{ - ctx: context.Background(), network: TCP.String(), addr: "google.com:443", }, @@ -1479,7 +1357,6 @@ func Test_dialer_dial(t *testing.T) { { name: "return error if invalid address", args: args{ - ctx: context.Background(), network: TCP.String(), addr: "invalid_address", }, @@ -1508,7 +1385,6 @@ func Test_dialer_dial(t *testing.T) { { name: "return error if empty address", args: args{ - ctx: context.Background(), network: TCP.String(), }, fields: fields{ @@ -1530,13 +1406,12 @@ func Test_dialer_dial(t *testing.T) { return nil }, want: want{ - err: stderrors.New("missing address"), + err: errors.New("missing address"), }, }, { name: "return error if invalid network", args: args{ - ctx: context.Background(), network: "invalid", }, fields: fields{ @@ -1563,9 +1438,7 @@ func Test_dialer_dial(t *testing.T) { }, { name: "return error if empty network", - args: args{ - ctx: context.Background(), - }, + args: args{}, fields: fields{ tlsConfig: nil, der: &net.Dialer{ @@ -1590,9 +1463,14 @@ func Test_dialer_dial(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1608,7 +1486,7 @@ func Test_dialer_dial(t *testing.T) { der: test.fields.der, } - got, err := d.dial(test.args.ctx, test.args.network, test.args.addr) + got, err := d.dial(ctx, test.args.network, test.args.addr) if err := checkFunc(test.want, got, err); err != nil { tt.Errorf("error = %v", err) } @@ -1617,29 +1495,15 @@ func Test_dialer_dial(t *testing.T) { } func Test_dialer_cacheExpireHook(t *testing.T) { + t.Parallel() type args struct { - ctx context.Context addr string } - type fields struct { - cache cache.Cache - dnsCache bool - tlsConfig *tls.Config - dnsRefreshDurationStr string - dnsCacheExpirationStr string - dnsRefreshDuration time.Duration - dnsCacheExpiration time.Duration - dialerTimeout time.Duration - dialerKeepalive time.Duration - dialerDualStack bool - der *net.Dialer - dialer func(ctx context.Context, network, addr string) (Conn, error) - } type want struct{} type test struct { name string args args - fields fields + opts []DialerOption want want checkFunc func(*dialer) error beforeFunc func(*dialer) @@ -1654,30 +1518,19 @@ func Test_dialer_cacheExpireHook(t *testing.T) { return test{ name: "cache refresh", args: args{ - ctx: context.Background(), addr: addr, }, - fields: fields{ - dnsCache: true, - dnsRefreshDuration: time.Millisecond * 100, - dnsCacheExpiration: time.Millisecond * 100, - }, - beforeFunc: func(d *dialer) { - d.cache, _ = cache.New() - - d.der = &net.Dialer{ - Timeout: time.Minute, - KeepAlive: time.Minute, - DualStack: d.dialerDualStack, - Resolver: &Resolver{ - PreferGo: false, - Dial: d.dialer, - }, - } + opts: []DialerOption{ + WithEnableDNSCache(), + WithDNSRefreshDuration("100ms"), + WithDNSCacheExpiration("100ms"), + WithDisableDialerDualStack(), + WithDialerTimeout("1m"), + WithDialerKeepalive("1m"), }, checkFunc: func(d *dialer) error { // get again and check if the cache is updated - if _, ok := d.cache.Get(addr); !ok { + if _, ok := d.dnsCache.Get(addr); !ok { return errors.New("cache not found") } return nil @@ -1686,9 +1539,14 @@ func Test_dialer_cacheExpireHook(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.afterFunc != nil { defer test.afterFunc(test.args) } @@ -1696,29 +1554,23 @@ func Test_dialer_cacheExpireHook(t *testing.T) { if test.checkFunc == nil { checkFunc = defaultCheckFunc } - d := &dialer{ - cache: test.fields.cache, - dnsCache: test.fields.dnsCache, - tlsConfig: test.fields.tlsConfig, - dnsRefreshDurationStr: test.fields.dnsRefreshDurationStr, - dnsCacheExpirationStr: test.fields.dnsCacheExpirationStr, - dnsRefreshDuration: test.fields.dnsRefreshDuration, - dnsCacheExpiration: test.fields.dnsCacheExpiration, - dialerTimeout: test.fields.dialerTimeout, - dialerKeepalive: test.fields.dialerKeepalive, - dialerDualStack: test.fields.dialerDualStack, - der: test.fields.der, - dialer: test.fields.dialer, + der, err := NewDialer(test.opts...) + if err != nil { + tt.Errorf("failed to initialize dialer: %v", err) + } + d, ok := der.(*dialer) + if !ok { + tt.Errorf("NewDialer return value Dialer is not *dialer: %v", der) } - if test.beforeFunc != nil { test.beforeFunc(d) } - d.cacheExpireHook(test.args.ctx, test.args.addr) + d.cacheExpireHook(ctx, test.args.addr) if err := checkFunc(d); err != nil { tt.Errorf("error = %v", err) } + cancel() }) } } @@ -1726,26 +1578,9 @@ func Test_dialer_cacheExpireHook(t *testing.T) { func Test_dialer_tlsHandshake(t *testing.T) { t.Parallel() type args struct { - ctx context.Context - conn Conn - addr string - } - type fields struct { - cache cache.Cache - dnsCache bool - dnsCachedOnce sync.Once - tlsConfig *tls.Config - dnsRefreshDurationStr string - dnsCacheExpirationStr string - dnsRefreshDuration time.Duration - dnsCacheExpiration time.Duration - dialerTimeout time.Duration - dialerKeepalive time.Duration - dialerFallbackDelay time.Duration - dialerDualStack bool - addrs sync.Map - der *net.Dialer - dialer func(ctx context.Context, network, addr string) (Conn, error) + conn net.Conn + network string + addr string } type want struct { want *tls.Conn @@ -1754,11 +1589,11 @@ func Test_dialer_tlsHandshake(t *testing.T) { type test struct { name string args args - fields fields + opts []DialerOption want want checkFunc func(want, *tls.Conn, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, got *tls.Conn, err error) error { if !errors.Is(err, w.err) { @@ -1773,43 +1608,46 @@ func Test_dialer_tlsHandshake(t *testing.T) { func() test { ctx, cancel := context.WithCancel(context.Background()) - h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) - }) - srv := httptest.NewTLSServer(h) + })) srv.TLS.InsecureSkipVerify = true + addr := srv.URL[len("https://"):] + d, err := NewDialer() if err != nil { t.Error(err) } - - host, port, _ := SplitHostPort(strings.TrimPrefix(strings.TrimPrefix(srv.URL, "https://"), "http://")) - addr := host + ":" + strconv.FormatUint(uint64(port), 10) - - conn, err := d.DialContext(ctx, "tcp", addr) - if err != nil { - t.Error(err) + conn, err := d.DialContext(ctx, TCP.String(), addr) + if err != nil || conn == nil { + t.Errorf("failed to dial: %s, err: %v", addr, err) } return test{ name: "return tls connection with handshake success with default timeout", args: args{ - ctx: ctx, - conn: conn, - addr: srv.URL, - }, - fields: fields{ - tlsConfig: srv.TLS, - der: new(net.Dialer), + network: TCP.String(), + addr: addr, + conn: conn, + }, + opts: []DialerOption{ + WithDialerTimeout("30s"), + WithTLS(func() *tls.Config { + tlsCfg, err := tls.NewClientConfig(tls.WithInsecureSkipVerify(true)) + if err != nil { + t.Fatal(err) + } + return tlsCfg + }()), }, - checkFunc: func(w want, c *tls.Conn, e error) error { - if !c.ConnectionState().HandshakeComplete { - return errors.New("Handshake not completed") + checkFunc: func(w want, c *tls.Conn, err error) error { + if c == nil || !c.ConnectionState().HandshakeComplete { + return errors.Errorf("Handshake not completed, got: %+v\terr: %v", c, err) } return nil }, - afterFunc: func(a args) { + afterFunc: func(*testing.T) { srv.Close() conn.Close() cancel() @@ -1819,45 +1657,49 @@ func Test_dialer_tlsHandshake(t *testing.T) { func() test { ctx, cancel := context.WithCancel(context.Background()) - h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) - }) - srv := httptest.NewTLSServer(h) + })) srv.TLS.InsecureSkipVerify = true - d, err := NewDialer() + addr := srv.URL[len("https://"):] + + // create a new dialer to create the connection instead of using the original dialer + c, err := tls.NewClientConfig(tls.WithInsecureSkipVerify(true)) if err != nil { t.Error(err) } - - host, port, _ := SplitHostPort(strings.TrimPrefix(strings.TrimPrefix(srv.URL, "https://"), "http://")) - addr := host + ":" + strconv.FormatUint(uint64(port), 10) - - conn, err := d.DialContext(ctx, "tcp", addr) + di, err := NewDialer(WithTLS(c)) if err != nil { - t.Error(err) + t.Errorf("failed to initialize dialer: %v", err) + } + + conn, err := di.DialContext(ctx, TCP.String(), addr) + if err != nil || conn == nil { + t.Errorf("failed to dial: %s, err: %v", addr, err) } return test{ name: "return error when handshake timeout", args: args{ - ctx: ctx, - conn: conn, - addr: srv.URL, + network: TCP.String(), + addr: addr, + conn: conn, + }, + opts: []DialerOption{ + WithDialerTimeout("1us"), + WithTLS(func() *tls.Config { + c, err := tls.NewClientConfig(tls.WithInsecureSkipVerify(true)) + if err != nil { + return nil + } + return c + }()), }, - fields: fields{ - tlsConfig: srv.TLS, - der: &net.Dialer{ - Timeout: 1, - }, - }, - checkFunc: func(w want, c *tls.Conn, e error) error { - if e == nil { - return errors.New("timeout error should be returned") - } - return nil + want: want{ + err: context.DeadlineExceeded, }, - afterFunc: func(a args) { + afterFunc: func(*testing.T) { srv.Close() conn.Close() cancel() @@ -1886,29 +1728,33 @@ func Test_dialer_tlsHandshake(t *testing.T) { t.Error(err) } - // close the server before the test - srv.Close() - return test{ name: "return error when host not found", args: args{ - ctx: ctx, - conn: conn, - addr: srv.URL, + network: TCP.String(), + addr: addr, + conn: conn, }, - fields: fields{ - tlsConfig: &tls.Config{ - MinVersion: ctls.VersionTLS13, - }, - der: new(net.Dialer), - }, - checkFunc: func(w want, c *tls.Conn, e error) error { - if e == nil { - return errors.New("Handshake not completed") + opts: []DialerOption{ + WithTLS(func() *tls.Config { + c, err := tls.NewClientConfig(tls.WithInsecureSkipVerify(true)) + if err != nil { + return nil + } + return c + }()), + }, + beforeFunc: func(*testing.T) { + // close the server before the test + srv.Close() + }, + checkFunc: func(w want, c *tls.Conn, err error) error { + if err == nil { + return errors.New("Handshake completed even server has been gone") } return nil }, - afterFunc: func(a args) { + afterFunc: func(t1 *testing.T) { conn.Close() cancel() }, @@ -1920,7 +1766,161 @@ func Test_dialer_tlsHandshake(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + if test.afterFunc != nil { + defer test.afterFunc(tt) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + der, err := NewDialer(test.opts...) + if err != nil { + tt.Errorf("failed to initialize dialer: %v", err) + } + d, ok := der.(*dialer) + if !ok || d == nil { + tt.Errorf("NewDialer return value Dialer is not *dialer: %v", der) + } + + if test.beforeFunc != nil { + test.beforeFunc(tt) + } + + got, err := d.tlsHandshake(ctx, test.args.conn, test.args.network, test.args.addr) + if err := checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func Test_dialer_lookupIPAddrs(t *testing.T) { + t.Parallel() + type args struct { + ctx context.Context + host string + } + type fields struct { + dnsCache cache.Cache + enableDNSCache bool + dnsCachedOnce sync.Once + tlsConfig *tls.Config + tmu sync.RWMutex + dnsRefreshDurationStr string + dnsCacheExpirationStr string + dnsRefreshDuration time.Duration + dnsCacheExpiration time.Duration + dialerTimeout time.Duration + dialerKeepalive time.Duration + dialerFallbackDelay time.Duration + ctrl control.SocketController + sockFlg control.SocketFlag + dialerDualStack bool + addrs sync.Map + der *net.Dialer + dialer func(ctx context.Context, network, addr string) (Conn, error) + } + type want struct { + wantIps []string + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, []string, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, gotIps []string, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(gotIps, w.wantIps) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotIps, w.wantIps) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + host: "", + }, + fields: fields { + dnsCache: nil, + enableDNSCache: false, + dnsCachedOnce: sync.Once{}, + tlsConfig: nil, + tmu: sync.RWMutex{}, + dnsRefreshDurationStr: "", + dnsCacheExpirationStr: "", + dnsRefreshDuration: nil, + dnsCacheExpiration: nil, + dialerTimeout: nil, + dialerKeepalive: nil, + dialerFallbackDelay: nil, + ctrl: nil, + sockFlg: nil, + dialerDualStack: false, + addrs: sync.Map{}, + der: net.Dialer{}, + dialer: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + host: "", + }, + fields: fields { + dnsCache: nil, + enableDNSCache: false, + dnsCachedOnce: sync.Once{}, + tlsConfig: nil, + tmu: sync.RWMutex{}, + dnsRefreshDurationStr: "", + dnsCacheExpirationStr: "", + dnsRefreshDuration: nil, + dnsCacheExpiration: nil, + dialerTimeout: nil, + dialerKeepalive: nil, + dialerFallbackDelay: nil, + ctrl: nil, + sockFlg: nil, + dialerDualStack: false, + addrs: sync.Map{}, + der: net.Dialer{}, + dialer: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1932,10 +1932,11 @@ func Test_dialer_tlsHandshake(t *testing.T) { checkFunc = defaultCheckFunc } d := &dialer{ - cache: test.fields.cache, dnsCache: test.fields.dnsCache, + enableDNSCache: test.fields.enableDNSCache, dnsCachedOnce: test.fields.dnsCachedOnce, tlsConfig: test.fields.tlsConfig, + tmu: test.fields.tmu, dnsRefreshDurationStr: test.fields.dnsRefreshDurationStr, dnsCacheExpirationStr: test.fields.dnsCacheExpirationStr, dnsRefreshDuration: test.fields.dnsRefreshDuration, @@ -1943,14 +1944,16 @@ func Test_dialer_tlsHandshake(t *testing.T) { dialerTimeout: test.fields.dialerTimeout, dialerKeepalive: test.fields.dialerKeepalive, dialerFallbackDelay: test.fields.dialerFallbackDelay, + ctrl: test.fields.ctrl, + sockFlg: test.fields.sockFlg, dialerDualStack: test.fields.dialerDualStack, addrs: test.fields.addrs, der: test.fields.der, dialer: test.fields.dialer, } - got, err := d.tlsHandshake(test.args.ctx, test.args.conn, test.args.addr) - if err := checkFunc(test.want, got, err); err != nil { + gotIps, err := d.lookupIPAddrs(test.args.ctx, test.args.host) + if err := checkFunc(test.want, gotIps, err); err != nil { tt.Errorf("error = %v", err) } }) diff --git a/internal/net/grpc/addrs_test.go b/internal/net/grpc/addrs_test.go index 57d90faaf3..7839198780 100644 --- a/internal/net/grpc/addrs_test.go +++ b/internal/net/grpc/addrs_test.go @@ -24,7 +24,6 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" ) func Test_newAddr(t *testing.T) { @@ -81,7 +80,6 @@ func Test_newAddr(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -168,7 +166,6 @@ func Test_atomicAddrs_GetAll(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -262,7 +259,6 @@ func Test_atomicAddrs_Range(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -356,7 +352,6 @@ func Test_atomicAddrs_Add(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -450,7 +445,6 @@ func Test_atomicAddrs_Delete(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -543,7 +537,6 @@ func Test_atomicAddrs_Next(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -632,7 +625,6 @@ func Test_atomicAddrs_Len(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/net/grpc/client_test.go b/internal/net/grpc/client_test.go index c31fbefe7a..691ec9b04b 100644 --- a/internal/net/grpc/client_test.go +++ b/internal/net/grpc/client_test.go @@ -37,7 +37,6 @@ import ( ) func TestNew(t *testing.T) { - t.Parallel() type args struct { opts []Option } @@ -111,7 +110,6 @@ func TestNew(t *testing.T) { } func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { - t.Parallel() type args struct { ctx context.Context } @@ -123,6 +121,7 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -130,10 +129,14 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { want <-chan error @@ -173,6 +176,7 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -180,10 +184,14 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -206,6 +214,7 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -213,10 +222,14 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -248,6 +261,7 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -255,10 +269,14 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } got, err := g.StartConnectionMonitor(test.args.ctx) @@ -270,7 +288,6 @@ func Test_gRPCClient_StartConnectionMonitor(t *testing.T) { } func Test_gRPCClient_Range(t *testing.T) { - t.Parallel() type args struct { ctx context.Context f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error @@ -283,6 +300,7 @@ func Test_gRPCClient_Range(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -290,10 +308,14 @@ func Test_gRPCClient_Range(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { err error @@ -330,6 +352,7 @@ func Test_gRPCClient_Range(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -337,10 +360,14 @@ func Test_gRPCClient_Range(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -364,6 +391,7 @@ func Test_gRPCClient_Range(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -371,10 +399,14 @@ func Test_gRPCClient_Range(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -406,6 +438,7 @@ func Test_gRPCClient_Range(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -413,10 +446,14 @@ func Test_gRPCClient_Range(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } err := g.Range(test.args.ctx, test.args.f) @@ -428,7 +465,6 @@ func Test_gRPCClient_Range(t *testing.T) { } func Test_gRPCClient_RangeConcurrent(t *testing.T) { - t.Parallel() type args struct { ctx context.Context concurrency int @@ -442,6 +478,7 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -449,10 +486,14 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { err error @@ -490,6 +531,7 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -497,10 +539,14 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -525,6 +571,7 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -532,10 +579,14 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -567,6 +618,7 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -574,10 +626,14 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } err := g.RangeConcurrent(test.args.ctx, test.args.concurrency, test.args.f) @@ -589,7 +645,6 @@ func Test_gRPCClient_RangeConcurrent(t *testing.T) { } func Test_gRPCClient_OrderedRange(t *testing.T) { - t.Parallel() type args struct { ctx context.Context orders []string @@ -603,6 +658,7 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -610,10 +666,14 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { err error @@ -651,6 +711,7 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -658,10 +719,14 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -686,6 +751,7 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -693,10 +759,14 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -728,6 +798,7 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -735,10 +806,14 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } err := g.OrderedRange(test.args.ctx, test.args.orders, test.args.f) @@ -750,7 +825,6 @@ func Test_gRPCClient_OrderedRange(t *testing.T) { } func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { - t.Parallel() type args struct { ctx context.Context orders []string @@ -765,6 +839,7 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -772,10 +847,14 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { err error @@ -814,6 +893,7 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -821,10 +901,14 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -850,6 +934,7 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -857,10 +942,14 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -892,6 +981,7 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -899,10 +989,14 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } err := g.OrderedRangeConcurrent(test.args.ctx, test.args.orders, test.args.concurrency, test.args.f) @@ -914,7 +1008,6 @@ func Test_gRPCClient_OrderedRangeConcurrent(t *testing.T) { } func Test_gRPCClient_RoundRobin(t *testing.T) { - t.Parallel() type args struct { ctx context.Context f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (interface{}, error) @@ -927,6 +1020,7 @@ func Test_gRPCClient_RoundRobin(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -934,10 +1028,14 @@ func Test_gRPCClient_RoundRobin(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { wantData interface{} @@ -978,6 +1076,7 @@ func Test_gRPCClient_RoundRobin(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -985,10 +1084,14 @@ func Test_gRPCClient_RoundRobin(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1012,6 +1115,7 @@ func Test_gRPCClient_RoundRobin(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1019,10 +1123,14 @@ func Test_gRPCClient_RoundRobin(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1054,6 +1162,7 @@ func Test_gRPCClient_RoundRobin(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -1061,10 +1170,14 @@ func Test_gRPCClient_RoundRobin(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } gotData, err := g.RoundRobin(test.args.ctx, test.args.f) @@ -1076,7 +1189,6 @@ func Test_gRPCClient_RoundRobin(t *testing.T) { } func Test_gRPCClient_Do(t *testing.T) { - t.Parallel() type args struct { ctx context.Context addr string @@ -1090,6 +1202,7 @@ func Test_gRPCClient_Do(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -1097,10 +1210,14 @@ func Test_gRPCClient_Do(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { wantData interface{} @@ -1142,6 +1259,7 @@ func Test_gRPCClient_Do(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1149,10 +1267,14 @@ func Test_gRPCClient_Do(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1177,6 +1299,7 @@ func Test_gRPCClient_Do(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1184,10 +1307,14 @@ func Test_gRPCClient_Do(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1219,6 +1346,7 @@ func Test_gRPCClient_Do(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -1226,10 +1354,14 @@ func Test_gRPCClient_Do(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } gotData, err := g.Do(test.args.ctx, test.args.addr, test.args.f) @@ -1241,7 +1373,6 @@ func Test_gRPCClient_Do(t *testing.T) { } func Test_gRPCClient_do(t *testing.T) { - t.Parallel() type args struct { ctx context.Context p pool.Conn @@ -1257,6 +1388,7 @@ func Test_gRPCClient_do(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -1264,10 +1396,14 @@ func Test_gRPCClient_do(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { wantData interface{} @@ -1311,6 +1447,7 @@ func Test_gRPCClient_do(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1318,10 +1455,14 @@ func Test_gRPCClient_do(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1348,6 +1489,7 @@ func Test_gRPCClient_do(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1355,10 +1497,14 @@ func Test_gRPCClient_do(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1390,6 +1536,7 @@ func Test_gRPCClient_do(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -1397,10 +1544,14 @@ func Test_gRPCClient_do(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } gotData, err := g.do(test.args.ctx, test.args.p, test.args.addr, test.args.enableBackoff, test.args.f) @@ -1412,7 +1563,6 @@ func Test_gRPCClient_do(t *testing.T) { } func Test_gRPCClient_GetDialOption(t *testing.T) { - t.Parallel() type fields struct { addrs map[string]struct{} atomicAddrs AtomicAddrs @@ -1421,6 +1571,7 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -1428,10 +1579,14 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { want []DialOption @@ -1463,6 +1618,7 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1470,10 +1626,14 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1493,6 +1653,7 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1500,10 +1661,14 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1535,6 +1700,7 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -1542,10 +1708,14 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } got := g.GetDialOption() @@ -1557,7 +1727,6 @@ func Test_gRPCClient_GetDialOption(t *testing.T) { } func Test_gRPCClient_GetCallOption(t *testing.T) { - t.Parallel() type fields struct { addrs map[string]struct{} atomicAddrs AtomicAddrs @@ -1566,6 +1735,7 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -1573,10 +1743,14 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { want []CallOption @@ -1608,6 +1782,7 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1615,10 +1790,14 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1638,6 +1817,7 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1645,10 +1825,14 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1680,6 +1864,7 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -1687,10 +1872,14 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } got := g.GetCallOption() @@ -1701,13 +1890,7 @@ func Test_gRPCClient_GetCallOption(t *testing.T) { } } -func Test_gRPCClient_Connect(t *testing.T) { - t.Parallel() - type args struct { - ctx context.Context - addr string - dopts []DialOption - } +func Test_gRPCClient_GetBackoff(t *testing.T) { type fields struct { addrs map[string]struct{} atomicAddrs AtomicAddrs @@ -1716,6 +1899,7 @@ func Test_gRPCClient_Connect(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -1723,30 +1907,29 @@ func Test_gRPCClient_Connect(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { - wantConn pool.Conn - err error + want backoff.Backoff } type test struct { name string - args args fields fields want want - checkFunc func(want, pool.Conn, error) error - beforeFunc func(args) - afterFunc func(args) + checkFunc func(want, backoff.Backoff) error + beforeFunc func() + afterFunc func() } - defaultCheckFunc := func(w want, gotConn pool.Conn, err error) error { - if !errors.Is(err, w.err) { - return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) - } - if !reflect.DeepEqual(gotConn, w.wantConn) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotConn, w.wantConn) + defaultCheckFunc := func(w want, got backoff.Backoff) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) } return nil } @@ -1755,11 +1938,6 @@ func Test_gRPCClient_Connect(t *testing.T) { /* { name: "test_case_1", - args: args { - ctx: nil, - addr: "", - dopts: nil, - }, fields: fields { addrs: nil, atomicAddrs: nil, @@ -1768,6 +1946,7 @@ func Test_gRPCClient_Connect(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1775,10 +1954,14 @@ func Test_gRPCClient_Connect(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1790,11 +1973,6 @@ func Test_gRPCClient_Connect(t *testing.T) { func() test { return test { name: "test_case_2", - args: args { - ctx: nil, - addr: "", - dopts: nil, - }, fields: fields { addrs: nil, atomicAddrs: nil, @@ -1803,6 +1981,7 @@ func Test_gRPCClient_Connect(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1810,10 +1989,14 @@ func Test_gRPCClient_Connect(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1828,10 +2011,10 @@ func Test_gRPCClient_Connect(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc() } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc() } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -1845,6 +2028,7 @@ func Test_gRPCClient_Connect(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -1852,25 +2036,29 @@ func Test_gRPCClient_Connect(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } - gotConn, err := g.Connect(test.args.ctx, test.args.addr, test.args.dopts...) - if err := checkFunc(test.want, gotConn, err); err != nil { + got := g.GetBackoff() + if err := checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } }) } } -func Test_gRPCClient_IsConnected(t *testing.T) { - t.Parallel() +func Test_gRPCClient_Connect(t *testing.T) { type args struct { - ctx context.Context - addr string + ctx context.Context + addr string + dopts []DialOption } type fields struct { addrs map[string]struct{} @@ -1880,6 +2068,7 @@ func Test_gRPCClient_IsConnected(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -1887,26 +2076,34 @@ func Test_gRPCClient_IsConnected(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { - want bool + wantConn pool.Conn + err error } type test struct { name string args args fields fields want want - checkFunc func(want, bool) error + checkFunc func(want, pool.Conn, error) error beforeFunc func(args) afterFunc func(args) } - defaultCheckFunc := func(w want, got bool) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + defaultCheckFunc := func(w want, gotConn pool.Conn, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(gotConn, w.wantConn) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotConn, w.wantConn) } return nil } @@ -1918,6 +2115,7 @@ func Test_gRPCClient_IsConnected(t *testing.T) { args: args { ctx: nil, addr: "", + dopts: nil, }, fields: fields { addrs: nil, @@ -1927,6 +2125,7 @@ func Test_gRPCClient_IsConnected(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1934,10 +2133,14 @@ func Test_gRPCClient_IsConnected(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -1952,6 +2155,7 @@ func Test_gRPCClient_IsConnected(t *testing.T) { args: args { ctx: nil, addr: "", + dopts: nil, }, fields: fields { addrs: nil, @@ -1961,6 +2165,7 @@ func Test_gRPCClient_IsConnected(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -1968,10 +2173,14 @@ func Test_gRPCClient_IsConnected(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -2003,6 +2212,7 @@ func Test_gRPCClient_IsConnected(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -2010,22 +2220,25 @@ func Test_gRPCClient_IsConnected(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } - got := g.IsConnected(test.args.ctx, test.args.addr) - if err := checkFunc(test.want, got); err != nil { + gotConn, err := g.Connect(test.args.ctx, test.args.addr, test.args.dopts...) + if err := checkFunc(test.want, gotConn, err); err != nil { tt.Errorf("error = %v", err) } }) } } -func Test_gRPCClient_Disconnect(t *testing.T) { - t.Parallel() +func Test_gRPCClient_IsConnected(t *testing.T) { type args struct { ctx context.Context addr string @@ -2038,6 +2251,7 @@ func Test_gRPCClient_Disconnect(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -2045,26 +2259,30 @@ func Test_gRPCClient_Disconnect(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { - err error + want bool } type test struct { name string args args fields fields want want - checkFunc func(want, error) error + checkFunc func(want, bool) 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + defaultCheckFunc := func(w want, got bool) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) } return nil } @@ -2085,6 +2303,7 @@ func Test_gRPCClient_Disconnect(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -2092,10 +2311,14 @@ func Test_gRPCClient_Disconnect(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -2119,6 +2342,7 @@ func Test_gRPCClient_Disconnect(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -2126,10 +2350,14 @@ func Test_gRPCClient_Disconnect(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -2161,6 +2389,7 @@ func Test_gRPCClient_Disconnect(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -2168,22 +2397,29 @@ func Test_gRPCClient_Disconnect(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } - err := g.Disconnect(test.args.ctx, test.args.addr) - if err := checkFunc(test.want, err); err != nil { + got := g.IsConnected(test.args.ctx, test.args.addr) + if err := checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } }) } } -func Test_gRPCClient_ConnectedAddrs(t *testing.T) { - t.Parallel() +func Test_gRPCClient_Disconnect(t *testing.T) { + type args struct { + ctx context.Context + addr string + } type fields struct { addrs map[string]struct{} atomicAddrs AtomicAddrs @@ -2192,6 +2428,7 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -2199,25 +2436,30 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { - want []string + err error } type test struct { name string + args args fields fields want want - checkFunc func(want, []string) error - beforeFunc func() - afterFunc func() + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) } - defaultCheckFunc := func(w want, got []string) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) } return nil } @@ -2226,6 +2468,10 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { /* { name: "test_case_1", + args: args { + ctx: nil, + addr: "", + }, fields: fields { addrs: nil, atomicAddrs: nil, @@ -2234,6 +2480,7 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -2241,10 +2488,14 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -2256,6 +2507,10 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { func() test { return test { name: "test_case_2", + args: args { + ctx: nil, + addr: "", + }, fields: fields { addrs: nil, atomicAddrs: nil, @@ -2264,6 +2519,7 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -2271,10 +2527,14 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -2289,10 +2549,10 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(test.args) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -2306,6 +2566,7 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -2313,25 +2574,25 @@ func Test_gRPCClient_ConnectedAddrs(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } - got := g.ConnectedAddrs() - if err := checkFunc(test.want, got); err != nil { + err := g.Disconnect(test.args.ctx, test.args.addr) + if err := checkFunc(test.want, err); err != nil { tt.Errorf("error = %v", err) } }) } } -func Test_gRPCClient_Close(t *testing.T) { - t.Parallel() - type args struct { - ctx context.Context - } +func Test_gRPCClient_ConnectedAddrs(t *testing.T) { type fields struct { addrs map[string]struct{} atomicAddrs AtomicAddrs @@ -2340,6 +2601,7 @@ func Test_gRPCClient_Close(t *testing.T) { conns grpcConns hcDur time.Duration prDur time.Duration + dialer net.Dialer enablePoolRebalance bool resolveDNS bool dopts []DialOption @@ -2347,26 +2609,29 @@ func Test_gRPCClient_Close(t *testing.T) { roccd string eg errgroup.Group bo backoff.Backoff + cb circuitbreaker.CircuitBreaker gbo gbackoff.Config mcd time.Duration group singleflight.Group crl sync.Map + ech <-chan error + monitorRunning atomic.Value + stopMonitor context.CancelFunc } type want struct { - err error + want []string } type test struct { name string - args args fields fields want want - checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + checkFunc func(want, []string) error + beforeFunc func() + afterFunc func() } - defaultCheckFunc := func(w want, err error) error { - if !errors.Is(err, w.err) { - return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + defaultCheckFunc := func(w want, got []string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) } return nil } @@ -2375,9 +2640,6 @@ func Test_gRPCClient_Close(t *testing.T) { /* { name: "test_case_1", - args: args { - ctx: nil, - }, fields: fields { addrs: nil, atomicAddrs: nil, @@ -2386,6 +2648,7 @@ func Test_gRPCClient_Close(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -2393,10 +2656,14 @@ func Test_gRPCClient_Close(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -2408,9 +2675,6 @@ func Test_gRPCClient_Close(t *testing.T) { func() test { return test { name: "test_case_2", - args: args { - ctx: nil, - }, fields: fields { addrs: nil, atomicAddrs: nil, @@ -2419,6 +2683,7 @@ func Test_gRPCClient_Close(t *testing.T) { conns: grpcConns{}, hcDur: nil, prDur: nil, + dialer: nil, enablePoolRebalance: false, resolveDNS: false, dopts: nil, @@ -2426,10 +2691,14 @@ func Test_gRPCClient_Close(t *testing.T) { roccd: "", eg: nil, bo: nil, + cb: nil, gbo: nil, mcd: nil, group: nil, crl: sync.Map{}, + ech: nil, + monitorRunning: nil, + stopMonitor: nil, }, want: want{}, checkFunc: defaultCheckFunc, @@ -2444,10 +2713,10 @@ func Test_gRPCClient_Close(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc() } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc() } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -2461,6 +2730,7 @@ func Test_gRPCClient_Close(t *testing.T) { conns: test.fields.conns, hcDur: test.fields.hcDur, prDur: test.fields.prDur, + dialer: test.fields.dialer, enablePoolRebalance: test.fields.enablePoolRebalance, resolveDNS: test.fields.resolveDNS, dopts: test.fields.dopts, @@ -2468,21 +2738,28 @@ func Test_gRPCClient_Close(t *testing.T) { roccd: test.fields.roccd, eg: test.fields.eg, bo: test.fields.bo, + cb: test.fields.cb, gbo: test.fields.gbo, mcd: test.fields.mcd, group: test.fields.group, crl: test.fields.crl, + ech: test.fields.ech, + monitorRunning: test.fields.monitorRunning, + stopMonitor: test.fields.stopMonitor, } - err := g.Close(test.args.ctx) - if err := checkFunc(test.want, err); err != nil { + got := g.ConnectedAddrs() + if err := checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } }) } } -func Test_gRPCClient_GetBackoff(t *testing.T) { +func Test_gRPCClient_Close(t *testing.T) { + type args struct { + ctx context.Context + } type fields struct { addrs map[string]struct{} atomicAddrs AtomicAddrs @@ -2509,19 +2786,20 @@ func Test_gRPCClient_GetBackoff(t *testing.T) { stopMonitor context.CancelFunc } type want struct { - want backoff.Backoff + err error } type test struct { name string + args args fields fields want want - checkFunc func(want, backoff.Backoff) error - beforeFunc func() - afterFunc func() + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) } - defaultCheckFunc := func(w want, got backoff.Backoff) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) } return nil } @@ -2530,6 +2808,9 @@ func Test_gRPCClient_GetBackoff(t *testing.T) { /* { name: "test_case_1", + args: args { + ctx: nil, + }, fields: fields { addrs: nil, atomicAddrs: nil, @@ -2550,7 +2831,7 @@ func Test_gRPCClient_GetBackoff(t *testing.T) { gbo: nil, mcd: nil, group: nil, - crl: nil, + crl: sync.Map{}, ech: nil, monitorRunning: nil, stopMonitor: nil, @@ -2565,6 +2846,9 @@ func Test_gRPCClient_GetBackoff(t *testing.T) { func() test { return test { name: "test_case_2", + args: args { + ctx: nil, + }, fields: fields { addrs: nil, atomicAddrs: nil, @@ -2585,7 +2869,7 @@ func Test_gRPCClient_GetBackoff(t *testing.T) { gbo: nil, mcd: nil, group: nil, - crl: nil, + crl: sync.Map{}, ech: nil, monitorRunning: nil, stopMonitor: nil, @@ -2603,10 +2887,10 @@ func Test_gRPCClient_GetBackoff(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(test.args) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -2638,8 +2922,8 @@ func Test_gRPCClient_GetBackoff(t *testing.T) { stopMonitor: test.fields.stopMonitor, } - got := g.GetBackoff() - if err := checkFunc(test.want, got); err != nil { + err := g.Close(test.args.ctx) + if err := checkFunc(test.want, err); err != nil { tt.Errorf("error = %v", err) } }) diff --git a/internal/net/grpc/codec_test.go b/internal/net/grpc/codec_test.go index 5286c01bbe..ed194bc7d3 100644 --- a/internal/net/grpc/codec_test.go +++ b/internal/net/grpc/codec_test.go @@ -23,10 +23,10 @@ import ( "github.com/vdaas/vald/apis/grpc/v1/payload" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" ) func TestCodec_Marshal(t *testing.T) { + t.Parallel() type args struct { v interface{} } @@ -97,7 +97,6 @@ func TestCodec_Marshal(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -119,6 +118,7 @@ func TestCodec_Marshal(t *testing.T) { } func TestCodec_Unmarshal(t *testing.T) { + t.Parallel() type args struct { data []byte v interface{} @@ -190,7 +190,6 @@ func TestCodec_Unmarshal(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -212,6 +211,7 @@ func TestCodec_Unmarshal(t *testing.T) { } func TestCodec_Name(t *testing.T) { + t.Parallel() type want struct { want string } @@ -242,7 +242,6 @@ func TestCodec_Name(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/net/grpc/context_test.go b/internal/net/grpc/context_test.go index ad95946274..705a7a6772 100644 --- a/internal/net/grpc/context_test.go +++ b/internal/net/grpc/context_test.go @@ -19,10 +19,10 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" ) func TestWithGRPCMethod(t *testing.T) { + t.Parallel() type args struct { ctx context.Context method string @@ -78,7 +78,6 @@ func TestWithGRPCMethod(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -99,6 +98,7 @@ func TestWithGRPCMethod(t *testing.T) { } func TestFromGRPCMethod(t *testing.T) { + t.Parallel() type args struct { ctx context.Context } @@ -151,7 +151,6 @@ func TestFromGRPCMethod(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/credentials/credentials_test.go b/internal/net/grpc/credentials/credentials_test.go index 6114243058..f680bb29f5 100644 --- a/internal/net/grpc/credentials/credentials_test.go +++ b/internal/net/grpc/credentials/credentials_test.go @@ -27,6 +27,10 @@ import ( "google.golang.org/grpc/credentials" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestNewTLS(t *testing.T) { t.Parallel() type args struct { @@ -78,7 +82,6 @@ func TestNewTLS(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/errdetails/errdetails_test.go b/internal/net/grpc/errdetails/errdetails_test.go index 940cf99f1f..0339e554fe 100644 --- a/internal/net/grpc/errdetails/errdetails_test.go +++ b/internal/net/grpc/errdetails/errdetails_test.go @@ -27,6 +27,7 @@ import ( ) func Test_decodeDetails(t *testing.T) { + t.Parallel() type args struct { objs []interface{} } @@ -47,6 +48,7 @@ func Test_decodeDetails(t *testing.T) { } func TestSerialize(t *testing.T) { + t.Parallel() type args struct { objs []interface{} } @@ -67,6 +69,7 @@ func TestSerialize(t *testing.T) { } func TestAnyToErrorDetail(t *testing.T) { + t.Parallel() type args struct { a *types.Any } @@ -87,6 +90,7 @@ func TestAnyToErrorDetail(t *testing.T) { } func TestDebugInfoFromInfoDetail(t *testing.T) { + t.Parallel() type args struct { v *info.Detail } diff --git a/internal/net/grpc/grpcconns_test.go b/internal/net/grpc/grpcconns_test.go index 628a773d85..41afd90b7d 100644 --- a/internal/net/grpc/grpcconns_test.go +++ b/internal/net/grpc/grpcconns_test.go @@ -26,7 +26,6 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/grpc/pool" - "github.com/vdaas/vald/internal/test/goleak" ) func Test_newEntryGrpcConns(t *testing.T) { @@ -83,7 +82,6 @@ func Test_newEntryGrpcConns(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -180,7 +178,6 @@ func Test_grpcConns_Load(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -264,7 +261,6 @@ func Test_entryGrpcConns_load(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -358,7 +354,6 @@ func Test_grpcConns_Store(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -448,7 +443,6 @@ func Test_entryGrpcConns_tryStore(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -525,7 +519,6 @@ func Test_entryGrpcConns_unexpungeLocked(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -607,7 +600,6 @@ func Test_entryGrpcConns_storeLocked(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -698,7 +690,6 @@ func Test_grpcConns_Delete(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -778,7 +769,6 @@ func Test_entryGrpcConns_delete(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -869,7 +859,6 @@ func Test_grpcConns_Range(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -953,7 +942,6 @@ func Test_grpcConns_missLocked(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -1037,7 +1025,6 @@ func Test_grpcConns_dirtyLocked(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -1117,7 +1104,6 @@ func Test_entryGrpcConns_tryExpungeLocked(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/net/grpc/health/health_test.go b/internal/net/grpc/health/health_test.go index 17110ad30d..28a5eed38c 100644 --- a/internal/net/grpc/health/health_test.go +++ b/internal/net/grpc/health/health_test.go @@ -25,7 +25,12 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestRegister(t *testing.T) { + t.Parallel() type args struct { name string srv *grpc.Server @@ -66,7 +71,6 @@ func TestRegister(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/interceptor/server/logging/accesslog_test.go b/internal/net/grpc/interceptor/server/logging/accesslog_test.go index d47aa77893..54adbdcd6b 100644 --- a/internal/net/grpc/interceptor/server/logging/accesslog_test.go +++ b/internal/net/grpc/interceptor/server/logging/accesslog_test.go @@ -26,6 +26,10 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestAccessLogInterceptor(t *testing.T) { t.Parallel() type want struct { @@ -70,7 +74,6 @@ func TestAccessLogInterceptor(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -134,7 +137,6 @@ func TestAccessLogStreamInterceptor(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -212,7 +214,6 @@ func Test_parseMethod(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/interceptor/server/recover/recover_test.go b/internal/net/grpc/interceptor/server/recover/recover_test.go index 1d191ce2cb..07311d894c 100644 --- a/internal/net/grpc/interceptor/server/recover/recover_test.go +++ b/internal/net/grpc/interceptor/server/recover/recover_test.go @@ -26,6 +26,10 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestRecoverInterceptor(t *testing.T) { t.Parallel() type want struct { @@ -70,7 +74,6 @@ func TestRecoverInterceptor(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -134,7 +137,6 @@ func TestRecoverStreamInterceptor(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } diff --git a/internal/net/grpc/interceptor/server/trace/payload_test.go b/internal/net/grpc/interceptor/server/trace/payload_test.go index 6b90e53354..63f0126173 100644 --- a/internal/net/grpc/interceptor/server/trace/payload_test.go +++ b/internal/net/grpc/interceptor/server/trace/payload_test.go @@ -26,6 +26,10 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestTracePayloadInterceptor(t *testing.T) { t.Parallel() type want struct { @@ -70,7 +74,6 @@ func TestTracePayloadInterceptor(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -134,7 +137,6 @@ func TestTracePayloadStreamInterceptor(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -224,7 +226,6 @@ func Test_tracingServerStream_RecvMsg(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -319,7 +320,6 @@ func Test_tracingServerStream_SendMsg(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -402,7 +402,6 @@ func Test_parseMethod(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -476,7 +475,6 @@ func Test_marshalJSON(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/logger/logger_test.go b/internal/net/grpc/logger/logger_test.go index 30d5c90e29..9ae72d437f 100644 --- a/internal/net/grpc/logger/logger_test.go +++ b/internal/net/grpc/logger/logger_test.go @@ -25,7 +25,12 @@ import ( "google.golang.org/grpc/grpclog" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestInit(t *testing.T) { + t.Parallel() type test struct { name string checkFunc func() error @@ -74,7 +79,6 @@ func TestInit(t *testing.T) { for _, tc := range tests { test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(tt) } @@ -94,6 +98,7 @@ func TestInit(t *testing.T) { } func Test_logger_Info(t *testing.T) { + t.Parallel() type args struct { args []interface{} } @@ -127,7 +132,6 @@ func Test_logger_Info(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -150,6 +154,7 @@ func Test_logger_Info(t *testing.T) { } func Test_logger_Infoln(t *testing.T) { + t.Parallel() type args struct { args []interface{} } @@ -183,7 +188,6 @@ func Test_logger_Infoln(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -206,6 +210,7 @@ func Test_logger_Infoln(t *testing.T) { } func Test_logger_Infof(t *testing.T) { + t.Parallel() type args struct { format string args []interface{} @@ -240,7 +245,6 @@ func Test_logger_Infof(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -263,6 +267,7 @@ func Test_logger_Infof(t *testing.T) { } func Test_logger_Warning(t *testing.T) { + t.Parallel() type args struct { args []interface{} } @@ -296,7 +301,6 @@ func Test_logger_Warning(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -319,6 +323,7 @@ func Test_logger_Warning(t *testing.T) { } func Test_logger_Warningln(t *testing.T) { + t.Parallel() type args struct { args []interface{} } @@ -352,7 +357,6 @@ func Test_logger_Warningln(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -375,6 +379,7 @@ func Test_logger_Warningln(t *testing.T) { } func Test_logger_Warningf(t *testing.T) { + t.Parallel() type args struct { format string args []interface{} @@ -409,7 +414,6 @@ func Test_logger_Warningf(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -432,6 +436,7 @@ func Test_logger_Warningf(t *testing.T) { } func Test_logger_Error(t *testing.T) { + t.Parallel() type args struct { args []interface{} } @@ -465,7 +470,6 @@ func Test_logger_Error(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -488,6 +492,7 @@ func Test_logger_Error(t *testing.T) { } func Test_logger_Errorln(t *testing.T) { + t.Parallel() type args struct { args []interface{} } @@ -521,7 +526,6 @@ func Test_logger_Errorln(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -544,6 +548,7 @@ func Test_logger_Errorln(t *testing.T) { } func Test_logger_Errorf(t *testing.T) { + t.Parallel() type args struct { format string args []interface{} @@ -578,7 +583,6 @@ func Test_logger_Errorf(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -647,7 +651,6 @@ func Test_logger_Fatal(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -713,7 +716,6 @@ func Test_logger_Fatalln(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -783,7 +785,6 @@ func Test_logger_Fatalf(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -806,6 +807,7 @@ func Test_logger_Fatalf(t *testing.T) { } func Test_logger_V(t *testing.T) { + t.Parallel() type args struct { v int } @@ -873,7 +875,6 @@ func Test_logger_V(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/metric/client_test.go b/internal/net/grpc/metric/client_test.go index a2c175bb01..51b89373e6 100644 --- a/internal/net/grpc/metric/client_test.go +++ b/internal/net/grpc/metric/client_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" "go.opencensus.io/trace" ) @@ -83,7 +82,6 @@ func TestNewClientHandler(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/metric/server_test.go b/internal/net/grpc/metric/server_test.go index 9adda8c657..4d53f9d97b 100644 --- a/internal/net/grpc/metric/server_test.go +++ b/internal/net/grpc/metric/server_test.go @@ -25,6 +25,10 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestNewServerHandler(t *testing.T) { t.Parallel() type args struct { @@ -75,7 +79,6 @@ func TestNewServerHandler(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/option_test.go b/internal/net/grpc/option_test.go index 093634e0ee..cca1011540 100644 --- a/internal/net/grpc/option_test.go +++ b/internal/net/grpc/option_test.go @@ -25,7 +25,6 @@ import ( "github.com/vdaas/vald/internal/circuitbreaker" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/net" - "github.com/vdaas/vald/internal/test/goleak" "google.golang.org/grpc" ) @@ -109,7 +108,6 @@ func TestWithAddrs(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -226,7 +224,6 @@ func TestWithHealthCheckDuration(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -343,7 +340,6 @@ func TestWithConnectionPoolRebalanceDuration(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -460,7 +456,6 @@ func TestWithResolveDNS(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -577,7 +572,6 @@ func TestWithEnableConnectionPoolRebalance(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -694,7 +688,6 @@ func TestWithConnectionPoolSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -811,7 +804,6 @@ func TestWithDialOptions(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -928,7 +920,6 @@ func TestWithBackoffMaxDelay(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1045,7 +1036,6 @@ func TestWithBackoffBaseDelay(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1162,7 +1152,6 @@ func TestWithBackoffMultiplier(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1279,7 +1268,6 @@ func TestWithBackoffJitter(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1396,7 +1384,6 @@ func TestWithMinConnectTimeout(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1513,7 +1500,6 @@ func TestWithCallOptions(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1630,7 +1616,6 @@ func TestWithErrGroup(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1747,7 +1732,6 @@ func TestWithBackoff(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1864,7 +1848,6 @@ func TestWithWaitForReady(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1981,7 +1964,6 @@ func TestWithMaxRetryRPCBufferSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2098,7 +2080,6 @@ func TestWithMaxRecvMsgSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2215,7 +2196,6 @@ func TestWithMaxSendMsgSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2332,7 +2312,6 @@ func TestWithWriteBufferSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2449,7 +2428,6 @@ func TestWithReadBufferSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2566,7 +2544,6 @@ func TestWithInitialWindowSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2683,7 +2660,6 @@ func TestWithInitialConnectionWindowSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2800,7 +2776,6 @@ func TestWithMaxMsgSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2917,7 +2892,6 @@ func TestWithInsecure(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -3034,7 +3008,6 @@ func TestWithDialTimeout(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -3157,7 +3130,6 @@ func TestWithKeepaliveParams(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -3274,7 +3246,6 @@ func TestWithDialer(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -3391,7 +3362,6 @@ func TestWithTLSConfig(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -3508,7 +3478,6 @@ func TestWithOldConnCloseDuration(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -3624,7 +3593,6 @@ func TestWithCircuitBreaker(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) 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 895ffe1c7b..16ab620906 100644 --- a/internal/net/grpc/pool/option_test.go +++ b/internal/net/grpc/pool/option_test.go @@ -22,7 +22,6 @@ import ( "github.com/vdaas/vald/internal/backoff" "github.com/vdaas/vald/internal/errgroup" - "github.com/vdaas/vald/internal/test/goleak" ) func TestWithAddr(t *testing.T) { @@ -105,7 +104,6 @@ func TestWithAddr(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -222,7 +220,6 @@ func TestWithHost(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -339,7 +336,6 @@ func TestWithPort(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -456,7 +452,6 @@ func TestWithStartPort(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -573,7 +568,6 @@ func TestWithEndPort(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -690,7 +684,6 @@ func TestWithResolveDNS(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -807,7 +800,6 @@ func TestWithBackoff(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -924,7 +916,6 @@ func TestWithSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1041,7 +1032,6 @@ func TestWithDialOptions(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1158,7 +1148,6 @@ func TestWithDialTimeout(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1275,7 +1264,6 @@ func TestWithOldConnCloseDuration(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1391,7 +1379,6 @@ func TestWithErrGroup(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/pool/pool.go b/internal/net/grpc/pool/pool.go index 3f6541cb14..a92890adf2 100644 --- a/internal/net/grpc/pool/pool.go +++ b/internal/net/grpc/pool/pool.go @@ -21,6 +21,7 @@ import ( "context" "math" "sort" + "strconv" "sync/atomic" "time" @@ -96,11 +97,25 @@ func New(ctx context.Context, opts ...Option) (c Conn, err error) { if err != nil { log.Warnf("failed to parse addr %s: %s", p.addr, err) if p.host == "" { - p.host = strings.SplitN(p.addr, ":", 2)[0] + var ( + ok bool + port string + ) + p.host, port, ok = strings.Cut(p.addr, ":") + if !ok { + p.host = p.addr + } else { + portNum, err := strconv.ParseUint(port, 10, 16) + if err != nil { + p.port = uint16(portNum) + } + } } - err = p.scanGRPCPort(ctx) - if err != nil { - return nil, err + if p.port == 0 { + err = p.scanGRPCPort(ctx) + if err != nil { + return nil, err + } } p.addr = net.JoinHostPort(p.host, p.port) } @@ -113,6 +128,10 @@ func New(ctx context.Context, opts ...Option) (c Conn, err error) { return nil, err } p.addr = net.JoinHostPort(p.host, p.port) + conn, err = grpc.DialContext(ctx, p.addr, p.dopts...) + if err != nil { + return nil, err + } } if conn != nil { err = conn.Close() diff --git a/internal/net/grpc/pool/pool_test.go b/internal/net/grpc/pool/pool_test.go index 840b33eea4..48e0ff14e2 100644 --- a/internal/net/grpc/pool/pool_test.go +++ b/internal/net/grpc/pool/pool_test.go @@ -29,6 +29,10 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestNew(t *testing.T) { t.Parallel() type args struct { @@ -90,7 +94,6 @@ func TestNew(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -223,7 +226,6 @@ func Test_pool_Connect(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -374,7 +376,6 @@ func Test_pool_load(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -525,7 +526,6 @@ func Test_pool_connect(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -662,7 +662,6 @@ func Test_pool_Disconnect(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -816,7 +815,6 @@ func Test_pool_dial(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -963,7 +961,6 @@ func Test_pool_IsHealthy(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1110,7 +1107,6 @@ func Test_pool_Do(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1251,7 +1247,6 @@ func Test_pool_Get(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -1402,7 +1397,6 @@ func Test_pool_get(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1539,7 +1533,6 @@ func Test_pool_Len(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -1676,7 +1669,6 @@ func Test_pool_Size(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -1827,7 +1819,6 @@ func Test_pool_lookupIPAddr(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1981,7 +1972,6 @@ func Test_pool_Reconnect(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2128,7 +2118,6 @@ func Test_pool_scanGRPCPort(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2226,7 +2215,6 @@ func Test_isGRPCPort(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2300,7 +2288,6 @@ func Test_isHealthy(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -2321,6 +2308,7 @@ func Test_isHealthy(t *testing.T) { } func Test_poolConn_Close(t *testing.T) { + t.Parallel() type args struct { ctx context.Context delay time.Duration @@ -2389,7 +2377,6 @@ func Test_poolConn_Close(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/proto/proto_test.go b/internal/net/grpc/proto/proto_test.go index 13f15722a2..6a55ac7e4f 100644 --- a/internal/net/grpc/proto/proto_test.go +++ b/internal/net/grpc/proto/proto_test.go @@ -27,7 +27,12 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestMarshal(t *testing.T) { + t.Parallel() type args struct { m Message } @@ -83,7 +88,6 @@ func TestMarshal(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -103,6 +107,7 @@ func TestMarshal(t *testing.T) { } func TestUnmarshal(t *testing.T) { + t.Parallel() type args struct { data []byte v Message @@ -178,7 +183,6 @@ func TestUnmarshal(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -244,7 +248,6 @@ func TestClone(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -265,6 +268,7 @@ func TestClone(t *testing.T) { } func TestToMessageV1(t *testing.T) { + t.Parallel() type args struct { m Message } @@ -316,7 +320,6 @@ func TestToMessageV1(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/grpc/server_test.go b/internal/net/grpc/server_test.go index 54502cd389..5e30b5aa74 100644 --- a/internal/net/grpc/server_test.go +++ b/internal/net/grpc/server_test.go @@ -37,6 +37,10 @@ var serverComparer = []comparator.Option{ comparator.WaitGroupComparer, } +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestNewServer(t *testing.T) { t.Parallel() type args struct { @@ -84,7 +88,6 @@ func TestNewServer(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -145,7 +148,6 @@ func TestCreds(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -208,7 +210,6 @@ func TestKeepaliveParams(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -269,7 +270,6 @@ func TestMaxRecvMsgSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -330,7 +330,6 @@ func TestMaxSendMsgSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -391,7 +390,6 @@ func TestInitialWindowSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -452,7 +450,6 @@ func TestInitialConnWindowSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -513,7 +510,6 @@ func TestReadBufferSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -574,7 +570,6 @@ func TestWriteBufferSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -635,7 +630,6 @@ func TestConnectionTimeout(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -696,7 +690,6 @@ func TestMaxHeaderListSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -757,7 +750,6 @@ func TestHeaderTableSize(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -778,6 +770,7 @@ func TestHeaderTableSize(t *testing.T) { } func TestKeepaliveEnforcementPolicy(t *testing.T) { + t.Parallel() type args struct { kep keepalive.EnforcementPolicy } @@ -819,7 +812,6 @@ func TestKeepaliveEnforcementPolicy(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) 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 106fe99a78..5ca04b4537 100644 --- a/internal/net/grpc/status/status_test.go +++ b/internal/net/grpc/status/status_test.go @@ -30,6 +30,10 @@ import ( "google.golang.org/grpc/status" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestNew(t *testing.T) { t.Parallel() type args struct { @@ -87,7 +91,6 @@ func TestNew(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -170,7 +173,6 @@ func Test_newStatus(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -250,7 +252,6 @@ func TestWrapWithCanceled(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -330,7 +331,6 @@ func TestWrapWithUnknown(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -410,7 +410,6 @@ func TestWrapWithInvalidArgument(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -490,7 +489,6 @@ func TestWrapWithDeadlineExceeded(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -570,7 +568,6 @@ func TestWrapWithNotFound(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -650,7 +647,6 @@ func TestWrapWithAlreadyExists(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -730,7 +726,6 @@ func TestWrapWithPermissionDenied(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -810,7 +805,6 @@ func TestWrapWithResourceExhausted(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -890,7 +884,6 @@ func TestWrapWithFailedPrecondition(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -970,7 +963,6 @@ func TestWrapWithAborted(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1050,7 +1042,6 @@ func TestWrapWithOutOfRange(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1130,7 +1121,6 @@ func TestWrapWithUnimplemented(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1210,7 +1200,6 @@ func TestWrapWithInternal(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1290,7 +1279,6 @@ func TestWrapWithUnavailable(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1370,7 +1358,6 @@ func TestWrapWithDataLoss(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1450,7 +1437,6 @@ func TestWrapWithUnauthenticated(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1527,7 +1513,6 @@ func TestError(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1607,7 +1592,6 @@ func TestErrorf(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1685,7 +1669,6 @@ func TestFromError(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1706,6 +1689,7 @@ func TestFromError(t *testing.T) { } func TestParseError(t *testing.T) { + t.Parallel() type args struct { err error defaultCode codes.Code @@ -1804,7 +1788,6 @@ func TestParseError(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1825,6 +1808,7 @@ func TestParseError(t *testing.T) { } func Test_withDetails(t *testing.T) { + t.Parallel() type args struct { st *Status err error @@ -1883,7 +1867,6 @@ func Test_withDetails(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1903,6 +1886,7 @@ func Test_withDetails(t *testing.T) { } func TestLog(t *testing.T) { + t.Parallel() type args struct { code codes.Code err error @@ -1953,7 +1937,6 @@ func TestLog(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) 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 a153a2fed3..9a786b89f1 100644 --- a/internal/net/grpc/stream_test.go +++ b/internal/net/grpc/stream_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" ) func TestBidirectionalStream(t *testing.T) { @@ -91,7 +90,6 @@ func TestBidirectionalStream(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -174,7 +172,6 @@ func TestBidirectionalStreamClient(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/http/client/client_test.go b/internal/net/http/client/client_test.go index 6d5d97d6a9..28df2285c9 100644 --- a/internal/net/http/client/client_test.go +++ b/internal/net/http/client/client_test.go @@ -21,7 +21,6 @@ import ( "crypto/tls" "net/http" "net/url" - "os" "reflect" "sync" "sync/atomic" @@ -91,10 +90,11 @@ var ( func TestMain(m *testing.M) { log.Init(log.WithLoggerType(logger.NOP.String())) - os.Exit(m.Run()) + goleak.VerifyTestMain(m) } func TestNew(t *testing.T) { + t.Parallel() type args struct { opts []Option } @@ -183,9 +183,10 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/http/client/option_test.go b/internal/net/http/client/option_test.go index d824fbabea..684ddf925e 100644 --- a/internal/net/http/client/option_test.go +++ b/internal/net/http/client/option_test.go @@ -27,10 +27,10 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net" "github.com/vdaas/vald/internal/test/comparator" - "github.com/vdaas/vald/internal/test/goleak" ) func TestWithProxy(t *testing.T) { + t.Parallel() type T = transport type args struct { px func(*http.Request) (*url.URL, error) @@ -91,9 +91,10 @@ func TestWithProxy(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -117,6 +118,7 @@ func TestWithProxy(t *testing.T) { } func TestWithDialContext(t *testing.T) { + t.Parallel() type T = transport type args struct { dx func(ctx context.Context, network, addr string) (net.Conn, error) @@ -175,9 +177,10 @@ func TestWithDialContext(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -201,6 +204,7 @@ func TestWithDialContext(t *testing.T) { } func TestWithTLSHandshakeTimeout(t *testing.T) { + t.Parallel() type T = transport type args struct { dur string @@ -265,9 +269,10 @@ func TestWithTLSHandshakeTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -291,6 +296,7 @@ func TestWithTLSHandshakeTimeout(t *testing.T) { } func TestWithEnableKeepalives(t *testing.T) { + t.Parallel() type T = transport type args struct { enable bool @@ -347,9 +353,10 @@ func TestWithEnableKeepalives(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -373,6 +380,7 @@ func TestWithEnableKeepalives(t *testing.T) { } func TestWithEnableCompression(t *testing.T) { + t.Parallel() type T = transport type args struct { enable bool @@ -429,9 +437,10 @@ func TestWithEnableCompression(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -455,6 +464,7 @@ func TestWithEnableCompression(t *testing.T) { } func TestWithMaxIdleConns(t *testing.T) { + t.Parallel() type T = transport type args struct { cn int @@ -508,9 +518,10 @@ func TestWithMaxIdleConns(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -534,6 +545,7 @@ func TestWithMaxIdleConns(t *testing.T) { } func TestWithMaxIdleConnsPerHost(t *testing.T) { + t.Parallel() type T = transport type args struct { cn int @@ -588,9 +600,10 @@ func TestWithMaxIdleConnsPerHost(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -614,6 +627,7 @@ func TestWithMaxIdleConnsPerHost(t *testing.T) { } func TestWithMaxConnsPerHost(t *testing.T) { + t.Parallel() type T = transport type args struct { cn int @@ -667,9 +681,10 @@ func TestWithMaxConnsPerHost(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -693,6 +708,7 @@ func TestWithMaxConnsPerHost(t *testing.T) { } func TestWithIdleConnTimeout(t *testing.T) { + t.Parallel() type T = transport type args struct { dur string @@ -758,9 +774,10 @@ func TestWithIdleConnTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -784,6 +801,7 @@ func TestWithIdleConnTimeout(t *testing.T) { } func TestWithResponseHeaderTimeout(t *testing.T) { + t.Parallel() type T = transport type args struct { dur string @@ -849,9 +867,10 @@ func TestWithResponseHeaderTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -875,6 +894,7 @@ func TestWithResponseHeaderTimeout(t *testing.T) { } func TestWithExpectContinueTimeout(t *testing.T) { + t.Parallel() type T = transport type args struct { dur string @@ -940,9 +960,10 @@ func TestWithExpectContinueTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -966,6 +987,7 @@ func TestWithExpectContinueTimeout(t *testing.T) { } func TestWithProxyConnectHeader(t *testing.T) { + t.Parallel() type T = transport type args struct { header http.Header @@ -1023,9 +1045,10 @@ func TestWithProxyConnectHeader(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1049,6 +1072,7 @@ func TestWithProxyConnectHeader(t *testing.T) { } func TestWithMaxResponseHeaderBytes(t *testing.T) { + t.Parallel() type T = transport type args struct { bs int64 @@ -1103,9 +1127,10 @@ func TestWithMaxResponseHeaderBytes(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1129,6 +1154,7 @@ func TestWithMaxResponseHeaderBytes(t *testing.T) { } func TestWithWriteBufferSize(t *testing.T) { + t.Parallel() type T = transport type args struct { bs int64 @@ -1183,9 +1209,10 @@ func TestWithWriteBufferSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1209,6 +1236,7 @@ func TestWithWriteBufferSize(t *testing.T) { } func TestWithReadBufferSize(t *testing.T) { + t.Parallel() type T = transport type args struct { bs int64 @@ -1263,9 +1291,10 @@ func TestWithReadBufferSize(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1289,6 +1318,7 @@ func TestWithReadBufferSize(t *testing.T) { } func TestWithForceAttemptHTTP2(t *testing.T) { + t.Parallel() type T = transport type args struct { force bool @@ -1332,9 +1362,10 @@ func TestWithForceAttemptHTTP2(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1358,6 +1389,7 @@ func TestWithForceAttemptHTTP2(t *testing.T) { } func TestWithBackoffOpts(t *testing.T) { + t.Parallel() type T = transport type args struct { opts []backoff.Option @@ -1451,9 +1483,10 @@ func TestWithBackoffOpts(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/http/dump/dump_test.go b/internal/net/http/dump/dump_test.go index 5939761b81..7ce4ac3982 100644 --- a/internal/net/http/dump/dump_test.go +++ b/internal/net/http/dump/dump_test.go @@ -20,9 +20,15 @@ import ( "github.com/vdaas/vald/internal/encoding/json" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestRequest(t *testing.T) { + t.Parallel() type args struct { values map[string]interface{} body map[string]interface{} @@ -90,10 +96,12 @@ func TestRequest(t *testing.T) { }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - res, err := Request(tt.args.values, tt.args.body, tt.args.r) - if err := tt.checkFunc(res, err); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + res, err := Request(test.args.values, test.args.body, test.args.r) + if err := test.checkFunc(res, err); err != nil { t.Error(err) } }) diff --git a/internal/net/http/json/json_test.go b/internal/net/http/json/json_test.go index 393955c0cb..8c12ad9556 100644 --- a/internal/net/http/json/json_test.go +++ b/internal/net/http/json/json_test.go @@ -32,30 +32,27 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) -// Goroutine leak is detected by `fastime`, but it should be ignored in the test because it is an external package. -var goleakIgnoreOptions = []goleak.Option{ - goleak.IgnoreTopFunction("github.com/kpango/fastime.(*fastime).StartTimerD.func1"), - goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"), +func TestMain(m *testing.M) { + log.Init(log.WithLoggerType(logger.NOP.String())) + goleak.VerifyTestMain(m) } func TestEncodeResponse(t *testing.T) { + t.Parallel() type args struct { w http.ResponseWriter data interface{} status int contentTypes []string } - type test struct { name string args args checkFunc func(err error) error } - tests := []test{ func() test { w := new(httptest.ResponseRecorder) - return test{ name: "returns nil", args: args{ @@ -70,48 +67,41 @@ func TestEncodeResponse(t *testing.T) { if err != nil { return errors.Errorf("err not equals. want: %v, got: %v", nil, err) } - if got, want := w.Header().Get(rest.ContentType), "application/json"; got != want { return errors.Errorf("content-type not equals. want: %v, got: %v", want, got) } - if got, want := w.Code, 200; got != want { return errors.Errorf("code not equals. want: %v, got: %v", want, got) } - return nil }, } }(), - - func() test { - w := new(httptest.ResponseRecorder) - - return test{ - name: "returns error when type is invalid", - args: args{ - w: w, - data: make(chan struct{}), - status: http.StatusOK, - contentTypes: []string{ - "application/json", - }, - }, - checkFunc: func(err error) error { - if err == nil { - return errors.New("err is nil") - } - return nil - }, - } - }(), - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - defer goleak.VerifyNone(t, goleakIgnoreOptions...) - err := EncodeResponse(tt.args.w, tt.args.data, tt.args.status, tt.args.contentTypes...) - if err := tt.checkFunc(err); err != nil { + { + name: "returns error when type is invalid", + args: args{ + w: new(httptest.ResponseRecorder), + data: make(chan struct{}), + status: http.StatusOK, + contentTypes: []string{ + "application/json", + }, + }, + checkFunc: func(err error) error { + if err == nil { + return errors.New("err is nil") + } + return nil + }, + }, + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + err := EncodeResponse(test.args.w, test.args.data, test.args.status, test.args.contentTypes...) + if err := test.checkFunc(err); err != nil { t.Error(err) } }) @@ -119,17 +109,16 @@ func TestEncodeResponse(t *testing.T) { } func TestDecodeRequest(t *testing.T) { + t.Parallel() type args struct { r *http.Request data map[string]string } - type test struct { name string args args checkFunc func(err error, data map[string]string) error } - tests := []test{ func() test { buf := new(bytes.Buffer) @@ -157,7 +146,6 @@ func TestDecodeRequest(t *testing.T) { }, } }(), - func() test { buf := new(bytes.Buffer) buf.WriteString(`10`) @@ -178,11 +166,12 @@ func TestDecodeRequest(t *testing.T) { }(), } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - defer goleak.VerifyNone(t, goleakIgnoreOptions...) - err := DecodeRequest(tt.args.r, &tt.args.data) - if err := tt.checkFunc(err, tt.args.data); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + err := DecodeRequest(test.args.r, &test.args.data) + if err := test.checkFunc(err, test.args.data); err != nil { t.Error(err) } }) @@ -190,19 +179,18 @@ func TestDecodeRequest(t *testing.T) { } func TestHandler(t *testing.T) { + t.Parallel() type args struct { w http.ResponseWriter r *http.Request data map[string]string logic func() (interface{}, error) } - type test struct { name string args args checkFunc func(code int, err error, data map[string]string) error } - tests := []test{ func() test { buf := new(bytes.Buffer) @@ -244,7 +232,6 @@ func TestHandler(t *testing.T) { }, } }(), - func() test { buf := new(bytes.Buffer) buf.WriteString(`2`) @@ -268,7 +255,6 @@ func TestHandler(t *testing.T) { }, } }(), - func() test { wantErr := errors.New("logic error") @@ -304,44 +290,42 @@ func TestHandler(t *testing.T) { }, } }(), - - func() test { - return test{ - name: "returns error because of faild to encode", - args: args{ - r: func() *http.Request { - buf := new(bytes.Buffer) - buf.WriteString(`{"name":"vald"}`) - return httptest.NewRequest(http.MethodPost, "/", buf) - }(), - w: new(httptest.ResponseRecorder), - data: make(map[string]string), - logic: func() (interface{}, error) { - return func() {}, nil - }, - }, - checkFunc: func(code int, err error, data map[string]string) error { - if code != http.StatusServiceUnavailable { - return errors.Errorf("code not equals. want: %v, got: %v", http.StatusServiceUnavailable, code) - } - - if got, want := data, map[string]string{ - "name": "vald", - }; !reflect.DeepEqual(got, want) { - return errors.Errorf("data not equals. want: %v, got: %v", want, got) - } - - return nil - }, - } - }(), - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - defer goleak.VerifyNone(t, goleakIgnoreOptions...) - code, err := Handler(tt.args.w, tt.args.r, &tt.args.data, tt.args.logic) - if err := tt.checkFunc(code, err, tt.args.data); err != nil { + { + name: "returns error because of faild to encode", + args: args{ + r: func() *http.Request { + buf := new(bytes.Buffer) + buf.WriteString(`{"name":"vald"}`) + return httptest.NewRequest(http.MethodPost, "/", buf) + }(), + w: new(httptest.ResponseRecorder), + data: make(map[string]string), + logic: func() (interface{}, error) { + return func() {}, nil + }, + }, + checkFunc: func(code int, err error, data map[string]string) error { + if code != http.StatusServiceUnavailable { + return errors.Errorf("code not equals. want: %v, got: %v", http.StatusServiceUnavailable, code) + } + + if got, want := data, map[string]string{ + "name": "vald", + }; !reflect.DeepEqual(got, want) { + return errors.Errorf("data not equals. want: %v, got: %v", want, got) + } + + return nil + }, + }, + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + code, err := Handler(test.args.w, test.args.r, &test.args.data, test.args.logic) + if err := test.checkFunc(code, err, test.args.data); err != nil { t.Error(err) } }) @@ -349,6 +333,7 @@ func TestHandler(t *testing.T) { } func TestErrorHandler(t *testing.T) { + t.Parallel() type args struct { w http.ResponseWriter r *http.Request @@ -356,13 +341,11 @@ func TestErrorHandler(t *testing.T) { code int err error } - type test struct { name string args args checkFunc func(err error) error } - tests := []test{ func() test { rbuf := new(bytes.Buffer) @@ -402,12 +385,12 @@ func TestErrorHandler(t *testing.T) { }(), } - log.Init(log.WithLoggerType(logger.NOP.String())) - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - defer goleak.VerifyNone(t, goleakIgnoreOptions...) - got := ErrorHandler(tt.args.w, tt.args.r, tt.args.msg, tt.args.code, tt.args.err) - if err := tt.checkFunc(got); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + got := ErrorHandler(test.args.w, test.args.r, test.args.msg, test.args.code, test.args.err) + if err := test.checkFunc(got); err != nil { t.Error(err) } }) @@ -415,6 +398,7 @@ func TestErrorHandler(t *testing.T) { } func TestDecodeResponse(t *testing.T) { + t.Parallel() type args struct { res *http.Response data interface{} @@ -540,9 +524,10 @@ func TestDecodeResponse(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -563,6 +548,7 @@ func TestDecodeResponse(t *testing.T) { } func TestEncodeRequest(t *testing.T) { + t.Parallel() type args struct { req *http.Request data interface{} @@ -651,9 +637,10 @@ func TestEncodeRequest(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -674,6 +661,7 @@ func TestEncodeRequest(t *testing.T) { } func TestRequest(t *testing.T) { + t.Parallel() type args struct { ctx context.Context method string @@ -787,9 +775,10 @@ func TestRequest(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/http/middleware/middleware_test.go b/internal/net/http/middleware/middleware_test.go new file mode 100644 index 0000000000..e9d0fadc3f --- /dev/null +++ b/internal/net/http/middleware/middleware_test.go @@ -0,0 +1,24 @@ +// Copyright (C) 2019-2022 vdaas.org vald team +// +// 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 middleware + +import ( + "testing" + + "github.com/vdaas/vald/internal/test/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/internal/net/http/middleware/option_test.go b/internal/net/http/middleware/option_test.go index 743899e5bc..14245aa68d 100644 --- a/internal/net/http/middleware/option_test.go +++ b/internal/net/http/middleware/option_test.go @@ -14,6 +14,7 @@ package middleware import ( + "context" "reflect" "testing" "time" @@ -23,6 +24,7 @@ import ( ) func TestWithErrorGroup(t *testing.T) { + t.Parallel() type test struct { name string dur string @@ -58,10 +60,12 @@ func TestWithErrorGroup(t *testing.T) { }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - opt := WithTimeout(tt.dur) - if err := tt.checkFunc(opt); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + opt := WithTimeout(test.dur) + if err := test.checkFunc(opt); err != nil { t.Error(err) } }) @@ -69,6 +73,7 @@ func TestWithErrorGroup(t *testing.T) { } func TestWithTimeout(t *testing.T) { + t.Parallel() type test struct { name string eg errgroup.Group @@ -77,7 +82,7 @@ func TestWithTimeout(t *testing.T) { tests := []test{ func() test { - eg := errgroup.Get() + eg, _ := errgroup.New(context.Background()) return test{ name: "set success", @@ -95,10 +100,12 @@ func TestWithTimeout(t *testing.T) { }(), } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - opt := WithErrorGroup(tt.eg) - if err := tt.checkFunc(opt); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + opt := WithErrorGroup(test.eg) + if err := test.checkFunc(opt); err != nil { t.Error(err) } }) diff --git a/internal/net/http/middleware/timeout_test.go b/internal/net/http/middleware/timeout_test.go index b047835ed3..97adb79c3d 100644 --- a/internal/net/http/middleware/timeout_test.go +++ b/internal/net/http/middleware/timeout_test.go @@ -14,25 +14,26 @@ package middleware import ( + "context" "net/http" "net/http/httptest" "reflect" + "strings" + "sync/atomic" "testing" "time" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/http/rest" - "github.com/vdaas/vald/internal/strings" - "github.com/vdaas/vald/internal/test/goleak" ) func TestNewTimeout(t *testing.T) { + t.Parallel() type test struct { name string want Wrapper } - tests := []test{ { name: "create object", @@ -42,41 +43,39 @@ func TestNewTimeout(t *testing.T) { }, }, } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() got := NewTimeout() - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("not equals. want: %v, got: %v", tt.want, got) + if !reflect.DeepEqual(got, test.want) { + t.Errorf("not equals. want: %v, got: %v", test.want, got) } }) } } -func TestWrap(t *testing.T) { +func Test_timeout_Wrap(t *testing.T) { + t.Parallel() type args struct { h rest.Func w http.ResponseWriter r *http.Request } - type field struct { dur time.Duration - eg errgroup.Group } - type test struct { name string args args field field checkFunc func(code int, err error) error } - tests := []test{ func() test { - var cnt int + var cnt uint64 = 0 h := func(w http.ResponseWriter, req *http.Request) (code int, err error) { - cnt++ + atomic.AddUint64(&cnt, 1) return http.StatusOK, nil } @@ -88,32 +87,27 @@ func TestWrap(t *testing.T) { r: new(http.Request), }, field: field{ - dur: 2 * time.Second, - eg: errgroup.Get(), + dur: 5 * time.Second, }, checkFunc: func(code int, err error) error { if err != nil { return errors.Errorf("err is not nil. err: %v", err) } - if code != http.StatusOK { return errors.Errorf("code is not equals. want: %v, got: %v", http.StatusOK, code) } - - if cnt != 1 { + if atomic.LoadUint64(&cnt) != 1 { return errors.Errorf("called cnt is equals. want: %v, got: %v", 1, cnt) } - return nil }, } }(), func() test { - wantErr := errors.New("faild") - - var cnt int + wantErr := errors.New("failed") + var cnt uint64 = 0 h := func(w http.ResponseWriter, req *http.Request) (code int, err error) { - cnt++ + atomic.AddUint64(&cnt, 1) return http.StatusInternalServerError, wantErr } @@ -126,160 +120,63 @@ func TestWrap(t *testing.T) { }, field: field{ dur: 2 * time.Second, - eg: errgroup.Get(), }, checkFunc: func(code int, err error) error { if !errors.Is(err, wantErr) { return errors.Errorf("err not equals. want: %v, got: %v", wantErr, err) } - if code != http.StatusInternalServerError { return errors.Errorf("code is not equals. want: %v, got: %v", http.StatusInternalServerError, code) } - - if cnt != 1 { + if atomic.LoadUint64(&cnt) != 1 { return errors.Errorf("called cnt is equals. want: %v, got: %v", 1, cnt) } - return nil }, } }(), - func() test { - h := func(w http.ResponseWriter, req *http.Request) (code int, err error) { - time.Sleep(10 * time.Second) - return http.StatusOK, nil - } - - return test{ - name: "timeout processing of internally called handler", - args: args{ - h: h, - w: new(httptest.ResponseRecorder), - r: new(http.Request), - }, - field: field{ - dur: 1 * time.Second, - eg: errgroup.Get(), - }, - checkFunc: func(code int, err error) error { - if err == nil { - return errors.Errorf("err is nil") - } - - if code != http.StatusRequestTimeout { - return errors.Errorf("code is not equals. want: %v, got: %v", http.StatusRequestTimeout, code) - } - - if !strings.Contains(err.Error(), "handler timeout") { - return errors.Errorf("err string no contains word of `handler timeout`") - } - - return nil + { + name: "timeout processing of internally called handler", + args: args{ + h: func(w http.ResponseWriter, req *http.Request) (code int, err error) { + return http.StatusOK, nil }, - } - }(), + w: new(httptest.ResponseRecorder), + r: new(http.Request), + }, + field: field{ + dur: 1, // set to extermemly small value to let it timeout + }, + checkFunc: func(code int, err error) error { + if err == nil { + return errors.Errorf("err is nil") + } + if code != http.StatusRequestTimeout { + return errors.Errorf("code is not equals. want: %v, got: %v", http.StatusRequestTimeout, code) + } + if !strings.Contains(err.Error(), "handler timeout") { + return errors.Errorf("err string no contains word of `handler timeout`") + } + + return nil + }, + }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + + eg, _ := errgroup.New(context.Background()) to := &timeout{ - dur: tt.field.dur, - eg: tt.field.eg, + dur: test.field.dur, + eg: eg, } - - code, err := to.Wrap(tt.args.h)(tt.args.w, tt.args.r) - if err := tt.checkFunc(code, err); err != nil { + code, err := to.Wrap(test.args.h)(test.args.w, test.args.r) + if err := test.checkFunc(code, err); err != nil { t.Error(err) } }) } } - -func Test_timeout_Wrap(t *testing.T) { - type args struct { - h rest.Func - } - type fields struct { - dur time.Duration - eg errgroup.Group - } - type want struct { - want rest.Func - } - type test struct { - name string - args args - fields fields - want want - checkFunc func(want, rest.Func) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want, got rest.Func) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - h: nil, - }, - fields: fields { - dur: nil, - eg: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - h: nil, - }, - fields: fields { - dur: nil, - eg: 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) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - t := &timeout{ - dur: test.fields.dur, - eg: test.fields.eg, - } - - got := t.Wrap(test.args.h) - if err := checkFunc(test.want, got); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} diff --git a/internal/net/http/rest/rest_test.go b/internal/net/http/rest/rest_test.go index ffedac9ae5..8b3b41c0bc 100644 --- a/internal/net/http/rest/rest_test.go +++ b/internal/net/http/rest/rest_test.go @@ -19,9 +19,15 @@ import ( "testing" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} + func TestHandlerToRestFunc(t *testing.T) { + t.Parallel() type test struct { name string hfn http.HandlerFunc @@ -59,10 +65,12 @@ func TestHandlerToRestFunc(t *testing.T) { }(), } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - fn := HandlerToRestFunc(tt.hfn) - if err := tt.checkFunc(fn); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + fn := HandlerToRestFunc(test.hfn) + if err := test.checkFunc(fn); err != nil { t.Error(err) } }) diff --git a/internal/net/http/routing/option_test.go b/internal/net/http/routing/option_test.go index b7e1136a7c..f76e888940 100644 --- a/internal/net/http/routing/option_test.go +++ b/internal/net/http/routing/option_test.go @@ -22,6 +22,7 @@ import ( ) func TestWithMiddleware(t *testing.T) { + t.Parallel() type test struct { name string mw middleware.Wrapper @@ -53,10 +54,12 @@ func TestWithMiddleware(t *testing.T) { }(), } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - opt := WithMiddleware(tt.mw) - if err := tt.checkFunc(opt); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + opt := WithMiddleware(test.mw) + if err := test.checkFunc(opt); err != nil { t.Error(err) } }) @@ -64,6 +67,7 @@ func TestWithMiddleware(t *testing.T) { } func TestWithMiddlewares(t *testing.T) { + t.Parallel() type test struct { name string mws []middleware.Wrapper @@ -122,7 +126,7 @@ func TestWithMiddlewares(t *testing.T) { return errors.New("invalid params count was set") } - mws = append([]middleware.Wrapper{mw}, mws...) + mws := append([]middleware.Wrapper{mw}, mws...) for i := range got.middlewares { if got, want := got.middlewares[i], mws[i]; !reflect.DeepEqual(got, want) { return errors.New("invalid params was set") @@ -135,10 +139,12 @@ func TestWithMiddlewares(t *testing.T) { }(), } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - opt := WithMiddlewares(tt.mws...) - if err := tt.checkFunc(opt); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + opt := WithMiddlewares(test.mws...) + if err := test.checkFunc(opt); err != nil { t.Error(err) } }) @@ -146,6 +152,7 @@ func TestWithMiddlewares(t *testing.T) { } func TestWithRoute(t *testing.T) { + t.Parallel() type test struct { name string route Route @@ -177,10 +184,12 @@ func TestWithRoute(t *testing.T) { }(), } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - opt := WithRoute(tt.route) - if err := tt.checkFunc(opt); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + opt := WithRoute(test.route) + if err := test.checkFunc(opt); err != nil { t.Error(err) } }) @@ -188,6 +197,7 @@ func TestWithRoute(t *testing.T) { } func TestWithRoutes(t *testing.T) { + t.Parallel() type test struct { name string routes []Route @@ -246,7 +256,7 @@ func TestWithRoutes(t *testing.T) { return errors.New("invalid params count was set") } - rs = append([]Route{r}, rs...) + rs := append([]Route{r}, rs...) for i := range got.routes { if got, want := got.routes[i], rs[i]; !reflect.DeepEqual(got, want) { return errors.New("invalid params was set") @@ -259,10 +269,12 @@ func TestWithRoutes(t *testing.T) { }(), } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - opt := WithRoutes(tt.routes...) - if err := tt.checkFunc(opt); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + opt := WithRoutes(test.routes...) + if err := test.checkFunc(opt); err != nil { t.Error(err) } }) diff --git a/internal/net/http/routing/router_test.go b/internal/net/http/routing/router_test.go index bd29976c63..7f775fbfbb 100644 --- a/internal/net/http/routing/router_test.go +++ b/internal/net/http/routing/router_test.go @@ -18,6 +18,7 @@ import ( "net/http" "net/http/httptest" "reflect" + "sync/atomic" "testing" "github.com/vdaas/vald/internal/errors" @@ -28,7 +29,13 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) +func TestMain(m *testing.M) { + log.Init(log.WithLoggerType(logger.NOP.String())) + goleak.VerifyTestMain(m) +} + func TestNew(t *testing.T) { + t.Parallel() type test struct { name string opts []Option @@ -36,30 +43,28 @@ func TestNew(t *testing.T) { } tests := []test{ - func() test { - mw := &middlewareMock{ - WrapFunc: func(r rest.Func) rest.Func { - return r - }, - } - - return test{ - name: "initialize success", - opts: []Option{ - WithMiddleware(mw), - WithRoutes( - Route{}, - ), - }, - initialized: true, - } - }(), + { + name: "initialize success", + opts: []Option{ + WithMiddleware(&middlewareMock{ + WrapFunc: func(r rest.Func) rest.Func { + return r + }, + }), + WithRoutes( + Route{}, + ), + }, + initialized: true, + }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := New(tt.opts...) - if (got != nil) != tt.initialized { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + got := New(test.opts...) + if (got != nil) != test.initialized { t.Error("New() is wrong.") } }) @@ -67,6 +72,7 @@ func TestNew(t *testing.T) { } func TestRouting(t *testing.T) { + t.Parallel() type args struct { name string path string @@ -85,9 +91,9 @@ func TestRouting(t *testing.T) { w := new(httptest.ResponseRecorder) r := httptest.NewRequest(http.MethodGet, "/", new(bytes.Buffer)) - cnt := 0 + var cnt int32 = 0 h := func(w http.ResponseWriter, req *http.Request) (code int, err error) { - cnt++ + atomic.AddInt32(&cnt, 1) w.WriteHeader(http.StatusOK) return http.StatusOK, nil } @@ -103,13 +109,14 @@ func TestRouting(t *testing.T) { checkFunc: func(hdr http.Handler) error { hdr.ServeHTTP(w, r) - if cnt != 1 { + if atomic.LoadInt32(&cnt) != 1 { return errors.Errorf("call count is wrong. want: %v, got: %v", 1, cnt) } if got, want := w.Code, http.StatusOK; got != want { return errors.Errorf("status code not equals. want: %v, got: %v", want, got) } + return nil }, } @@ -136,9 +143,9 @@ func TestRouting(t *testing.T) { w := new(httptest.ResponseRecorder) r := httptest.NewRequest(http.MethodGet, "/", new(bytes.Buffer)) - cnt := 0 + var cnt int32 = 0 h := func(w http.ResponseWriter, req *http.Request) (code int, err error) { - cnt++ + atomic.AddInt32(&cnt, 1) w.WriteHeader(http.StatusBadRequest) return http.StatusOK, errors.New("faild") } @@ -154,7 +161,7 @@ func TestRouting(t *testing.T) { checkFunc: func(hdr http.Handler) error { hdr.ServeHTTP(w, r) - if cnt != 1 { + if atomic.LoadInt32(&cnt) != 1 { return errors.Errorf("call count is wrong. want: %v, got: %v", 1, cnt) } @@ -167,11 +174,12 @@ func TestRouting(t *testing.T) { }(), } - log.Init(log.WithLoggerType(logger.NOP.String())) - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - hdr := new(router).routing(tt.args.name, tt.args.path, tt.args.m, tt.args.h) - if err := tt.checkFunc(hdr); err != nil { + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + // tt.Parallel() + hdr := new(router).routing(test.args.name, test.args.path, test.args.m, test.args.h) + if err := test.checkFunc(hdr); err != nil { t.Error(err) } }) @@ -179,6 +187,7 @@ func TestRouting(t *testing.T) { } func Test_router_routing(t *testing.T) { + t.Parallel() type args struct { name string path string @@ -249,9 +258,10 @@ func Test_router_routing(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/http/transport/option_test.go b/internal/net/http/transport/option_test.go index b5859eacc2..102cfb6cce 100644 --- a/internal/net/http/transport/option_test.go +++ b/internal/net/http/transport/option_test.go @@ -24,15 +24,10 @@ import ( "github.com/vdaas/vald/internal/backoff" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" ) -// Goroutine leak is detected by `fastime`, but it should be ignored in the test because it is an external package. -var goleakIgnoreOptions = []goleak.Option{ - goleak.IgnoreTopFunction("github.com/kpango/fastime.(*fastime).StartTimerD.func1"), -} - func TestWithRoundTripper(t *testing.T) { + t.Parallel() type T = ert type args struct { tr http.RoundTripper @@ -73,9 +68,10 @@ func TestWithRoundTripper(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -98,6 +94,7 @@ func TestWithRoundTripper(t *testing.T) { } func TestWithBackoff(t *testing.T) { + t.Parallel() type T = ert type args struct { bo backoff.Backoff @@ -138,9 +135,10 @@ func TestWithBackoff(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() 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 4e35631e5f..30be01e59e 100644 --- a/internal/net/http/transport/roundtrip_test.go +++ b/internal/net/http/transport/roundtrip_test.go @@ -22,7 +22,6 @@ import ( "context" "net/http" "net/http/httptest" - "os" "reflect" "testing" @@ -36,10 +35,11 @@ import ( func TestMain(m *testing.M) { log.Init(log.WithLoggerType(logger.NOP.String())) - os.Exit(m.Run()) + goleak.VerifyTestMain(m) } func TestNewExpBackoff(t *testing.T) { + t.Parallel() type args struct { opts []Option } @@ -88,9 +88,10 @@ func TestNewExpBackoff(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -111,6 +112,7 @@ func TestNewExpBackoff(t *testing.T) { } func Test_ert_RoundTrip(t *testing.T) { + t.Parallel() type args struct { req *http.Request } @@ -301,9 +303,10 @@ func Test_ert_RoundTrip(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -328,6 +331,7 @@ func Test_ert_RoundTrip(t *testing.T) { } func Test_ert_roundTrip(t *testing.T) { + t.Parallel() type args struct { req *http.Request } @@ -434,9 +438,10 @@ func Test_ert_roundTrip(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -461,6 +466,7 @@ func Test_ert_roundTrip(t *testing.T) { } func Test_retryableStatusCode(t *testing.T) { + t.Parallel() type args struct { status int } @@ -502,9 +508,10 @@ func Test_retryableStatusCode(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -525,6 +532,7 @@ func Test_retryableStatusCode(t *testing.T) { } func Test_closeBody(t *testing.T) { + t.Parallel() type args struct { rc io.ReadCloser } @@ -558,9 +566,10 @@ func Test_closeBody(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/net.go b/internal/net/net.go index 91ad63f2ad..5bc92c46f6 100644 --- a/internal/net/net.go +++ b/internal/net/net.go @@ -207,11 +207,17 @@ func SplitHostPort(hostport string) (host string, port uint16, err error) { host = hostport port = defaultPort } - p, err := strconv.ParseUint(portStr, 10, 16) - if err != nil || p > math.MaxUint16 { - port = defaultPort - } else { - port = uint16(p) + if len(portStr) > 0 { + var p uint64 + p, err = strconv.ParseUint(portStr, 10, 16) + if err != nil || p > math.MaxUint16 { + port = defaultPort + } else { + port = uint16(p) + } + } + if len(host) == 0 { + host = "localhost" } return host, port, err } diff --git a/internal/net/net_test.go b/internal/net/net_test.go index c706d00d11..3fb09d9412 100644 --- a/internal/net/net_test.go +++ b/internal/net/net_test.go @@ -21,11 +21,10 @@ import ( "context" "fmt" "math" + "net" "net/http" "net/http/httptest" - "os" "reflect" - "strconv" "testing" "github.com/vdaas/vald/internal/errors" @@ -36,19 +35,13 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) -// Goroutine leak is detected by `fastime`, but it should be ignored in the test because it is an external package. -var goleakIgnoreOptions = []goleak.Option{ - goleak.IgnoreTopFunction("github.com/kpango/fastime.(*fastime).StartTimerD.func1"), - goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"), - goleak.IgnoreTopFunction("net._C2func_getaddrinfo"), -} - func TestMain(m *testing.M) { log.Init(log.WithLoggerType(logger.NOP.String())) - os.Exit(m.Run()) + goleak.VerifyTestMain(m) } func TestIsLocal(t *testing.T) { + t.Parallel() type args struct { host string } @@ -117,9 +110,10 @@ func TestIsLocal(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -140,8 +134,8 @@ func TestIsLocal(t *testing.T) { } func TestDialContext(t *testing.T) { + t.Parallel() type args struct { - ctx context.Context network string addr string } @@ -153,9 +147,10 @@ func TestDialContext(t *testing.T) { name string args args want want + srv *httptest.Server checkFunc func(want, Conn, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*test) + afterFunc func(*test) } defaultCheckFunc := func(w want, gotConn Conn, err error) error { if !errors.Is(err, w.err) { @@ -167,67 +162,73 @@ func TestDialContext(t *testing.T) { return nil } tests := []test{ - func() test { - srvContent := "test" - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - fmt.Fprint(w, srvContent) - }) - testSrv := httptest.NewServer(handler) + { + name: "dial return server content", + args: args{ + network: TCP.String(), + }, + beforeFunc: func(t *test) { + srvContent := "test" - return test{ - name: "dial return server content", - args: args{ - ctx: context.Background(), - network: TCP.String(), - addr: testSrv.URL[len("http://"):], - }, - checkFunc: func(w want, gotConn Conn, err error) error { - if !errors.Is(err, w.err) { - return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) - } + t.srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + fmt.Fprint(w, srvContent) + })) + t.args.addr = t.srv.URL[len("http://"):] + }, + checkFunc: func(w want, gotConn Conn, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } - // read the output from the server and check if it is equals to the count - fmt.Fprintf(gotConn, "GET / HTTP/1.0\r\n\r\n") - buf, _ := io.ReadAll(gotConn) - content := strings.Split(string(buf), "\n")[5] // skip HTTP header - if content != srvContent { - return errors.Errorf("invalid content, got: %v, want: %v", content, srvContent) - } + srvContent := "test" - return nil - }, - afterFunc: func(args) { - testSrv.CloseClientConnections() - testSrv.Close() - }, - } - }(), + // read the output from the server and check if it is equals to the count + fmt.Fprintf(gotConn, "GET / HTTP/1.0\r\n\r\n") + buf, _ := io.ReadAll(gotConn) + content := strings.Split(string(buf), "\n")[5] // skip HTTP header + if content != srvContent { + return errors.Errorf("invalid content, got: %v, want: %v", content, srvContent) + } + + return nil + }, + afterFunc: func(t *test) { + t.srv.Client().CloseIdleConnections() + t.srv.CloseClientConnections() + t.srv.Close() + }, + }, } - for _, test := range tests { + for i := range tests { + test := &tests[i] t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) + test.beforeFunc(test) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - gotConn, err := DialContext(test.args.ctx, test.args.network, test.args.addr) + gotConn, err := DialContext(ctx, test.args.network, test.args.addr) if err := checkFunc(test.want, gotConn, err); err != nil { tt.Errorf("error = %v", err) } + + if test.afterFunc != nil { + test.afterFunc(test) + } }) } } func TestParse(t *testing.T) { + t.Parallel() type args struct { addr string } @@ -329,10 +330,9 @@ func TestParse(t *testing.T) { want: want{ wantHost: "dummy", wantPort: uint16(80), - err: &strconv.NumError{ - Func: "ParseUint", - Num: "", - Err: strconv.ErrSyntax, + err: &net.AddrError{ + Addr: "dummy", + Err: "missing port in address", }, }, }, @@ -347,10 +347,9 @@ func TestParse(t *testing.T) { isV4: true, isV6: false, isLocal: false, - err: &strconv.NumError{ - Func: "ParseUint", - Num: "", - Err: strconv.ErrSyntax, + err: &net.AddrError{ + Addr: "192.168.1.1", + Err: "missing port in address", }, }, }, @@ -365,18 +364,18 @@ func TestParse(t *testing.T) { isV4: false, isV6: true, isLocal: false, - err: &strconv.NumError{ - Func: "ParseUint", - Num: "", - Err: strconv.ErrSyntax, + err: &net.AddrError{ + Addr: "2001:db8::1", + Err: "too many colons in address", }, }, }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -397,6 +396,7 @@ func TestParse(t *testing.T) { } func TestSplitHostPort(t *testing.T) { + t.Parallel() type args struct { hostport string } @@ -464,10 +464,9 @@ func TestSplitHostPort(t *testing.T) { want: want{ wantHost: "dummy", wantPort: uint16(80), - err: &strconv.NumError{ - Func: "ParseUint", - Num: "", - Err: strconv.ErrSyntax, + err: &net.AddrError{ + Addr: "dummy", + Err: "missing port in address", }, }, }, @@ -479,10 +478,9 @@ func TestSplitHostPort(t *testing.T) { want: want{ wantHost: "192.168.1.1", wantPort: uint16(80), - err: &strconv.NumError{ - Func: "ParseUint", - Num: "", - Err: strconv.ErrSyntax, + err: &net.AddrError{ + Addr: "192.168.1.1", + Err: "missing port in address", }, }, }, @@ -494,10 +492,9 @@ func TestSplitHostPort(t *testing.T) { want: want{ wantHost: "2001:db8::1", wantPort: uint16(80), - err: &strconv.NumError{ - Func: "ParseUint", - Num: "", - Err: strconv.ErrSyntax, + err: &net.AddrError{ + Addr: "2001:db8::1", + Err: "too many colons in address", }, }, }, @@ -513,9 +510,10 @@ func TestSplitHostPort(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -536,8 +534,8 @@ func TestSplitHostPort(t *testing.T) { } func TestScanPorts(t *testing.T) { + t.Parallel() type args struct { - ctx context.Context start uint16 end uint16 host string @@ -550,9 +548,17 @@ func TestScanPorts(t *testing.T) { name string args args want want + srvs []*httptest.Server checkFunc func(want, []uint16, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, *test) + afterFunc func(*test) + } + defaultAfterFunc := func(t *test) { + for _, s := range t.srvs { + s.Client().CloseIdleConnections() + s.CloseClientConnections() + s.Close() + } } defaultCheckFunc := func(w want, gotPorts []uint16, err error) error { if !errors.Is(err, w.err) { @@ -576,140 +582,141 @@ func TestScanPorts(t *testing.T) { return nil } tests := []test{ - func() test { - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - }) - testSrv := httptest.NewServer(handler) + { + name: "return test server port number in given range", + args: args{ + host: "localhost", + }, + beforeFunc: func(t *testing.T, test *test) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + })) - s := strings.Split(testSrv.URL, ":") - p, _ := strconv.ParseUint(s[len(s)-1], 10, 16) - srvPort := uint16(p) + _, p, err := SplitHostPort(srv.URL[len("http://"):]) + if err != nil { + t.Error(err) + } - return test{ - name: "return test server port number in given range", - args: args{ - ctx: context.Background(), - host: "localhost", - start: srvPort - 5, - end: srvPort + 5, - }, - want: want{ - wantPorts: []uint16{ - srvPort, - }, - }, - afterFunc: func(args) { - testSrv.Close() - }, - } - }(), - func() test { - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - }) - testSrv := httptest.NewServer(handler) + test.srvs = []*httptest.Server{ + srv, + } - s := strings.Split(testSrv.URL, ":") - p, _ := strconv.ParseUint(s[len(s)-1], 10, 16) - srvPort := uint16(p) + // set args to server port range + test.args.start = p - 5 + test.args.end = p + 5 - return test{ - name: "return test server port number when start = end", - args: args{ - ctx: context.Background(), - host: "localhost", - start: srvPort, - end: srvPort, - }, - want: want{ - wantPorts: []uint16{ - srvPort, - }, - }, - afterFunc: func(args) { - testSrv.Close() - }, - } - }(), - func() test { - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - }) - testSrv := httptest.NewServer(handler) + // set want to server port + test.want.wantPorts = []uint16{ + p, + } + }, + }, + { + name: "return test server port number when start = end", + args: args{ + host: "localhost", + }, + beforeFunc: func(t *testing.T, test *test) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + })) - s := strings.Split(testSrv.URL, ":") - p, _ := strconv.ParseUint(s[len(s)-1], 10, 16) - srvPort := uint16(p) + _, p, err := SplitHostPort(srv.URL[len("http://"):]) + if err != nil { + t.Error(err) + } - return test{ - name: "return test server port number when start > end", - args: args{ - ctx: context.Background(), - host: "localhost", - start: srvPort + 10, - end: srvPort - 10, - }, - want: want{ - wantPorts: []uint16{ - srvPort, - }, - }, - afterFunc: func(args) { - testSrv.Close() - }, - } - }(), - func() test { - srvNum := 20 + test.srvs = []*httptest.Server{ + srv, + } - srvs := make([]*httptest.Server, 0, srvNum) - ports := make([]uint16, 0, srvNum) - minPort := uint16(math.MaxUint16) - maxPort := uint16(0) + // set args to server port range + test.args.start = p + test.args.end = p - for i := 0; i < srvNum; i++ { - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // set want to server port + test.want.wantPorts = []uint16{ + p, + } + }, + }, + { + name: "return test server port number when start > end", + args: args{ + host: "localhost", + }, + beforeFunc: func(t *testing.T, test *test) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) - }) - srv := httptest.NewServer(handler) - srvs = append(srvs, srv) + })) - s := strings.Split(srv.URL, ":") - p, _ := strconv.ParseUint(s[len(s)-1], 10, 16) - port := uint16(p) - ports = append(ports, port) + _, p, err := SplitHostPort(srv.URL[len("http://"):]) + if err != nil { + t.Error(err) + } - if port < minPort { - minPort = port + test.srvs = []*httptest.Server{ + srv, } - if port > maxPort { - maxPort = port + + // set args to server port range + test.args.start = p + 10 + test.args.end = p - 10 + + // set want to server port + test.want.wantPorts = []uint16{ + p, } - } + }, + }, + { + name: "return multiple test server port number", + args: args{ + host: "localhost", + }, + beforeFunc: func(t *testing.T, test *test) { + srvNum := 20 - return test{ - name: "return multiple test server port number", - args: args{ - ctx: context.Background(), - host: "localhost", - start: minPort - 5, - end: maxPort + 5, - }, - want: want{ - wantPorts: ports, - }, - afterFunc: func(args) { - for _, s := range srvs { - s.Close() + srvs := make([]*httptest.Server, 0, srvNum) + ports := make([]uint16, 0, srvNum) + minPort := uint16(math.MaxUint16) + maxPort := uint16(0) + + for i := 0; i < srvNum; i++ { + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + }) + srv := httptest.NewServer(handler) + srvs = append(srvs, srv) + + _, p, err := SplitHostPort(srv.URL[len("http://"):]) + if err != nil { + t.Error(err) } - }, - } - }(), + + ports = append(ports, p) + + if p < minPort { + minPort = p + } + if p > maxPort { + maxPort = p + } + } + + test.srvs = srvs + + // set args to server port range + test.args.start = minPort - 10 + test.args.end = maxPort + 10 + + // set want to server port + test.want.wantPorts = ports + }, + }, { name: "return no port available if no port is scanned", args: args{ - ctx: context.Background(), host: "localhost", start: 65534, end: 65535, @@ -720,30 +727,37 @@ func TestScanPorts(t *testing.T) { }, } - for _, test := range tests { + for i := range tests { + test := &tests[i] t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } + afterFunc := test.afterFunc + if test.afterFunc == nil { + afterFunc = defaultAfterFunc + } + defer afterFunc(test) - gotPorts, err := ScanPorts(test.args.ctx, test.args.start, test.args.end, test.args.host) + gotPorts, err := ScanPorts(ctx, test.args.start, test.args.end, test.args.host) if err := checkFunc(test.want, gotPorts, err); err != nil { tt.Errorf("error = %v", err) } - if test.afterFunc != nil { - test.afterFunc(test.args) - } + afterFunc(test) }) } } func TestLoadLocalIP(t *testing.T) { + t.Parallel() type want struct { want string } @@ -772,7 +786,7 @@ func TestLoadLocalIP(t *testing.T) { for _, tc := range tests { test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc() } @@ -938,7 +952,6 @@ func TestNetworkTypeFromString(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1075,7 +1088,6 @@ func TestNetworkType_String(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc() } @@ -1155,7 +1167,6 @@ func TestJoinHostPort(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/net/option.go b/internal/net/option.go index e131aecd5a..d6b5ee50af 100644 --- a/internal/net/option.go +++ b/internal/net/option.go @@ -37,10 +37,13 @@ var defaultDialerOptions = []DialerOption{ WithDisableDNSCache(), } -// WithCache returns the functional option to set the cache. -func WithCache(c cache.Cache) DialerOption { +// WithDNSCache returns the functional option to set the cache. +func WithDNSCache(c cache.Cache) DialerOption { return func(d *dialer) { - d.cache = c + d.dnsCache = c + if d.dnsCache != nil { + WithEnableDNSCache()(d) + } } } @@ -138,14 +141,14 @@ func WithTLS(cfg *tls.Config) DialerOption { // WithEnableDNSCache returns the functional option to enable DNSCache. func WithEnableDNSCache() DialerOption { return func(d *dialer) { - d.dnsCache = true + d.enableDNSCache = true } } // WithDisableDNSCache returns the functional option to disable DNSCache. func WithDisableDNSCache() DialerOption { return func(d *dialer) { - d.dnsCache = false + d.enableDNSCache = false } } diff --git a/internal/net/option_test.go b/internal/net/option_test.go index ea465a1ecb..6e50d10b49 100644 --- a/internal/net/option_test.go +++ b/internal/net/option_test.go @@ -27,10 +27,10 @@ import ( "github.com/vdaas/vald/internal/cache/gache" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/net/control" - "github.com/vdaas/vald/internal/test/goleak" ) -func TestWithCache(t *testing.T) { +func TestWithDNSCache(t *testing.T) { + t.Parallel() type T = dialer type args struct { c cache.Cache @@ -64,7 +64,8 @@ func TestWithCache(t *testing.T) { }, want: want{ obj: &T{ - cache: c, + dnsCache: c, + enableDNSCache: true, }, }, } @@ -76,15 +77,16 @@ func TestWithCache(t *testing.T) { }, want: want{ obj: &T{ - cache: nil, + dnsCache: nil, }, }, }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -97,7 +99,7 @@ func TestWithCache(t *testing.T) { checkFunc = defaultCheckFunc } - got := WithCache(test.args.c) + got := WithDNSCache(test.args.c) obj := new(T) got(obj) if err := checkFunc(test.want, obj); err != nil { @@ -108,6 +110,7 @@ func TestWithCache(t *testing.T) { } func TestWithDNSRefreshDuration(t *testing.T) { + t.Parallel() // Change interface type to the type of object you are testing type T = dialer type args struct { @@ -165,9 +168,10 @@ func TestWithDNSRefreshDuration(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -189,6 +193,7 @@ func TestWithDNSRefreshDuration(t *testing.T) { } func TestWithDNSCacheExpiration(t *testing.T) { + t.Parallel() type T = dialer type args struct { dur string @@ -222,7 +227,7 @@ func TestWithDNSCacheExpiration(t *testing.T) { obj: &T{ dnsCacheExpiration: 10 * time.Second, dnsCacheExpirationStr: "10s", - dnsCache: true, + enableDNSCache: true, }, }, }, @@ -235,7 +240,7 @@ func TestWithDNSCacheExpiration(t *testing.T) { obj: &T{ dnsCacheExpiration: 1 * time.Hour, dnsCacheExpirationStr: "1h", - dnsCache: true, + enableDNSCache: true, }, }, }, @@ -247,9 +252,10 @@ func TestWithDNSCacheExpiration(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -272,6 +278,7 @@ func TestWithDNSCacheExpiration(t *testing.T) { } func TestWithDialerTimeout(t *testing.T) { + t.Parallel() type T = dialer type args struct { dur string @@ -325,9 +332,10 @@ func TestWithDialerTimeout(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -350,6 +358,7 @@ func TestWithDialerTimeout(t *testing.T) { } func TestWithDialerKeepalive(t *testing.T) { + t.Parallel() type T = dialer type args struct { dur string @@ -404,9 +413,10 @@ func TestWithDialerKeepalive(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -429,6 +439,7 @@ func TestWithDialerKeepalive(t *testing.T) { } func TestWithTLS(t *testing.T) { + t.Parallel() type T = dialer type args struct { cfg *tls.Config @@ -474,9 +485,10 @@ func TestWithTLS(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -499,6 +511,7 @@ func TestWithTLS(t *testing.T) { } func TestWithEnableDNSCache(t *testing.T) { + t.Parallel() type T = dialer type want struct { obj *T @@ -522,15 +535,16 @@ func TestWithEnableDNSCache(t *testing.T) { name: "dnsCache enabled", want: want{ obj: &T{ - dnsCache: true, + enableDNSCache: true, }, }, }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc() } @@ -553,6 +567,7 @@ func TestWithEnableDNSCache(t *testing.T) { } func TestWithDisableDNSCache(t *testing.T) { + t.Parallel() type T = dialer type want struct { obj *T @@ -576,15 +591,16 @@ func TestWithDisableDNSCache(t *testing.T) { name: "dnsCache disabled", want: want{ obj: &T{ - dnsCache: false, + enableDNSCache: false, }, }, }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc() } @@ -607,6 +623,7 @@ func TestWithDisableDNSCache(t *testing.T) { } func TestWithEnableDialerDualStack(t *testing.T) { + t.Parallel() type T = dialer type want struct { obj *T @@ -636,9 +653,10 @@ func TestWithEnableDialerDualStack(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc() } @@ -661,6 +679,7 @@ func TestWithEnableDialerDualStack(t *testing.T) { } func TestWithDisableDialerDualStack(t *testing.T) { + t.Parallel() type T = dialer type want struct { obj *T @@ -690,9 +709,10 @@ func TestWithDisableDialerDualStack(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(tt, goleakIgnoreOptions...) + tt.Parallel() if test.beforeFunc != nil { test.beforeFunc() } @@ -794,7 +814,6 @@ func TestWithDialerFallbackDelay(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -911,7 +930,6 @@ func TestWithSocketFlag(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/client/google/option_test.go b/internal/observability/client/google/option_test.go new file mode 100644 index 0000000000..7c63d7c5bf --- /dev/null +++ b/internal/observability/client/google/option_test.go @@ -0,0 +1,1289 @@ +// +// Copyright (C) 2019-2022 vdaas.org vald team +// +// 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 google provides a google API client options. +package google + +import ( + "testing" + + "github.com/vdaas/vald/internal/test/goleak" +) + +func TestWithAPIKey(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + apiKey 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + apiKey: "", + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + apiKey: "", + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithAPIKey(test.args.apiKey) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithAPIKey(test.args.apiKey) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithAudiences(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + audiences []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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + audiences: nil, + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + audiences: nil, + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithAudiences(test.args.audiences...) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithAudiences(test.args.audiences...) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithCredentialsFile(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + path 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + path: "", + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + path: "", + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithCredentialsFile(test.args.path) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithCredentialsFile(test.args.path) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithEndpoint(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + endpoint 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + endpoint: "", + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + endpoint: "", + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithEndpoint(test.args.endpoint) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithEndpoint(test.args.endpoint) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithQuotaProject(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + qp 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + qp: "", + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + qp: "", + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithQuotaProject(test.args.qp) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithQuotaProject(test.args.qp) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithRequestReason(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + rr 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + rr: "", + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + rr: "", + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithRequestReason(test.args.rr) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithRequestReason(test.args.rr) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithScopes(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + scopes []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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + scopes: nil, + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + scopes: nil, + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithScopes(test.args.scopes...) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithScopes(test.args.scopes...) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithUserAgent(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + ua 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ua: "", + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ua: "", + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithUserAgent(test.args.ua) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithUserAgent(test.args.ua) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithCredentialsJSON(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + json 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + json: "", + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + json: "", + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithCredentialsJSON(test.args.json) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithCredentialsJSON(test.args.json) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithTelemetry(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + enabled 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + enabled: false, + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + enabled: false, + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithTelemetry(test.args.enabled) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithTelemetry(test.args.enabled) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithAuthentication(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + enabled 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\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#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 errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + enabled: false, + }, + want: want { + obj: new(T), + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + enabled: false, + }, + want: want { + obj: new(T), + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + defer goleak.VerifyNone(tt) + 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 := WithAuthentication(test.args.enabled) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + if test.checkFunc == nil { + test.checkFunc = defaultCheckFunc + } + got := WithAuthentication(test.args.enabled) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} diff --git a/internal/observability/collector/collector_option_test.go b/internal/observability/collector/collector_option_test.go index 1f00edb3e2..e9698658a8 100644 --- a/internal/observability/collector/collector_option_test.go +++ b/internal/observability/collector/collector_option_test.go @@ -100,7 +100,8 @@ func TestWithErrGroup(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -214,7 +215,8 @@ func TestWithDuration(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -328,7 +330,8 @@ func TestWithMetrics(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -445,7 +448,8 @@ func TestWithVersionInfo(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -559,7 +563,8 @@ func TestWithMemoryMetrics(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -673,7 +678,8 @@ func TestWithGoroutineMetrics(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -787,7 +793,8 @@ func TestWithCGOMetrics(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/observability/collector/collector_test.go b/internal/observability/collector/collector_test.go index 3eb2ed9e30..8bc40a5329 100644 --- a/internal/observability/collector/collector_test.go +++ b/internal/observability/collector/collector_test.go @@ -82,9 +82,11 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -169,9 +171,11 @@ func Test_collector_PreStart(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -261,9 +265,11 @@ func Test_collector_Start(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -348,9 +354,11 @@ func Test_collector_Stop(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -440,9 +448,11 @@ func Test_collector_collect(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/observability/exporter/prometheus/prometheus_option_test.go b/internal/observability/exporter/prometheus/prometheus_option_test.go index 3466c53483..9cb00a783c 100644 --- a/internal/observability/exporter/prometheus/prometheus_option_test.go +++ b/internal/observability/exporter/prometheus/prometheus_option_test.go @@ -98,7 +98,8 @@ func TestWithEndpoint(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -212,7 +213,8 @@ func TestWithNamespace(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -326,7 +328,8 @@ func TestWithOnErrorFunc(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/observability/exporter/prometheus/prometheus_test.go b/internal/observability/exporter/prometheus/prometheus_test.go index ef23f8a4d0..ece638e3c4 100644 --- a/internal/observability/exporter/prometheus/prometheus_test.go +++ b/internal/observability/exporter/prometheus/prometheus_test.go @@ -81,7 +81,8 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -165,7 +166,8 @@ func Test_exp_Start(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -248,7 +250,8 @@ func Test_exp_Stop(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -326,7 +329,8 @@ func Test_exp_NewHTTPHandler(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -395,7 +399,8 @@ func TestExporter(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/observability/metrics/agent/sidecar/sidecar_test.go b/internal/observability/metrics/agent/sidecar/sidecar_test.go index b87c94640a..67926b5099 100644 --- a/internal/observability/metrics/agent/sidecar/sidecar_test.go +++ b/internal/observability/metrics/agent/sidecar/sidecar_test.go @@ -73,7 +73,8 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -181,7 +182,8 @@ func Test_sidecarMetrics_Measurement(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -299,7 +301,8 @@ func Test_sidecarMetrics_MeasurementWithTags(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -403,7 +406,8 @@ func Test_sidecarMetrics_View(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -524,7 +528,8 @@ func Test_sidecarMetrics_BeforeProcess(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -641,7 +646,8 @@ func Test_sidecarMetrics_AfterProcess(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) diff --git a/internal/observability/metrics/manager/index/index_test.go b/internal/observability/metrics/manager/index/index_test.go index 69d3b08c52..31b1ed5fe4 100644 --- a/internal/observability/metrics/manager/index/index_test.go +++ b/internal/observability/metrics/manager/index/index_test.go @@ -78,7 +78,8 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -174,7 +175,8 @@ func Test_indexerMetrics_Measurement(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -276,7 +278,8 @@ func Test_indexerMetrics_MeasurementWithTags(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -364,7 +367,8 @@ func Test_indexerMetrics_View(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) diff --git a/internal/observability/metrics/mem/mem_test.go b/internal/observability/metrics/mem/mem_test.go index 7d8045b06f..e1e981370f 100644 --- a/internal/observability/metrics/mem/mem_test.go +++ b/internal/observability/metrics/mem/mem_test.go @@ -67,7 +67,8 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -193,7 +194,8 @@ func Test_memory_Measurement(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -335,7 +337,8 @@ func Test_memory_MeasurementWithTags(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -463,7 +466,8 @@ func Test_memory_View(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) diff --git a/internal/observability/metrics/metrics_test.go b/internal/observability/metrics/metrics_test.go index 377d2548e7..6321f9153e 100644 --- a/internal/observability/metrics/metrics_test.go +++ b/internal/observability/metrics/metrics_test.go @@ -76,7 +76,8 @@ func TestRegisterView(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -147,7 +148,8 @@ func TestRecord(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -223,7 +225,8 @@ func TestRecordWithTags(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -296,7 +299,8 @@ func TestMeasurementsCount(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) diff --git a/internal/observability/metrics/runtime/cgo/cgo_test.go b/internal/observability/metrics/runtime/cgo/cgo_test.go index b08bf35522..fc08f05510 100644 --- a/internal/observability/metrics/runtime/cgo/cgo_test.go +++ b/internal/observability/metrics/runtime/cgo/cgo_test.go @@ -67,7 +67,8 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -154,7 +155,8 @@ func Test_cgo_Measurement(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -244,7 +246,8 @@ func Test_cgo_MeasurementWithTags(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -320,7 +323,8 @@ func Test_cgo_View(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) diff --git a/internal/observability/metrics/runtime/goroutine/goroutine_test.go b/internal/observability/metrics/runtime/goroutine/goroutine_test.go index 84183fdf0c..f6a4ac7528 100644 --- a/internal/observability/metrics/runtime/goroutine/goroutine_test.go +++ b/internal/observability/metrics/runtime/goroutine/goroutine_test.go @@ -67,7 +67,8 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -154,7 +155,8 @@ func Test_goroutines_Measurement(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -244,7 +246,8 @@ func Test_goroutines_MeasurementWithTags(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -320,7 +323,8 @@ func Test_goroutines_View(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) diff --git a/internal/observability/metrics/version/version_test.go b/internal/observability/metrics/version/version_test.go index e2796005af..9c63849c56 100644 --- a/internal/observability/metrics/version/version_test.go +++ b/internal/observability/metrics/version/version_test.go @@ -81,7 +81,8 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -158,7 +159,8 @@ func Test_labelKVs(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -248,7 +250,8 @@ func Test_version_Measurement(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -342,7 +345,8 @@ func Test_version_MeasurementWithTags(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) @@ -422,7 +426,8 @@ func Test_version_View(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt) diff --git a/internal/observability/observability_option_test.go b/internal/observability/observability_option_test.go index 770e705fd8..05979b68a8 100644 --- a/internal/observability/observability_option_test.go +++ b/internal/observability/observability_option_test.go @@ -102,7 +102,8 @@ func TestWithErrGroup(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -216,7 +217,8 @@ func TestWithCollector(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -330,7 +332,8 @@ func TestWithTracer(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -444,7 +447,8 @@ func TestWithExporters(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/observability/observability_test.go b/internal/observability/observability_test.go index 71257a72fe..c8ee0f6cb6 100644 --- a/internal/observability/observability_test.go +++ b/internal/observability/observability_test.go @@ -88,7 +88,8 @@ func TestNewWithConfig(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -163,7 +164,8 @@ func TestNew(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -253,7 +255,8 @@ func Test_observability_PreStart(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -349,7 +352,8 @@ func Test_observability_Start(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -440,7 +444,8 @@ func Test_observability_Stop(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/observability/trace/trace_option_test.go b/internal/observability/trace/trace_option_test.go index 5993d75d2a..a6c57c05b8 100644 --- a/internal/observability/trace/trace_option_test.go +++ b/internal/observability/trace/trace_option_test.go @@ -97,9 +97,11 @@ func TestWithSamplingRate(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/params/option_test.go b/internal/params/option_test.go index bcb4d3ae81..7a3682c12e 100644 --- a/internal/params/option_test.go +++ b/internal/params/option_test.go @@ -73,7 +73,8 @@ func TestWithConfigFilePathKeys(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -141,7 +142,8 @@ func TestWithConfigFilePathDefault(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -209,7 +211,8 @@ func TestWithConfigFileDescription(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -281,7 +284,8 @@ func TestWithVersionKeys(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -349,7 +353,8 @@ func TestWithVersionFlagDefault(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -417,7 +422,8 @@ func TestWithVersionDescription(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/params/params_test.go b/internal/params/params_test.go index fcf589f959..21d951c34e 100644 --- a/internal/params/params_test.go +++ b/internal/params/params_test.go @@ -128,7 +128,8 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -287,7 +288,8 @@ func Test_parser_Parse(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -346,7 +348,8 @@ func Test_data_ConfigFilePath(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -404,7 +407,8 @@ func Test_data_ShowVersion(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/runner/option_test.go b/internal/runner/option_test.go index 09cf1a3737..88301fd03a 100644 --- a/internal/runner/option_test.go +++ b/internal/runner/option_test.go @@ -76,7 +76,8 @@ func TestWithName(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -193,7 +194,8 @@ func TestWithVersion(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -267,7 +269,8 @@ func TestWithConfigLoader(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { @@ -341,7 +344,8 @@ func TestWithDaemonInitializer(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/runner/runner_race_test.go b/internal/runner/runner_race_test.go index c73587c899..614fda6705 100644 --- a/internal/runner/runner_race_test.go +++ b/internal/runner/runner_race_test.go @@ -217,7 +217,8 @@ func TestDo_for_race(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/runner/runner_test.go b/internal/runner/runner_test.go index bea0f61f93..d67a3401da 100644 --- a/internal/runner/runner_test.go +++ b/internal/runner/runner_test.go @@ -259,7 +259,8 @@ func TestRun(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) if test.beforeFunc != nil { diff --git a/internal/safety/safety_bench_test.go b/internal/safety/safety_bench_test.go index 543b4af323..378a74f529 100644 --- a/internal/safety/safety_bench_test.go +++ b/internal/safety/safety_bench_test.go @@ -37,7 +37,8 @@ func BenchmarkRecoverFunc(b *testing.B) { }, }, } - for _, test := range tests { + for _, tc := range tests { + test := tc b.Run(test.name, func(b *testing.B) { b.RunParallel(func(pb *testing.PB) { for pb.Next() { @@ -102,7 +103,8 @@ func BenchmarkRecoverWithoutPanicFunc(b *testing.B) { }, }, } - for _, test := range tests { + for _, tc := range tests { + test := tc b.Run(test.name, func(b *testing.B) { b.RunParallel(func(pb *testing.PB) { for pb.Next() { diff --git a/internal/safety/safety_test.go b/internal/safety/safety_test.go index fbafe11967..69ee31c552 100644 --- a/internal/safety/safety_test.go +++ b/internal/safety/safety_test.go @@ -125,7 +125,8 @@ func TestRecoverFunc(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt, goleakIgnoreOptions...) @@ -212,7 +213,8 @@ func TestRecoverWithoutPanicFunc(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -286,7 +288,8 @@ func Test_recoverFunc(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { diff --git a/internal/servers/starter/starter_test.go b/internal/servers/starter/starter_test.go index 4d222144b8..93ea2f4054 100644 --- a/internal/servers/starter/starter_test.go +++ b/internal/servers/starter/starter_test.go @@ -541,9 +541,11 @@ func Test_srvs_setupAPIs(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -649,9 +651,11 @@ func Test_srvs_setupHealthCheck(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -757,9 +761,11 @@ func Test_srvs_setupMetrics(t *testing.T) { */ } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { - defer goleak.VerifyNone(t) + tt.Parallel() + defer goleak.VerifyNone(tt) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/internal/singleflight/singleflight_test.go b/internal/singleflight/singleflight_test.go index a3fa3a7ba3..355ae5ee20 100644 --- a/internal/singleflight/singleflight_test.go +++ b/internal/singleflight/singleflight_test.go @@ -57,7 +57,8 @@ func TestNew(t *testing.T) { }, } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.beforeFunc != nil { @@ -266,7 +267,8 @@ func Test_group_Do(t *testing.T) { }(), } - for _, test := range tests { + for _, tc := range tests { + test := tc t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(tt) if test.afterFunc != nil { diff --git a/internal/strings/strings.go b/internal/strings/strings.go index 46a48b3c71..6ec9697d9e 100644 --- a/internal/strings/strings.go +++ b/internal/strings/strings.go @@ -26,6 +26,7 @@ type ( var ( Contains = strings.Contains Count = strings.Count + Cut = strings.Cut EqualFold = strings.EqualFold HasPrefix = strings.HasPrefix HasSuffix = strings.HasSuffix diff --git a/internal/test/data/backup/100index/grp b/internal/test/data/backup/100index/grp deleted file mode 100644 index ce58bc9f84b9623e708de4eb8427a57d9f9a160f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12 KcmZQzKmY&$3;+QD diff --git a/internal/test/data/backup/100index/obj b/internal/test/data/backup/100index/obj deleted file mode 100644 index 1b1cb4d44c57c2d7a5122870fa6ac3e62ff7e94e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8 KcmZQzfB*mh2mk>9 diff --git a/internal/test/data/backup/100index/prf b/internal/test/data/backup/100index/prf deleted file mode 100644 index f08f25b718..0000000000 --- a/internal/test/data/backup/100index/prf +++ /dev/null @@ -1,26 +0,0 @@ -AccuracyTable -BatchSizeForCreation 200 -BuildTimeLimit 0 -DatabaseType Memory -Dimension 784 -DistanceType Angle -DynamicEdgeSizeBase 30 -DynamicEdgeSizeRate 20 -EdgeSizeForCreation 0 -EdgeSizeForSearch 0 -EdgeSizeLimitForCreation 5 -EpsilonForCreation 0.1 -GraphType ANNG -IncomingEdge 80 -IncrimentalEdgeSizeLimitForTruncation 0 -IndexType GraphAndTree -ObjectAlignment False -ObjectType Float-4 -OutgoingEdge 10 -PathAdjustmentInterval 0 -PrefetchOffset 1 -PrefetchSize 3136 -SeedSize 10 -SeedType None -ThreadPoolSize 32 -TruncationThreadPoolSize 8 diff --git a/internal/test/data/backup/100index/tre b/internal/test/data/backup/100index/tre deleted file mode 100644 index f9f6340605723f78c8170267ef42c4ba0f69d808..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28 UcmZQ#fB;=>Mh1okC= len(insertReqs) { return io.EOF } @@ -2696,16 +2663,13 @@ func Test_server_StreamInsert(t *testing.T) { }, } - s := &server{ - name: test.fields.name, - ip: test.fields.ip, - ngt: ngt, - eg: eg, - streamConcurrency: test.fields.streamConcurrency, + s, err := New(append(test.fields.srvOpts, WithNGT(ngt), WithErrGroup(eg))...) + if err != nil { + t.Errorf("failed to init service, err: %v", err) } if test.beforeFunc != nil { - test.beforeFunc(tt, test.args, s) + test.beforeFunc(tt, ctx, test.args, s) } if test.afterFunc != nil { defer test.afterFunc(test.args) @@ -2727,7 +2691,6 @@ func Test_server_MultiInsert(t *testing.T) { t.Parallel() type args struct { - ctx context.Context reqs *payload.Insert_MultiRequest } type fields struct { @@ -2748,13 +2711,10 @@ func Test_server_MultiInsert(t *testing.T) { fields fields want want checkFunc func(want, *payload.Object_Locations, error) error - beforeFunc func(*testing.T, *server) + beforeFunc func(*testing.T, context.Context, *server) afterFunc func(args) } - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - // common variables for test const ( name = "vald-agent-ngt-1" // agent name @@ -2924,7 +2884,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 1.1: Success to MultiInsert 1 vector (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -2949,7 +2908,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 1.2: Success to MultiInsert 1 vector (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -2974,7 +2932,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 1.3: Success to MultiInsert 100 vector (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -2999,7 +2956,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 1.4: Success to MultiInsert 100 vector (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3017,7 +2973,6 @@ func Test_server_MultiInsert(t *testing.T) { { name: "Equivalence Class Testing case 1.5: Success to MultiInsert 0 vector (vector type is uint8)", args: args{ - ctx: ctx, reqs: &payload.Insert_MultiRequest{ Requests: []*payload.Insert_Request{}, }, @@ -3036,7 +2991,6 @@ func Test_server_MultiInsert(t *testing.T) { { name: "Equivalence Class Testing case 1.6: Success to MultiInsert 0 vector (vector type is float32)", args: args{ - ctx: ctx, reqs: &payload.Insert_MultiRequest{ Requests: []*payload.Insert_Request{}, }, @@ -3062,7 +3016,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 2.1: Fail to MultiInsert 1 vector with different dimension (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3107,7 +3060,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 2.2: Fail to MultiInsert 1 vector with different dimension (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3158,7 +3110,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 3.1: Fail to MultiInsert 100 vector with 1 vector with different dimension (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3209,7 +3160,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 3.2: Fail to MultiInsert 100 vector with 1 vector with different dimension (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3264,7 +3214,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 3.3: Fail to MultiInsert 100 vector with 50 vector with different dimension (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3318,7 +3267,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 3.4: Fail to MultiInsert 100 vector with 50 vector with different dimension (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3363,7 +3311,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 3.5: Fail to MultiInsert 100 vector with all vector with different dimension (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3408,7 +3355,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Equivalence Class Testing case 3.6: Fail to MultiInsert 100 vector with all vector with different dimension (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3448,7 +3394,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 1.1: Success to MultiInsert with 0 value vector (vector type is uint8)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(intVecDim, 0), nil), }, fields: fields{ @@ -3468,7 +3413,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 1.2: Success to MultiInsert with 0 value vector (vector type is float32)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(f32VecDim, 0), nil), }, fields: fields{ @@ -3488,7 +3432,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 2.1: Success to MultiInsert with min value vector (vector type is uint8)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(intVecDim, math.MinInt), nil), }, fields: fields{ @@ -3508,7 +3451,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 2.2: Success to MultiInsert with min value vector (vector type is float32)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(f32VecDim, -math.MaxFloat32), nil), }, fields: fields{ @@ -3528,7 +3470,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 3.1: Success to MultiInsert with max value vector (vector type is uint8)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(intVecDim, math.MaxUint8), nil), }, fields: fields{ @@ -3548,7 +3489,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 3.2: Success to MultiInsert with max value vector (vector type is float32)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(f32VecDim, math.MaxFloat32), nil), }, fields: fields{ @@ -3579,7 +3519,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 4.1: Fail to MultiInsert with 1 request with empty UUID (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3626,7 +3565,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 4.2: Fail to MultiInsert with 1 request with empty UUID (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3675,7 +3613,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 4.3: Fail to MultiInsert with 50 request with empty UUID (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3724,7 +3661,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 4.4: Fail to MultiInsert with 50 request with empty UUID (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3773,7 +3709,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 4.5: Fail to MultiInsert with all request with empty UUID (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3822,7 +3757,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 4.6: Fail to MultiInsert with all request with empty UUID (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3864,7 +3798,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 5.1: Fail to MultiInsert with 1 vector with maximum dimension (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3911,7 +3844,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 5.1: Fail to MultiInsert with 1 vector with maximum dimension (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -3960,7 +3892,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 5.3: Fail to MultiInsert with 50 vector with maximum dimension (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4009,7 +3940,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 5.4: Fail to MultiInsert with 50 vector with maximum dimension (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4052,7 +3982,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 5.5: Fail to MultiInsert with all vector with maximum dimension (vector type is uint8)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4095,7 +4024,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 5.6: Fail to MultiInsert with all vector with maximum dimension (vector type is float32)", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4136,7 +4064,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 6.1: Success to MultiInsert with NaN value (vector type is float32)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(f32VecDim, float32(math.NaN())), nil), }, fields: fields{ @@ -4156,7 +4083,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 6.2: Success to MultiInsert with +Inf value (vector type is float32)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(f32VecDim, float32(math.Inf(+1.0))), nil), }, fields: fields{ @@ -4176,7 +4102,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 6.3: Success to MultiInsert with -Inf value (vector type is float32)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(f32VecDim, float32(math.Inf(-1.0))), nil), }, fields: fields{ @@ -4196,7 +4121,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 6.4: Success to MultiInsert with -0 value (vector type is float32)", args: args{ - ctx: ctx, reqs: request.GenSameVecMultiInsertReq(insertNum, vector.GenSameValueVec(f32VecDim, float32(math.Copysign(0, -1.0))), nil), }, fields: fields{ @@ -4223,7 +4147,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 7.1: Fail to MultiInsert with 1 vector with nil insert request", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4272,7 +4195,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 7.2: Fail to MultiInsert with 50 vector with nil insert request", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4321,7 +4243,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 7.3: Fail to MultiInsert with all vector with nil insert request", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4368,7 +4289,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 8.1: Fail to MultiInsert with 1 vector with nil vector", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4417,7 +4337,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 8.2: Fail to MultiInsert with 50 vector with nil vector", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4466,7 +4385,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 8.3: Fail to MultiInsert with all vector with nil vector", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4513,7 +4431,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 9.1: Fail to MultiInsert with 1 vector with empty insert vector", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4562,7 +4479,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 9.2: Fail to MultiInsert with 50 vector with empty insert vector", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4611,7 +4527,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Boundary Value Testing case 9.3: Fail to MultiInsert with all vector with empty insert vector", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4665,7 +4580,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 1.1: Success to MultiInsert with 2 duplicated ID when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4702,7 +4616,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 1.2: Success to MultiInsert with all duplicated ID when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4736,7 +4649,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 1.3: Success to MultiInsert with 2 duplicated ID when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4773,7 +4685,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 1.4: Success to MultiInsert with all duplicated ID when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4802,7 +4713,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 2.1: Success to MultiInsert with 2 duplicated vector when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4833,7 +4743,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 2.2: Success to MultiInsert with all duplicated vector when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4862,7 +4771,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 2.3: Success to MultiInsert with 2 duplicated vector when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4893,7 +4801,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 2.4: Success to MultiInsert with all duplicated vector when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4926,7 +4833,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 3.1: Success to MultiInsert with 2 duplicated ID & vector when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4964,7 +4870,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 3.2: Success to MultiInsert with all duplicated ID & vector when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -4998,7 +4903,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 3.3: Success to MultiInsert with 2 duplicated ID & vector when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5036,7 +4940,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 3.4: Success to MultiInsert with all duplicated ID & vector when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5060,7 +4963,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 4.1: Fail to MultiInsert with 2 existed ID when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5069,7 +4971,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { vecs, err := vector.GenF32Vec(vector.Gaussian, 2, f32VecDim) if err != nil { t.Error(err) @@ -5118,7 +5020,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 4.2: Fail to MultiInsert with all existed ID when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5127,7 +5028,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { vecs, err := vector.GenF32Vec(vector.Gaussian, insertNum, f32VecDim) if err != nil { t.Error(err) @@ -5167,7 +5068,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 4.3: Fail to MultiInsert with 2 existed ID when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5176,7 +5076,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { vecs, err := vector.GenF32Vec(vector.Gaussian, 2, f32VecDim) if err != nil { t.Error(err) @@ -5225,7 +5125,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 4.4: Fail to MultiInsert with all existed ID when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5234,7 +5133,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { vecs, err := vector.GenF32Vec(vector.Gaussian, insertNum, f32VecDim) if err != nil { t.Error(err) @@ -5274,7 +5173,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 5.1: Success to MultiInsert with 2 existed vector when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5283,7 +5181,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { // insert same request with different ID for i := 0; i < 2; i++ { ir := &payload.Insert_Request{ @@ -5320,7 +5218,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 5.2: Success to MultiInsert with all existed vector when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5329,7 +5226,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { // insert same request with different ID for i := range req.Requests { ir := &payload.Insert_Request{ @@ -5366,7 +5263,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 5.3: Success to MultiInsert with 2 existed vector when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5375,7 +5271,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { // insert same request with different ID for i := 0; i < 2; i++ { ir := &payload.Insert_Request{ @@ -5412,7 +5308,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 5.4: Success to MultiInsert with all existed vector when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5421,7 +5316,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { // insert same request with different ID for i := range req.Requests { ir := &payload.Insert_Request{ @@ -5458,7 +5353,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 6.1: Fail to MultiInsert with 2 existed ID & vector when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5467,7 +5361,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { for i := 0; i < 2; i++ { ir := &payload.Insert_Request{ Vector: req.Requests[i].Vector, @@ -5509,7 +5403,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testingcase 6.2: Fail to MultiInsert with all existed ID & vector when SkipStrictExistCheck is false", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5518,7 +5411,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { for _, r := range req.Requests { ir := &payload.Insert_Request{ Vector: r.Vector, @@ -5551,7 +5444,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 6.3: Fail to MultiInsert with 2 existed ID & vector when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5560,7 +5452,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { for i := 0; i < 2; i++ { ir := &payload.Insert_Request{ Vector: req.Requests[i].Vector, @@ -5602,7 +5494,6 @@ func Test_server_MultiInsert(t *testing.T) { return test{ name: "Decision Table Testing case 6.4: Fail to MultiInsert with all existed ID & vector when SkipStrictExistCheck is true", args: args{ - ctx: ctx, reqs: req, }, fields: fields{ @@ -5611,7 +5502,7 @@ func Test_server_MultiInsert(t *testing.T) { svcCfg: defaultF32SvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, s *server) { + beforeFunc: func(t *testing.T, ctx context.Context, s *server) { for _, r := range req.Requests { ir := &payload.Insert_Request{ Vector: r.Vector, @@ -5640,7 +5531,10 @@ func Test_server_MultiInsert(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.afterFunc != nil { defer test.afterFunc(test.args) } @@ -5664,10 +5558,10 @@ func Test_server_MultiInsert(t *testing.T) { } if test.beforeFunc != nil { - test.beforeFunc(tt, s) + test.beforeFunc(tt, ctx, s) } - gotRes, err := s.MultiInsert(test.args.ctx, test.args.reqs) + gotRes, err := s.MultiInsert(ctx, test.args.reqs) if err := checkFunc(test.want, gotRes, err); err != nil { tt.Errorf("error = %v", err) } diff --git a/pkg/agent/core/ngt/handler/grpc/linear_search_test.go b/pkg/agent/core/ngt/handler/grpc/linear_search_test.go index 74fece7a5f..3317864f90 100644 --- a/pkg/agent/core/ngt/handler/grpc/linear_search_test.go +++ b/pkg/agent/core/ngt/handler/grpc/linear_search_test.go @@ -23,11 +23,11 @@ import ( "github.com/vdaas/vald/apis/grpc/v1/vald" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/pkg/agent/core/ngt/service" ) func Test_server_LinearSearch(t *testing.T) { + t.Parallel() type args struct { ctx context.Context req *payload.Search_Request @@ -115,7 +115,6 @@ func Test_server_LinearSearch(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -144,6 +143,7 @@ func Test_server_LinearSearch(t *testing.T) { } func Test_server_LinearSearchByID(t *testing.T) { + t.Parallel() type args struct { ctx context.Context req *payload.Search_IDRequest @@ -231,7 +231,6 @@ func Test_server_LinearSearchByID(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -260,6 +259,7 @@ func Test_server_LinearSearchByID(t *testing.T) { } func Test_server_StreamLinearSearch(t *testing.T) { + t.Parallel() type args struct { stream vald.Search_StreamLinearSearchServer } @@ -340,7 +340,6 @@ func Test_server_StreamLinearSearch(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -369,6 +368,7 @@ func Test_server_StreamLinearSearch(t *testing.T) { } func Test_server_StreamLinearSearchByID(t *testing.T) { + t.Parallel() type args struct { stream vald.Search_StreamLinearSearchByIDServer } @@ -449,7 +449,6 @@ func Test_server_StreamLinearSearchByID(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -478,6 +477,7 @@ func Test_server_StreamLinearSearchByID(t *testing.T) { } func Test_server_MultiLinearSearch(t *testing.T) { + t.Parallel() type args struct { ctx context.Context reqs *payload.Search_MultiRequest @@ -565,7 +565,6 @@ func Test_server_MultiLinearSearch(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -594,6 +593,7 @@ func Test_server_MultiLinearSearch(t *testing.T) { } func Test_server_MultiLinearSearchByID(t *testing.T) { + t.Parallel() type args struct { ctx context.Context reqs *payload.Search_MultiIDRequest @@ -681,7 +681,6 @@ func Test_server_MultiLinearSearchByID(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/handler/grpc/object_test.go b/pkg/agent/core/ngt/handler/grpc/object_test.go index 460486fcfe..d2d1591777 100644 --- a/pkg/agent/core/ngt/handler/grpc/object_test.go +++ b/pkg/agent/core/ngt/handler/grpc/object_test.go @@ -30,18 +30,13 @@ import ( "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/test/data/request" "github.com/vdaas/vald/internal/test/data/vector" - "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/pkg/agent/core/ngt/service" ) func Test_server_Exists(t *testing.T) { t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - type args struct { - ctx context.Context indexID string searchID string } @@ -53,7 +48,7 @@ func Test_server_Exists(t *testing.T) { args args want want checkFunc func(want, *payload.Object_ID, error) error - beforeFunc func(args) (Server, error) + beforeFunc func(context.Context, args) (Server, error) afterFunc func(args) } defaultCheckFunc := func(w want, gotRes *payload.Object_ID, err error) error { @@ -101,8 +96,8 @@ func Test_server_Exists(t *testing.T) { defaultInsertConfig := &payload.Insert_Config{ SkipStrictExistCheck: true, } - defaultBeforeFunc := func(a args) (Server, error) { - return buildIndex(a.ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) + defaultBeforeFunc := func(ctx context.Context, a args) (Server, error) { + return buildIndex(ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) } /* @@ -135,7 +130,6 @@ func Test_server_Exists(t *testing.T) { { name: "Equivalence Class Testing case 1.1: success exists vector", args: args{ - ctx: ctx, indexID: "test", searchID: "test", }, @@ -144,7 +138,6 @@ func Test_server_Exists(t *testing.T) { { name: "Equivalence Class Testing case 2.1: fail exists with non-existent ID", args: args{ - ctx: ctx, indexID: "test", searchID: "non-existent", }, @@ -155,7 +148,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 1.1: fail exists with \"\"", args: args{ - ctx: ctx, indexID: "test", searchID: "", }, @@ -166,7 +158,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 2.1: success exists with ^@", args: args{ - ctx: ctx, indexID: string([]byte{0}), searchID: string([]byte{0}), }, @@ -175,7 +166,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 2.2: success exists with ^I", args: args{ - ctx: ctx, indexID: "\t", searchID: "\t", }, @@ -184,7 +174,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 2.3: success exists with ^J", args: args{ - ctx: ctx, indexID: "\n", searchID: "\n", }, @@ -193,7 +182,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 2.4: success exists with ^M", args: args{ - ctx: ctx, indexID: "\r", searchID: "\r", }, @@ -202,7 +190,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 2.5: success exists with ^[", args: args{ - ctx: ctx, indexID: string([]byte{27}), searchID: string([]byte{27}), }, @@ -211,7 +198,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 2.6: success exists with ^?", args: args{ - ctx: ctx, indexID: string([]byte{127}), searchID: string([]byte{127}), }, @@ -220,7 +206,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 3.1: success exists with utf-8 ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, searchID: utf8Str, }, @@ -229,7 +214,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 3.2: fail exists with utf-8 ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, searchID: utf8Str, }, @@ -240,7 +224,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 3.3: fail exists with utf-8 ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, searchID: utf8Str, }, @@ -251,7 +234,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 3.4: fail exists with s-jis ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, searchID: sjisStr, }, @@ -262,7 +244,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 3.5: success exists with s-jis ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, searchID: sjisStr, }, @@ -271,7 +252,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 3.6: fail exists with s-jis ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, searchID: sjisStr, }, @@ -282,7 +262,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 3.7: fail exists with euc-jp ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, searchID: eucjpStr, }, @@ -293,7 +272,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 3.8: fail exists with euc-jp ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, searchID: eucjpStr, }, @@ -304,7 +282,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 3.9: success exists with euc-jp ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, searchID: eucjpStr, }, @@ -313,7 +290,6 @@ func Test_server_Exists(t *testing.T) { { name: "Boundary Value Testing case 4.1: success exists with 😀", args: args{ - ctx: ctx, indexID: "😀", searchID: "😀", }, @@ -325,11 +301,14 @@ func Test_server_Exists(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.beforeFunc == nil { test.beforeFunc = defaultBeforeFunc } - s, err := test.beforeFunc(test.args) + s, err := test.beforeFunc(ctx, test.args) if err != nil { tt.Errorf("error = %v", err) } @@ -344,7 +323,7 @@ func Test_server_Exists(t *testing.T) { req := &payload.Object_ID{ Id: test.args.searchID, } - gotRes, err := s.Exists(test.args.ctx, req) + gotRes, err := s.Exists(ctx, req) if err := checkFunc(test.want, gotRes, err); err != nil { tt.Errorf("error = %v", err) } @@ -358,11 +337,9 @@ func Test_server_GetObject(t *testing.T) { id *payload.Object_VectorRequest } type fields struct { - name string - ip string - streamConcurrency int - svcCfg *config.NGT - svcOpts []service.Option + srvOpts []Option + svcCfg *config.NGT + svcOpts []service.Option } type want struct { wantRes *payload.Object_Vector @@ -374,7 +351,7 @@ func Test_server_GetObject(t *testing.T) { fields fields want want checkFunc func(want, *payload.Object_Vector, error) error - beforeFunc func(*testing.T, args, *server) + beforeFunc func(*testing.T, context.Context, args, Server) afterFunc func(args) } @@ -416,9 +393,7 @@ func Test_server_GetObject(t *testing.T) { t.Error(err) } - insertAndCreateIndex := func(t *testing.T, s *server, req *payload.Insert_MultiRequest) { - ctx := context.Background() - + insertAndCreateIndex := func(t *testing.T, ctx context.Context, s Server, req *payload.Insert_MultiRequest) { if _, err := s.MultiInsert(ctx, req); err != nil { t.Fatal(err) } @@ -487,8 +462,10 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: &config.NGT{ Dimension: dim, DistanceType: ngt.Angle.String(), @@ -498,8 +475,8 @@ func Test_server_GetObject(t *testing.T) { }, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -526,13 +503,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -558,13 +537,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ errCode: codes.InvalidArgument, @@ -589,13 +570,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -623,13 +606,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -657,13 +642,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -691,13 +678,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -725,13 +714,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -759,13 +750,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -793,13 +786,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -827,13 +822,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ errCode: codes.NotFound, @@ -858,13 +855,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ errCode: codes.NotFound, @@ -889,13 +888,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ errCode: codes.NotFound, @@ -920,13 +921,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -954,13 +957,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ errCode: codes.NotFound, @@ -985,13 +990,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ errCode: codes.NotFound, @@ -1016,13 +1023,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ errCode: codes.NotFound, @@ -1047,13 +1056,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -1081,13 +1092,15 @@ func Test_server_GetObject(t *testing.T) { }, }, fields: fields{ - name: name, - ip: ip, + srvOpts: []Option{ + WithName(name), + WithIP(ip), + }, svcCfg: defaultSvcCfg, svcOpts: defaultSvcOpts, }, - beforeFunc: func(t *testing.T, a args, s *server) { - insertAndCreateIndex(t, s, ir) + beforeFunc: func(t *testing.T, ctx context.Context, a args, s Server) { + insertAndCreateIndex(t, ctx, s, ir) }, want: want{ wantRes: &payload.Object_Vector{ @@ -1103,7 +1116,6 @@ func Test_server_GetObject(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -1122,15 +1134,13 @@ func Test_server_GetObject(t *testing.T) { tt.Errorf("failed to init ngt service, error = %v", err) } - s := &server{ - name: test.fields.name, - ip: test.fields.ip, - ngt: ngt, - eg: eg, - streamConcurrency: test.fields.streamConcurrency, + s, err := New(append(test.fields.srvOpts, WithNGT(ngt), WithErrGroup(eg))...) + if err != nil { + t.Errorf("failed to init service, err: %v", err) } + if test.beforeFunc != nil { - test.beforeFunc(tt, test.args, s) + test.beforeFunc(tt, ctx, test.args, s) } gotRes, err := s.GetObject(ctx, test.args.id) @@ -1217,7 +1227,6 @@ func Test_server_StreamGetObject(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/handler/grpc/option_test.go b/pkg/agent/core/ngt/handler/grpc/option_test.go index c9a98d5841..df8eada1cf 100644 --- a/pkg/agent/core/ngt/handler/grpc/option_test.go +++ b/pkg/agent/core/ngt/handler/grpc/option_test.go @@ -24,7 +24,6 @@ import ( "github.com/vdaas/vald/internal/config" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/pkg/agent/core/ngt/service" ) @@ -85,7 +84,6 @@ func TestWithIP(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -162,7 +160,6 @@ func TestWithName(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -253,7 +250,6 @@ func TestWithNGT(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(tt, &test.args, &test.want) } @@ -344,7 +340,6 @@ func TestWithStreamConcurrency(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -428,7 +423,6 @@ func TestWithErrGroup(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/handler/grpc/remove_test.go b/pkg/agent/core/ngt/handler/grpc/remove_test.go index 9534c941cc..217c6f17a5 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove_test.go +++ b/pkg/agent/core/ngt/handler/grpc/remove_test.go @@ -29,18 +29,13 @@ import ( "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/test/data/request" "github.com/vdaas/vald/internal/test/data/vector" - "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/pkg/agent/core/ngt/service" ) func Test_server_Remove(t *testing.T) { t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - type args struct { - ctx context.Context indexID string removeID string } @@ -53,7 +48,7 @@ func Test_server_Remove(t *testing.T) { args args want want checkFunc func(want, *payload.Object_Location, error) error - beforeFunc func(args) (Server, error) + beforeFunc func(context.Context, args) (Server, error) afterFunc func(args) } defaultCheckFunc := func(w want, gotRes *payload.Object_Location, err error) error { @@ -104,8 +99,8 @@ func Test_server_Remove(t *testing.T) { defaultInsertConfig := &payload.Insert_Config{ SkipStrictExistCheck: true, } - defaultBeforeFunc := func(a args) (Server, error) { - return buildIndex(a.ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) + defaultBeforeFunc := func(ctx context.Context, a args) (Server, error) { + return buildIndex(ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) } /* @@ -138,7 +133,6 @@ func Test_server_Remove(t *testing.T) { { name: "Equivalence Class Testing case 1.1: success exists vector", args: args{ - ctx: ctx, indexID: "test", removeID: "test", }, @@ -149,7 +143,6 @@ func Test_server_Remove(t *testing.T) { { name: "Equivalence Class Testing case 2.1: fail exists with non-existent ID", args: args{ - ctx: ctx, indexID: "test", removeID: "non-existent", }, @@ -160,7 +153,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 1.1: fail exists with \"\"", args: args{ - ctx: ctx, indexID: "test", removeID: "", }, @@ -171,7 +163,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 2.1: success exists with ^@", args: args{ - ctx: ctx, indexID: string([]byte{0}), removeID: string([]byte{0}), }, @@ -182,7 +173,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 2.2: success exists with ^I", args: args{ - ctx: ctx, indexID: "\t", removeID: "\t", }, @@ -193,7 +183,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 2.3: success exists with ^J", args: args{ - ctx: ctx, indexID: "\n", removeID: "\n", }, @@ -204,7 +193,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 2.4: success exists with ^M", args: args{ - ctx: ctx, indexID: "\r", removeID: "\r", }, @@ -215,7 +203,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 2.5: success exists with ^[", args: args{ - ctx: ctx, indexID: string([]byte{27}), removeID: string([]byte{27}), }, @@ -226,7 +213,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 2.6: success exists with ^?", args: args{ - ctx: ctx, indexID: string([]byte{127}), removeID: string([]byte{127}), }, @@ -237,7 +223,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 3.1: success exists with utf-8 ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, removeID: utf8Str, }, @@ -248,7 +233,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 3.2: fail exists with utf-8 ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, removeID: utf8Str, }, @@ -259,7 +243,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 3.3: fail exists with utf-8 ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, removeID: utf8Str, }, @@ -270,7 +253,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 3.4: fail exists with s-jis ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, removeID: sjisStr, }, @@ -281,7 +263,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 3.5: success exists with s-jis ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, removeID: sjisStr, }, @@ -292,7 +273,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 3.6: fail exists with s-jis ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, removeID: sjisStr, }, @@ -303,7 +283,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 3.7: fail exists with euc-jp ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, removeID: eucjpStr, }, @@ -314,7 +293,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 3.8: fail exists with euc-jp ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, removeID: eucjpStr, }, @@ -325,7 +303,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 3.9: success exists with euc-jp ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, removeID: eucjpStr, }, @@ -336,7 +313,6 @@ func Test_server_Remove(t *testing.T) { { name: "Boundary Value Testing case 4.1: success exists with 😀", args: args{ - ctx: ctx, indexID: "😀", removeID: "😀", }, @@ -350,11 +326,14 @@ func Test_server_Remove(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.beforeFunc == nil { test.beforeFunc = defaultBeforeFunc } - s, err := test.beforeFunc(test.args) + s, err := test.beforeFunc(ctx, test.args) if err != nil { tt.Errorf("error = %v", err) } @@ -371,7 +350,7 @@ func Test_server_Remove(t *testing.T) { Id: test.args.removeID, }, } - gotRes, err := s.Remove(test.args.ctx, req) + gotRes, err := s.Remove(ctx, req) if err := checkFunc(test.want, gotRes, err); err != nil { tt.Errorf("error = %v", err) } @@ -455,7 +434,6 @@ func Test_server_StreamRemove(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -565,7 +543,6 @@ func Test_server_MultiRemove(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/handler/grpc/search_test.go b/pkg/agent/core/ngt/handler/grpc/search_test.go index 582f91588c..0ef45898ec 100644 --- a/pkg/agent/core/ngt/handler/grpc/search_test.go +++ b/pkg/agent/core/ngt/handler/grpc/search_test.go @@ -18,6 +18,7 @@ import ( "math" "reflect" "testing" + "time" "github.com/vdaas/vald/apis/grpc/v1/payload" "github.com/vdaas/vald/apis/grpc/v1/vald" @@ -30,7 +31,6 @@ import ( "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/test/data/request" "github.com/vdaas/vald/internal/test/data/vector" - "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/pkg/agent/core/ngt/model" "github.com/vdaas/vald/pkg/agent/core/ngt/service" ) @@ -38,11 +38,7 @@ import ( func Test_server_Search(t *testing.T) { t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - type args struct { - ctx context.Context insertNum int req *payload.Search_Request } @@ -64,7 +60,7 @@ func Test_server_Search(t *testing.T) { fields fields want want checkFunc func(want, *payload.Search_Response, error) error - beforeFunc func(fields, args) (Server, error) + beforeFunc func(context.Context, fields, args) (Server, error) afterFunc func(args) } @@ -75,8 +71,8 @@ func Test_server_Search(t *testing.T) { defaultInsertConfig := &payload.Insert_Config{ SkipStrictExistCheck: true, } - defaultBeforeFunc := func(f fields, a args) (Server, error) { - return buildIndex(a.ctx, f.objectType, f.distribution, a.insertNum, defaultInsertConfig, f.ngtCfg, f.ngtOpts, nil, f.overwriteVec) + defaultBeforeFunc := func(ctx context.Context, f fields, a args) (Server, error) { + return buildIndex(ctx, f.objectType, f.distribution, a.insertNum, defaultInsertConfig, f.ngtCfg, f.ngtOpts, nil, f.overwriteVec) } defaultCheckFunc := func(w want, gotRes *payload.Search_Response, err error) error { if err != nil { @@ -114,7 +110,7 @@ func Test_server_Search(t *testing.T) { Num: 10, Radius: -1, Epsilon: 0.1, - Timeout: 1000000000, + Timeout: int64(time.Second), } genSameVecs := func(ot request.ObjectType, n int, dim int) [][]float32 { var vecs [][]float32 @@ -179,7 +175,6 @@ func Test_server_Search(t *testing.T) { { name: "Equivalence Class Testing case 1.1: success search vector (type: uint8)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.ConvertVectorsUint8ToFloat32(vector.GaussianDistributedUint8VectorGenerator(1, defaultDimensionSize))[0], @@ -198,7 +193,6 @@ func Test_server_Search(t *testing.T) { { name: "Equivalence Class Testing case 1.2: success search vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GaussianDistributedFloat32VectorGenerator(1, defaultDimensionSize)[0], @@ -217,7 +211,6 @@ func Test_server_Search(t *testing.T) { { name: "Equivalence Class Testing case 2.1: fail search vector with different dimension (type: uint8)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.ConvertVectorsUint8ToFloat32(vector.GaussianDistributedUint8VectorGenerator(1, defaultDimensionSize+1))[0], @@ -237,7 +230,6 @@ func Test_server_Search(t *testing.T) { { name: "Equivalence Class Testing case 2.2: fail search vector with different dimension (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GaussianDistributedFloat32VectorGenerator(1, defaultDimensionSize+1)[0], @@ -259,7 +251,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 1.1: success search with 0 value (min value) vector (type: uint8)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GenSameValueVec(defaultDimensionSize, float32(uint8(0))), @@ -278,7 +269,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 1.2: success search with +0 value vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GenSameValueVec(defaultDimensionSize, +0.0), @@ -297,7 +287,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 1.3: success search with -0 value vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GenSameValueVec(defaultDimensionSize, float32(math.Copysign(0, -1.0))), @@ -316,7 +305,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 2.1: success search with max value vector (type: uint8)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GenSameValueVec(defaultDimensionSize, float32(math.MaxUint8)), @@ -335,7 +323,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 2.2: success search with max value vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GenSameValueVec(defaultDimensionSize, math.MaxFloat32), @@ -355,7 +342,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 3.1: success search with min value vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GenSameValueVec(defaultDimensionSize, -math.MaxFloat32), @@ -375,7 +361,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 4.1: fail search with NaN value vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GenSameValueVec(defaultDimensionSize, float32(math.NaN())), @@ -395,7 +380,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 5.1: fail search with Inf value vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GenSameValueVec(defaultDimensionSize, float32(math.Inf(+1.0))), @@ -415,7 +399,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 6.1: fail search with -Inf value vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GenSameValueVec(defaultDimensionSize, float32(math.Inf(-1.0))), @@ -435,7 +418,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 7.1: fail search with 0 length vector (type: uint8)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: []float32{}, @@ -455,7 +437,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 7.2: fail search with 0 length vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: []float32{}, @@ -475,7 +456,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 8.1: fail search with max dimension vector (type: uint8)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.ConvertVectorsUint8ToFloat32(vector.GaussianDistributedUint8VectorGenerator(1, math.MaxInt32>>7))[0], @@ -495,7 +475,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 8.2: fail search with max dimension vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: vector.GaussianDistributedFloat32VectorGenerator(1, math.MaxInt32>>7)[0], @@ -515,7 +494,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 9.1: fail search with nil vector (type: uint8)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: nil, @@ -535,7 +513,6 @@ func Test_server_Search(t *testing.T) { { name: "Boundary Value Testing case 9.2: fail search with nil vector (type: float32)", args: args{ - ctx: ctx, insertNum: 1000, req: &payload.Search_Request{ Vector: nil, @@ -557,7 +534,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 1.1: success search with Search_Config.Num=10 from 5 different vectors (type: uint8)", args: args{ - ctx: ctx, insertNum: 5, req: &payload.Search_Request{ Vector: vector.ConvertVectorsUint8ToFloat32(vector.GaussianDistributedUint8VectorGenerator(1, defaultDimensionSize))[0], @@ -576,7 +552,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 1.2: success search with Search_Config.Num=10 from 5 different vectors (type: float32)", args: args{ - ctx: ctx, insertNum: 5, req: &payload.Search_Request{ Vector: vector.GaussianDistributedFloat32VectorGenerator(1, defaultDimensionSize)[0], @@ -595,7 +570,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 2.1: success search with Search_Config.Num=10 from 10 different vectors (type: uint8)", args: args{ - ctx: ctx, insertNum: 10, req: &payload.Search_Request{ Vector: vector.ConvertVectorsUint8ToFloat32(vector.GaussianDistributedUint8VectorGenerator(1, defaultDimensionSize))[0], @@ -614,7 +588,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 2.2: success search with Search_Config.Num=10 from 10 different vectors (type: float32)", args: args{ - ctx: ctx, insertNum: 10, req: &payload.Search_Request{ Vector: vector.GaussianDistributedFloat32VectorGenerator(1, defaultDimensionSize)[0], @@ -633,7 +606,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 3.1: success search with Search_Config.Num=10 from 20 different vectors (type: uint8)", args: args{ - ctx: ctx, insertNum: 20, req: &payload.Search_Request{ Vector: vector.ConvertVectorsUint8ToFloat32(vector.GaussianDistributedUint8VectorGenerator(1, defaultDimensionSize))[0], @@ -652,7 +624,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 3.2: success search with Search_Config.Num=10 from 20 different vectors (type: float32)", args: args{ - ctx: ctx, insertNum: 20, req: &payload.Search_Request{ Vector: vector.GaussianDistributedFloat32VectorGenerator(1, defaultDimensionSize)[0], @@ -671,7 +642,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 4.1: success search with Search_Config.Num=10 from 5 same vectors (type: uint8)", args: args{ - ctx: ctx, insertNum: 5, req: &payload.Search_Request{ Vector: vector.ConvertVectorsUint8ToFloat32(vector.GaussianDistributedUint8VectorGenerator(1, defaultDimensionSize))[0], @@ -691,7 +661,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 4.2: success search with Search_Config.Num=10 from 5 same vectors (type: float32)", args: args{ - ctx: ctx, insertNum: 5, req: &payload.Search_Request{ Vector: vector.GaussianDistributedFloat32VectorGenerator(1, defaultDimensionSize)[0], @@ -711,7 +680,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 5.1: success search with Search_Config.Num=10 from 10 same vectors (type: uint8)", args: args{ - ctx: ctx, insertNum: 10, req: &payload.Search_Request{ Vector: vector.ConvertVectorsUint8ToFloat32(vector.GaussianDistributedUint8VectorGenerator(1, defaultDimensionSize))[0], @@ -731,7 +699,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 5.2: success search with Search_Config.Num=10 from 10 same vectors (type: float32)", args: args{ - ctx: ctx, insertNum: 10, req: &payload.Search_Request{ Vector: vector.GaussianDistributedFloat32VectorGenerator(1, defaultDimensionSize)[0], @@ -751,7 +718,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 6.1: success search with Search_Config.Num=10 from 20 same vectors (type: uint8)", args: args{ - ctx: ctx, insertNum: 20, req: &payload.Search_Request{ Vector: vector.ConvertVectorsUint8ToFloat32(vector.GaussianDistributedUint8VectorGenerator(1, defaultDimensionSize))[0], @@ -771,7 +737,6 @@ func Test_server_Search(t *testing.T) { { name: "Decision Table Testing case 6.2: success search with Search_Config.Num=10 from 20 same vectors (type: float32)", args: args{ - ctx: ctx, insertNum: 20, req: &payload.Search_Request{ Vector: vector.GaussianDistributedFloat32VectorGenerator(1, defaultDimensionSize)[0], @@ -794,11 +759,14 @@ func Test_server_Search(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.beforeFunc == nil { test.beforeFunc = defaultBeforeFunc } - s, err := test.beforeFunc(test.fields, test.args) + s, err := test.beforeFunc(ctx, test.fields, test.args) if err != nil { tt.Errorf("error = %v", err) } @@ -1148,7 +1116,6 @@ func Test_server_SearchByID(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc == nil { test.beforeFunc = defaultBeforeFunc } @@ -1237,7 +1204,6 @@ func Test_toSearchResponse(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1333,7 +1299,6 @@ func Test_server_StreamSearch(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1436,7 +1401,6 @@ func Test_server_StreamSearchByID(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1546,7 +1510,6 @@ func Test_server_MultiSearch(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1656,7 +1619,6 @@ func Test_server_MultiSearchByID(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/handler/grpc/update_test.go b/pkg/agent/core/ngt/handler/grpc/update_test.go index 41583ed4c6..057f72d9fb 100644 --- a/pkg/agent/core/ngt/handler/grpc/update_test.go +++ b/pkg/agent/core/ngt/handler/grpc/update_test.go @@ -30,22 +30,20 @@ import ( "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/test/data/request" "github.com/vdaas/vald/internal/test/data/vector" - "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/pkg/agent/core/ngt/service" ) func Test_server_Update(t *testing.T) { t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - type args struct { - ctx context.Context indexID string indexVector []float32 req *payload.Update_Request } + type fields struct { + objectType string + } type want struct { code codes.Code wantUUID string @@ -53,6 +51,7 @@ func Test_server_Update(t *testing.T) { type test struct { name string args args + fields fields want want checkFunc func(want, *payload.Object_Location, error) error beforeFunc func(args) (Server, error) @@ -96,7 +95,11 @@ func Test_server_Update(t *testing.T) { defaultInsertConfig := &payload.Insert_Config{ SkipStrictExistCheck: true, } - beforeFunc := func(objectType string) func(args) (Server, error) { + beforeFunc := func(ctx context.Context, objectType string) func(args) (Server, error) { + if objectType == "" { + objectType = ngt.Float.String() + } + cfg := &config.NGT{ Dimension: dimension, DistanceType: ngt.L2.String(), @@ -119,7 +122,7 @@ func Test_server_Update(t *testing.T) { a.indexVector, } } - return buildIndex(a.ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, cfg, nil, []string{a.indexID}, overwriteVec) + return buildIndex(ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, cfg, nil, []string{a.indexID}, overwriteVec) } } @@ -172,7 +175,6 @@ func Test_server_Update(t *testing.T) { { name: "Equivalent Class Testing case 1.1: success update one vector", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -189,7 +191,6 @@ func Test_server_Update(t *testing.T) { { name: "Equivalent Class Testing case 2.1: fail update with non-existent ID", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -205,8 +206,10 @@ func Test_server_Update(t *testing.T) { }, { name: "Equivalent Class Testing case 3.1: fail update with one different dimension vector (type: uint8)", + fields: fields{ + objectType: ngt.Uint8.String(), + }, args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -219,12 +222,10 @@ func Test_server_Update(t *testing.T) { want: want{ code: codes.InvalidArgument, }, - beforeFunc: beforeFunc(ngt.Uint8.String()), }, { name: "Equivalent Class Testint case 3.2: fail update with one different dimension vector (type: float32)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -242,7 +243,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 1.1: fail update with \"\" as ID", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -259,7 +259,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 2.1: success update with ^@ as ID", args: args{ - ctx: ctx, indexID: string([]byte{0}), req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -276,7 +275,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 2.2: success update with ^I as ID", args: args{ - ctx: ctx, indexID: "\t", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -293,7 +291,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 2.3: success update with ^J as ID", args: args{ - ctx: ctx, indexID: "\n", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -310,7 +307,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 2.4: success update with ^M as ID", args: args{ - ctx: ctx, indexID: "\r", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -327,7 +323,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 2.5: success update with ^[ as ID", args: args{ - ctx: ctx, indexID: string([]byte{27}), req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -344,7 +339,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 2.6: success update with ^? as ID", args: args{ - ctx: ctx, indexID: string([]byte{127}), req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -361,7 +355,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 3.1: success update with utf-8 ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -378,7 +371,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 3.2: success update with utf-8 ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -395,7 +387,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 3.3: success update with utf-8 ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -412,7 +403,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 3.4: fail update with s-jis ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -429,7 +419,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 3.5: success update with s-jis ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -446,7 +435,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 3.6: fail update with s-jis ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -463,7 +451,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 3.7: fail update with euc-jp ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -480,7 +467,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 3.8: fail update with euc-jp ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -497,7 +483,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 3.9: success update with euc-jp ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -514,7 +499,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 4.1: success update with 😀 as ID", args: args{ - ctx: ctx, indexID: "😀", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -531,7 +515,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 5.1: success update with one 0 value vector (type: uint8)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -548,7 +531,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 5.2: success update with one +0 value vector (type: float32)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -565,7 +547,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 5.3: success update with one -0 value vector (type: float32)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -582,7 +563,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 6.1: success update with one min value vector (type: uint8)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -599,7 +579,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 6.2: success update with one min value vector (type: float32)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -616,7 +595,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 7.1: success update with one max value vector (type: uint8)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -633,7 +611,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 7.2: success update with one max value vector (type: float32)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -650,7 +627,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 8.1: success update with one NaN value vector (type: float32)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -667,7 +643,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 9.1: success update with one +inf value vector (type: float32)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -684,7 +659,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 9.2: success update with one -inf value vector (type: float32)", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -701,7 +675,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 10.1: fail update with one nil vector", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -718,7 +691,6 @@ func Test_server_Update(t *testing.T) { { name: "Boundary Value Testing case 11.1: fail update with one empty vector", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -738,7 +710,6 @@ func Test_server_Update(t *testing.T) { args: func() args { vector := vector.GaussianDistributedFloat32VectorGenerator(1, dimension)[0] return args{ - ctx: ctx, indexID: "test", indexVector: vector, req: &payload.Update_Request{ @@ -757,7 +728,6 @@ func Test_server_Update(t *testing.T) { { name: "Decision Table Testing case 1.2: success update with one different vector, duplicated ID and SkipStrictExistCheck is true", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -776,7 +746,6 @@ func Test_server_Update(t *testing.T) { args: func() args { vector := vector.GaussianDistributedFloat32VectorGenerator(1, dimension)[0] return args{ - ctx: ctx, indexID: "test", indexVector: vector, req: &payload.Update_Request{ @@ -797,7 +766,6 @@ func Test_server_Update(t *testing.T) { args: func() args { vector := vector.GaussianDistributedFloat32VectorGenerator(1, dimension)[0] return args{ - ctx: ctx, indexID: "test", indexVector: vector, req: &payload.Update_Request{ @@ -818,7 +786,6 @@ func Test_server_Update(t *testing.T) { { name: "Decision Table Testing case 2.2: success update with one duplicated vector, duplicated ID and SkipStrictExistCheck is false", args: args{ - ctx: ctx, indexID: "test", req: &payload.Update_Request{ Vector: &payload.Object_Vector{ @@ -839,7 +806,6 @@ func Test_server_Update(t *testing.T) { args: func() args { vector := vector.GaussianDistributedFloat32VectorGenerator(1, dimension)[0] return args{ - ctx: ctx, indexID: "test", indexVector: vector, req: &payload.Update_Request{ @@ -863,9 +829,12 @@ func Test_server_Update(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.beforeFunc == nil { - test.beforeFunc = beforeFunc(ngt.Float.String()) + test.beforeFunc = beforeFunc(ctx, tc.fields.objectType) } s, err := test.beforeFunc(test.args) if err != nil { @@ -879,7 +848,7 @@ func Test_server_Update(t *testing.T) { checkFunc = defaultCheckFunc } - gotRes, err := s.Update(test.args.ctx, test.args.req) + gotRes, err := s.Update(ctx, test.args.req) if err := checkFunc(test.want, gotRes, err); err != nil { tt.Errorf("error = %v", err) } @@ -963,7 +932,6 @@ func Test_server_StreamUpdate(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1073,7 +1041,6 @@ func Test_server_MultiUpdate(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/handler/grpc/upsert_test.go b/pkg/agent/core/ngt/handler/grpc/upsert_test.go index 6c68018471..64f2407b2d 100644 --- a/pkg/agent/core/ngt/handler/grpc/upsert_test.go +++ b/pkg/agent/core/ngt/handler/grpc/upsert_test.go @@ -30,7 +30,6 @@ import ( "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/test/data/request" "github.com/vdaas/vald/internal/test/data/vector" - "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/pkg/agent/core/ngt/service" ) @@ -1556,9 +1555,10 @@ func Test_server_Upsert(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() + ctx, cancel := context.WithCancel(context.Background()) - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) defer cancel() + if test.beforeFunc == nil { test.beforeFunc = defaultBeforeFunc(ngt.Float.String(), defaultInsertNum) } @@ -1658,7 +1658,6 @@ func Test_server_StreamUpsert(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } @@ -1768,7 +1767,6 @@ func Test_server_MultiUpsert(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { test.beforeFunc(test.args) } diff --git a/pkg/agent/core/ngt/service/kvs/kvs_test.go b/pkg/agent/core/ngt/service/kvs/kvs_test.go index 2e37dfe02c..44c230d952 100644 --- a/pkg/agent/core/ngt/service/kvs/kvs_test.go +++ b/pkg/agent/core/ngt/service/kvs/kvs_test.go @@ -1390,8 +1390,7 @@ func Test_bidi_DeleteInverse(t *testing.T) { func Test_bidi_Range(t *testing.T) { t.Parallel() type args struct { - ctx context.Context - f func(string, uint32) bool + f func(string, uint32) bool } type fields struct { ou [slen]*ou @@ -1438,7 +1437,6 @@ func Test_bidi_Range(t *testing.T) { return test{ name: "rage get successes", args: args{ - ctx: context.Background(), f: func(s string, u uint32) bool { mu.Lock() got[s] = u @@ -1490,7 +1488,6 @@ func Test_bidi_Range(t *testing.T) { return test{ name: "rage get successes when l of fields is 100", args: args{ - ctx: context.Background(), f: func(s string, u uint32) bool { mu.Lock() got[s] = u @@ -1542,7 +1539,6 @@ func Test_bidi_Range(t *testing.T) { return test{ name: "rage get successes when l of fields is maximun value of uint64", args: args{ - ctx: context.Background(), f: func(s string, u uint32) bool { mu.Lock() got[s] = u @@ -1578,11 +1574,14 @@ func Test_bidi_Range(t *testing.T) { t.Run(test.name, func(tt *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + eg, egctx := errgroup.New(ctx) b := &bidi{ ou: test.fields.ou, uo: test.fields.uo, l: test.fields.l, - eg: errgroup.Get(), + eg: eg, } if test.beforeFunc != nil { test.beforeFunc(test.args, b) @@ -1595,7 +1594,7 @@ func Test_bidi_Range(t *testing.T) { checkFunc = defaultCheckFunc } - b.Range(test.args.ctx, test.args.f) + b.Range(egctx, test.args.f) if err := checkFunc(test.want, b); err != nil { tt.Errorf("error = %v", err) } diff --git a/pkg/agent/core/ngt/service/option_test.go b/pkg/agent/core/ngt/service/option_test.go index eee576c819..ec58e6a59a 100644 --- a/pkg/agent/core/ngt/service/option_test.go +++ b/pkg/agent/core/ngt/service/option_test.go @@ -55,7 +55,9 @@ func TestWithErrGroup(t *testing.T) { } tests := []test{ func() test { - eg, _ := errgroup.New(context.Background()) + ctx, cancel := context.WithCancel(context.Background()) + eg, _ := errgroup.New(ctx) + return test{ name: "set success when eg is not nil", args: args{ @@ -66,6 +68,9 @@ func TestWithErrGroup(t *testing.T) { eg: eg, }, }, + afterFunc: func(a args) { + cancel() + }, } }(), { diff --git a/pkg/discoverer/k8s/service/discover.go b/pkg/discoverer/k8s/service/discover.go index 1ee68a4ce8..ae0b656f12 100644 --- a/pkg/discoverer/k8s/service/discover.go +++ b/pkg/discoverer/k8s/service/discover.go @@ -97,8 +97,8 @@ func New(selector *config.Selectors, opts ...Option) (dsc Discoverer, err error) }) }), mnode.WithNamespace(d.namespace), - mnode.WithFields(selector.NodeMetrics.Fields), - mnode.WithLabels(selector.NodeMetrics.Labels), + mnode.WithFields(selector.GetNodeMetricsFields()), + mnode.WithLabels(selector.GetNodeMetricsLabels()), )), k8s.WithResourceController(mpod.New( mpod.WithControllerName("pod metrics discoverer"), @@ -119,8 +119,8 @@ func New(selector *config.Selectors, opts ...Option) (dsc Discoverer, err error) }) }), mpod.WithNamespace(d.namespace), - mpod.WithFields(selector.PodMetrics.Fields), - mpod.WithLabels(selector.PodMetrics.Labels), + mpod.WithFields(selector.GetPodMetricsFields()), + mpod.WithLabels(selector.GetPodMetricsLabels()), )), k8s.WithResourceController(pod.New( pod.WithControllerName("pod discoverer"), @@ -144,8 +144,8 @@ func New(selector *config.Selectors, opts ...Option) (dsc Discoverer, err error) }) }), pod.WithNamespace(d.namespace), - pod.WithFields(selector.Pod.Fields), - pod.WithLabels(selector.Pod.Labels), + pod.WithFields(selector.GetPodFields()), + pod.WithLabels(selector.GetPodLabels()), )), k8s.WithResourceController(node.New( node.WithControllerName("node discoverer"), @@ -168,8 +168,8 @@ func New(selector *config.Selectors, opts ...Option) (dsc Discoverer, err error) }) }), node.WithNamespace(d.namespace), - node.WithFields(selector.Node.Fields), - node.WithLabels(selector.Node.Labels), + node.WithFields(selector.GetNodeFields()), + node.WithLabels(selector.GetNodeLabels()), )), ) if err != nil { diff --git a/tests/chaos/chart/README.md b/tests/chaos/chart/README.md index 228d963c7f..b44b1506ab 100644 --- a/tests/chaos/chart/README.md +++ b/tests/chaos/chart/README.md @@ -40,4 +40,4 @@ A Helm chart for testing Vald using Chaos Mesh. | podChaos.kill.selector.namespaces[0] | string | `"default"` | | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.8.1](https://github.com/norwoodj/helm-docs/releases/v1.8.1) +Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/versions/GO_VERSION b/versions/GO_VERSION index bc4493477a..66e2ae6c25 100644 --- a/versions/GO_VERSION +++ b/versions/GO_VERSION @@ -1 +1 @@ -1.19 +1.19.1