diff --git a/.gitfiles b/.gitfiles index 57a22cb2e3..3461f07a1f 100644 --- a/.gitfiles +++ b/.gitfiles @@ -630,6 +630,7 @@ go.mod go.sum hack/CHANGELOG.template.md hack/actions/gen/main.go +hack/actions/gen/main_test.go hack/benchmark/assets/checksum/fashion-mnist-784-euclidean.md5 hack/benchmark/assets/checksum/gist-960-euclidean.md5 hack/benchmark/assets/checksum/glove-100-angular.md5 @@ -717,6 +718,8 @@ hack/helm/schema/gen/main.go hack/helm/schema/gen/main_test.go hack/license/gen/main.go hack/license/gen/main_test.go +hack/tools/deadlink/index.html +hack/tools/deadlink/main.go hack/tools/kvsdb/main.go hack/tools/metrics/main.go hack/tools/metrics/main_test.go @@ -887,6 +890,7 @@ internal/core/algorithm/ngt/ngt_test.go internal/core/algorithm/ngt/option.go internal/core/algorithm/ngt/option_test.go internal/core/algorithm/usearch/option.go +internal/core/algorithm/usearch/option_test.go internal/core/algorithm/usearch/usearch.go internal/core/algorithm/usearch/usearch_test.go internal/db/kvs/bbolt/bbolt.go @@ -1032,6 +1036,7 @@ internal/errors/tls.go internal/errors/unit.go internal/errors/unit_test.go internal/errors/usearch.go +internal/errors/usearch_test.go internal/errors/vald.go internal/errors/vald_test.go internal/errors/vqueue.go @@ -1161,6 +1166,7 @@ internal/net/grpc/client_test.go internal/net/grpc/codec.go internal/net/grpc/codec_test.go internal/net/grpc/codes/codes.go +internal/net/grpc/codes/codes_test.go internal/net/grpc/context.go internal/net/grpc/context_test.go internal/net/grpc/credentials/credentials.go @@ -1288,6 +1294,8 @@ internal/observability/trace/status_test.go internal/observability/trace/trace.go internal/observability/trace/trace_option.go internal/observability/trace/trace_test.go +internal/os/hostname.go +internal/os/hostname_test.go internal/params/option.go internal/params/option_test.go internal/params/params.go @@ -1702,7 +1710,6 @@ pkg/gateway/filter/router/router.go pkg/gateway/filter/router/router_test.go pkg/gateway/filter/usecase/vald.go pkg/gateway/filter/usecase/vald_test.go -pkg/gateway/internal/location/location_test.go pkg/gateway/lb/README.md pkg/gateway/lb/config/config.go pkg/gateway/lb/config/config_test.go diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 55143b8fda..21c388a3ce 100755 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -23,7 +23,7 @@ assignees: "" - Vald Version: v1.7.13 -- Go Version: v1.23.1 +- Go Version: v1.23.2 - Rust Version: v1.81.0 - Docker Version: v27.3.1 - Kubernetes Version: v1.31.1 diff --git a/.github/ISSUE_TEMPLATE/security_issue_report.md b/.github/ISSUE_TEMPLATE/security_issue_report.md index 8e7fc2d081..ade2f8720f 100644 --- a/.github/ISSUE_TEMPLATE/security_issue_report.md +++ b/.github/ISSUE_TEMPLATE/security_issue_report.md @@ -17,7 +17,7 @@ assignees: "" - Vald Version: v1.7.13 -- Go Version: v1.23.1 +- Go Version: v1.23.2 - Rust Version: v1.81.0 - Docker Version: v27.3.1 - Kubernetes Version: v1.31.1 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a534bf495f..5d46241b71 100755 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -16,7 +16,7 @@ - Vald Version: v1.7.13 -- Go Version: v1.23.1 +- Go Version: v1.23.2 - Rust Version: v1.81.0 - Docker Version: v27.3.1 - Kubernetes Version: v1.31.1 diff --git a/Makefile b/Makefile index 1eb5851603..6480b303a3 100644 --- a/Makefile +++ b/Makefile @@ -139,18 +139,18 @@ GIT_COMMIT := $(eval GIT_COMMIT := $(shell git rev-list -1 HEAD))$(GIT_COMMIT) MAKELISTS := Makefile $(shell find Makefile.d -type f -regex ".*\.mk") ROOTDIR = $(eval ROOTDIR := $(or $(shell git rev-parse --show-toplevel), $(PWD)))$(ROOTDIR) -PROTODIRS := $(eval PROTODIRS := $(shell find apis/proto -type d | sed -e "s%apis/proto/%%g" | grep -v "apis/proto"))$(PROTODIRS) +PROTODIRS := $(eval PROTODIRS := $(shell find $(ROOTDIR)/apis/proto -type d | sed -e "s%apis/proto/%%g" | grep -v "apis/proto"))$(PROTODIRS) BENCH_DATASET_BASE_DIR = hack/benchmark/assets BENCH_DATASET_MD5_DIR_NAME = checksum BENCH_DATASET_HDF5_DIR_NAME = dataset BENCH_DATASET_MD5_DIR = $(BENCH_DATASET_BASE_DIR)/$(BENCH_DATASET_MD5_DIR_NAME) BENCH_DATASET_HDF5_DIR = $(BENCH_DATASET_BASE_DIR)/$(BENCH_DATASET_HDF5_DIR_NAME) -PROTOS := $(eval PROTOS := $(shell find apis/proto -type f -regex ".*\.proto"))$(PROTOS) +PROTOS := $(eval PROTOS := $(shell find $(ROOTDIR)/apis/proto -type f -regex ".*\.proto"))$(PROTOS) PROTOS_V1 := $(eval PROTOS_V1 := $(filter apis/proto/v1/%.proto,$(PROTOS)))$(PROTOS_V1) PBGOS = $(PROTOS:apis/proto/%.proto=apis/grpc/%.pb.go) SWAGGERS = $(PROTOS:apis/proto/%.proto=apis/swagger/%.swagger.json) -PBDOCS = apis/docs/v1/docs.md +PBDOCS = $(ROOTDIR)/apis/docs/v1/docs.md LDFLAGS = -static -fPIC -pthread -std=gnu++23 -lstdc++ -lm -z relro -z now -flto=auto -march=native -mtune=native -fno-plt -Ofast -fvisibility=hidden -ffp-contract=fast -fomit-frame-pointer -fmerge-all-constants -funroll-loops -falign-functions=32 -ffunction-sections -fdata-sections @@ -795,13 +795,13 @@ changelog/update: echo "" >> $(TEMP_DIR)/CHANGELOG.md $(MAKE) -s changelog/next/print >> $(TEMP_DIR)/CHANGELOG.md echo "" >> $(TEMP_DIR)/CHANGELOG.md - tail -n +2 CHANGELOG.md >> $(TEMP_DIR)/CHANGELOG.md - mv -f $(TEMP_DIR)/CHANGELOG.md CHANGELOG.md + tail -n +2 $(ROOTDIR)/CHANGELOG.md >> $(TEMP_DIR)/CHANGELOG.md + mv -f $(TEMP_DIR)/CHANGELOG.md $(ROOTDIR)/CHANGELOG.md .PHONY: changelog/next/print ## print next changelog entry changelog/next/print: - @cat hack/CHANGELOG.template.md | \ + @cat $(ROOTDIR)/hack/CHANGELOG.template.md | \ sed -e 's/{{ version }}/$(VERSION)/g' @echo "$$BODY" diff --git a/Makefile.d/docker.mk b/Makefile.d/docker.mk index b653757ffa..d9ef1ac5f4 100644 --- a/Makefile.d/docker.mk +++ b/Makefile.d/docker.mk @@ -101,7 +101,7 @@ ifeq ($(REMOTE),true) -t $(GHCRORG)/$(IMAGE):$(TAG) \ $(EXTRA_ARGS) \ --output type=registry,oci-mediatypes=true,compression=zstd,compression-level=5,force-compression=true,push=true \ - -f $(DOCKERFILE) . + -f $(DOCKERFILE) $(ROOTDIR) else @echo "starting local build for $(IMAGE):$(TAG)" DOCKER_BUILDKIT=1 $(DOCKER) build \ @@ -113,7 +113,7 @@ else $(EXTRA_ARGS) \ -t $(CRORG)/$(IMAGE):$(TAG) \ -t $(GHCRORG)/$(IMAGE):$(TAG) \ - -f $(DOCKERFILE) . + -f $(DOCKERFILE) $(ROOTDIR) endif .PHONY: docker/name/agent-ngt diff --git a/Makefile.d/functions.mk b/Makefile.d/functions.mk index 9710a92f4a..f9c3312112 100644 --- a/Makefile.d/functions.mk +++ b/Makefile.d/functions.mk @@ -74,7 +74,7 @@ define go-build -X '$(GOPKG)/internal/info.AlgorithmInfo=$5' \ -X '$(GOPKG)/internal/info.BuildCPUInfoFlags=$(CPU_INFO_FLAGS)' \ -X '$(GOPKG)/internal/info.BuildTime=$(DATETIME)' \ - -X '$(GOPKG)/internal/info.CGOEnabled=$(CGO_ENABLED)' \ + -X '$(GOPKG)/internal/info.CGOEnabled=$(if $(filter 1,$(strip $(CGO_ENABLED))),true,false)' \ -X '$(GOPKG)/internal/info.GitCommit=$(GIT_COMMIT)' \ -X '$(GOPKG)/internal/info.GoArch=$(GOARCH)' \ -X '$(GOPKG)/internal/info.GoOS=$(GOOS)' \ @@ -434,4 +434,3 @@ define gen-deadlink-checker $$BIN_PATH -path $3 -ignore-path $4 -format $5 $1; \ rm -rf $$BIN_PATH endef - diff --git a/Makefile.d/git.mk b/Makefile.d/git.mk index ac858a1842..766f0362fe 100644 --- a/Makefile.d/git.mk +++ b/Makefile.d/git.mk @@ -16,7 +16,7 @@ .PHONY: git/config/init ## add git configs required for development git/config/init: - git config commit.template ".commit_template" + git config commit.template "$(ROOTDIR)/.commit_template" git config core.fileMode false .PHONY: git/hooks/init diff --git a/Makefile.d/helm.mk b/Makefile.d/helm.mk index 06d49345c9..c468abe6c7 100644 --- a/Makefile.d/helm.mk +++ b/Makefile.d/helm.mk @@ -37,14 +37,14 @@ $(BINDIR)/helm-docs: .PHONY: helm/package/vald ## packaging Helm chart for Vald helm/package/vald: - helm package charts/vald + helm package $(ROOTDIR)/charts/vald .PHONY: helm/package/vald-helm-operator ## packaging Helm chart for vald-helm-operator helm/package/vald-helm-operator: \ helm/schema/crd/vald \ helm/schema/crd/vald-helm-operator - helm package charts/vald-helm-operator + helm package $(ROOTDIR)/charts/vald-helm-operator .PHONY: helm/package/vald-benchmark-operator ## packaging Helm chart for vald-helm-operator @@ -52,11 +52,11 @@ helm/package/vald-benchmark-operator: \ helm/schema/crd/vald-benchmark-job \ helm/schema/crd/vald-benchmark-scenario \ helm/schema/crd/vald-benchmark-operator - helm package charts/vald-benchmark-operator + helm package $(ROOTDIR)/charts/vald-benchmark-operator .PHONY: helm/package/vald-readreplica helm/package/vald-readreplica: - helm package charts/vald-readreplica + helm package $(ROOTDIR)/charts/vald-readreplica .PHONY: helm/repo/add ## add Helm chart repository @@ -64,42 +64,42 @@ helm/repo/add: helm repo add vald https://vald.vdaas.org/charts .PHONY: helm/docs/vald -helm/docs/vald: charts/vald/README.md +helm/docs/vald: $(ROOTDIR)/charts/vald/README.md # force to rebuild -.PHONY: charts/vald/README.md -charts/vald/README.md: \ - charts/vald/README.md.gotmpl \ - charts/vald/values.yaml +.PHONY: $(ROOTDIR)/charts/vald/README.md +$(ROOTDIR)/charts/vald/README.md: \ + $(ROOTDIR)/charts/vald/README.md.gotmpl \ + $(ROOTDIR)/charts/vald/values.yaml helm-docs .PHONY: helm/docs/vald-helm-operator -helm/docs/vald-helm-operator: charts/vald-helm-operator/README.md +helm/docs/vald-helm-operator: $(ROOTDIR)/charts/vald-helm-operator/README.md # force to rebuild -.PHONY: charts/vald-helm-operator/README.md -charts/vald-helm-operator/README.md: \ - charts/vald-helm-operator/README.md.gotmpl \ - charts/vald-helm-operator/values.yaml +.PHONY: $(ROOTDIR)/charts/vald-helm-operator/README.md +$(ROOTDIR)/charts/vald-helm-operator/README.md: \ + $(ROOTDIR)/charts/vald-helm-operator/README.md.gotmpl \ + $(ROOTDIR)/charts/vald-helm-operator/values.yaml helm-docs .PHONY: helm/docs/vald-readreplica -helm/docs/vald-readreplica: charts/vald-readreplica/README.md +helm/docs/vald-readreplica: $(ROOTDIR)/charts/vald-readreplica/README.md .PHONY: helm/docs/vald-benchmark-operator -helm/docs/vald-benchmark-operator: charts/vald-benchmark-operator/README.md +helm/docs/vald-benchmark-operator: $(ROOTDIR)/charts/vald-benchmark-operator/README.md -.PHONY: charts/vald-benchmark-operator/README.md -charts/vald-benchmark-operator/README.md: \ - charts/vald-benchmark-operator/README.md.gotmpl \ - charts/vald-benchmark-operator/values.yaml +.PHONY: $(ROOTDIR)/charts/vald-benchmark-operator/README.md +$(ROOTDIR)/charts/vald-benchmark-operator/README.md: \ + $(ROOTDIR)/charts/vald-benchmark-operator/README.md.gotmpl \ + $(ROOTDIR)/charts/vald-benchmark-operator/values.yaml helm-docs # force to rebuild -.PHONY: charts/vald-readreplica/README.md -charts/vald-readreplica/README.md: \ - charts/vald-readreplica/README.md.gotmpl \ - charts/vald-readreplica/values.yaml +.PHONY: $(ROOTDIR)/charts/vald-readreplica/README.md +$(ROOTDIR)/charts/vald-readreplica/README.md: \ + $(ROOTDIR)/charts/vald-readreplica/README.md.gotmpl \ + $(ROOTDIR)/charts/vald-readreplica/values.yaml helm-docs .PHONY: helm/schema/all @@ -112,42 +112,42 @@ helm/schema/all: \ .PHONY: helm/schema/vald ## generate json schema for Vald Helm Chart -helm/schema/vald: charts/vald/values.schema.json +helm/schema/vald: $(ROOTDIR)/charts/vald/values.schema.json -charts/vald/values.schema.json: \ - charts/vald/values.yaml +$(ROOTDIR)/charts/vald/values.schema.json: \ + $(ROOTDIR)/charts/vald/values.yaml $(call gen-vald-helm-schema,vald/values) .PHONY: helm/schema/vald-helm-operator ## generate json schema for Vald Helm Operator Chart -helm/schema/vald-helm-operator: charts/vald-helm-operator/values.schema.json +helm/schema/vald-helm-operator: $(ROOTDIR)/charts/vald-helm-operator/values.schema.json -charts/vald-helm-operator/values.schema.json: \ - charts/vald-helm-operator/values.yaml +$(ROOTDIR)/charts/vald-helm-operator/values.schema.json: \ + $(ROOTDIR)/charts/vald-helm-operator/values.yaml $(call gen-vald-helm-schema,vald-helm-operator/values) .PHONY: helm/schema/vald-benchmark-job ## generate json schema for Vald Benchmark Job Chart -helm/schema/vald-benchmark-job: charts/vald-benchmark-operator/job-values.schema.json +helm/schema/vald-benchmark-job: $(ROOTDIR)/charts/vald-benchmark-operator/job-values.schema.json -charts/vald-benchmark-operator/job-values.schema.json: \ - charts/vald-benchmark-operator/schemas/job-values.yaml +$(ROOTDIR)/charts/vald-benchmark-operator/job-values.schema.json: \ + $(ROOTDIR)/charts/vald-benchmark-operator/schemas/job-values.yaml $(call gen-vald-helm-schema,vald-benchmark-operator/schemas/job-values) .PHONY: helm/schema/vald-benchmark-scenario ## generate json schema for Vald Benchmark Job Chart -helm/schema/vald-benchmark-scenario: charts/vald-benchmark-operator/scenario-values.schema.json +helm/schema/vald-benchmark-scenario: $(ROOTDIR)/charts/vald-benchmark-operator/scenario-values.schema.json -charts/vald-benchmark-operator/scenario-values.schema.json: \ - charts/vald-benchmark-operator/schemas/scenario-values.yaml +$(ROOTDIR)/charts/vald-benchmark-operator/scenario-values.schema.json: \ + $(ROOTDIR)/charts/vald-benchmark-operator/schemas/scenario-values.yaml $(call gen-vald-helm-schema,vald-benchmark-operator/schemas/scenario-values) .PHONY: helm/schema/vald-benchmark-operator ## generate json schema for Vald Benchmark Operator Chart -helm/schema/vald-benchmark-operator: charts/vald-benchmark-operator/values.schema.json +helm/schema/vald-benchmark-operator: $(ROOTDIR)/charts/vald-benchmark-operator/values.schema.json -charts/vald-benchmark-operator/values.schema.json: \ - charts/vald-benchmark-operator/values.yaml +$(ROOTDIR)/charts/vald-benchmark-operator/values.schema.json: \ + $(ROOTDIR)/charts/vald-benchmark-operator/values.yaml $(call gen-vald-helm-schema,vald-benchmark-operator/values) .PHONY: yq/install diff --git a/Makefile.d/k8s.mk b/Makefile.d/k8s.mk index 5da9210129..8693f9d2fe 100644 --- a/Makefile.d/k8s.mk +++ b/Makefile.d/k8s.mk @@ -44,19 +44,19 @@ k8s/manifest/update: \ --set gateway.mirror.enabled=true \ --output-dir $(TEMP_DIR) \ charts/vald - mkdir -p k8s/gateway - mkdir -p k8s/manager - mkdir -p k8s/index/job - mkdir -p k8s/index/job/readreplica - mv $(TEMP_DIR)/vald/templates/agent k8s/agent - mv $(TEMP_DIR)/vald/templates/discoverer k8s/discoverer - mv $(TEMP_DIR)/vald/templates/gateway k8s/gateway - mv $(TEMP_DIR)/vald/templates/manager/index k8s/manager/index - mv $(TEMP_DIR)/vald/templates/index/operator k8s/index/operator - mv $(TEMP_DIR)/vald/templates/index/job/correction k8s/index/job/correction - mv $(TEMP_DIR)/vald/templates/index/job/creation k8s/index/job/creation - mv $(TEMP_DIR)/vald/templates/index/job/save k8s/index/job/save - mv $(TEMP_DIR)/vald/templates/index/job/readreplica/rotate k8s/index/job/readreplica/rotate + mkdir -p $(ROOTDIR)/k8s/gateway + mkdir -p $(ROOTDIR)/k8s/manager + mkdir -p $(ROOTDIR)/k8s/index/job + mkdir -p $(ROOTDIR)/k8s/index/job/readreplica + mv $(TEMP_DIR)/vald/templates/agent $(ROOTDIR)/k8s/agent + mv $(TEMP_DIR)/vald/templates/discoverer $(ROOTDIR)/k8s/discoverer + mv $(TEMP_DIR)/vald/templates/gateway $(ROOTDIR)/k8s/gateway + mv $(TEMP_DIR)/vald/templates/manager/index $(ROOTDIR)/k8s/manager/index + mv $(TEMP_DIR)/vald/templates/index/operator $(ROOTDIR)/k8s/index/operator + mv $(TEMP_DIR)/vald/templates/index/job/correction $(ROOTDIR)/k8s/index/job/correction + mv $(TEMP_DIR)/vald/templates/index/job/creation $(ROOTDIR)/k8s/index/job/creation + mv $(TEMP_DIR)/vald/templates/index/job/save $(ROOTDIR)/k8s/index/job/save + mv $(TEMP_DIR)/vald/templates/index/job/readreplica/rotate $(ROOTDIR)/k8s/index/job/readreplica/rotate rm -rf $(TEMP_DIR) .PHONY: k8s/manifest/helm-operator/clean @@ -72,10 +72,10 @@ k8s/manifest/helm-operator/update: \ helm template \ --output-dir $(TEMP_DIR) \ charts/vald-helm-operator - mkdir -p k8s/operator - mv $(TEMP_DIR)/vald-helm-operator/templates k8s/operator/helm + mkdir -p $(ROOTDIR)/k8s/operator + mv $(TEMP_DIR)/vald-helm-operator/templates $(ROOTDIR)/k8s/operator/helm rm -rf $(TEMP_DIR) - cp -r charts/vald-helm-operator/crds k8s/operator/helm/crds + cp -r $(ROOTDIR)/charts/vald-helm-operator/crds $(ROOTDIR)/k8s/operator/helm/crds .PHONY: k8s/manifest/benchmark-operator/clean ## clean k8s manifests for benchmark-operator @@ -90,10 +90,10 @@ k8s/manifest/benchmark-operator/update: \ helm template \ --output-dir $(TEMP_DIR) \ charts/vald-benchmark-operator - mkdir -p k8s/tools/benchmark - mv $(TEMP_DIR)/vald-benchmark-operator/templates k8s/tools/benchmark/operator + mkdir -p $(ROOTDIR)/k8s/tools/benchmark + mv $(TEMP_DIR)/vald-benchmark-operator/templates $(ROOTDIR)/k8s/tools/benchmark/operator rm -rf $(TEMP_DIR) - cp -r charts/vald-benchmark-operator/crds k8s/tools/benchmark/operator/crds + cp -r $(ROOTDIR)/charts/vald-benchmark-operator/crds $(ROOTDIR)/k8s/tools/benchmark/operator/crds .PHONY: k8s/manifest/readreplica/clean ## clean k8s manifests for readreplica @@ -108,7 +108,7 @@ k8s/manifest/readreplica/update: \ helm template \ --output-dir $(TEMP_DIR) \ charts/vald-readreplica - mv $(TEMP_DIR)/vald-readreplica/templates k8s/readreplica + mv $(TEMP_DIR)/vald-readreplica/templates $(ROOTDIR)/k8s/readreplica rm -rf $(TEMP_DIR) .PHONY: k8s/vald/deploy @@ -190,15 +190,15 @@ k8s/multi/vald/deploy: -@kubectl create ns $(MIRROR01_NAMESPACE) -@kubectl create ns $(MIRROR02_NAMESPACE) -@kubectl create ns $(MIRROR03_NAMESPACE) - helm install vald-cluster-01 charts/vald \ + helm install vald-cluster-01 $(ROOTDIR)/charts/vald \ -f $(ROOTDIR)/charts/vald/values/multi-vald/dev-vald-with-mirror.yaml \ -f $(ROOTDIR)/charts/vald/values/multi-vald/dev-vald-01.yaml \ -n $(MIRROR01_NAMESPACE) - helm install vald-cluster-02 charts/vald \ + helm install vald-cluster-02 $(ROOTDIR)/charts/vald \ -f $(ROOTDIR)/charts/vald/values/multi-vald/dev-vald-with-mirror.yaml \ -f $(ROOTDIR)/charts/vald/values/multi-vald/dev-vald-02.yaml \ -n $(MIRROR02_NAMESPACE) - helm install vald-cluster-03 charts/vald \ + helm install vald-cluster-03 $(ROOTDIR)/charts/vald \ -f $(ROOTDIR)/charts/vald/values/multi-vald/dev-vald-with-mirror.yaml \ -f $(ROOTDIR)/charts/vald/values/multi-vald/dev-vald-03.yaml \ -n $(MIRROR03_NAMESPACE) @@ -346,18 +346,18 @@ k8s/external/cert-manager/delete: .PHONY: k8s/external/minio/deploy ## deploy minio k8s/external/minio/deploy: - kubectl apply -f k8s/external/minio/deployment.yaml - kubectl apply -f k8s/external/minio/svc.yaml + kubectl apply -f $(ROOTDIR)/k8s/external/minio/deployment.yaml + kubectl apply -f $(ROOTDIR)/k8s/external/minio/svc.yaml sleep $(K8S_SLEEP_DURATION_FOR_WAIT_COMMAND) kubectl wait --for=condition=ready pod -l app=minio --timeout=600s - kubectl apply -f k8s/external/minio/mb-job.yaml + kubectl apply -f $(ROOTDIR)/k8s/external/minio/mb-job.yaml sleep $(K8S_SLEEP_DURATION_FOR_WAIT_COMMAND) kubectl wait --for=condition=complete job/minio-make-bucket --timeout=600s .PHONY: k8s/external/minio/delete ## delete minio k8s/external/minio/delete: - kubectl delete -f k8s/external/minio + kubectl delete -f $(ROOTDIR)/k8s/external/minio .PHONY: k8s/metrics/metrics-server/deploy ## deploy metrics-serrver @@ -374,12 +374,12 @@ k8s/metrics/metrics-server/delete: .PHONY: k8s/metrics/prometheus/deploy ## deploy prometheus k8s/metrics/prometheus/deploy: - kubectl apply -f k8s/metrics/prometheus + kubectl apply -f $(ROOTDIR)/k8s/metrics/prometheus .PHONY: k8s/metrics/prometheus/delete ## delete prometheus k8s/metrics/prometheus/delete: - kubectl delete -f k8s/metrics/prometheus + kubectl delete -f $(ROOTDIR)/k8s/metrics/prometheus .PHONY: k8s/metrics/prometheus/operator/deploy ## deploy prometheus operator @@ -395,14 +395,14 @@ k8s/metrics/prometheus/operator/delete: .PHONY: k8s/metrics/grafana/deploy ## deploy grafana k8s/metrics/grafana/deploy: - kubectl apply -f k8s/metrics/grafana/dashboards - kubectl apply -f k8s/metrics/grafana + kubectl apply -f $(ROOTDIR)/k8s/metrics/grafana/dashboards + kubectl apply -f $(ROOTDIR)/k8s/metrics/grafana .PHONY: k8s/metrics/grafana/delete ## delete grafana k8s/metrics/grafana/delete: - kubectl delete -f k8s/metrics/grafana/dashboards - kubectl delete -f k8s/metrics/grafana + kubectl delete -f $(ROOTDIR)/k8s/metrics/grafana/dashboards + kubectl delete -f $(ROOTDIR)/k8s/metrics/grafana .PHONY: k8s/metrics/jaeger/deploy ## deploy jaeger @@ -412,63 +412,63 @@ k8s/metrics/jaeger/deploy: kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=jaeger-operator --timeout=60s kubectl wait --for=condition=available deployment/jaeger-jaeger-operator --timeout=60s sleep $(JAEGER_OPERATOR_WAIT_DURATION) - kubectl apply -f k8s/metrics/jaeger/jaeger.yaml + kubectl apply -f $(ROOTDIR)/k8s/metrics/jaeger/jaeger.yaml .PHONY: k8s/metrics/jaeger/delete ## delete jaeger k8s/metrics/jaeger/delete: - kubectl delete -f k8s/metrics/jaeger + kubectl delete -f $(ROOTDIR)/k8s/metrics/jaeger helm uninstall jaeger .PHONY: k8s/metrics/loki/deploy ## deploy loki and promtail k8s/metrics/loki/deploy: - kubectl apply -f k8s/metrics/loki + kubectl apply -f $(ROOTDIR)/k8s/metrics/loki .PHONY: k8s/metrics/loki/delete ## delete loki and promtail k8s/metrics/loki/delete: - kubectl delete -f k8s/metrics/loki + kubectl delete -f $(ROOTDIR)/k8s/metrics/loki .PHONY: k8s/metrics/tempo/deploy ## deploy tempo and jaeger-agent k8s/metrics/tempo/deploy: - kubectl apply -f k8s/metrics/tempo + kubectl apply -f $(ROOTDIR)/k8s/metrics/tempo .PHONY: k8s/metrics/tempo/delete ## delete tempo and jaeger-agent k8s/metrics/tempo/delete: - kubectl delete -f k8s/metrics/tempo + kubectl delete -f $(ROOTDIR)/k8s/metrics/tempo .PHONY: k8s/metrics/profefe/deploy ## deploy profefe k8s/metrics/profefe/deploy: - kubectl apply -f k8s/metrics/profefe + kubectl apply -f $(ROOTDIR)/k8s/metrics/profefe .PHONY: k8s/metrics/profefe/delete ## delete profefe k8s/metrics/profefe/delete: - kubectl delete -f k8s/metrics/profefe + kubectl delete -f $(ROOTDIR)/k8s/metrics/profefe .PHONY: k8s/metrics/pyroscope/deploy ## deploy pyroscope k8s/metrics/pyroscope/deploy: - kubectl apply -k k8s/metrics/pyroscope/base + kubectl apply -k $(ROOTDIR)/k8s/metrics/pyroscope/base .PHONY: k8s/metrics/pyroscope/delete ## delete pyroscope k8s/metrics/pyroscope/delete: - kubectl delete -k k8s/metrics/pyroscope/base + kubectl delete -k $(ROOTDIR)/k8s/metrics/pyroscope/base .PHONY: k8s/metrics/pyroscope/pv/deploy ## deploy pyroscope on persistent volume k8s/metrics/pyroscope/pv/deploy: - kubectl apply -k k8s/metrics/pyroscope/overlay + kubectl apply -k $(ROOTDIR)/k8s/metrics/pyroscope/overlay .PHONY: k8s/metrics/pyroscope/pv/delete ## delete pyroscope on persistent volume k8s/metrics/pyroscope/pv/delete: - kubectl delete -k k8s/metrics/pyroscope/overlay + kubectl delete -k $(ROOTDIR)/k8s/metrics/pyroscope/overlay .PHONY: k8s/linkerd/deploy ## deploy linkerd to k8s diff --git a/Makefile.d/proto.mk b/Makefile.d/proto.mk index 2eef443f91..1870f8aa72 100644 --- a/Makefile.d/proto.mk +++ b/Makefile.d/proto.mk @@ -22,9 +22,9 @@ proto/all: \ .PHONY: proto/clean ## clean proto artifacts proto/clean: - find apis/grpc -name "*.pb.go" | xargs -P$(CORES) rm -f - find apis/grpc -name "*.pb.json.go" | xargs -P$(CORES) rm -f - rm -rf apis/swagger apis/docs + find $(ROOTDIR)/apis/grpc -name "*.pb.go" | xargs -P$(CORES) rm -f + find $(ROOTDIR)/apis/grpc -name "*.pb.json.go" | xargs -P$(CORES) rm -f + rm -rf $(ROOTDIR)/apis/swagger $(ROOTDIR)/apis/docs .PHONY: proto/paths/print ## print proto paths diff --git a/Makefile.d/tools.mk b/Makefile.d/tools.mk index c9968e5d75..f1071faf00 100644 --- a/Makefile.d/tools.mk +++ b/Makefile.d/tools.mk @@ -216,13 +216,15 @@ $(LIB_PATH)/libz.a: $(LIB_PATH) -DBUILD_SHARED_LIBS=OFF \ -DBUILD_STATIC_EXECS=ON \ -DBUILD_TESTING=OFF \ - -DCMAKE_C_FLAGS="-fPIC" \ - -DCMAKE_INSTALL_PREFIX=$(USR_LOCAL) \ -DZLIB_BUILD_SHARED=OFF \ -DZLIB_BUILD_STATIC=ON \ - -DZLIB_USE_STATIC_LIBS=ON \ -DZLIB_COMPAT=ON \ - .. \ + -DZLIB_USE_STATIC_LIBS=ON \ + -DCMAKE_CXX_FLAGS="$(CXXFLAGS)" \ + -DCMAKE_C_FLAGS="$(CFLAGS)" \ + -DCMAKE_INSTALL_LIBDIR=$(LIB_PATH) \ + -DCMAKE_INSTALL_PREFIX=$(USR_LOCAL) \ + -B $(TEMP_DIR)/zlib/build $(TEMP_DIR)/zlib \ && make -j$(CORES) \ && make install \ && cd $(ROOTDIR) \ @@ -234,24 +236,27 @@ hdf5/install: $(LIB_PATH)/libhdf5.a $(LIB_PATH)/libhdf5.a: $(LIB_PATH) \ zlib/install mkdir -p $(TEMP_DIR)/hdf5 \ - && curl -fsSL https://github.com/HDFGroup/hdf5/releases/download/$(HDF5_VERSION)/hdf5.tar.gz -o $(TEMP_DIR)/hdf5.tar.gz \ - && tar -xzvf $(TEMP_DIR)/hdf5.tar.gz -C $(TEMP_DIR)/hdf5 --strip-components 2 \ + && curl -fsSL https://github.com/HDFGroup/hdf5/archive/refs/tags/$(HDF5_VERSION).tar.gz -o $(TEMP_DIR)/hdf5.tar.gz \ + && tar -xzvf $(TEMP_DIR)/hdf5.tar.gz -C $(TEMP_DIR)/hdf5 --strip-components 1 \ && mkdir -p $(TEMP_DIR)/hdf5/build \ && cd $(TEMP_DIR)/hdf5/build \ && cmake -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=OFF \ -DBUILD_STATIC_EXECS=ON \ -DBUILD_TESTING=OFF \ - -DCMAKE_INSTALL_PREFIX=$(USR_LOCAL) \ - -DH5_ZLIB_INCLUDE_DIR=$(USR_LOCAL)/include \ - -DH5_ZLIB_LIBRARY=$(LIB_PATH)/libz.a \ -DHDF5_BUILD_CPP_LIB=OFF \ -DHDF5_BUILD_HL_LIB=ON \ -DHDF5_BUILD_STATIC_EXECS=ON \ -DHDF5_BUILD_TOOLS=OFF \ -DHDF5_ENABLE_Z_LIB_SUPPORT=ON \ - .. \ + -DH5_ZLIB_INCLUDE_DIR=$(USR_LOCAL)/include \ + -DH5_ZLIB_LIBRARY=$(LIB_PATH)/libz.a \ + -DCMAKE_CXX_FLAGS="$(CXXFLAGS)" \ + -DCMAKE_C_FLAGS="$(CFLAGS)" \ + -DCMAKE_INSTALL_LIBDIR=$(LIB_PATH) \ + -DCMAKE_INSTALL_PREFIX=$(USR_LOCAL) \ + -B $(TEMP_DIR)/hdf5/build $(TEMP_DIR)/hdf5 \ && make -j$(CORES) \ && make install \ && cd $(ROOTDIR) \ - && rm -rf $(TEMP_DIR)/hdf5.tar.gz $(TEMP_DIR)/HDF5_VERSION + && rm -rf $(TEMP_DIR)/hdf5.tar.gz $(TEMP_DIR)/hdf5 diff --git a/dockers/agent/core/agent/Dockerfile b/dockers/agent/core/agent/Dockerfile index 9f8e80f25f..1060dbb2ca 100644 --- a/dockers/agent/core/agent/Dockerfile +++ b/dockers/agent/core/agent/Dockerfile @@ -39,8 +39,8 @@ ENV REPO=vald ENV RUST_HOME=/usr/local/lib/rust ENV TZ=Etc/UTC ENV USER=root -ENV RUSTUP_HOME=${RUST_HOME}/rustup ENV CARGO_HOME=${RUST_HOME}/cargo +ENV RUSTUP_HOME=${RUST_HOME}/rustup ENV PATH=${CARGO_HOME}/bin:${RUSTUP_HOME}/bin:/usr/local/bin:${PATH} WORKDIR ${HOME}/rust/src/github.com/${ORG}/${REPO} SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -63,10 +63,10 @@ RUN --mount=type=bind,target=.,rw \ locales \ git \ cmake \ - gcc \ g++ \ - unzip \ + gcc \ libssl-dev \ + unzip \ liblapack-dev \ libomp-dev \ libopenblas-dev \ @@ -93,4 +93,4 @@ LABEL maintainer="vdaas.org vald team " COPY --from=builder /usr/bin/agent /usr/bin/agent # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/agent"] +ENTRYPOINT ["/usr/bin/agent"] \ No newline at end of file diff --git a/dockers/agent/core/faiss/Dockerfile b/dockers/agent/core/faiss/Dockerfile index 7566609ed7..bfd27599f6 100644 --- a/dockers/agent/core/faiss/Dockerfile +++ b/dockers/agent/core/faiss/Dockerfile @@ -66,10 +66,10 @@ RUN --mount=type=bind,target=.,rw \ locales \ git \ cmake \ - gcc \ g++ \ - unzip \ + gcc \ libssl-dev \ + unzip \ liblapack-dev \ libomp-dev \ libopenblas-dev \ @@ -95,4 +95,4 @@ COPY --from=builder /usr/bin/faiss /usr/bin/faiss COPY cmd/agent/core/faiss/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/faiss"] +ENTRYPOINT ["/usr/bin/faiss"] \ No newline at end of file diff --git a/dockers/agent/core/ngt/Dockerfile b/dockers/agent/core/ngt/Dockerfile index d764a800d1..51e564c224 100644 --- a/dockers/agent/core/ngt/Dockerfile +++ b/dockers/agent/core/ngt/Dockerfile @@ -66,10 +66,10 @@ RUN --mount=type=bind,target=.,rw \ locales \ git \ cmake \ - gcc \ g++ \ - unzip \ + gcc \ libssl-dev \ + unzip \ liblapack-dev \ libomp-dev \ libopenblas-dev \ @@ -94,4 +94,4 @@ COPY --from=builder /usr/bin/ngt /usr/bin/ngt COPY cmd/agent/core/ngt/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/ngt"] +ENTRYPOINT ["/usr/bin/ngt"] \ No newline at end of file diff --git a/dockers/agent/sidecar/Dockerfile b/dockers/agent/sidecar/Dockerfile index b4a1d5ed90..5c19e85c8e 100644 --- a/dockers/agent/sidecar/Dockerfile +++ b/dockers/agent/sidecar/Dockerfile @@ -84,4 +84,4 @@ LABEL maintainer="vdaas.org vald team " COPY --from=builder /usr/bin/sidecar /usr/bin/sidecar # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/sidecar"] +ENTRYPOINT ["/usr/bin/sidecar"] \ No newline at end of file diff --git a/dockers/binfmt/Dockerfile b/dockers/binfmt/Dockerfile index f2d73909bd..47284d17e2 100644 --- a/dockers/binfmt/Dockerfile +++ b/dockers/binfmt/Dockerfile @@ -16,4 +16,4 @@ # # DO_NOT_EDIT this Dockerfile is generated by https://github.com/vdaas/vald/blob/main/hack/docker/gen/main.go -FROM tonistiigi/binfmt:master AS builder +FROM tonistiigi/binfmt:master AS builder \ No newline at end of file diff --git a/dockers/buildbase/Dockerfile b/dockers/buildbase/Dockerfile index 301a31e010..6457b01457 100644 --- a/dockers/buildbase/Dockerfile +++ b/dockers/buildbase/Dockerfile @@ -16,4 +16,4 @@ # # DO_NOT_EDIT this Dockerfile is generated by https://github.com/vdaas/vald/blob/main/hack/docker/gen/main.go -FROM ubuntu:devel AS builder +FROM ubuntu:devel AS builder \ No newline at end of file diff --git a/dockers/buildkit/Dockerfile b/dockers/buildkit/Dockerfile index 99c71c61e2..9dd722ea25 100644 --- a/dockers/buildkit/Dockerfile +++ b/dockers/buildkit/Dockerfile @@ -16,4 +16,4 @@ # # DO_NOT_EDIT this Dockerfile is generated by https://github.com/vdaas/vald/blob/main/hack/docker/gen/main.go -FROM moby/buildkit:master AS builder +FROM moby/buildkit:master AS builder \ No newline at end of file diff --git a/dockers/buildkit/syft/scanner/Dockerfile b/dockers/buildkit/syft/scanner/Dockerfile index 4a23207c47..df32fe5705 100644 --- a/dockers/buildkit/syft/scanner/Dockerfile +++ b/dockers/buildkit/syft/scanner/Dockerfile @@ -16,4 +16,4 @@ # # DO_NOT_EDIT this Dockerfile is generated by https://github.com/vdaas/vald/blob/main/hack/docker/gen/main.go -FROM docker/buildkit-syft-scanner:edge AS scanner +FROM docker/buildkit-syft-scanner:edge AS scanner \ No newline at end of file diff --git a/dockers/ci/base/Dockerfile b/dockers/ci/base/Dockerfile index ecbdeceeec..e39363d3d1 100644 --- a/dockers/ci/base/Dockerfile +++ b/dockers/ci/base/Dockerfile @@ -44,8 +44,8 @@ ENV REPO=vald ENV RUST_HOME=/usr/local/lib/rust ENV TZ=Etc/UTC ENV USER=root -ENV CARGO_HOME=${RUST_HOME}/cargo ENV RUSTUP_HOME=${RUST_HOME}/rustup +ENV CARGO_HOME=${RUST_HOME}/cargo ENV PATH=${CARGO_HOME}/bin:${GOPATH}/bin:${GOROOT}/bin:${RUSTUP_HOME}/bin:/usr/local/bin:${PATH} WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -72,21 +72,22 @@ RUN --mount=type=bind,target=.,rw \ git \ npm \ cmake \ - gcc \ g++ \ - unzip \ + gcc \ libssl-dev \ + unzip \ liblapack-dev \ libomp-dev \ libopenblas-dev \ gfortran \ pkg-config \ + file \ gawk \ gnupg2 \ graphviz \ jq \ - libhdf5-dev \ libaec-dev \ + libhdf5-dev \ sed \ zip \ && ldconfig \ @@ -114,16 +115,16 @@ RUN --mount=type=bind,target=.,rw \ && make kind/install \ && make kubectl/install \ && make kubelinter/install \ - && make reviewdog/install \ - && make tparse/install \ - && make yq/install \ && make minikube/install \ + && make reviewdog/install \ && make stern/install \ && make telepresence/install \ + && make tparse/install \ + && make yq/install \ && make ngt/install \ && make faiss/install \ && make usearch/install \ && rm -rf ${GOPATH}/src/github.com/${ORG}/${REPO}/* # skipcq: DOK-DL3002 USER root:root -ENTRYPOINT ["/bin/bash"] +ENTRYPOINT ["/bin/bash"] \ No newline at end of file diff --git a/dockers/dev/Dockerfile b/dockers/dev/Dockerfile index a084f9b51c..3e80596341 100644 --- a/dockers/dev/Dockerfile +++ b/dockers/dev/Dockerfile @@ -77,21 +77,22 @@ RUN --mount=type=bind,target=.,rw \ locales \ git \ cmake \ - gcc \ g++ \ - unzip \ + gcc \ libssl-dev \ + unzip \ liblapack-dev \ libomp-dev \ libopenblas-dev \ gfortran \ pkg-config \ + file \ gawk \ gnupg2 \ graphviz \ jq \ - libhdf5-dev \ libaec-dev \ + libhdf5-dev \ sed \ zip \ && ldconfig \ @@ -134,14 +135,14 @@ RUN --mount=type=bind,target=.,rw \ && make kind/install \ && make kubectl/install \ && make kubelinter/install \ - && make reviewdog/install \ - && make tparse/install \ - && make yq/install \ && make minikube/install \ + && make reviewdog/install \ && make stern/install \ && make telepresence/install \ + && make tparse/install \ + && make yq/install \ && make ngt/install \ && make faiss/install \ && rm -rf ${GOPATH}/src/github.com/${ORG}/${REPO}/* # skipcq: DOK-DL3002 -USER root:root +USER root:root \ No newline at end of file diff --git a/dockers/discoverer/k8s/Dockerfile b/dockers/discoverer/k8s/Dockerfile index a9bf1e5781..84302fe9f6 100644 --- a/dockers/discoverer/k8s/Dockerfile +++ b/dockers/discoverer/k8s/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/discoverer /usr/bin/discoverer COPY cmd/discoverer/k8s/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/discoverer"] +ENTRYPOINT ["/usr/bin/discoverer"] \ No newline at end of file diff --git a/dockers/gateway/filter/Dockerfile b/dockers/gateway/filter/Dockerfile index 4ddc9858e9..c4b3c751aa 100644 --- a/dockers/gateway/filter/Dockerfile +++ b/dockers/gateway/filter/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/filter /usr/bin/filter COPY cmd/gateway/filter/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/filter"] +ENTRYPOINT ["/usr/bin/filter"] \ No newline at end of file diff --git a/dockers/gateway/lb/Dockerfile b/dockers/gateway/lb/Dockerfile index c3bd773deb..8d666ebfa4 100644 --- a/dockers/gateway/lb/Dockerfile +++ b/dockers/gateway/lb/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/lb /usr/bin/lb COPY cmd/gateway/lb/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/lb"] +ENTRYPOINT ["/usr/bin/lb"] \ No newline at end of file diff --git a/dockers/gateway/mirror/Dockerfile b/dockers/gateway/mirror/Dockerfile index 693d891601..eb136bd4ac 100644 --- a/dockers/gateway/mirror/Dockerfile +++ b/dockers/gateway/mirror/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/mirror /usr/bin/mirror COPY cmd/gateway/mirror/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/mirror"] +ENTRYPOINT ["/usr/bin/mirror"] \ No newline at end of file diff --git a/dockers/index/job/correction/Dockerfile b/dockers/index/job/correction/Dockerfile index 1dbefb3c48..96152e486e 100644 --- a/dockers/index/job/correction/Dockerfile +++ b/dockers/index/job/correction/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/index-correction /usr/bin/index-correction COPY cmd/index/job/correction/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/index-correction"] +ENTRYPOINT ["/usr/bin/index-correction"] \ No newline at end of file diff --git a/dockers/index/job/creation/Dockerfile b/dockers/index/job/creation/Dockerfile index 13576d6dc6..3d89245d18 100644 --- a/dockers/index/job/creation/Dockerfile +++ b/dockers/index/job/creation/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/index-creation /usr/bin/index-creation COPY cmd/index/job/creation/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/index-creation"] +ENTRYPOINT ["/usr/bin/index-creation"] \ No newline at end of file diff --git a/dockers/index/job/readreplica/rotate/Dockerfile b/dockers/index/job/readreplica/rotate/Dockerfile index d443e0fcc0..2c5f7cfba9 100644 --- a/dockers/index/job/readreplica/rotate/Dockerfile +++ b/dockers/index/job/readreplica/rotate/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/readreplica-rotate /usr/bin/readreplica-rotate COPY cmd/index/job/readreplica/rotate/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/readreplica-rotate"] +ENTRYPOINT ["/usr/bin/readreplica-rotate"] \ No newline at end of file diff --git a/dockers/index/job/save/Dockerfile b/dockers/index/job/save/Dockerfile index 9ef2ef629c..5c4b9ccc45 100644 --- a/dockers/index/job/save/Dockerfile +++ b/dockers/index/job/save/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/index-save /usr/bin/index-save COPY cmd/index/job/save/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/index-save"] +ENTRYPOINT ["/usr/bin/index-save"] \ No newline at end of file diff --git a/dockers/index/operator/Dockerfile b/dockers/index/operator/Dockerfile index d1ff09eec6..fa713abbd1 100644 --- a/dockers/index/operator/Dockerfile +++ b/dockers/index/operator/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/index-operator /usr/bin/index-operator COPY cmd/index/operator/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/index-operator"] +ENTRYPOINT ["/usr/bin/index-operator"] \ No newline at end of file diff --git a/dockers/manager/index/Dockerfile b/dockers/manager/index/Dockerfile index 2fadc08ebb..5fe2b80e92 100644 --- a/dockers/manager/index/Dockerfile +++ b/dockers/manager/index/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/index /usr/bin/index COPY cmd/manager/index/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/index"] +ENTRYPOINT ["/usr/bin/index"] \ No newline at end of file diff --git a/dockers/operator/helm/Dockerfile b/dockers/operator/helm/Dockerfile index 049914cba3..5e06bc5f31 100644 --- a/dockers/operator/helm/Dockerfile +++ b/dockers/operator/helm/Dockerfile @@ -106,4 +106,4 @@ COPY --from=builder /opt/helm/charts/vald /opt/helm/charts/vald COPY --from=builder /opt/helm/charts/vald-helm-operator /opt/helm/charts/vald-helm-operator # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/helm-operator", "run", "--watches-file=/opt/helm/watches.yaml"] +ENTRYPOINT ["/usr/bin/helm-operator", "run", "--watches-file=/opt/helm/watches.yaml"] \ No newline at end of file diff --git a/dockers/tools/benchmark/job/Dockerfile b/dockers/tools/benchmark/job/Dockerfile index cb2669cb87..92440346c7 100644 --- a/dockers/tools/benchmark/job/Dockerfile +++ b/dockers/tools/benchmark/job/Dockerfile @@ -66,10 +66,10 @@ RUN --mount=type=bind,target=.,rw \ locales \ git \ cmake \ - gcc \ g++ \ - unzip \ + gcc \ libssl-dev \ + unzip \ libhdf5-dev \ libaec-dev \ && ldconfig \ @@ -93,4 +93,4 @@ COPY --from=builder /usr/bin/job /usr/bin/job COPY cmd/tools/benchmark/job/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/job"] +ENTRYPOINT ["/usr/bin/job"] \ No newline at end of file diff --git a/dockers/tools/benchmark/operator/Dockerfile b/dockers/tools/benchmark/operator/Dockerfile index f99fa41491..580eca69f1 100644 --- a/dockers/tools/benchmark/operator/Dockerfile +++ b/dockers/tools/benchmark/operator/Dockerfile @@ -85,4 +85,4 @@ COPY --from=builder /usr/bin/operator /usr/bin/operator COPY cmd/tools/benchmark/operator/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/operator"] +ENTRYPOINT ["/usr/bin/operator"] \ No newline at end of file diff --git a/dockers/tools/cli/loadtest/Dockerfile b/dockers/tools/cli/loadtest/Dockerfile index 594c94eb99..282806ad4c 100644 --- a/dockers/tools/cli/loadtest/Dockerfile +++ b/dockers/tools/cli/loadtest/Dockerfile @@ -66,10 +66,10 @@ RUN --mount=type=bind,target=.,rw \ locales \ git \ cmake \ - gcc \ g++ \ - unzip \ + gcc \ libssl-dev \ + unzip \ libhdf5-dev \ libaec-dev \ && ldconfig \ @@ -93,4 +93,4 @@ COPY --from=builder /usr/bin/loadtest /usr/bin/loadtest COPY cmd/tools/cli/loadtest/sample.yaml /etc/server/config.yaml # skipcq: DOK-DL3002 USER nonroot:nonroot -ENTRYPOINT ["/usr/bin/loadtest"] +ENTRYPOINT ["/usr/bin/loadtest"] \ No newline at end of file diff --git a/example/client/go.mod b/example/client/go.mod index 1b680ca571..0162083b72 100644 --- a/example/client/go.mod +++ b/example/client/go.mod @@ -1,6 +1,6 @@ module github.com/vdaas/vald/example/client -go 1.23.1 +go 1.23.2 replace ( github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v1.1.0 @@ -11,10 +11,10 @@ replace ( golang.org/x/crypto => golang.org/x/crypto v0.27.0 golang.org/x/net => golang.org/x/net v0.29.0 golang.org/x/text => golang.org/x/text v0.18.0 - google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240924160255-9d4c2d233b61 - google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240924160255-9d4c2d233b61 - google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 - google.golang.org/grpc => google.golang.org/grpc v1.67.0 + google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240930140551-af27646dc61f + google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f + google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f + google.golang.org/grpc => google.golang.org/grpc v1.67.1 google.golang.org/protobuf => google.golang.org/protobuf v1.34.2 gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1 @@ -37,6 +37,6 @@ require ( golang.org/x/sys v0.25.0 // indirect golang.org/x/text v0.18.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 // indirect google.golang.org/protobuf v1.34.2 // indirect ) diff --git a/example/client/go.mod.default b/example/client/go.mod.default index a1ab487b5a..205d365b8e 100644 --- a/example/client/go.mod.default +++ b/example/client/go.mod.default @@ -1,6 +1,6 @@ module github.com/vdaas/vald/example/client -go 1.23.1 +go 1.23.2 replace ( github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate latest diff --git a/example/client/go.sum b/example/client/go.sum index 215ea70b56..21700f4311 100644 --- a/example/client/go.sum +++ b/example/client/go.sum @@ -30,11 +30,11 @@ golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= 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/googleapis/api v0.0.0-20240924160255-9d4c2d233b61 h1:pAjq8XSSzXoP9ya73v/w+9QEAAJNluLrpmMq5qFJQNY= -google.golang.org/genproto/googleapis/api v0.0.0-20240924160255-9d4c2d233b61/go.mod h1:O6rP0uBq4k0mdi/b4ZEMAZjkhYWhS815kCvaMha4VN8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 h1:N9BgCIAUvn/M+p4NJccWPWb3BWh88+zyL0ll9HgbEeM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= -google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f h1:jTm13A2itBi3La6yTGqn8bVSrc3ZZ1r8ENHlIXBfnRA= +google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f/go.mod h1:CLGoBuH1VHxAUXVPP8FfPwPEVJB6lz3URE5mY2SuayE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f h1:cUMEy+8oS78BWIH9OWazBkzbr090Od9tWBNtZHkOhf0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= diff --git a/go.mod b/go.mod index 9dd20907f9..e21ae9375a 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/vdaas/vald -go 1.23.1 +go 1.23.2 replace ( cloud.google.com/go => cloud.google.com/go v0.115.1 - cloud.google.com/go/bigquery => cloud.google.com/go/bigquery v1.63.0 + cloud.google.com/go/bigquery => cloud.google.com/go/bigquery v1.63.1 cloud.google.com/go/compute => cloud.google.com/go/compute v1.28.1 cloud.google.com/go/datastore => cloud.google.com/go/datastore v1.19.0 cloud.google.com/go/firestore => cloud.google.com/go/firestore v1.17.0 @@ -15,7 +15,7 @@ replace ( cloud.google.com/go/secretmanager => cloud.google.com/go/secretmanager v1.14.1 cloud.google.com/go/storage => cloud.google.com/go/storage v1.43.0 cloud.google.com/go/trace => cloud.google.com/go/trace v1.11.1 - code.cloudfoundry.org/bytefmt => code.cloudfoundry.org/bytefmt v0.10.0 + code.cloudfoundry.org/bytefmt => code.cloudfoundry.org/bytefmt v0.11.0 contrib.go.opencensus.io/exporter/aws => contrib.go.opencensus.io/exporter/aws v0.0.0-20230502192102-15967c811cec 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 @@ -25,7 +25,7 @@ replace ( github.com/Azure/azure-sdk-for-go/sdk/azcore => github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity => github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/internal => github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 - github.com/Azure/go-amqp => github.com/Azure/go-amqp v1.1.0 + github.com/Azure/go-amqp => github.com/Azure/go-amqp v1.2.0 github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.2.1-0.20240530140449-f7ea664c9cff+incompatible github.com/Azure/go-autorest/autorest => github.com/Azure/go-autorest/autorest v0.11.30-0.20240530140449-f7ea664c9cff github.com/Azure/go-autorest/autorest/adal => github.com/Azure/go-autorest/autorest/adal v0.9.24 @@ -47,10 +47,10 @@ replace ( github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.55.5 github.com/aws/aws-sdk-go-v2 => github.com/aws/aws-sdk-go-v2 v1.31.0 github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream => github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5 - github.com/aws/aws-sdk-go-v2/config => github.com/aws/aws-sdk-go-v2/config v1.27.38 - github.com/aws/aws-sdk-go-v2/credentials => github.com/aws/aws-sdk-go-v2/credentials v1.17.36 + github.com/aws/aws-sdk-go-v2/config => github.com/aws/aws-sdk-go-v2/config v1.27.39 + github.com/aws/aws-sdk-go-v2/credentials => github.com/aws/aws-sdk-go-v2/credentials v1.17.37 github.com/aws/aws-sdk-go-v2/feature/ec2/imds => github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 - github.com/aws/aws-sdk-go-v2/feature/s3/manager => github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.24 + github.com/aws/aws-sdk-go-v2/feature/s3/manager => github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.26 github.com/aws/aws-sdk-go-v2/internal/configsources => github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 => github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 github.com/aws/aws-sdk-go-v2/internal/ini => github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 @@ -58,14 +58,14 @@ replace ( github.com/aws/aws-sdk-go-v2/service/internal/checksum => github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.20 github.com/aws/aws-sdk-go-v2/service/internal/presigned-url => github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 github.com/aws/aws-sdk-go-v2/service/internal/s3shared => github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.18 - github.com/aws/aws-sdk-go-v2/service/kms => github.com/aws/aws-sdk-go-v2/service/kms v1.36.2 - github.com/aws/aws-sdk-go-v2/service/s3 => github.com/aws/aws-sdk-go-v2/service/s3 v1.63.2 - github.com/aws/aws-sdk-go-v2/service/secretsmanager => github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.33.2 - github.com/aws/aws-sdk-go-v2/service/sns => github.com/aws/aws-sdk-go-v2/service/sns v1.32.2 - github.com/aws/aws-sdk-go-v2/service/sqs => github.com/aws/aws-sdk-go-v2/service/sqs v1.35.2 - github.com/aws/aws-sdk-go-v2/service/ssm => github.com/aws/aws-sdk-go-v2/service/ssm v1.54.2 - github.com/aws/aws-sdk-go-v2/service/sso => github.com/aws/aws-sdk-go-v2/service/sso v1.23.2 - github.com/aws/aws-sdk-go-v2/service/sts => github.com/aws/aws-sdk-go-v2/service/sts v1.31.2 + github.com/aws/aws-sdk-go-v2/service/kms => github.com/aws/aws-sdk-go-v2/service/kms v1.36.3 + github.com/aws/aws-sdk-go-v2/service/s3 => github.com/aws/aws-sdk-go-v2/service/s3 v1.64.0 + github.com/aws/aws-sdk-go-v2/service/secretsmanager => github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.33.3 + github.com/aws/aws-sdk-go-v2/service/sns => github.com/aws/aws-sdk-go-v2/service/sns v1.32.3 + github.com/aws/aws-sdk-go-v2/service/sqs => github.com/aws/aws-sdk-go-v2/service/sqs v1.35.3 + github.com/aws/aws-sdk-go-v2/service/ssm => github.com/aws/aws-sdk-go-v2/service/ssm v1.54.3 + github.com/aws/aws-sdk-go-v2/service/sso => github.com/aws/aws-sdk-go-v2/service/sso v1.23.3 + github.com/aws/aws-sdk-go-v2/service/sts => github.com/aws/aws-sdk-go-v2/service/sts v1.31.3 github.com/aws/smithy-go => github.com/aws/smithy-go v1.21.0 github.com/benbjohnson/clock => github.com/benbjohnson/clock v1.3.5 github.com/beorn7/perks => github.com/beorn7/perks v1.0.1 @@ -132,7 +132,7 @@ replace ( github.com/gobwas/pool => github.com/gobwas/pool v0.2.1 github.com/gobwas/ws => github.com/gobwas/ws v1.4.0 github.com/goccy/go-json => github.com/goccy/go-json v0.10.3 - github.com/gocql/gocql => github.com/gocql/gocql v1.6.0 + github.com/gocql/gocql => github.com/gocql/gocql v1.7.0 github.com/gocraft/dbr/v2 => github.com/gocraft/dbr/v2 v2.7.6 github.com/godbus/dbus/v5 => github.com/godbus/dbus/v5 v5.1.0 github.com/gofrs/uuid => github.com/gofrs/uuid v4.4.0+incompatible @@ -154,7 +154,7 @@ replace ( github.com/google/gofuzz => github.com/google/gofuzz v1.2.0 github.com/google/martian => github.com/google/martian v2.1.0+incompatible github.com/google/martian/v3 => github.com/google/martian/v3 v3.3.3 - github.com/google/pprof => github.com/google/pprof v0.0.0-20240925223930-fa3061bff0bc + github.com/google/pprof => github.com/google/pprof v0.0.0-20241001023024-f4c0cfd0cf1d github.com/google/shlex => github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/subcommands => github.com/google/subcommands v1.2.0 github.com/google/uuid => github.com/google/uuid v1.6.0 @@ -166,7 +166,7 @@ replace ( github.com/gregjones/httpcache => github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 github.com/hailocab/go-hostpool => github.com/kpango/go-hostpool v0.0.0-20210303030322-aab80263dcd0 - github.com/hanwen/go-fuse/v2 => github.com/hanwen/go-fuse/v2 v2.5.1 + github.com/hanwen/go-fuse/v2 => github.com/hanwen/go-fuse/v2 v2.6.1 github.com/hashicorp/go-uuid => github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/go-version => github.com/hashicorp/go-version v1.7.0 github.com/iancoleman/strcase => github.com/iancoleman/strcase v0.3.0 @@ -192,7 +192,7 @@ replace ( github.com/jstemmer/go-junit-report => github.com/jstemmer/go-junit-report v1.0.0 github.com/kisielk/errcheck => github.com/kisielk/errcheck v1.7.0 github.com/kisielk/gotool => github.com/kisielk/gotool v1.0.0 - github.com/klauspost/compress => github.com/klauspost/compress v1.17.11-0.20240923131516-13a1ce6df1e0 + github.com/klauspost/compress => github.com/klauspost/compress v1.17.11-0.20241002081118-f2a4f2583ec1 github.com/klauspost/cpuid/v2 => github.com/klauspost/cpuid/v2 v2.2.8 github.com/kpango/fastime => github.com/kpango/fastime v1.1.9 github.com/kpango/fuid => github.com/kpango/fuid v0.0.0-20221203053508-503b5ad89aa1 @@ -239,7 +239,7 @@ replace ( github.com/prashantv/gostub => github.com/prashantv/gostub v1.1.0 github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.20.4 github.com/prometheus/client_model => github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common => github.com/prometheus/common v0.59.1 + github.com/prometheus/common => github.com/prometheus/common v0.60.0 github.com/prometheus/procfs => github.com/prometheus/procfs v0.15.1 github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.99.0 github.com/quasilyte/go-ruleguard => github.com/quasilyte/go-ruleguard v0.4.2 @@ -299,7 +299,7 @@ replace ( golang.org/x/exp/typeparams => golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 golang.org/x/image => golang.org/x/image v0.20.0 golang.org/x/lint => golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 - golang.org/x/mobile => golang.org/x/mobile v0.0.0-20240909163608-642950227fb3 + golang.org/x/mobile => golang.org/x/mobile v0.0.0-20240930194658-c6794c95c70b golang.org/x/mod => golang.org/x/mod v0.21.0 golang.org/x/net => golang.org/x/net v0.29.0 golang.org/x/oauth2 => golang.org/x/oauth2 v0.23.0 @@ -316,10 +316,10 @@ replace ( gonum.org/v1/plot => gonum.org/v1/plot v0.14.0 google.golang.org/api => google.golang.org/api v0.199.0 google.golang.org/appengine => google.golang.org/appengine v1.6.8 - google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240924160255-9d4c2d233b61 - google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240924160255-9d4c2d233b61 - google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 - google.golang.org/grpc => google.golang.org/grpc v1.67.0 + google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240930140551-af27646dc61f + google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f + google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f + google.golang.org/grpc => google.golang.org/grpc v1.67.1 google.golang.org/grpc/cmd/protoc-gen-go-grpc => google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 google.golang.org/protobuf => google.golang.org/protobuf v1.34.2 gopkg.in/check.v1 => gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c @@ -380,7 +380,7 @@ require ( github.com/quasilyte/go-ruleguard/dsl v0.3.22 github.com/scylladb/gocqlx v0.0.0-00010101000000-000000000000 github.com/stretchr/testify v1.9.0 - github.com/unum-cloud/usearch/golang v0.0.0-20240828190432-b9a9758a06e1 + github.com/unum-cloud/usearch/golang v0.0.0-20240928043120-b3da75964080 github.com/zeebo/xxh3 v1.0.2 go.etcd.io/bbolt v1.3.8 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 @@ -406,8 +406,8 @@ require ( golang.org/x/tools v0.25.0 gonum.org/v1/hdf5 v0.0.0-00010101000000-000000000000 gonum.org/v1/plot v0.14.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 - google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 + google.golang.org/genproto/googleapis/api v0.0.0-20240924160255-9d4c2d233b61 + google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 google.golang.org/grpc v1.67.0 google.golang.org/protobuf v1.34.2 gopkg.in/yaml.v2 v2.4.0 @@ -462,7 +462,7 @@ require ( github.com/google/btree v1.1.3 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20240910150728-a0b0bb1d4134 // indirect + github.com/google/pprof v0.0.0-20240929191954-255acd752d31 // indirect github.com/google/s2a-go v0.1.8 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/wire v0.6.0 // indirect @@ -490,7 +490,7 @@ require ( github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.20.0 // indirect + github.com/prometheus/client_golang v1.20.4 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect diff --git a/go.sum b/go.sum index 5d8173de0d..aef89bc0a1 100644 --- a/go.sum +++ b/go.sum @@ -37,7 +37,7 @@ cloud.google.com/go/automl v1.14.1/go.mod h1:BocG5mhT32cjmf5CXxVsdSM04VXzJW7chVT cloud.google.com/go/baremetalsolution v1.3.1/go.mod h1:D1djGGmBl4M6VlyjOMc1SEzDYlO4EeEG1TCUv5mCPi0= cloud.google.com/go/batch v1.11.0/go.mod h1:dS/ceyT1eUmQUPtRGvSaXsb8Aa4M3nCc8LIn0qUYiL4= cloud.google.com/go/beyondcorp v1.1.1/go.mod h1:L09o0gLkgXMxCZs4qojrgpI2/dhWtasMc71zPPiHMn4= -cloud.google.com/go/bigquery v1.63.0/go.mod h1:TQto6OR4kw27bqjNTGkVk1Vo5PJlTgxvDJn6YEIZL/E= +cloud.google.com/go/bigquery v1.63.1/go.mod h1:ufaITfroCk17WTqBhMpi8CRjsfHjMX07pDrQaRKKX2o= cloud.google.com/go/bigtable v1.18.1/go.mod h1:NAVyfJot9jlo+KmgWLUJ5DJGwNDoChzAcrecLpmuAmY= cloud.google.com/go/bigtable v1.20.0/go.mod h1:upJDn8frsjzpRMfybiWkD1PG6WCCL7CRl26MgVeoXY4= cloud.google.com/go/bigtable v1.33.0/go.mod h1:HtpnH4g25VT1pejHRtInlFPnN5sjTxbQlsYBjh9t5l0= @@ -45,7 +45,7 @@ cloud.google.com/go/billing v1.19.1/go.mod h1:c5l7ORJjOLH/aASJqUqNsEmwrhfjWZYHX+ cloud.google.com/go/binaryauthorization v1.9.1/go.mod h1:jqBzP68bfzjoiMFT6Q1EdZtKJG39zW9ywwzHuv7V8ms= cloud.google.com/go/certificatemanager v1.9.1/go.mod h1:a6bXZULtd6iQTRuSVs1fopcHLMJ/T3zSpIB7aJaq/js= cloud.google.com/go/channel v1.18.1/go.mod h1:aitAlN/pIlbtjVWsNjbJT5FZRpvwjZtcnYp5ALsb7rA= -cloud.google.com/go/cloudbuild v1.17.1/go.mod h1:L3Y9HrIRFRg92SyCM3aThSgHnWdNSHm6gDUFRb+iQ9A= +cloud.google.com/go/cloudbuild v1.18.0/go.mod h1:KCHWGIoS/5fj+By9YmgIQnUiDq8P6YURWOjX3hoc6As= cloud.google.com/go/clouddms v1.8.1/go.mod h1:bmW2eDFH1LjuwkHcKKeeppcmuBGS0r6Qz6TXanehKP0= cloud.google.com/go/cloudtasks v1.13.1/go.mod h1:dyRD7tEEkLMbHLagb7UugkDa77UVJp9d/6O9lm3ModI= cloud.google.com/go/compute v1.28.1/go.mod h1:b72iXMY4FucVry3NR3Li4kVyyTvbMDE7x5WsqvxjsYk= @@ -59,19 +59,18 @@ cloud.google.com/go/compute/metadata v0.5.2/go.mod h1:C66sj2AluDcIqakBq/M8lw8/yb cloud.google.com/go/contactcenterinsights v1.14.1/go.mod h1:OxSWVQxosMh18KCQ3D5UZWYxVrOcK9xrJCV5waxD2dY= cloud.google.com/go/container v1.40.0/go.mod h1:wNI1mOUivm+ZkpHMbouutgbD4sQxyphMwK31X5cThY4= cloud.google.com/go/containeranalysis v0.13.1/go.mod h1:bmd9H880BNR4Hc8JspEg8ge9WccSQfO+/N+CYvU3sEA= -cloud.google.com/go/datacatalog v1.22.0/go.mod h1:4Wff6GphTY6guF5WphrD76jOdfBiflDiRGFAxq7t//I= cloud.google.com/go/datacatalog v1.22.1/go.mod h1:MscnJl9B2lpYlFoxRjicw19kFTwEke8ReKL5Y/6TWg8= cloud.google.com/go/dataflow v0.10.1/go.mod h1:zP4/tNjONFRcS4NcI9R94YDQEkPalimdbPkijVNJt/g= cloud.google.com/go/dataform v0.10.1/go.mod h1:c5y0hIOBCfszmBcLJyxnELF30gC1qC/NeHdmkzA7TNQ= cloud.google.com/go/datafusion v1.8.1/go.mod h1:I5+nRt6Lob4g1eCbcxP4ayRNx8hyOZ8kA3PB/vGd9Lo= cloud.google.com/go/datalabeling v0.9.1/go.mod h1:umplHuZX+x5DItNPV5BFBXau5TDsljLNzEj5AB5uRUM= cloud.google.com/go/dataplex v1.19.1/go.mod h1:WzoQ+vcxrAyM0cjJWmluEDVsg7W88IXXCfuy01BslKE= -cloud.google.com/go/dataproc/v2 v2.8.0/go.mod h1:i4365hSwNP6Bx0SAUnzCC6VloeNxChDjJWH6BfVPcbs= +cloud.google.com/go/dataproc/v2 v2.9.0/go.mod h1:i4365hSwNP6Bx0SAUnzCC6VloeNxChDjJWH6BfVPcbs= cloud.google.com/go/dataqna v0.9.1/go.mod h1:86DNLE33yEfNDp5F2nrITsmTYubMbsF7zQRzC3CcZrY= cloud.google.com/go/datastore v1.19.0/go.mod h1:KGzkszuj87VT8tJe67GuB+qLolfsOt6bZq/KFuWaahc= cloud.google.com/go/datastream v1.11.1/go.mod h1:a4j5tnptIxdZ132XboR6uQM/ZHcuv/hLqA6hH3NJWgk= cloud.google.com/go/deploy v1.22.1/go.mod h1:OEV1lWIaXrAnOEayZekdR5YwHW03EA6BFNr09D8R+lY= -cloud.google.com/go/dialogflow v1.57.1/go.mod h1:ARkUX3FWRg1wl0hq/VP/heydctZ6nj/WqiXrrXtjxCE= +cloud.google.com/go/dialogflow v1.58.0/go.mod h1:sWcyFLdUrg+TWBJVq/OtwDyjcyDOfirTF0Gx12uKy7o= cloud.google.com/go/dlp v1.19.0/go.mod h1:cr8dKBq8un5LALiyGkz4ozcwzt3FyTlOwA4/fFzJ64c= cloud.google.com/go/documentai v1.34.0/go.mod h1:onJlbHi4ZjQTsANSZJvW7fi2M8LZJrrupXkWDcy4gLY= cloud.google.com/go/domains v0.10.1/go.mod h1:RjDl3K8iq/ZZHMVqfZzRuBUr5t85gqA6LEXQBeBL5F4= @@ -104,13 +103,12 @@ cloud.google.com/go/longrunning v0.5.2/go.mod h1:nqo6DQbNV2pXhGDbDMoN2bWz68MjZUz cloud.google.com/go/longrunning v0.5.6/go.mod h1:vUaDrWYOMKRuhiv6JBnn49YxCPz2Ayn9GqyjaBT8/mA= cloud.google.com/go/longrunning v0.5.7/go.mod h1:8GClkudohy1Fxm3owmBGid8W0pSgodEMwEAztp38Xng= cloud.google.com/go/longrunning v0.5.9/go.mod h1:HD+0l9/OOW0za6UWdKJtXoFAX/BGg/3Wj8p10NeWF7c= -cloud.google.com/go/longrunning v0.5.11/go.mod h1:rDn7//lmlfWV1Dx6IB4RatCPenTwwmqXuiP0/RgoEO4= cloud.google.com/go/longrunning v0.5.12/go.mod h1:S5hMV8CDJ6r50t2ubVJSKQVv5u0rmik5//KgLO3k4lU= cloud.google.com/go/longrunning v0.6.0/go.mod h1:uHzSZqW89h7/pasCWNYdUpwGz3PcVWhrWupreVPYLts= cloud.google.com/go/longrunning v0.6.1 h1:lOLTFxYpr8hcRtcwWir5ITh1PAKUD/sG2lKrTSYjyMc= cloud.google.com/go/longrunning v0.6.1/go.mod h1:nHISoOZpBcmlwbJmiVk5oDRz0qG/ZxPynEGs1iZ79s0= cloud.google.com/go/managedidentities v1.7.1/go.mod h1:iK4qqIBOOfePt5cJR/Uo3+uol6oAVIbbG7MGy917cYM= -cloud.google.com/go/maps v1.13.0/go.mod h1:UepOes9un0UP7i8JBiaqgh8jqUaZAHVRXCYjrVlhSC8= +cloud.google.com/go/maps v1.14.0/go.mod h1:UepOes9un0UP7i8JBiaqgh8jqUaZAHVRXCYjrVlhSC8= cloud.google.com/go/mediatranslation v0.9.1/go.mod h1:vQH1amULNhSGryBjbjLb37g54rxrOwVxywS8WvUCsIU= cloud.google.com/go/memcache v1.11.1/go.mod h1:3zF+dEqmEmElHuO4NtHiShekQY5okQtssjPBv7jpmZ8= cloud.google.com/go/metastore v1.14.1/go.mod h1:WDvsAcbQLl9M4xL+eIpbKogH7aEaPWMhO9aRBcFOnJE= @@ -144,7 +142,7 @@ cloud.google.com/go/security v1.18.1/go.mod h1:5P1q9rqwt0HuVeL9p61pTqQ6Lgio1c64j cloud.google.com/go/securitycenter v1.35.1/go.mod h1:UDeknPuHWi15TaxrJCIv3aN1VDTz9nqWVUmW2vGayTo= cloud.google.com/go/servicedirectory v1.12.1/go.mod h1:d2H6joDMjnTQ4cUUCZn6k9NgZFbXjLVJbHETjoJR9k0= cloud.google.com/go/shell v1.8.1/go.mod h1:jaU7OHeldDhTwgs3+clM0KYEDYnBAPevUI6wNLf7ycE= -cloud.google.com/go/spanner v1.67.0/go.mod h1:Um+TNmxfcCHqNCKid4rmAMvoe/Iu1vdz6UfxJ9GPxRQ= +cloud.google.com/go/spanner v1.68.0/go.mod h1:X5T0XftydYp0K1adeJQDJtdWpbrOeJ7wHecM4tK6FiE= cloud.google.com/go/speech v1.25.1/go.mod h1:WgQghvghkZ1htG6BhYn98mP7Tg0mti8dBFDLMVXH/vM= cloud.google.com/go/storage v1.43.0 h1:CcxnSohZwizt4LCzQHWvBf1/kvtHUn7gk9QERXPyXFs= cloud.google.com/go/storage v1.43.0/go.mod h1:ajvxEa7WmZS1PxvKRq4bq0tFT3vMd502JwstCcYv0Q0= @@ -164,8 +162,8 @@ cloud.google.com/go/vpcaccess v1.8.1/go.mod h1:cWlLCpLOuMH8oaNmobaymgmLesasLd9w1 cloud.google.com/go/webrisk v1.10.1/go.mod h1:VzmUIag5P6V71nVAuzc7Hu0VkIDKjDa543K7HOulH/k= cloud.google.com/go/websecurityscanner v1.7.1/go.mod h1:vAZ6hyqECDhgF+gyVRGzfXMrURQN5NH75Y9yW/7sSHU= cloud.google.com/go/workflows v1.13.1/go.mod h1:xNdYtD6Sjoug+khNCAtBMK/rdh8qkjyL6aBas2XlkNc= -code.cloudfoundry.org/bytefmt v0.10.0 h1:q/n3VEyTHSYIr+MTRIYxNMRutBilgv0gbFWZbXqWI60= -code.cloudfoundry.org/bytefmt v0.10.0/go.mod h1:FQhPpsF//guTvK6ZnAC2JkVRZjl6s5ee0H90K2r3zxI= +code.cloudfoundry.org/bytefmt v0.11.0 h1:nyYr03vV/5apByN4lYr1vYM4/KKrM9Fc2PFQVmYRbi0= +code.cloudfoundry.org/bytefmt v0.11.0/go.mod h1:9nh0kJEX7nqb9l+byNdSy4xRtWeHy98a/P1Z0zdEnOE= dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20221208032759-85de2813cf6b/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA= @@ -194,6 +192,7 @@ github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2 github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0/go.mod h1:dppbR7CwXD4pgtV9t3wD1812RaLDcBjtblcDF5f1vI0= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.1/go.mod h1:itPGVDKf9cC/ov4MdvJ2QZ0khw4bfoo9jzwTJlaxy2k= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I= github.com/ajstarks/deck v0.0.0-20240918141114-8d365813662d/go.mod h1:5o5HzZ3nUiOivE0SPQepE7oNquDd+9yip0PtlFpq888= @@ -224,14 +223,14 @@ github.com/aws/aws-sdk-go-v2 v1.31.0 h1:3V05LbxTSItI5kUqNwhJrrrY1BAXxXt0sN0l72Qm github.com/aws/aws-sdk-go-v2 v1.31.0/go.mod h1:ztolYtaEUtdpf9Wftr31CJfLVjOnD/CVRkKOOYgF8hA= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5 h1:xDAuZTn4IMm8o1LnBZvmrL8JA1io4o3YWNXgohbf20g= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5/go.mod h1:wYSv6iDS621sEFLfKvpPE2ugjTuGlAG7iROg0hLOkfc= -github.com/aws/aws-sdk-go-v2/config v1.27.38 h1:mMVyJJuSUdbD4zKXoxDgWrgM60QwlFEg+JhihCq6wCw= -github.com/aws/aws-sdk-go-v2/config v1.27.38/go.mod h1:6xOiNEn58bj/64MPKx89r6G/el9JZn8pvVbquSqTKK4= -github.com/aws/aws-sdk-go-v2/credentials v1.17.36 h1:zwI5WrT+oWWfzSKoTNmSyeBKQhsFRJRv+PGW/UZW+Yk= -github.com/aws/aws-sdk-go-v2/credentials v1.17.36/go.mod h1:3AG/sY1rc9NJrNWcN/3KPU4SIDPGTrd/qegKB0TnFdE= +github.com/aws/aws-sdk-go-v2/config v1.27.39 h1:FCylu78eTGzW1ynHcongXK9YHtoXD5AiiUqq3YfJYjU= +github.com/aws/aws-sdk-go-v2/config v1.27.39/go.mod h1:wczj2hbyskP4LjMKBEZwPRO1shXY+GsQleab+ZXT2ik= +github.com/aws/aws-sdk-go-v2/credentials v1.17.37 h1:G2aOH01yW8X373JK419THj5QVqu9vKEwxSEsGxihoW0= +github.com/aws/aws-sdk-go-v2/credentials v1.17.37/go.mod h1:0ecCjlb7htYCptRD45lXJ6aJDQac6D2NlKGpZqyTG6A= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 h1:C/d03NAmh8C4BZXhuRNboF/DqhBkBCeDiJDcaqIT5pA= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14/go.mod h1:7I0Ju7p9mCIdlrfS+JCgqcYD0VXz/N4yozsox+0o078= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.24 h1:WEiv2o2tjSx9tv5jP7rCR1P8FE8c6DxkFpvHGy6SYZg= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.24/go.mod h1:mhxj3DJiOXogLRZ/wlGmI9VHiCW2kzHjHTJLxexOtEk= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.26 h1:BTfwWNFVGLxW2bih/V2xhgCsYDQwG1cAWhWoW9Jx7wE= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.26/go.mod h1:LA1/FxoEFFmv7XpkB8KKqLAUz8AePdK9H0Ec7PUKazs= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 h1:kYQ3H1u0ANr9KEKlGs/jTLrBFPo8P8NaH/w7A01NeeM= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18/go.mod h1:r506HmK5JDUh9+Mw4CfGJGSSoqIiLCndAuqXuhbv67Y= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 h1:Z7IdFUONvTcvS7YuhtVxN99v2cCoHRXOS4mTr0B/pUc= @@ -248,14 +247,14 @@ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 h1:Xbwbmk44 github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20/go.mod h1:oAfOFzUB14ltPZj1rWwRc3d/6OgD76R8KlvU3EqM9Fg= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.18 h1:eb+tFOIl9ZsUe2259/BKPeniKuz4/02zZFH/i4Nf8Rg= github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.18/go.mod h1:GVCC2IJNJTmdlyEsSmofEy7EfJncP7DNnXDzRjJ5Keg= -github.com/aws/aws-sdk-go-v2/service/s3 v1.63.2 h1:1iXmXy8SJzQVMGvo40TSzBYS9ig6BSyXfRIMzLfmBfE= -github.com/aws/aws-sdk-go-v2/service/s3 v1.63.2/go.mod h1:NLTqRLe3pUNu3nTEHI6XlHLKYmc8fbHUdMxAB6+s41Q= -github.com/aws/aws-sdk-go-v2/service/sso v1.23.2 h1:yzi/y/vKlLyzOfG7pSu5ONNGRxHIgLeDrV4w2AMRCo0= -github.com/aws/aws-sdk-go-v2/service/sso v1.23.2/go.mod h1:XRlMvmad0ZNL+75C5FYdMvbbLkd6qiqz6foR1nA1PXY= +github.com/aws/aws-sdk-go-v2/service/s3 v1.64.0 h1:I0p8knB/IDYSQ3dbanaCr4UhiYQ96bvKRhGYxvLyiD8= +github.com/aws/aws-sdk-go-v2/service/s3 v1.64.0/go.mod h1:NLTqRLe3pUNu3nTEHI6XlHLKYmc8fbHUdMxAB6+s41Q= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.3 h1:rs4JCczF805+FDv2tRhZ1NU0RB2H6ryAvsWPanAr72Y= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.3/go.mod h1:XRlMvmad0ZNL+75C5FYdMvbbLkd6qiqz6foR1nA1PXY= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 h1:yiwVzJW2ZxZTurVbYWA7QOrAaCYQR72t0wrSBfoesUE= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4/go.mod h1:0oxfLkpz3rQ/CHlx5hB7H69YUpFiI1tql6Q6Ne+1bCw= -github.com/aws/aws-sdk-go-v2/service/sts v1.31.2 h1:O6tyji8mXmBGsHvTCB0VIhrDw19lGTUSbKIyjnw79s8= -github.com/aws/aws-sdk-go-v2/service/sts v1.31.2/go.mod h1:yMWe0F+XG0DkRZK5ODZhG7BEFYhLXi2dqGsv6tX0cgI= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.3 h1:VzudTFrDCIDakXtemR7l6Qzt2+JYsVqo2MxBPt5k8T8= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.3/go.mod h1:yMWe0F+XG0DkRZK5ODZhG7BEFYhLXi2dqGsv6tX0cgI= github.com/aws/smithy-go v1.21.0 h1:H7L8dtDRk0P1Qm6y0ji7MCYMQObJ5R9CRpyPhRUkLYA= github.com/aws/smithy-go v1.21.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= @@ -376,8 +375,8 @@ github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/goccy/go-yaml v1.9.8/go.mod h1:JubOolP3gh0HpiBc4BLRD4YmjEjHAmIIB2aaXKkTfoE= github.com/goccy/go-yaml v1.11.0/go.mod h1:H+mJrWtjPTJAHvRbV09MCK9xYwODM+wRTVFFTWckfng= -github.com/gocql/gocql v1.6.0 h1:IdFdOTbnpbd0pDhl4REKQDM+Q0SzKXQ1Yh+YZZ8T/qU= -github.com/gocql/gocql v1.6.0/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8= +github.com/gocql/gocql v1.7.0 h1:O+7U7/1gSN7QTEAaMEsJc1Oq2QHXvCWoF3DFK9HDHus= +github.com/gocql/gocql v1.7.0/go.mod h1:vnlvXyFZeLBF0Wy+RS8hrOdbn0UWsWtdg07XJnFxZ+4= github.com/gocraft/dbr/v2 v2.7.6 h1:ASHKFgCbTLODbb9f756Cl8VAlnvQLKqIzx9E1Cfb7eo= github.com/gocraft/dbr/v2 v2.7.6/go.mod h1:8IH98S8M8J0JSEiYk0MPH26ZDUKemiQ/GvmXL5jo+Uw= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -416,8 +415,8 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc= github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= -github.com/google/pprof v0.0.0-20240925223930-fa3061bff0bc h1:7bf8bGo4akhLJrmttkYLjxIz0yQmBi5umb+Nj1qRPpE= -github.com/google/pprof v0.0.0-20240925223930-fa3061bff0bc/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/pprof v0.0.0-20241001023024-f4c0cfd0cf1d h1:Jaz2JzpQaQXyET0AjLBXShrthbpqMkhGiEfkcQAiAUs= +github.com/google/pprof v0.0.0-20241001023024-f4c0cfd0cf1d/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= @@ -492,8 +491,8 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:C github.com/kisielk/errcheck v1.7.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/FqKluHJQ= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= -github.com/klauspost/compress v1.17.11-0.20240923131516-13a1ce6df1e0 h1:YNGbURX+AQoK0BmPSNoJrHLjfNQw8NvNOqLshq3hcpo= -github.com/klauspost/compress v1.17.11-0.20240923131516-13a1ce6df1e0/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= +github.com/klauspost/compress v1.17.11-0.20241002081118-f2a4f2583ec1 h1:Dvn9WOWnQvt7Z5txFg96+SqBIZ8S/n+SDW/XT1QbmLI= +github.com/klauspost/compress v1.17.11-0.20241002081118-f2a4f2583ec1/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kpango/fastime v1.1.9 h1:xVQHcqyPt5M69DyFH7g1EPRns1YQNap9d5eLhl/Jy84= @@ -586,8 +585,8 @@ github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zI github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= -github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= +github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA= +github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/quasilyte/go-ruleguard v0.4.2 h1:htXcXDK6/rO12kiTHKfHuqR4kr3Y4M0J0rOL6CH/BYs= @@ -640,8 +639,8 @@ github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vl github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/unum-cloud/usearch/golang v0.0.0-20240828190432-b9a9758a06e1 h1:hILse+Dt0Sk6RfyG19Ld48kcdTOnHx2F6dm3QH1X4Mw= -github.com/unum-cloud/usearch/golang v0.0.0-20240828190432-b9a9758a06e1/go.mod h1:NxBpQibuBBeA/V8RGbrNzVAv4OyWWL5yNao7mVz656k= +github.com/unum-cloud/usearch/golang v0.0.0-20240928043120-b3da75964080 h1:8Bp9eul9roXA0UUSEZa3fyhGz4i/nD6CL8UzZlsbYmg= +github.com/unum-cloud/usearch/golang v0.0.0-20240928043120-b3da75964080/go.mod h1:NxBpQibuBBeA/V8RGbrNzVAv4OyWWL5yNao7mVz656k= github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg= github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= @@ -655,6 +654,7 @@ go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/contrib/detectors/gcp v1.29.0/go.mod h1:GW2aWZNwR2ZxDLdv8OyC2G8zkRoQBuURgV7RPQgcPoU= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 h1:hCq2hNMwsegUvPzI7sPOvtO9cqyy5GbWt/Ybp2xrx8Q= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0/go.mod h1:LqaApwGx/oUmzsbqxkzuBvyoPpkxk3JQWnqfVrJ3wCA= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= @@ -708,7 +708,7 @@ golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0/go.mod h1:AbB0pIl golang.org/x/image v0.20.0 h1:7cVCUjQwfL18gyBJOmYvptfSHS8Fb3YUDtfLIZ7Nbpw= golang.org/x/image v0.20.0/go.mod h1:0a88To4CYVBAHp5FXJm8o7QbUl37Vd85ply1vyD8auM= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20240909163608-642950227fb3/go.mod h1:5EJr05J3jS1A5hwVNxs4vC0pIRxtWmwM15D1ZxCj93s= +golang.org/x/mobile v0.0.0-20240930194658-c6794c95c70b/go.mod h1:5EJr05J3jS1A5hwVNxs4vC0pIRxtWmwM15D1ZxCj93s= golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= @@ -741,15 +741,15 @@ gonum.org/v1/plot v0.14.0/go.mod h1:MLdR9424SJed+5VqC6MsouEpig9pZX2VZ57H9ko2bXU= google.golang.org/api v0.199.0 h1:aWUXClp+VFJmqE0JPvpZOK3LDQMyFKYIow4etYd9qxs= google.golang.org/api v0.199.0/go.mod h1:ohG4qSztDJmZdjK/Ar6MhbAmb/Rpi4JHOqagsh90K28= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20240924160255-9d4c2d233b61 h1:KipVMxePgXPFBzXOvpKbny3RVdVmJOD64R/Ob7GPWEs= -google.golang.org/genproto v0.0.0-20240924160255-9d4c2d233b61/go.mod h1:HiAZQz/G7n0EywFjmncAwsfnmFm2bjm7qPjwl8hyzjM= -google.golang.org/genproto/googleapis/api v0.0.0-20240924160255-9d4c2d233b61 h1:pAjq8XSSzXoP9ya73v/w+9QEAAJNluLrpmMq5qFJQNY= -google.golang.org/genproto/googleapis/api v0.0.0-20240924160255-9d4c2d233b61/go.mod h1:O6rP0uBq4k0mdi/b4ZEMAZjkhYWhS815kCvaMha4VN8= +google.golang.org/genproto v0.0.0-20240930140551-af27646dc61f h1:mCJ6SGikSxVlt9scCayUl2dMq0msUgmBArqRY6umieI= +google.golang.org/genproto v0.0.0-20240930140551-af27646dc61f/go.mod h1:xtVODtPkMQRUZ4kqOTgp6JrXQrPevvfCSdk4mJtHUbM= +google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f h1:jTm13A2itBi3La6yTGqn8bVSrc3ZZ1r8ENHlIXBfnRA= +google.golang.org/genproto/googleapis/api v0.0.0-20240930140551-af27646dc61f/go.mod h1:CLGoBuH1VHxAUXVPP8FfPwPEVJB6lz3URE5mY2SuayE= google.golang.org/genproto/googleapis/bytestream v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:q0eWNnCW04EJlyrmLT+ZHsjuoUiZ36/eAEdCCezZoco= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 h1:N9BgCIAUvn/M+p4NJccWPWb3BWh88+zyL0ll9HgbEeM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= -google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f h1:cUMEy+8oS78BWIH9OWazBkzbr090Od9tWBNtZHkOhf0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/hack/actions/gen/main.go b/hack/actions/gen/main.go index 63298521c1..1a63a285a3 100644 --- a/hack/actions/gen/main.go +++ b/hack/actions/gen/main.go @@ -19,19 +19,19 @@ package main import ( "bytes" "context" - "errors" "fmt" "io/fs" "os" "os/signal" - "strings" "syscall" "text/template" "time" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/file" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/safety" + "github.com/vdaas/vald/internal/strings" "github.com/vdaas/vald/internal/sync/errgroup" "gopkg.in/yaml.v2" ) diff --git a/hack/actions/gen/main_test.go b/hack/actions/gen/main_test.go new file mode 100644 index 0000000000..7b569c75b8 --- /dev/null +++ b/hack/actions/gen/main_test.go @@ -0,0 +1,692 @@ +// Copyright (C) 2019-2024 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 main + +// NOT IMPLEMENTED BELOW +// +// func TestData_initPullRequestPaths(t *testing.T) { +// type fields struct { +// AliasImage bool +// ConfigExists bool +// Year int +// ContainerType ContainerType +// AppName string +// BinDir string +// BuildUser string +// BuilderImage string +// BuilderTag string +// BuildStageName string +// Maintainer string +// PackageDir string +// RootDir string +// RuntimeImage string +// RuntimeTag string +// RuntimeUser string +// Name string +// BuildPlatforms string +// Arguments map[string]string +// Environments map[string]string +// Entrypoints []string +// EnvironmentsSlice []string +// ExtraCopies []string +// ExtraImages []string +// ExtraPackages []string +// Preprocess []string +// RunCommands []string +// RunMounts []string +// StageFiles []string +// PullRequestPaths []string +// } +// type want struct{} +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want) error { +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// AliasImage:false, +// ConfigExists:false, +// Year:0, +// ContainerType:nil, +// AppName:"", +// BinDir:"", +// BuildUser:"", +// BuilderImage:"", +// BuilderTag:"", +// BuildStageName:"", +// Maintainer:"", +// PackageDir:"", +// RootDir:"", +// RuntimeImage:"", +// RuntimeTag:"", +// RuntimeUser:"", +// Name:"", +// BuildPlatforms:"", +// Arguments:nil, +// Environments:nil, +// Entrypoints:nil, +// EnvironmentsSlice:nil, +// ExtraCopies:nil, +// ExtraImages:nil, +// ExtraPackages:nil, +// Preprocess:nil, +// RunCommands:nil, +// RunMounts:nil, +// StageFiles:nil, +// PullRequestPaths:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// fields: fields { +// AliasImage:false, +// ConfigExists:false, +// Year:0, +// ContainerType:nil, +// AppName:"", +// BinDir:"", +// BuildUser:"", +// BuilderImage:"", +// BuilderTag:"", +// BuildStageName:"", +// Maintainer:"", +// PackageDir:"", +// RootDir:"", +// RuntimeImage:"", +// RuntimeTag:"", +// RuntimeUser:"", +// Name:"", +// BuildPlatforms:"", +// Arguments:nil, +// Environments:nil, +// Entrypoints:nil, +// EnvironmentsSlice:nil, +// ExtraCopies:nil, +// ExtraImages:nil, +// ExtraPackages:nil, +// Preprocess:nil, +// RunCommands:nil, +// RunMounts:nil, +// StageFiles:nil, +// PullRequestPaths:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// data := &Data{ +// AliasImage: test.fields.AliasImage, +// ConfigExists: test.fields.ConfigExists, +// Year: test.fields.Year, +// ContainerType: test.fields.ContainerType, +// AppName: test.fields.AppName, +// BinDir: test.fields.BinDir, +// BuildUser: test.fields.BuildUser, +// BuilderImage: test.fields.BuilderImage, +// BuilderTag: test.fields.BuilderTag, +// BuildStageName: test.fields.BuildStageName, +// Maintainer: test.fields.Maintainer, +// PackageDir: test.fields.PackageDir, +// RootDir: test.fields.RootDir, +// RuntimeImage: test.fields.RuntimeImage, +// RuntimeTag: test.fields.RuntimeTag, +// RuntimeUser: test.fields.RuntimeUser, +// Name: test.fields.Name, +// BuildPlatforms: test.fields.BuildPlatforms, +// Arguments: test.fields.Arguments, +// Environments: test.fields.Environments, +// Entrypoints: test.fields.Entrypoints, +// EnvironmentsSlice: test.fields.EnvironmentsSlice, +// ExtraCopies: test.fields.ExtraCopies, +// ExtraImages: test.fields.ExtraImages, +// ExtraPackages: test.fields.ExtraPackages, +// Preprocess: test.fields.Preprocess, +// RunCommands: test.fields.RunCommands, +// RunMounts: test.fields.RunMounts, +// StageFiles: test.fields.StageFiles, +// PullRequestPaths: test.fields.PullRequestPaths, +// } +// +// data.initPullRequestPaths() +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestData_initData(t *testing.T) { +// type fields struct { +// AliasImage bool +// ConfigExists bool +// Year int +// ContainerType ContainerType +// AppName string +// BinDir string +// BuildUser string +// BuilderImage string +// BuilderTag string +// BuildStageName string +// Maintainer string +// PackageDir string +// RootDir string +// RuntimeImage string +// RuntimeTag string +// RuntimeUser string +// Name string +// BuildPlatforms string +// Arguments map[string]string +// Environments map[string]string +// Entrypoints []string +// EnvironmentsSlice []string +// ExtraCopies []string +// ExtraImages []string +// ExtraPackages []string +// Preprocess []string +// RunCommands []string +// RunMounts []string +// StageFiles []string +// PullRequestPaths []string +// } +// type want struct{} +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want) error { +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// AliasImage:false, +// ConfigExists:false, +// Year:0, +// ContainerType:nil, +// AppName:"", +// BinDir:"", +// BuildUser:"", +// BuilderImage:"", +// BuilderTag:"", +// BuildStageName:"", +// Maintainer:"", +// PackageDir:"", +// RootDir:"", +// RuntimeImage:"", +// RuntimeTag:"", +// RuntimeUser:"", +// Name:"", +// BuildPlatforms:"", +// Arguments:nil, +// Environments:nil, +// Entrypoints:nil, +// EnvironmentsSlice:nil, +// ExtraCopies:nil, +// ExtraImages:nil, +// ExtraPackages:nil, +// Preprocess:nil, +// RunCommands:nil, +// RunMounts:nil, +// StageFiles:nil, +// PullRequestPaths:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// fields: fields { +// AliasImage:false, +// ConfigExists:false, +// Year:0, +// ContainerType:nil, +// AppName:"", +// BinDir:"", +// BuildUser:"", +// BuilderImage:"", +// BuilderTag:"", +// BuildStageName:"", +// Maintainer:"", +// PackageDir:"", +// RootDir:"", +// RuntimeImage:"", +// RuntimeTag:"", +// RuntimeUser:"", +// Name:"", +// BuildPlatforms:"", +// Arguments:nil, +// Environments:nil, +// Entrypoints:nil, +// EnvironmentsSlice:nil, +// ExtraCopies:nil, +// ExtraImages:nil, +// ExtraPackages:nil, +// Preprocess:nil, +// RunCommands:nil, +// RunMounts:nil, +// StageFiles:nil, +// PullRequestPaths:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// data := &Data{ +// AliasImage: test.fields.AliasImage, +// ConfigExists: test.fields.ConfigExists, +// Year: test.fields.Year, +// ContainerType: test.fields.ContainerType, +// AppName: test.fields.AppName, +// BinDir: test.fields.BinDir, +// BuildUser: test.fields.BuildUser, +// BuilderImage: test.fields.BuilderImage, +// BuilderTag: test.fields.BuilderTag, +// BuildStageName: test.fields.BuildStageName, +// Maintainer: test.fields.Maintainer, +// PackageDir: test.fields.PackageDir, +// RootDir: test.fields.RootDir, +// RuntimeImage: test.fields.RuntimeImage, +// RuntimeTag: test.fields.RuntimeTag, +// RuntimeUser: test.fields.RuntimeUser, +// Name: test.fields.Name, +// BuildPlatforms: test.fields.BuildPlatforms, +// Arguments: test.fields.Arguments, +// Environments: test.fields.Environments, +// Entrypoints: test.fields.Entrypoints, +// EnvironmentsSlice: test.fields.EnvironmentsSlice, +// ExtraCopies: test.fields.ExtraCopies, +// ExtraImages: test.fields.ExtraImages, +// ExtraPackages: test.fields.ExtraPackages, +// Preprocess: test.fields.Preprocess, +// RunCommands: test.fields.RunCommands, +// RunMounts: test.fields.RunMounts, +// StageFiles: test.fields.StageFiles, +// PullRequestPaths: test.fields.PullRequestPaths, +// } +// +// data.initData() +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestData_generateWorkflowStruct(t *testing.T) { +// type fields struct { +// AliasImage bool +// ConfigExists bool +// Year int +// ContainerType ContainerType +// AppName string +// BinDir string +// BuildUser string +// BuilderImage string +// BuilderTag string +// BuildStageName string +// Maintainer string +// PackageDir string +// RootDir string +// RuntimeImage string +// RuntimeTag string +// RuntimeUser string +// Name string +// BuildPlatforms string +// Arguments map[string]string +// Environments map[string]string +// Entrypoints []string +// EnvironmentsSlice []string +// ExtraCopies []string +// ExtraImages []string +// ExtraPackages []string +// Preprocess []string +// RunCommands []string +// RunMounts []string +// StageFiles []string +// PullRequestPaths []string +// } +// type want struct { +// want *Workflow +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, *Workflow, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got *Workflow, 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(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 { +// AliasImage:false, +// ConfigExists:false, +// Year:0, +// ContainerType:nil, +// AppName:"", +// BinDir:"", +// BuildUser:"", +// BuilderImage:"", +// BuilderTag:"", +// BuildStageName:"", +// Maintainer:"", +// PackageDir:"", +// RootDir:"", +// RuntimeImage:"", +// RuntimeTag:"", +// RuntimeUser:"", +// Name:"", +// BuildPlatforms:"", +// Arguments:nil, +// Environments:nil, +// Entrypoints:nil, +// EnvironmentsSlice:nil, +// ExtraCopies:nil, +// ExtraImages:nil, +// ExtraPackages:nil, +// Preprocess:nil, +// RunCommands:nil, +// RunMounts:nil, +// StageFiles:nil, +// PullRequestPaths:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// fields: fields { +// AliasImage:false, +// ConfigExists:false, +// Year:0, +// ContainerType:nil, +// AppName:"", +// BinDir:"", +// BuildUser:"", +// BuilderImage:"", +// BuilderTag:"", +// BuildStageName:"", +// Maintainer:"", +// PackageDir:"", +// RootDir:"", +// RuntimeImage:"", +// RuntimeTag:"", +// RuntimeUser:"", +// Name:"", +// BuildPlatforms:"", +// Arguments:nil, +// Environments:nil, +// Entrypoints:nil, +// EnvironmentsSlice:nil, +// ExtraCopies:nil, +// ExtraImages:nil, +// ExtraPackages:nil, +// Preprocess:nil, +// RunCommands:nil, +// RunMounts:nil, +// StageFiles:nil, +// PullRequestPaths:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// data := &Data{ +// AliasImage: test.fields.AliasImage, +// ConfigExists: test.fields.ConfigExists, +// Year: test.fields.Year, +// ContainerType: test.fields.ContainerType, +// AppName: test.fields.AppName, +// BinDir: test.fields.BinDir, +// BuildUser: test.fields.BuildUser, +// BuilderImage: test.fields.BuilderImage, +// BuilderTag: test.fields.BuilderTag, +// BuildStageName: test.fields.BuildStageName, +// Maintainer: test.fields.Maintainer, +// PackageDir: test.fields.PackageDir, +// RootDir: test.fields.RootDir, +// RuntimeImage: test.fields.RuntimeImage, +// RuntimeTag: test.fields.RuntimeTag, +// RuntimeUser: test.fields.RuntimeUser, +// Name: test.fields.Name, +// BuildPlatforms: test.fields.BuildPlatforms, +// Arguments: test.fields.Arguments, +// Environments: test.fields.Environments, +// Entrypoints: test.fields.Entrypoints, +// EnvironmentsSlice: test.fields.EnvironmentsSlice, +// ExtraCopies: test.fields.ExtraCopies, +// ExtraImages: test.fields.ExtraImages, +// ExtraPackages: test.fields.ExtraPackages, +// Preprocess: test.fields.Preprocess, +// RunCommands: test.fields.RunCommands, +// RunMounts: test.fields.RunMounts, +// StageFiles: test.fields.StageFiles, +// PullRequestPaths: test.fields.PullRequestPaths, +// } +// +// got, err := data.generateWorkflowStruct() +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_main(t *testing.T) { +// type want struct{} +// type test struct { +// name string +// want want +// checkFunc func(want) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want) error { +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// main() +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/hack/cspell/main.go b/hack/cspell/main.go index 0595983918..075bb26076 100644 --- a/hack/cspell/main.go +++ b/hack/cspell/main.go @@ -22,8 +22,9 @@ import ( "os" "regexp" "slices" - "strings" - "sync" + + "github.com/vdaas/vald/internal/strings" + "github.com/vdaas/vald/internal/sync" ) type CSpellConfig struct { diff --git a/hack/docker/gen/main.go b/hack/docker/gen/main.go index 3cd50d9f81..df6d58ec62 100644 --- a/hack/docker/gen/main.go +++ b/hack/docker/gen/main.go @@ -338,10 +338,10 @@ var ( clangBuildDeps = []string{ "cmake", - "gcc", "g++", - "unzip", + "gcc", "libssl-dev", + "unzip", } ngtBuildDeps = []string{ "liblapack-dev", @@ -355,12 +355,13 @@ var ( "pkg-config", } devContainerDeps = []string{ + "file", "gawk", "gnupg2", "graphviz", "jq", - "libhdf5-dev", "libaec-dev", + "libhdf5-dev", "sed", "zip", } @@ -379,12 +380,12 @@ var ( "make kind/install", "make kubectl/install", "make kubelinter/install", - "make reviewdog/install", - "make tparse/install", - "make yq/install", "make minikube/install", + "make reviewdog/install", "make stern/install", "make telepresence/install", + "make tparse/install", + "make yq/install", } devContainerPreprocess = []string{ @@ -805,10 +806,7 @@ func main() { data.Environments["HOME"] = "/" + rootUser data.Environments["USER"] = rootUser } else { - user := data.BuildUser - if strings.Contains(user, ":") { - user = strings.SplitN(user, ":", 2)[0] - } + user, _, _ := strings.Cut(data.BuildUser, ":") data.Environments["HOME"] = "/home/" + user data.Environments["USER"] = user } diff --git a/hack/go.mod.default b/hack/go.mod.default index 7185722665..38793cafcd 100644 --- a/hack/go.mod.default +++ b/hack/go.mod.default @@ -1,6 +1,6 @@ module github.com/vdaas/vald -go 1.23.1 +go 1.23.2 replace ( cloud.google.com/go => cloud.google.com/go upgrade diff --git a/hack/tools/deadlink/main.go b/hack/tools/deadlink/main.go index 2579dbe72e..098523acf7 100644 --- a/hack/tools/deadlink/main.go +++ b/hack/tools/deadlink/main.go @@ -23,13 +23,13 @@ import ( "os" "path/filepath" "regexp" - "strings" "sync/atomic" "github.com/vdaas/vald/internal/file" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net" "github.com/vdaas/vald/internal/net/http/client" + "github.com/vdaas/vald/internal/strings" "github.com/vdaas/vald/internal/sync" "github.com/vdaas/vald/internal/sync/errgroup" ) diff --git a/internal/core/algorithm/faiss/faiss.go b/internal/core/algorithm/faiss/faiss.go index 1a43dbc83b..5e0d19021d 100644 --- a/internal/core/algorithm/faiss/faiss.go +++ b/internal/core/algorithm/faiss/faiss.go @@ -24,11 +24,11 @@ package faiss import "C" import ( - "sync" "unsafe" "github.com/vdaas/vald/internal/core/algorithm" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/sync" ) type ( diff --git a/internal/core/algorithm/faiss/option.go b/internal/core/algorithm/faiss/option.go index d426722b27..89ea6ffad2 100644 --- a/internal/core/algorithm/faiss/option.go +++ b/internal/core/algorithm/faiss/option.go @@ -24,10 +24,9 @@ package faiss import "C" import ( - "strings" - "github.com/vdaas/vald/internal/core/algorithm" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/strings" ) // Option represents the functional option for faiss. diff --git a/internal/core/algorithm/usearch/option.go b/internal/core/algorithm/usearch/option.go index d4bf0061c8..71dd10a0ee 100644 --- a/internal/core/algorithm/usearch/option.go +++ b/internal/core/algorithm/usearch/option.go @@ -19,12 +19,12 @@ package usearch import ( "strconv" - "strings" "github.com/kpango/fastime" core "github.com/unum-cloud/usearch/golang" "github.com/vdaas/vald/internal/core/algorithm" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/strings" ) // Option represents the functional option for usearch. diff --git a/internal/core/algorithm/usearch/option_test.go b/internal/core/algorithm/usearch/option_test.go new file mode 100644 index 0000000000..26be929db9 --- /dev/null +++ b/internal/core/algorithm/usearch/option_test.go @@ -0,0 +1,696 @@ +// Copyright (C) 2019-2024 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 usearch + +// NOT IMPLEMENTED BELOW +// +// func TestWithIndexPath(t *testing.T) { +// type args struct { +// path string +// } +// type want struct { +// want Option +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Option) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Option) 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 { +// path:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// path:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := WithIndexPath(test.args.path) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithQuantizationType(t *testing.T) { +// type args struct { +// quantizationType string +// } +// type want struct { +// want Option +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Option) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Option) 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 { +// quantizationType:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// quantizationType:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := WithQuantizationType(test.args.quantizationType) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithMetricType(t *testing.T) { +// type args struct { +// metricType string +// } +// type want struct { +// want Option +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Option) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Option) 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 { +// metricType:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// metricType:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := WithMetricType(test.args.metricType) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithDimension(t *testing.T) { +// type args struct { +// dim int +// } +// type want struct { +// want Option +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Option) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Option) 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 { +// dim:0, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// dim:0, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := WithDimension(test.args.dim) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithConnectivity(t *testing.T) { +// type args struct { +// connectivity int +// } +// type want struct { +// want Option +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Option) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Option) 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 { +// connectivity:0, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// connectivity:0, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := WithConnectivity(test.args.connectivity) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithExpansionAdd(t *testing.T) { +// type args struct { +// expansionAdd int +// } +// type want struct { +// want Option +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Option) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Option) 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 { +// expansionAdd:0, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// expansionAdd:0, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := WithExpansionAdd(test.args.expansionAdd) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithExpansionSearch(t *testing.T) { +// type args struct { +// expansionSearch int +// } +// type want struct { +// want Option +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Option) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Option) 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 { +// expansionSearch:0, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// expansionSearch:0, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := WithExpansionSearch(test.args.expansionSearch) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestWithMulti(t *testing.T) { +// type args struct { +// multi bool +// } +// type want struct { +// want Option +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Option) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Option) 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 { +// multi:false, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// multi:false, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := WithMulti(test.args.multi) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/core/algorithm/usearch/usearch.go b/internal/core/algorithm/usearch/usearch.go index 0d8c647f63..0aa50f8260 100644 --- a/internal/core/algorithm/usearch/usearch.go +++ b/internal/core/algorithm/usearch/usearch.go @@ -19,11 +19,11 @@ package usearch import ( "strconv" - "sync" core "github.com/unum-cloud/usearch/golang" "github.com/vdaas/vald/internal/core/algorithm" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/sync" ) type ( diff --git a/internal/core/algorithm/usearch/usearch_test.go b/internal/core/algorithm/usearch/usearch_test.go index bcd03fee5b..8537488831 100644 --- a/internal/core/algorithm/usearch/usearch_test.go +++ b/internal/core/algorithm/usearch/usearch_test.go @@ -349,3 +349,1331 @@ func Test_usearch_Search(t *testing.T) { }) } } + +// NOT IMPLEMENTED BELOW +// +// func TestNew(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Usearch +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Usearch, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Usearch, 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(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 { +// opts:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// opts:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got, err := New(test.args.opts...) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestLoad(t *testing.T) { +// type args struct { +// opts []Option +// } +// type want struct { +// want Usearch +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Usearch, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Usearch, 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(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 { +// opts:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// opts:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got, err := Load(test.args.opts...) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_gen(t *testing.T) { +// type args struct { +// isLoad bool +// opts []Option +// } +// type want struct { +// want Usearch +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, Usearch, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got Usearch, 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(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 { +// isLoad:false, +// opts:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// isLoad:false, +// opts:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got, err := gen(test.args.isLoad, test.args.opts...) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_usearch_SaveIndex(t *testing.T) { +// type fields struct { +// index *core.Index +// quantizationType core.Quantization +// metricType core.Metric +// dimension uint +// connectivity uint +// expansionAdd uint +// expansionSearch uint +// multi bool +// idxPath string +// mu *sync.RWMutex +// } +// type want struct { +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// u := &usearch{ +// index: test.fields.index, +// quantizationType: test.fields.quantizationType, +// metricType: test.fields.metricType, +// dimension: test.fields.dimension, +// connectivity: test.fields.connectivity, +// expansionAdd: test.fields.expansionAdd, +// expansionSearch: test.fields.expansionSearch, +// multi: test.fields.multi, +// idxPath: test.fields.idxPath, +// mu: test.fields.mu, +// } +// +// err := u.SaveIndex() +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_usearch_SaveIndexWithPath(t *testing.T) { +// type args struct { +// idxPath string +// } +// type fields struct { +// index *core.Index +// quantizationType core.Quantization +// metricType core.Metric +// dimension uint +// connectivity uint +// expansionAdd uint +// expansionSearch uint +// multi bool +// idxPath string +// mu *sync.RWMutex +// } +// type want struct { +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// idxPath:"", +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// idxPath:"", +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// u := &usearch{ +// index: test.fields.index, +// quantizationType: test.fields.quantizationType, +// metricType: test.fields.metricType, +// dimension: test.fields.dimension, +// connectivity: test.fields.connectivity, +// expansionAdd: test.fields.expansionAdd, +// expansionSearch: test.fields.expansionSearch, +// multi: test.fields.multi, +// idxPath: test.fields.idxPath, +// mu: test.fields.mu, +// } +// +// err := u.SaveIndexWithPath(test.args.idxPath) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_usearch_GetIndicesSize(t *testing.T) { +// type fields struct { +// index *core.Index +// quantizationType core.Quantization +// metricType core.Metric +// dimension uint +// connectivity uint +// expansionAdd uint +// expansionSearch uint +// multi bool +// idxPath string +// mu *sync.RWMutex +// } +// type want struct { +// wantIndicesSize int +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, int, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, gotIndicesSize int, 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(gotIndicesSize, w.wantIndicesSize) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotIndicesSize, w.wantIndicesSize) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// u := &usearch{ +// index: test.fields.index, +// quantizationType: test.fields.quantizationType, +// metricType: test.fields.metricType, +// dimension: test.fields.dimension, +// connectivity: test.fields.connectivity, +// expansionAdd: test.fields.expansionAdd, +// expansionSearch: test.fields.expansionSearch, +// multi: test.fields.multi, +// idxPath: test.fields.idxPath, +// mu: test.fields.mu, +// } +// +// gotIndicesSize, err := u.GetIndicesSize() +// if err := checkFunc(test.want, gotIndicesSize, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_usearch_Add(t *testing.T) { +// type args struct { +// key core.Key +// vec []float32 +// } +// type fields struct { +// index *core.Index +// quantizationType core.Quantization +// metricType core.Metric +// dimension uint +// connectivity uint +// expansionAdd uint +// expansionSearch uint +// multi bool +// idxPath string +// mu *sync.RWMutex +// } +// type want struct { +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// key:nil, +// vec:nil, +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// key:nil, +// vec:nil, +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// u := &usearch{ +// index: test.fields.index, +// quantizationType: test.fields.quantizationType, +// metricType: test.fields.metricType, +// dimension: test.fields.dimension, +// connectivity: test.fields.connectivity, +// expansionAdd: test.fields.expansionAdd, +// expansionSearch: test.fields.expansionSearch, +// multi: test.fields.multi, +// idxPath: test.fields.idxPath, +// mu: test.fields.mu, +// } +// +// err := u.Add(test.args.key, test.args.vec) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_usearch_Reserve(t *testing.T) { +// type args struct { +// vectorCount int +// } +// type fields struct { +// index *core.Index +// quantizationType core.Quantization +// metricType core.Metric +// dimension uint +// connectivity uint +// expansionAdd uint +// expansionSearch uint +// multi bool +// idxPath string +// mu *sync.RWMutex +// } +// type want struct { +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// vectorCount:0, +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// vectorCount:0, +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// u := &usearch{ +// index: test.fields.index, +// quantizationType: test.fields.quantizationType, +// metricType: test.fields.metricType, +// dimension: test.fields.dimension, +// connectivity: test.fields.connectivity, +// expansionAdd: test.fields.expansionAdd, +// expansionSearch: test.fields.expansionSearch, +// multi: test.fields.multi, +// idxPath: test.fields.idxPath, +// mu: test.fields.mu, +// } +// +// err := u.Reserve(test.args.vectorCount) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_usearch_GetObject(t *testing.T) { +// type args struct { +// key core.Key +// count int +// } +// type fields struct { +// index *core.Index +// quantizationType core.Quantization +// metricType core.Metric +// dimension uint +// connectivity uint +// expansionAdd uint +// expansionSearch uint +// multi bool +// idxPath string +// mu *sync.RWMutex +// } +// type want struct { +// want []float32 +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, []float32, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, got []float32, 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(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 { +// key:nil, +// count:0, +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// key:nil, +// count:0, +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// u := &usearch{ +// index: test.fields.index, +// quantizationType: test.fields.quantizationType, +// metricType: test.fields.metricType, +// dimension: test.fields.dimension, +// connectivity: test.fields.connectivity, +// expansionAdd: test.fields.expansionAdd, +// expansionSearch: test.fields.expansionSearch, +// multi: test.fields.multi, +// idxPath: test.fields.idxPath, +// mu: test.fields.mu, +// } +// +// got, err := u.GetObject(test.args.key, test.args.count) +// if err := checkFunc(test.want, got, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_usearch_Remove(t *testing.T) { +// type args struct { +// key core.Key +// } +// type fields struct { +// index *core.Index +// quantizationType core.Quantization +// metricType core.Metric +// dimension uint +// connectivity uint +// expansionAdd uint +// expansionSearch uint +// multi bool +// idxPath string +// mu *sync.RWMutex +// } +// type want struct { +// err error +// } +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// key:nil, +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// key:nil, +// }, +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// u := &usearch{ +// index: test.fields.index, +// quantizationType: test.fields.quantizationType, +// metricType: test.fields.metricType, +// dimension: test.fields.dimension, +// connectivity: test.fields.connectivity, +// expansionAdd: test.fields.expansionAdd, +// expansionSearch: test.fields.expansionSearch, +// multi: test.fields.multi, +// idxPath: test.fields.idxPath, +// mu: test.fields.mu, +// } +// +// err := u.Remove(test.args.key) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_usearch_Close(t *testing.T) { +// type fields struct { +// index *core.Index +// quantizationType core.Quantization +// metricType core.Metric +// dimension uint +// connectivity uint +// expansionAdd uint +// expansionSearch uint +// multi bool +// idxPath string +// mu *sync.RWMutex +// } +// type want struct { +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// 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 +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// fields: fields { +// index:nil, +// quantizationType:nil, +// metricType:nil, +// dimension:0, +// connectivity:0, +// expansionAdd:0, +// expansionSearch:0, +// multi:false, +// idxPath:"", +// mu:sync.RWMutex{}, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// u := &usearch{ +// index: test.fields.index, +// quantizationType: test.fields.quantizationType, +// metricType: test.fields.metricType, +// dimension: test.fields.dimension, +// connectivity: test.fields.connectivity, +// expansionAdd: test.fields.expansionAdd, +// expansionSearch: test.fields.expansionSearch, +// multi: test.fields.multi, +// idxPath: test.fields.idxPath, +// mu: test.fields.mu, +// } +// +// err := u.Close() +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/errors/usearch_test.go b/internal/errors/usearch_test.go new file mode 100644 index 0000000000..70a2325350 --- /dev/null +++ b/internal/errors/usearch_test.go @@ -0,0 +1,189 @@ +// Copyright (C) 2019-2024 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 errors + +// NOT IMPLEMENTED BELOW +// +// func TestNewUsearchError(t *testing.T) { +// type args struct { +// msg string +// } +// type want struct { +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, err error) error { +// if !Is(err, w.err) { +// return Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// msg:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// msg:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// err := NewUsearchError(test.args.msg) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func TestUsearchError_Error(t *testing.T) { +// type fields struct { +// Msg string +// } +// type want struct { +// want string +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, string) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, got string) error { +// if !reflect.DeepEqual(got, w.want) { +// return 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 { +// Msg:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// fields: fields { +// Msg:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// u := UsearchError{ +// Msg: test.fields.Msg, +// } +// +// got := u.Error() +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/info/info.go b/internal/info/info.go index 223a507b07..c64fb9a905 100644 --- a/internal/info/info.go +++ b/internal/info/info.go @@ -37,9 +37,10 @@ type Info interface { } type info struct { - baseURL string // e.g https://github.com/vdaas/vald/tree/main - detail Detail - prepOnce sync.Once + baseURL string // e.g https://github.com/vdaas/vald/tree/main + detail Detail + prepOnce sync.Once + valdReplacer *strings.Replacer // runtime functions rtCaller func(skip int) (pc uintptr, file string, line int, ok bool) @@ -115,13 +116,14 @@ var ( ) const ( - goSrc = "go/src/" - goSrcLen = len(goSrc) - goMod = "go/pkg/mod/" - goModLen = len(goMod) - cgoTrue = "true" - cgoFalse = "false" - cgoUnknown = "unknown" + goSrc = "go/src/" + goSrcLen = len(goSrc) + goMod = "go/pkg/mod/" + goModLen = len(goMod) + cgoTrue = "true" + cgoFalse = "false" + cgoUnknown = "unknown" + googleGolang = "google.golang.org" ) // Init initializes Detail object only once. @@ -298,11 +300,35 @@ func (i info) getDetail() Detail { if funcName == "runtime.main" { break } + index := strings.LastIndex(funcName, "/") + if index != -1 { + funcName = funcName[index+1:] + } 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) + url = "https://github.com/golang/go/blob/" + i.detail.GoVersion + strings.TrimPrefix(file, i.detail.GoRoot) + case strings.HasPrefix(file, "runtime"): + url = "https://github.com/golang/go/blob/" + i.detail.GoVersion + "/src/" + file + case strings.HasPrefix(file, googleGolang+"/grpc"): + // google.golang.org/grpc@v1.65.0/server.go to https://github.com/grpc/grpc-go/blob/v1.65.0/server.go + url = "https://github.com/grpc/grpc-go/blob/" + _, versionSource, ok := strings.Cut(file, "@") + if ok && versionSource != "" { + url += versionSource + } else { + url = strings.ReplaceAll(file, googleGolang+"/grpc@", url) + } + case strings.HasPrefix(file, googleGolang+"/protobuf"): + // google.golang.org/protobuf@v1.34.0/proto/decode.go to https://github.com/protocolbuffers/protobuf-go/blob/v1.34.0/proto/decode.go + url = "https://github.com/protocolbuffers/protobuf-go/blob/" + _, versionSource, ok := strings.Cut(file, "@") + if ok && versionSource != "" { + url += versionSource + } else { + url = strings.ReplaceAll(file, googleGolang+"/protobuf@", url) + } case func() bool { idx = strings.Index(file, goMod) return idx >= 0 @@ -319,15 +345,16 @@ func (i info) getDetail() Detail { } url += "/" + path } - url += "#L" + strconv.Itoa(line) 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) + url = i.valdReplacer.Replace(file[idx+goSrcLen:]) case strings.HasPrefix(file, valdRepo): - url = fmt.Sprintf("%s#L%d", strings.Replace(file, valdRepo, "https://"+valdRepo+"/blob/"+i.detail.GitCommit, -1), line) + url = i.valdReplacer.Replace(file) } + url += "#L" + strconv.Itoa(line) + i.detail.StackTrace = append(i.detail.StackTrace, StackTrace{ FuncName: funcName, File: file, @@ -364,7 +391,7 @@ func (i *info) prepare() { if i.detail.CGOEnabled == "" && CGOEnabled != "" { i.detail.CGOEnabled = CGOEnabled } - switch i.detail.CGOEnabled { + switch CGOEnabled { case "0", cgoFalse: i.detail.CGOEnabled = cgoFalse case "1", cgoTrue: @@ -390,9 +417,16 @@ func (i *info) prepare() { if len(i.detail.GoroutineCount) == 0 { i.detail.GoroutineCount = strconv.Itoa(runtime.NumGoroutine()) } + if i.valdReplacer == nil { + i.valdReplacer = strings.NewReplacer(valdRepo, "https://"+valdRepo+"/blob/"+i.detail.GitCommit) + } }) } func (s StackTrace) String() string { return "URL: " + s.URL + "\tFile: " + s.File + "\tLine: #" + strconv.Itoa(s.Line) + "\tFuncName: " + s.FuncName } + +func (s StackTrace) ShortString() string { + return s.URL + " " + s.FuncName +} diff --git a/internal/k8s/job/job.go b/internal/k8s/job/job.go index db984ef28c..bd29584969 100644 --- a/internal/k8s/job/job.go +++ b/internal/k8s/job/job.go @@ -16,13 +16,13 @@ package job import ( "context" "reflect" - "strings" - "sync" "time" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/k8s" "github.com/vdaas/vald/internal/log" + "github.com/vdaas/vald/internal/strings" + "github.com/vdaas/vald/internal/sync" batchv1 "k8s.io/api/batch/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" "sigs.k8s.io/controller-runtime/pkg/builder" diff --git a/internal/net/grpc/client.go b/internal/net/grpc/client.go index d5aef913ec..6409d07b1d 100644 --- a/internal/net/grpc/client.go +++ b/internal/net/grpc/client.go @@ -19,7 +19,9 @@ package grpc import ( "context" + "maps" "math" + "slices" "sync/atomic" "time" @@ -155,11 +157,7 @@ func (g *gRPCClient) StartConnectionMonitor(ctx context.Context) (<-chan error, } g.monitorRunning.Store(true) - addrs := make([]string, len(g.addrs)) - for addr := range g.addrs { - addrs = append(addrs, addr) - } - + addrs := slices.Collect(maps.Keys(g.addrs)) if g.dialer != nil { g.dialer.StartDialerCache(ctx) } diff --git a/internal/net/grpc/client_test.go b/internal/net/grpc/client_test.go index f28d50023b..15d9e06b80 100644 --- a/internal/net/grpc/client_test.go +++ b/internal/net/grpc/client_test.go @@ -109,28 +109,29 @@ package grpc // ctx context.Context // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // want <-chan error @@ -171,6 +172,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -214,6 +216,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -258,28 +261,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -296,28 +300,29 @@ package grpc // f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // err error @@ -355,6 +360,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -399,6 +405,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -443,28 +450,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -482,28 +490,29 @@ package grpc // f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // err error @@ -542,6 +551,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -587,6 +597,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -631,28 +642,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -670,28 +682,29 @@ package grpc // f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // err error @@ -730,6 +743,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -775,6 +789,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -819,28 +834,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -859,28 +875,29 @@ package grpc // f func(ctx context.Context, addr string, conn *ClientConn, copts ...CallOption) error // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // err error @@ -920,6 +937,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -966,6 +984,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1010,28 +1029,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -1048,28 +1068,29 @@ package grpc // f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (any, error) // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // wantData any @@ -1111,6 +1132,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1155,6 +1177,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1199,28 +1222,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -1238,28 +1262,29 @@ package grpc // f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (any, error) // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // wantData any @@ -1302,6 +1327,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1347,6 +1373,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1391,28 +1418,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -1432,28 +1460,29 @@ package grpc // f func(ctx context.Context, conn *ClientConn, copts ...CallOption) (any, error) // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // wantData any @@ -1498,6 +1527,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1545,6 +1575,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1589,28 +1620,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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.connectWithBackoff(test.args.ctx, test.args.p, test.args.addr, test.args.enableBackoff, test.args.f) @@ -1623,28 +1655,29 @@ package grpc // // func Test_gRPCClient_GetDialOption(t *testing.T) { // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // want []DialOption @@ -1677,6 +1710,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1717,6 +1751,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1761,28 +1796,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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() @@ -1795,28 +1831,29 @@ package grpc // // func Test_gRPCClient_GetCallOption(t *testing.T) { // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // want []CallOption @@ -1849,6 +1886,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1889,6 +1927,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -1933,28 +1972,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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() @@ -1967,28 +2007,29 @@ package grpc // // func Test_gRPCClient_GetBackoff(t *testing.T) { // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // want backoff.Backoff @@ -2021,6 +2062,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2061,6 +2103,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2105,28 +2148,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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.GetBackoff() @@ -2137,6 +2181,190 @@ package grpc // } // } // +// func Test_gRPCClient_SetDisableResolveDNSAddr(t *testing.T) { +// type args struct { +// addr string +// disabled bool +// } +// type fields struct { +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc +// } +// type want struct{} +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want) error { +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// addr:"", +// disabled:false, +// }, +// fields: fields { +// addrs:nil, +// poolSize:0, +// clientCount:0, +// conns:nil, +// hcDur:nil, +// prDur:nil, +// dialer:nil, +// enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, +// resolveDNS:false, +// dopts:nil, +// copts:nil, +// roccd:"", +// eg:nil, +// bo:nil, +// cb:nil, +// gbo:nil, +// mcd:nil, +// group:nil, +// crl:nil, +// ech:nil, +// monitorRunning:nil, +// stopMonitor:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// addr:"", +// disabled:false, +// }, +// fields: fields { +// addrs:nil, +// poolSize:0, +// clientCount:0, +// conns:nil, +// hcDur:nil, +// prDur:nil, +// dialer:nil, +// enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, +// resolveDNS:false, +// dopts:nil, +// copts:nil, +// roccd:"", +// eg:nil, +// bo:nil, +// cb:nil, +// gbo:nil, +// mcd:nil, +// group:nil, +// crl:nil, +// ech:nil, +// monitorRunning:nil, +// stopMonitor:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// g := &gRPCClient{ +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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, +// } +// +// g.SetDisableResolveDNSAddr(test.args.addr, test.args.disabled) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func Test_gRPCClient_Connect(t *testing.T) { // type args struct { // ctx context.Context @@ -2144,28 +2372,29 @@ package grpc // dopts []DialOption // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // wantConn pool.Conn @@ -2208,6 +2437,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2253,6 +2483,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2297,28 +2528,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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...) @@ -2335,28 +2567,29 @@ package grpc // addr string // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // want bool @@ -2394,6 +2627,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2438,6 +2672,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2482,28 +2717,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -2520,28 +2756,29 @@ package grpc // addr string // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // err error @@ -2579,6 +2816,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2623,6 +2861,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2667,28 +2906,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -2701,28 +2941,29 @@ package grpc // // func Test_gRPCClient_ConnectedAddrs(t *testing.T) { // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // wantAddrs []string @@ -2755,6 +2996,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2795,6 +3037,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2839,28 +3082,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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, // } // // gotAddrs := g.ConnectedAddrs() @@ -2876,28 +3120,29 @@ package grpc // ctx context.Context // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // err error @@ -2934,6 +3179,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -2977,6 +3223,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -3021,28 +3268,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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) @@ -3058,28 +3306,29 @@ package grpc // fn func(addr string, p pool.Conn) bool // } // type fields struct { -// addrs map[string]struct{} -// poolSize uint64 -// clientCount uint64 -// conns sync.Map[string, pool.Conn] -// hcDur time.Duration -// prDur time.Duration -// dialer net.Dialer -// enablePoolRebalance bool -// resolveDNS bool -// dopts []DialOption -// copts []CallOption -// roccd string -// eg errgroup.Group -// bo backoff.Backoff -// cb circuitbreaker.CircuitBreaker -// gbo gbackoff.Config -// mcd time.Duration -// group singleflight.Group[pool.Conn] -// crl sync.Map[string, bool] -// ech <-chan error -// monitorRunning atomic.Bool -// stopMonitor context.CancelFunc +// addrs map[string]struct{} +// poolSize uint64 +// clientCount uint64 +// conns sync.Map[string, pool.Conn] +// hcDur time.Duration +// prDur time.Duration +// dialer net.Dialer +// enablePoolRebalance bool +// disableResolveDNSAddrs sync.Map[string, bool] +// resolveDNS bool +// dopts []DialOption +// copts []CallOption +// roccd string +// eg errgroup.Group +// bo backoff.Backoff +// cb circuitbreaker.CircuitBreaker +// gbo gbackoff.Config +// mcd time.Duration +// group singleflight.Group[pool.Conn] +// crl sync.Map[string, bool] +// ech <-chan error +// monitorRunning atomic.Bool +// stopMonitor context.CancelFunc // } // type want struct { // err error @@ -3116,6 +3365,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -3159,6 +3409,7 @@ package grpc // prDur:nil, // dialer:nil, // enablePoolRebalance:false, +// disableResolveDNSAddrs:nil, // resolveDNS:false, // dopts:nil, // copts:nil, @@ -3203,28 +3454,29 @@ package grpc // checkFunc = defaultCheckFunc // } // g := &gRPCClient{ -// addrs: test.fields.addrs, -// poolSize: test.fields.poolSize, -// clientCount: test.fields.clientCount, -// 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, -// copts: test.fields.copts, -// 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, +// addrs: test.fields.addrs, +// poolSize: test.fields.poolSize, +// clientCount: test.fields.clientCount, +// conns: test.fields.conns, +// hcDur: test.fields.hcDur, +// prDur: test.fields.prDur, +// dialer: test.fields.dialer, +// enablePoolRebalance: test.fields.enablePoolRebalance, +// disableResolveDNSAddrs: test.fields.disableResolveDNSAddrs, +// resolveDNS: test.fields.resolveDNS, +// dopts: test.fields.dopts, +// copts: test.fields.copts, +// 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.rangeConns(test.args.fn) diff --git a/internal/net/grpc/codes/codes_test.go b/internal/net/grpc/codes/codes_test.go new file mode 100644 index 0000000000..a478c49127 --- /dev/null +++ b/internal/net/grpc/codes/codes_test.go @@ -0,0 +1,101 @@ +// Copyright (C) 2019-2024 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 codes + +// NOT IMPLEMENTED BELOW +// +// func TestToString(t *testing.T) { +// type args struct { +// c T +// } +// type want struct { +// want string +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, string) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// c:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// c:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := ToString(test.args.c) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/net/grpc/errdetails/errdetails.go b/internal/net/grpc/errdetails/errdetails.go index a8e016c1d7..b7443978d7 100644 --- a/internal/net/grpc/errdetails/errdetails.go +++ b/internal/net/grpc/errdetails/errdetails.go @@ -411,12 +411,7 @@ func DebugInfoFromInfoDetail(v *info.Detail) (debug *DebugInfo) { if v.StackTrace != nil { debug.StackEntries = make([]string, 0, len(v.StackTrace)) for i, stack := range v.StackTrace { - debug.StackEntries = append(debug.GetStackEntries(), strings.Join([]string{ - "id:", - strconv.Itoa(i), - "stack_trace:", - stack.String(), - }, " ")) + debug.StackEntries = append(debug.GetStackEntries(), "id: "+strconv.Itoa(i)+" stack_trace: "+stack.ShortString()) } v.StackTrace = nil } diff --git a/internal/net/grpc/errdetails/errdetails_test.go b/internal/net/grpc/errdetails/errdetails_test.go index 0a80077106..6b6c8d1681 100644 --- a/internal/net/grpc/errdetails/errdetails_test.go +++ b/internal/net/grpc/errdetails/errdetails_test.go @@ -111,3 +111,99 @@ func TestDebugInfoFromInfoDetail(t *testing.T) { } // NOT IMPLEMENTED BELOW +// +// func TestDetail_MarshalJSON(t *testing.T) { +// type fields struct { +// TypeURL string +// Message proto.Message +// } +// type want struct { +// wantBody []byte +// err error +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, []byte, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, gotBody []byte, 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(gotBody, w.wantBody) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotBody, w.wantBody) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// TypeURL:"", +// Message:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// fields: fields { +// TypeURL:"", +// Message:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// d := &Detail{ +// TypeURL: test.fields.TypeURL, +// Message: test.fields.Message, +// } +// +// gotBody, err := d.MarshalJSON() +// if err := checkFunc(test.want, gotBody, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/internal/net/grpc/interceptor/server/logging/accesslog_test.go b/internal/net/grpc/interceptor/server/logging/accesslog_test.go index 328f92880a..6670fc8e2a 100644 --- a/internal/net/grpc/interceptor/server/logging/accesslog_test.go +++ b/internal/net/grpc/interceptor/server/logging/accesslog_test.go @@ -29,6 +29,114 @@ func TestMain(m *testing.M) { // NOT IMPLEMENTED BELOW // +// func TestAccessLogEntity_String(t *testing.T) { +// type fields struct { +// GRPC *AccessLogGRPCEntity +// StartTime int64 +// EndTime int64 +// Latency int64 +// TraceID string +// Error error +// } +// type want struct { +// wantStr string +// } +// type test struct { +// name string +// fields fields +// want want +// checkFunc func(want, string) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, gotStr string) error { +// if !reflect.DeepEqual(gotStr, w.wantStr) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotStr, w.wantStr) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// fields: fields { +// GRPC:AccessLogGRPCEntity{}, +// StartTime:0, +// EndTime:0, +// Latency:0, +// TraceID:"", +// Error:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// fields: fields { +// GRPC:AccessLogGRPCEntity{}, +// StartTime:0, +// EndTime:0, +// Latency:0, +// TraceID:"", +// Error:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// e := AccessLogEntity{ +// GRPC: test.fields.GRPC, +// StartTime: test.fields.StartTime, +// EndTime: test.fields.EndTime, +// Latency: test.fields.Latency, +// TraceID: test.fields.TraceID, +// Error: test.fields.Error, +// } +// +// gotStr := e.String() +// if err := checkFunc(test.want, gotStr); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func TestAccessLogInterceptor(t *testing.T) { // type want struct { // want grpc.UnaryServerInterceptor diff --git a/internal/net/grpc/status/status.go b/internal/net/grpc/status/status.go index 5d61fb41cf..f24d48c458 100644 --- a/internal/net/grpc/status/status.go +++ b/internal/net/grpc/status/status.go @@ -20,8 +20,8 @@ package status import ( "cmp" "context" - "os" "slices" + "strconv" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/info" @@ -30,6 +30,7 @@ import ( "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/proto" "github.com/vdaas/vald/internal/net/grpc/types" + "github.com/vdaas/vald/internal/os" "github.com/vdaas/vald/internal/strings" spb "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/grpc/status" @@ -137,7 +138,7 @@ func ParseError( st, ok = FromError(err) if !ok || st == nil { if defaultCode == 0 { - defaultCode = codes.Internal + defaultCode = codes.Unknown } if len(defaultMsg) == 0 { defaultMsg = "failed to parse gRPC status from error" @@ -158,6 +159,18 @@ func ParseError( return st, msg, err } + switch st.Code() { + case codes.Aborted, + codes.Canceled, + codes.DeadlineExceeded, + codes.AlreadyExists, + codes.NotFound, + codes.OK, + codes.Unimplemented: + return st, st.Message(), st.Err() + default: + } + sst := withDetails(st, err, details...) if sst != nil { return sst, sst.Message(), sst.Err() @@ -239,23 +252,23 @@ func FromError(err error) (st *Status, ok bool) { } } -func withDetails(st *Status, err error, details ...any) *Status { - if st != nil { - details = append(st.Details(), details...) +var hostname = func() (h string) { + var err error + h, err = os.Hostname() + if err != nil { + log.Warnf("failed to fetch hostname: %s,\terror: %v", h, err) + h = "unknown-host" } - dmap := make(map[string][]proto.Message, len(details)+1) + return h +}() + +func toProtoMessage(err error, details ...any) (dmap map[string][]proto.Message) { + dmap = make(map[string][]proto.Message, len(details)+1) if err != nil { typeName := errdetails.ErrorInfoMessageName dmap[typeName] = []proto.Message{&errdetails.ErrorInfo{ Reason: err.Error(), - Domain: func() (hostname string) { - var err error - hostname, err = os.Hostname() - if err != nil { - log.Warn("failed to fetch hostname:", err) - } - return hostname - }(), + Domain: hostname, }} } for _, detail := range details { @@ -423,6 +436,30 @@ func withDetails(st *Status, err error, details ...any) *Status { } } } + return dmap +} + +func withDetails(st *Status, err error, details ...any) *Status { + if st != nil { + if len(st.Details()) == 0 { + ds := make([]proto.MessageV1, 0, len(details)) + for _, msgs := range toProtoMessage(err, details) { + for _, msg := range msgs { + ds = append(ds, proto.ToMessageV1(msg)) + } + } + sst, err := st.WithDetails(ds...) + if err != nil { + return st + } + return sst + + } + details = append(st.Details(), details...) + } + + dmap := toProtoMessage(err, details) + msgs := make([]proto.MessageV1, 0, len(dmap)) visited := make(map[string]bool, len(dmap)) for typeName, ds := range dmap { @@ -431,15 +468,18 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.DebugInfo) for _, msg := range ds { d, ok := msg.(*errdetails.DebugInfo) - if ok && d != nil && !visited[d.String()] { - visited[d.String()] = true - if m.GetDetail() == "" { - m.Detail = d.GetDetail() - } else if m.GetDetail() != d.GetDetail() && !strings.Contains(m.GetDetail(), d.GetDetail()) { - m.Detail += "\t" + d.GetDetail() - } - if len(m.GetStackEntries()) < len(d.GetStackEntries()) { - m.StackEntries = d.GetStackEntries() + if ok && d != nil { + key := errdetails.DebugInfoMessageName + d.GetDetail() + strings.Join(d.GetStackEntries(), ",") + if !visited[key] { + visited[key] = true + if m.GetDetail() == "" { + m.Detail = d.GetDetail() + } else if m.GetDetail() != d.GetDetail() && !strings.Contains(m.GetDetail(), d.GetDetail()) { + m.Detail += "\t" + d.GetDetail() + } + if len(m.GetStackEntries()) < len(d.GetStackEntries()) { + m.StackEntries = d.GetStackEntries() + } } } } @@ -449,24 +489,27 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.ErrorInfo) for _, msg := range ds { e, ok := msg.(*errdetails.ErrorInfo) - if ok && e != nil && !visited[e.String()] && !visited[e.GetReason()] { - visited[e.String()] = true + if ok && e != nil && !visited[e.GetReason()] { visited[e.GetReason()] = true - if m.GetDomain() == "" { - m.Domain = e.GetDomain() - } else if m.GetDomain() != e.GetDomain() && !strings.Contains(m.GetDomain(), e.GetDomain()) { - m.Domain += "\t" + e.GetDomain() - } - if m.GetReason() == "" { - m.Reason += e.GetReason() - } else if m.GetReason() != e.GetReason() && !strings.Contains(m.GetReason(), e.GetReason()) { - m.Reason += "\t" + e.GetReason() - } - if e.GetMetadata() != nil { - if m.GetMetadata() == nil { - m.Metadata = e.GetMetadata() - } else { - m.Metadata = appendM(m.GetMetadata(), e.GetMetadata()) + key := errdetails.ErrorInfoMessageName + e.GetDomain() + e.GetReason() + if !visited[key] { + visited[key] = true + if m.GetDomain() == "" { + m.Domain = e.GetDomain() + } else if m.GetDomain() != e.GetDomain() && !strings.Contains(m.GetDomain(), e.GetDomain()) { + m.Domain += "\t" + e.GetDomain() + } + if m.GetReason() == "" { + m.Reason += e.GetReason() + } else if m.GetReason() != e.GetReason() && !strings.Contains(m.GetReason(), e.GetReason()) { + m.Reason += "\t" + e.GetReason() + } + if e.GetMetadata() != nil { + if m.GetMetadata() == nil { + m.Metadata = e.GetMetadata() + } else { + m.Metadata = appendM(m.GetMetadata(), e.GetMetadata()) + } } } } @@ -498,17 +541,20 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.BadRequestFieldViolation) for _, msg := range ds { b, ok := msg.(*errdetails.BadRequestFieldViolation) - if ok && b != nil && !visited[b.String()] { - visited[b.String()] = true - if m.GetField() == "" { - m.Field = b.GetField() - } else if m.GetField() != b.GetField() && !strings.Contains(m.GetField(), b.GetField()) { - m.Field += "\t" + b.GetField() - } - if m.GetDescription() == "" { - m.Description = b.GetDescription() - } else if m.GetDescription() != b.GetDescription() && !strings.Contains(m.GetDescription(), b.GetDescription()) { - m.Description += "\t" + b.GetDescription() + if ok && b != nil { + key := errdetails.BadRequestFieldViolationMessageName + b.GetField() + b.GetDescription() + if !visited[key] { + visited[key] = true + if m.GetField() == "" { + m.Field = b.GetField() + } else if m.GetField() != b.GetField() && !strings.Contains(m.GetField(), b.GetField()) { + m.Field += "\t" + b.GetField() + } + if m.GetDescription() == "" { + m.Description = b.GetDescription() + } else if m.GetDescription() != b.GetDescription() && !strings.Contains(m.GetDescription(), b.GetDescription()) { + m.Description += "\t" + b.GetDescription() + } } } } @@ -517,17 +563,20 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.LocalizedMessage) for _, msg := range ds { l, ok := msg.(*errdetails.LocalizedMessage) - if ok && l != nil && !visited[l.String()] { - visited[l.String()] = true - if m.GetLocale() == "" { - m.Locale = l.GetLocale() - } else if m.GetLocale() != l.GetLocale() && !strings.Contains(m.GetLocale(), l.GetLocale()) { - m.Locale += "\t" + l.GetLocale() - } - if m.GetMessage() == "" { - m.Message = l.GetMessage() - } else if m.GetMessage() != l.GetMessage() && !strings.Contains(m.GetMessage(), l.GetMessage()) { - m.Message += "\t" + l.GetMessage() + if ok && l != nil { + key := errdetails.LocalizedMessageMessageName + l.GetLocale() + l.GetMessage() + if !visited[key] { + visited[key] = true + if m.GetLocale() == "" { + m.Locale = l.GetLocale() + } else if m.GetLocale() != l.GetLocale() && !strings.Contains(m.GetLocale(), l.GetLocale()) { + m.Locale += "\t" + l.GetLocale() + } + if m.GetMessage() == "" { + m.Message = l.GetMessage() + } else if m.GetMessage() != l.GetMessage() && !strings.Contains(m.GetMessage(), l.GetMessage()) { + m.Message += "\t" + l.GetMessage() + } } } } @@ -556,22 +605,25 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.PreconditionFailureViolation) for _, msg := range ds { p, ok := msg.(*errdetails.PreconditionFailureViolation) - if ok && p != nil && !visited[p.String()] { - visited[p.String()] = true - if m.GetType() == "" { - m.Type = p.GetType() - } else if m.GetType() != p.GetType() && !strings.Contains(m.GetType(), p.GetType()) { - m.Type += "\t" + p.GetType() - } - if m.GetSubject() == "" { - m.Subject = p.GetSubject() - } else if m.GetSubject() != p.GetSubject() && !strings.Contains(m.GetSubject(), p.GetSubject()) { - m.Subject += "\t" + p.GetSubject() - } - if m.GetDescription() == "" { - m.Description = p.GetDescription() - } else if m.GetDescription() != p.GetDescription() && !strings.Contains(m.GetDescription(), p.GetDescription()) { - m.Description += "\t" + p.GetDescription() + if ok && p != nil { + key := errdetails.PreconditionFailureViolationMessageName + p.GetType() + p.GetSubject() + p.GetDescription() + if !visited[key] { + visited[key] = true + if m.GetType() == "" { + m.Type = p.GetType() + } else if m.GetType() != p.GetType() && !strings.Contains(m.GetType(), p.GetType()) { + m.Type += "\t" + p.GetType() + } + if m.GetSubject() == "" { + m.Subject = p.GetSubject() + } else if m.GetSubject() != p.GetSubject() && !strings.Contains(m.GetSubject(), p.GetSubject()) { + m.Subject += "\t" + p.GetSubject() + } + if m.GetDescription() == "" { + m.Description = p.GetDescription() + } else if m.GetDescription() != p.GetDescription() && !strings.Contains(m.GetDescription(), p.GetDescription()) { + m.Description += "\t" + p.GetDescription() + } } } } @@ -600,17 +652,20 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.HelpLink) for _, msg := range ds { h, ok := msg.(*errdetails.HelpLink) - if ok && h != nil && !visited[h.String()] { - visited[h.String()] = true - if m.GetUrl() == "" { - m.Url = h.GetUrl() - } else if m.GetUrl() != h.GetUrl() && !strings.Contains(m.GetUrl(), h.GetUrl()) { - m.Url += "\t" + h.GetUrl() - } - if m.GetDescription() == "" { - m.Description = h.GetDescription() - } else if m.GetDescription() != h.GetDescription() && !strings.Contains(m.GetDescription(), h.GetDescription()) { - m.Description += "\t" + h.GetDescription() + if ok && h != nil { + key := errdetails.HelpLinkMessageName + h.GetUrl() + h.GetDescription() + if !visited[key] { + visited[key] = true + if m.GetUrl() == "" { + m.Url = h.GetUrl() + } else if m.GetUrl() != h.GetUrl() && !strings.Contains(m.GetUrl(), h.GetUrl()) { + m.Url += "\t" + h.GetUrl() + } + if m.GetDescription() == "" { + m.Description = h.GetDescription() + } else if m.GetDescription() != h.GetDescription() && !strings.Contains(m.GetDescription(), h.GetDescription()) { + m.Description += "\t" + h.GetDescription() + } } } } @@ -639,17 +694,20 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.QuotaFailureViolation) for _, msg := range ds { q, ok := msg.(*errdetails.QuotaFailureViolation) - if ok && q != nil && !visited[q.String()] { - visited[q.String()] = true - if m.GetSubject() == "" { - m.Subject = q.GetSubject() - } else if m.GetSubject() != q.GetSubject() && !strings.Contains(m.GetSubject(), q.GetSubject()) { - m.Subject += "\t" + q.GetSubject() - } - if m.GetDescription() == "" { - m.Description = q.GetDescription() - } else if m.GetDescription() != q.GetDescription() && !strings.Contains(m.GetDescription(), q.GetDescription()) { - m.Description += "\t" + q.GetDescription() + if ok && q != nil { + key := errdetails.QuotaFailureViolationMessageName + q.GetSubject() + q.GetDescription() + if !visited[key] { + visited[key] = true + if m.GetSubject() == "" { + m.Subject = q.GetSubject() + } else if m.GetSubject() != q.GetSubject() && !strings.Contains(m.GetSubject(), q.GetSubject()) { + m.Subject += "\t" + q.GetSubject() + } + if m.GetDescription() == "" { + m.Description = q.GetDescription() + } else if m.GetDescription() != q.GetDescription() && !strings.Contains(m.GetDescription(), q.GetDescription()) { + m.Description += "\t" + q.GetDescription() + } } } } @@ -658,17 +716,20 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.RequestInfo) for _, msg := range ds { r, ok := msg.(*errdetails.RequestInfo) - if ok && r != nil && !visited[r.String()] { - visited[r.String()] = true - if m.GetRequestId() == "" { - m.RequestId = r.GetRequestId() - } else if m.GetRequestId() != r.GetRequestId() && !strings.Contains(m.GetRequestId(), r.GetRequestId()) { - m.RequestId += "\t" + r.GetRequestId() - } - if m.GetServingData() == "" { - m.ServingData = r.GetServingData() - } else if m.GetServingData() != r.GetServingData() && !strings.Contains(m.GetServingData(), r.GetServingData()) { - m.ServingData += "\t" + r.GetServingData() + if ok && r != nil { + key := errdetails.RequestInfoMessageName + r.GetRequestId() + r.GetServingData() + if !visited[key] { + visited[key] = true + if m.GetRequestId() == "" { + m.RequestId = r.GetRequestId() + } else if m.GetRequestId() != r.GetRequestId() && !strings.Contains(m.GetRequestId(), r.GetRequestId()) { + m.RequestId += "\t" + r.GetRequestId() + } + if m.GetServingData() == "" { + m.ServingData = r.GetServingData() + } else if m.GetServingData() != r.GetServingData() && !strings.Contains(m.GetServingData(), r.GetServingData()) { + m.ServingData += "\t" + r.GetServingData() + } } } } @@ -677,22 +738,25 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.ResourceInfo) for _, msg := range ds { r, ok := msg.(*errdetails.ResourceInfo) - if ok && r != nil && !visited[r.String()] { - visited[r.String()] = true - if m.GetResourceType() == "" { - m.ResourceType = r.GetResourceType() - } else if m.GetResourceType() != r.GetResourceType() && len(m.GetResourceType()) < len(r.GetResourceType()) { - m.ResourceType += r.GetResourceType() - } - if m.GetResourceName() == "" { - m.ResourceName = r.GetResourceName() - } else if m.GetResourceName() != r.GetResourceName() && !strings.Contains(m.GetResourceName(), r.GetResourceName()) { - m.ResourceName += "\t" + r.GetResourceName() - } - if m.GetDescription() == "" { - m.Description = r.GetDescription() - } else if m.GetDescription() != r.GetDescription() && !strings.Contains(m.GetDescription(), r.GetDescription()) { - m.Description += "\t" + r.GetDescription() + if ok && r != nil { + key := errdetails.ResourceInfoMessageName + r.GetResourceType() + r.GetResourceName() + r.GetDescription() + if !visited[key] { + visited[key] = true + if m.GetResourceType() == "" { + m.ResourceType = r.GetResourceType() + } else if m.GetResourceType() != r.GetResourceType() && len(m.GetResourceType()) < len(r.GetResourceType()) { + m.ResourceType += r.GetResourceType() + } + if m.GetResourceName() == "" { + m.ResourceName = r.GetResourceName() + } else if m.GetResourceName() != r.GetResourceName() && !strings.Contains(m.GetResourceName(), r.GetResourceName()) { + m.ResourceName += "\t" + r.GetResourceName() + } + if m.GetDescription() == "" { + m.Description = r.GetDescription() + } else if m.GetDescription() != r.GetDescription() && !strings.Contains(m.GetDescription(), r.GetDescription()) { + m.Description += "\t" + r.GetDescription() + } } } } @@ -701,10 +765,13 @@ func withDetails(st *Status, err error, details ...any) *Status { m := new(errdetails.RetryInfo) for _, msg := range ds { r, ok := msg.(*errdetails.RetryInfo) - if ok && r != nil && !visited[r.String()] { - visited[r.String()] = true - if m.GetRetryDelay() == nil || r.GetRetryDelay().Seconds < m.GetRetryDelay().Seconds { - m.RetryDelay = r.GetRetryDelay() + if ok && r != nil { + key := errdetails.RetryInfoMessageName + strconv.FormatInt(r.GetRetryDelay().GetSeconds(), 10) + strconv.FormatInt(int64(r.GetRetryDelay().GetNanos()), 10) + if !visited[key] { + visited[key] = true + if m.GetRetryDelay() == nil || r.GetRetryDelay().GetSeconds() < m.GetRetryDelay().GetSeconds() { + m.RetryDelay = r.GetRetryDelay() + } } } } diff --git a/internal/net/grpc/status/status_test.go b/internal/net/grpc/status/status_test.go index 5d9f6d818f..f0d526c482 100644 --- a/internal/net/grpc/status/status_test.go +++ b/internal/net/grpc/status/status_test.go @@ -2151,6 +2151,94 @@ func TestParseError(t *testing.T) { // } // } // +// func Test_toProtoMessage(t *testing.T) { +// type args struct { +// err error +// details []any +// } +// type want struct { +// wantDmap map[string][]proto.Message +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, map[string][]proto.Message) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotDmap map[string][]proto.Message) error { +// if !reflect.DeepEqual(gotDmap, w.wantDmap) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotDmap, w.wantDmap) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// err:nil, +// details:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// err:nil, +// details:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// gotDmap := toProtoMessage(test.args.err, test.args.details...) +// if err := checkFunc(test.want, gotDmap); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func Test_withDetails(t *testing.T) { // type args struct { // st *Status @@ -2242,6 +2330,261 @@ func TestParseError(t *testing.T) { // } // } // +// func Test_typeURL(t *testing.T) { +// type args struct { +// msg proto.Message +// } +// type want struct { +// want string +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, string) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// msg:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// msg:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := typeURL(test.args.msg) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_appendM(t *testing.T) { +// type args struct { +// maps []map[K]string +// } +// type want struct { +// wantResult map[K]string +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, map[K]string) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want, gotResult map[K]string) error { +// if !reflect.DeepEqual(gotResult, w.wantResult) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotResult, w.wantResult) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// maps:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// maps:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// gotResult := appendM(test.args.maps...) +// if err := checkFunc(test.want, gotResult); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_removeDuplicatesFromTSVLine(t *testing.T) { +// type args struct { +// line string +// } +// type want struct { +// want string +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, string) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// line:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// line:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// got := removeDuplicatesFromTSVLine(test.args.line) +// if err := checkFunc(test.want, got); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func TestLog(t *testing.T) { // type args struct { // code codes.Code diff --git a/internal/net/http/json/json.go b/internal/net/http/json/json.go index f93608be5e..33f9b86f72 100644 --- a/internal/net/http/json/json.go +++ b/internal/net/http/json/json.go @@ -20,7 +20,6 @@ import ( "bytes" "context" "net/http" - "os" "github.com/vdaas/vald/internal/encoding/json" "github.com/vdaas/vald/internal/errors" @@ -28,6 +27,7 @@ import ( "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/http/dump" "github.com/vdaas/vald/internal/net/http/rest" + "github.com/vdaas/vald/internal/os" ) // RFC7807Error represents RFC 7807 error. diff --git a/internal/observability/metrics/mem/mem.go b/internal/observability/metrics/mem/mem.go index ece3236388..75cb3095a1 100644 --- a/internal/observability/metrics/mem/mem.go +++ b/internal/observability/metrics/mem/mem.go @@ -19,11 +19,11 @@ import ( "os" "runtime" "strconv" - "strings" "time" "github.com/vdaas/vald/internal/conv" "github.com/vdaas/vald/internal/observability/metrics" + "github.com/vdaas/vald/internal/strings" api "go.opentelemetry.io/otel/metric" view "go.opentelemetry.io/otel/sdk/metric" ) diff --git a/internal/os/hostname.go b/internal/os/hostname.go new file mode 100644 index 0000000000..0bc060ba98 --- /dev/null +++ b/internal/os/hostname.go @@ -0,0 +1,55 @@ +// +// Copyright (C) 2019-2024 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 os provides os functions +package os + +import ( + "net" + "os" + + "github.com/vdaas/vald/internal/strings" +) + +const unknownHost = "unknown-host" + +var hostname = func() string { + h, err := os.Hostname() + if err != nil { + addrs, err := net.InterfaceAddrs() + if err != nil { + return unknownHost + } + ips := make([]string, 0, len(addrs)) + for _, addr := range addrs { + if ipn, ok := addr.(*net.IPNet); ok && !ipn.IP.IsLoopback() { + ips = append(ips, ipn.IP.String()) + } + } + if len(ips) == 0 { + return unknownHost + } + return strings.Join(ips, ",\t") + } + return h +}() + +func Hostname() (hn string, err error) { + if hostname != "" { + return hostname, nil + } + return os.Hostname() +} diff --git a/internal/os/hostname_test.go b/internal/os/hostname_test.go new file mode 100644 index 0000000000..fc6f6bfad6 --- /dev/null +++ b/internal/os/hostname_test.go @@ -0,0 +1,95 @@ +// Copyright (C) 2019-2024 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 os + +// NOT IMPLEMENTED BELOW +// +// func TestHostname(t *testing.T) { +// type want struct { +// wantHn string +// err error +// } +// type test struct { +// name string +// want want +// checkFunc func(want, string, error) error +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) +// } +// defaultCheckFunc := func(w want, gotHn 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(gotHn, w.wantHn) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotHn, w.wantHn) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T,) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T,) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// gotHn, err := Hostname() +// if err := checkFunc(test.want, gotHn, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } diff --git a/pkg/agent/core/faiss/handler/grpc/option.go b/pkg/agent/core/faiss/handler/grpc/option.go index 439889b7bf..3a7ba5a338 100644 --- a/pkg/agent/core/faiss/handler/grpc/option.go +++ b/pkg/agent/core/faiss/handler/grpc/option.go @@ -18,12 +18,12 @@ package grpc import ( - "os" "runtime" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net" + "github.com/vdaas/vald/internal/os" "github.com/vdaas/vald/internal/sync/errgroup" "github.com/vdaas/vald/pkg/agent/core/faiss/service" ) diff --git a/pkg/agent/core/ngt/handler/grpc/option.go b/pkg/agent/core/ngt/handler/grpc/option.go index d7af083e0c..2b1d32c45b 100644 --- a/pkg/agent/core/ngt/handler/grpc/option.go +++ b/pkg/agent/core/ngt/handler/grpc/option.go @@ -18,12 +18,12 @@ package grpc import ( - "os" "runtime" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net" + "github.com/vdaas/vald/internal/os" "github.com/vdaas/vald/internal/sync/errgroup" "github.com/vdaas/vald/pkg/agent/core/ngt/service" ) diff --git a/pkg/agent/core/ngt/service/ngt_test.go b/pkg/agent/core/ngt/service/ngt_test.go index e85c19993f..1da0b1a286 100644 --- a/pkg/agent/core/ngt/service/ngt_test.go +++ b/pkg/agent/core/ngt/service/ngt_test.go @@ -1784,10 +1784,423 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // +// func Test_ngt_copyNGT(t *testing.T) { +// type args struct { +// src *ngt +// } +// type fields struct { +// core core.NGT +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// indexing atomic.Value +// flushing atomic.Bool +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// nobic uint64 +// nopvq atomic.Uint64 +// cfg *config.NGT +// opts []Option +// inMem bool +// dim int +// alen int +// lim time.Duration +// dur time.Duration +// sdur time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// podName string +// podNamespace string +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// brokenPath string +// poolSize uint32 +// radius float32 +// epsilon float32 +// idelay time.Duration +// dcd bool +// kvsdbConcurrency int +// historyLimit int +// isReadReplica bool +// enableExportIndexInfo bool +// exportIndexInfoDuration time.Duration +// patcher client.Patcher +// enableStatistics bool +// statisticsCache atomic.Pointer[payload.Info_Index_Statistics] +// } +// type want struct{} +// type test struct { +// name string +// args args +// fields fields +// want want +// checkFunc func(want) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, args) +// } +// defaultCheckFunc := func(w want) error { +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// src:ngt{}, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// indexing:nil, +// flushing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// nobic:0, +// nopvq:nil, +// cfg:nil, +// opts:nil, +// inMem:false, +// dim:0, +// alen:0, +// lim:nil, +// dur:nil, +// sdur:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// brokenPath:"", +// poolSize:0, +// radius:0, +// epsilon:0, +// idelay:nil, +// dcd:false, +// kvsdbConcurrency:0, +// historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// src:ngt{}, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// indexing:nil, +// flushing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// nobic:0, +// nopvq:nil, +// cfg:nil, +// opts:nil, +// inMem:false, +// dim:0, +// alen:0, +// lim:nil, +// dur:nil, +// sdur:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", +// path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// brokenPath:"", +// poolSize:0, +// radius:0, +// epsilon:0, +// idelay:nil, +// dcd:false, +// kvsdbConcurrency:0, +// historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// n := &ngt{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// indexing: test.fields.indexing, +// flushing: test.fields.flushing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// nobic: test.fields.nobic, +// nopvq: test.fields.nopvq, +// cfg: test.fields.cfg, +// opts: test.fields.opts, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// alen: test.fields.alen, +// lim: test.fields.lim, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// podName: test.fields.podName, +// podNamespace: test.fields.podNamespace, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// brokenPath: test.fields.brokenPath, +// poolSize: test.fields.poolSize, +// radius: test.fields.radius, +// epsilon: test.fields.epsilon, +// idelay: test.fields.idelay, +// dcd: test.fields.dcd, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// historyLimit: test.fields.historyLimit, +// isReadReplica: test.fields.isReadReplica, +// enableExportIndexInfo: test.fields.enableExportIndexInfo, +// exportIndexInfoDuration: test.fields.exportIndexInfoDuration, +// patcher: test.fields.patcher, +// enableStatistics: test.fields.enableStatistics, +// statisticsCache: test.fields.statisticsCache, +// } +// +// n.copyNGT(test.args.src) +// if err := checkFunc(test.want); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// // func Test_migrate(t *testing.T) { // type args struct { -// ctx context.Context -// path string +// ctx context.Context +// path string +// } +// type want struct { +// err error +// } +// type test struct { +// name string +// args args +// want want +// checkFunc func(want, error) error +// beforeFunc func(*testing.T, args) +// afterFunc func(*testing.T, 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) +// } +// return nil +// } +// tests := []test{ +// // TODO test cases +// /* +// { +// name: "test_case_1", +// args: args { +// ctx:nil, +// path:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// }, +// */ +// +// // TODO test cases +// /* +// func() test { +// return test { +// name: "test_case_2", +// args: args { +// ctx:nil, +// path:"", +// }, +// want: want{}, +// checkFunc: defaultCheckFunc, +// beforeFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// afterFunc: func(t *testing.T, args args) { +// t.Helper() +// }, +// } +// }(), +// */ +// } +// +// 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(tt, test.args) +// } +// if test.afterFunc != nil { +// defer test.afterFunc(tt, test.args) +// } +// checkFunc := test.checkFunc +// if test.checkFunc == nil { +// checkFunc = defaultCheckFunc +// } +// +// err := migrate(test.args.ctx, test.args.path) +// if err := checkFunc(test.want, err); err != nil { +// tt.Errorf("error = %v", err) +// } +// }) +// } +// } +// +// func Test_ngt_prepareFolders(t *testing.T) { +// type args struct { +// ctx context.Context +// } +// type fields struct { +// core core.NGT +// eg errgroup.Group +// kvs kvs.BidiMap +// fmap map[string]int64 +// vq vqueue.Queue +// indexing atomic.Value +// flushing atomic.Bool +// saving atomic.Value +// lastNocie uint64 +// nocie uint64 +// nogce uint64 +// wfci uint64 +// nobic uint64 +// nopvq atomic.Uint64 +// cfg *config.NGT +// opts []Option +// inMem bool +// dim int +// alen int +// lim time.Duration +// dur time.Duration +// sdur time.Duration +// minLit time.Duration +// maxLit time.Duration +// litFactor time.Duration +// enableProactiveGC bool +// enableCopyOnWrite bool +// podName string +// podNamespace string +// path string +// tmpPath atomic.Value +// oldPath string +// basePath string +// brokenPath string +// poolSize uint32 +// radius float32 +// epsilon float32 +// idelay time.Duration +// dcd bool +// kvsdbConcurrency int +// historyLimit int +// isReadReplica bool +// enableExportIndexInfo bool +// exportIndexInfoDuration time.Duration +// patcher client.Patcher +// enableStatistics bool +// statisticsCache atomic.Pointer[payload.Info_Index_Statistics] // } // type want struct { // err error @@ -1795,6 +2208,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // type test struct { // name string // args args +// fields fields // want want // checkFunc func(want, error) error // beforeFunc func(*testing.T, args) @@ -1813,7 +2227,55 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// indexing:nil, +// flushing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// nobic:0, +// nopvq:nil, +// cfg:nil, +// opts:nil, +// inMem:false, +// dim:0, +// alen:0, +// lim:nil, +// dur:nil, +// sdur:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// brokenPath:"", +// poolSize:0, +// radius:0, +// epsilon:0, +// idelay:nil, +// dcd:false, +// kvsdbConcurrency:0, +// historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1833,7 +2295,55 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, +// }, +// fields: fields { +// core:nil, +// eg:nil, +// kvs:nil, +// fmap:nil, +// vq:nil, +// indexing:nil, +// flushing:nil, +// saving:nil, +// lastNocie:0, +// nocie:0, +// nogce:0, +// wfci:0, +// nobic:0, +// nopvq:nil, +// cfg:nil, +// opts:nil, +// inMem:false, +// dim:0, +// alen:0, +// lim:nil, +// dur:nil, +// sdur:nil, +// minLit:nil, +// maxLit:nil, +// litFactor:nil, +// enableProactiveGC:false, +// enableCopyOnWrite:false, +// podName:"", +// podNamespace:"", // path:"", +// tmpPath:nil, +// oldPath:"", +// basePath:"", +// brokenPath:"", +// poolSize:0, +// radius:0, +// epsilon:0, +// idelay:nil, +// dcd:false, +// kvsdbConcurrency:0, +// historyLimit:0, +// isReadReplica:false, +// enableExportIndexInfo:false, +// exportIndexInfoDuration:nil, +// patcher:nil, +// enableStatistics:false, +// statisticsCache:nil, // }, // want: want{}, // checkFunc: defaultCheckFunc, @@ -1863,8 +2373,57 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // if test.checkFunc == nil { // checkFunc = defaultCheckFunc // } +// n := &ngt{ +// core: test.fields.core, +// eg: test.fields.eg, +// kvs: test.fields.kvs, +// fmap: test.fields.fmap, +// vq: test.fields.vq, +// indexing: test.fields.indexing, +// flushing: test.fields.flushing, +// saving: test.fields.saving, +// lastNocie: test.fields.lastNocie, +// nocie: test.fields.nocie, +// nogce: test.fields.nogce, +// wfci: test.fields.wfci, +// nobic: test.fields.nobic, +// nopvq: test.fields.nopvq, +// cfg: test.fields.cfg, +// opts: test.fields.opts, +// inMem: test.fields.inMem, +// dim: test.fields.dim, +// alen: test.fields.alen, +// lim: test.fields.lim, +// dur: test.fields.dur, +// sdur: test.fields.sdur, +// minLit: test.fields.minLit, +// maxLit: test.fields.maxLit, +// litFactor: test.fields.litFactor, +// enableProactiveGC: test.fields.enableProactiveGC, +// enableCopyOnWrite: test.fields.enableCopyOnWrite, +// podName: test.fields.podName, +// podNamespace: test.fields.podNamespace, +// path: test.fields.path, +// tmpPath: test.fields.tmpPath, +// oldPath: test.fields.oldPath, +// basePath: test.fields.basePath, +// brokenPath: test.fields.brokenPath, +// poolSize: test.fields.poolSize, +// radius: test.fields.radius, +// epsilon: test.fields.epsilon, +// idelay: test.fields.idelay, +// dcd: test.fields.dcd, +// kvsdbConcurrency: test.fields.kvsdbConcurrency, +// historyLimit: test.fields.historyLimit, +// isReadReplica: test.fields.isReadReplica, +// enableExportIndexInfo: test.fields.enableExportIndexInfo, +// exportIndexInfoDuration: test.fields.exportIndexInfoDuration, +// patcher: test.fields.patcher, +// enableStatistics: test.fields.enableStatistics, +// statisticsCache: test.fields.statisticsCache, +// } // -// err := migrate(test.args.ctx, test.args.path) +// err := n.prepareFolders(test.args.ctx) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -1872,9 +2431,11 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_prepareFolders(t *testing.T) { +// func Test_ngt_load(t *testing.T) { // type args struct { -// ctx context.Context +// ctx context.Context +// path string +// opts []core.Option // } // type fields struct { // core core.NGT @@ -1950,6 +2511,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, +// path:"", +// opts:nil, // }, // fields: fields { // core:nil, @@ -2018,6 +2581,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, +// path:"", +// opts:nil, // }, // fields: fields { // core:nil, @@ -2146,7 +2711,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.prepareFolders(test.args.ctx) +// err := n.load(test.args.ctx, test.args.path, test.args.opts...) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -2154,11 +2719,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_load(t *testing.T) { +// func Test_ngt_backupBroken(t *testing.T) { // type args struct { -// ctx context.Context -// path string -// opts []core.Option +// ctx context.Context // } // type fields struct { // core core.NGT @@ -2234,8 +2797,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// path:"", -// opts:nil, // }, // fields: fields { // core:nil, @@ -2304,8 +2865,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// path:"", -// opts:nil, // }, // fields: fields { // core:nil, @@ -2434,7 +2993,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.load(test.args.ctx, test.args.path, test.args.opts...) +// err := n.backupBroken(test.args.ctx) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -2442,9 +3001,11 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_backupBroken(t *testing.T) { +// func Test_ngt_rebuild(t *testing.T) { // type args struct { -// ctx context.Context +// ctx context.Context +// path string +// opts []core.Option // } // type fields struct { // core core.NGT @@ -2520,6 +3081,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, +// path:"", +// opts:nil, // }, // fields: fields { // core:nil, @@ -2588,6 +3151,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, +// path:"", +// opts:nil, // }, // fields: fields { // core:nil, @@ -2716,7 +3281,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.backupBroken(test.args.ctx) +// err := n.rebuild(test.args.ctx, test.args.path, test.args.opts...) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -2724,10 +3289,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_rebuild(t *testing.T) { +// func Test_ngt_initNGT(t *testing.T) { // type args struct { -// ctx context.Context -// path string // opts []core.Option // } // type fields struct { @@ -2803,8 +3366,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// ctx:nil, -// path:"", // opts:nil, // }, // fields: fields { @@ -2873,8 +3434,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// ctx:nil, -// path:"", // opts:nil, // }, // fields: fields { @@ -3004,7 +3563,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.rebuild(test.args.ctx, test.args.path, test.args.opts...) +// err := n.initNGT(test.args.opts...) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -3012,9 +3571,11 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_initNGT(t *testing.T) { +// func Test_ngt_loadKVS(t *testing.T) { // type args struct { -// opts []core.Option +// ctx context.Context +// path string +// timeout time.Duration // } // type fields struct { // core core.NGT @@ -3089,7 +3650,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// opts:nil, +// ctx:nil, +// path:"", +// timeout:nil, // }, // fields: fields { // core:nil, @@ -3157,7 +3720,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// opts:nil, +// ctx:nil, +// path:"", +// timeout:nil, // }, // fields: fields { // core:nil, @@ -3286,7 +3851,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.initNGT(test.args.opts...) +// err := n.loadKVS(test.args.ctx, test.args.path, test.args.timeout) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -3294,11 +3859,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_loadKVS(t *testing.T) { +// func Test_ngt_Start(t *testing.T) { // type args struct { -// ctx context.Context -// path string -// timeout time.Duration +// ctx context.Context // } // type fields struct { // core core.NGT @@ -3350,20 +3913,20 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache atomic.Pointer[payload.Info_Index_Statistics] // } // type want struct { -// err error +// want <-chan error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, error) error +// checkFunc func(want, <-chan error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, 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 <-chan error) error { +// if !reflect.DeepEqual(got, w.want) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) // } // return nil // } @@ -3374,8 +3937,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// path:"", -// timeout:nil, // }, // fields: fields { // core:nil, @@ -3444,8 +4005,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// path:"", -// timeout:nil, // }, // fields: fields { // core:nil, @@ -3574,17 +4133,21 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.loadKVS(test.args.ctx, test.args.path, test.args.timeout) -// if err := checkFunc(test.want, err); err != nil { +// got := n.Start(test.args.ctx) +// if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_ngt_Start(t *testing.T) { +// func Test_ngt_Search(t *testing.T) { // type args struct { -// ctx context.Context +// ctx context.Context +// vec []float32 +// size uint32 +// epsilon float32 +// radius float32 // } // type fields struct { // core core.NGT @@ -3636,20 +4199,24 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache atomic.Pointer[payload.Info_Index_Statistics] // } // type want struct { -// want <-chan error +// wantRes *payload.Search_Response +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, <-chan error) error +// checkFunc func(want, *payload.Search_Response, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, got <-chan error) 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, gotRes *payload.Search_Response, 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(gotRes, w.wantRes) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) // } // return nil // } @@ -3660,6 +4227,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, +// vec:nil, +// size:0, +// epsilon:0, +// radius:0, // }, // fields: fields { // core:nil, @@ -3728,6 +4299,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, +// vec:nil, +// size:0, +// epsilon:0, +// radius:0, // }, // fields: fields { // core:nil, @@ -3856,18 +4431,18 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// got := n.Start(test.args.ctx) -// if err := checkFunc(test.want, got); err != nil { +// gotRes, err := n.Search(test.args.ctx, test.args.vec, test.args.size, test.args.epsilon, test.args.radius) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_ngt_Search(t *testing.T) { +// func Test_ngt_SearchByID(t *testing.T) { // type args struct { // ctx context.Context -// vec []float32 +// uuid string // size uint32 // epsilon float32 // radius float32 @@ -3922,7 +4497,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache atomic.Pointer[payload.Info_Index_Statistics] // } // type want struct { -// wantRes *payload.Search_Response +// wantVec []float32 +// wantDst *payload.Search_Response // err error // } // type test struct { @@ -3930,16 +4506,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, []float32, *payload.Search_Response, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Search_Response, err error) error { +// defaultCheckFunc := func(w want, gotVec []float32, gotDst *payload.Search_Response, 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(gotRes, w.wantRes) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) +// if !reflect.DeepEqual(gotVec, w.wantVec) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotVec, w.wantVec) +// } +// if !reflect.DeepEqual(gotDst, w.wantDst) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotDst, w.wantDst) // } // return nil // } @@ -3950,7 +4529,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// vec:nil, +// uuid:"", // size:0, // epsilon:0, // radius:0, @@ -4022,7 +4601,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// vec:nil, +// uuid:"", // size:0, // epsilon:0, // radius:0, @@ -4154,21 +4733,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// gotRes, err := n.Search(test.args.ctx, test.args.vec, test.args.size, test.args.epsilon, test.args.radius) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// gotVec, gotDst, err := n.SearchByID(test.args.ctx, test.args.uuid, test.args.size, test.args.epsilon, test.args.radius) +// if err := checkFunc(test.want, gotVec, gotDst, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_ngt_SearchByID(t *testing.T) { +// func Test_ngt_LinearSearch(t *testing.T) { // type args struct { -// ctx context.Context -// uuid string -// size uint32 -// epsilon float32 -// radius float32 +// ctx context.Context +// vec []float32 +// size uint32 // } // type fields struct { // core core.NGT @@ -4220,8 +4797,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache atomic.Pointer[payload.Info_Index_Statistics] // } // type want struct { -// wantVec []float32 -// wantDst *payload.Search_Response +// wantRes *payload.Search_Response // err error // } // type test struct { @@ -4229,19 +4805,16 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // args args // fields fields // want want -// checkFunc func(want, []float32, *payload.Search_Response, error) error +// checkFunc func(want, *payload.Search_Response, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotVec []float32, gotDst *payload.Search_Response, err error) error { +// defaultCheckFunc := func(w want, gotRes *payload.Search_Response, 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(gotVec, w.wantVec) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotVec, w.wantVec) -// } -// if !reflect.DeepEqual(gotDst, w.wantDst) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotDst, w.wantDst) +// if !reflect.DeepEqual(gotRes, w.wantRes) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) // } // return nil // } @@ -4252,10 +4825,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// uuid:"", +// vec:nil, // size:0, -// epsilon:0, -// radius:0, // }, // fields: fields { // core:nil, @@ -4324,10 +4895,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// uuid:"", +// vec:nil, // size:0, -// epsilon:0, -// radius:0, // }, // fields: fields { // core:nil, @@ -4456,18 +5025,18 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// gotVec, gotDst, err := n.SearchByID(test.args.ctx, test.args.uuid, test.args.size, test.args.epsilon, test.args.radius) -// if err := checkFunc(test.want, gotVec, gotDst, err); err != nil { +// gotRes, err := n.LinearSearch(test.args.ctx, test.args.vec, test.args.size) +// if err := checkFunc(test.want, gotRes, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_ngt_LinearSearch(t *testing.T) { +// func Test_ngt_LinearSearchByID(t *testing.T) { // type args struct { // ctx context.Context -// vec []float32 +// uuid string // size uint32 // } // type fields struct { @@ -4520,7 +5089,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache atomic.Pointer[payload.Info_Index_Statistics] // } // type want struct { -// wantRes *payload.Search_Response +// wantVec []float32 +// wantDst *payload.Search_Response // err error // } // type test struct { @@ -4528,16 +5098,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // args args // fields fields // want want -// checkFunc func(want, *payload.Search_Response, error) error +// checkFunc func(want, []float32, *payload.Search_Response, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotRes *payload.Search_Response, err error) error { +// defaultCheckFunc := func(w want, gotVec []float32, gotDst *payload.Search_Response, 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(gotRes, w.wantRes) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotRes, w.wantRes) +// if !reflect.DeepEqual(gotVec, w.wantVec) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotVec, w.wantVec) +// } +// if !reflect.DeepEqual(gotDst, w.wantDst) { +// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotDst, w.wantDst) // } // return nil // } @@ -4548,7 +5121,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // ctx:nil, -// vec:nil, +// uuid:"", // size:0, // }, // fields: fields { @@ -4618,7 +5191,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // ctx:nil, -// vec:nil, +// uuid:"", // size:0, // }, // fields: fields { @@ -4748,19 +5321,18 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// gotRes, err := n.LinearSearch(test.args.ctx, test.args.vec, test.args.size) -// if err := checkFunc(test.want, gotRes, err); err != nil { +// gotVec, gotDst, err := n.LinearSearchByID(test.args.ctx, test.args.uuid, test.args.size) +// if err := checkFunc(test.want, gotVec, gotDst, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_ngt_LinearSearchByID(t *testing.T) { +// func Test_ngt_Insert(t *testing.T) { // type args struct { -// ctx context.Context // uuid string -// size uint32 +// vec []float32 // } // type fields struct { // core core.NGT @@ -4812,29 +5384,21 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache atomic.Pointer[payload.Info_Index_Statistics] // } // type want struct { -// wantVec []float32 -// wantDst *payload.Search_Response -// err error +// err error // } // type test struct { // name string // args args // fields fields // want want -// checkFunc func(want, []float32, *payload.Search_Response, error) error +// checkFunc func(want, error) error // beforeFunc func(*testing.T, args) // afterFunc func(*testing.T, args) // } -// defaultCheckFunc := func(w want, gotVec []float32, gotDst *payload.Search_Response, err error) error { +// 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) // } -// if !reflect.DeepEqual(gotVec, w.wantVec) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotVec, w.wantVec) -// } -// if !reflect.DeepEqual(gotDst, w.wantDst) { -// return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotDst, w.wantDst) -// } // return nil // } // tests := []test{ @@ -4843,9 +5407,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// ctx:nil, // uuid:"", -// size:0, +// vec:nil, // }, // fields: fields { // core:nil, @@ -4913,9 +5476,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// ctx:nil, // uuid:"", -// size:0, +// vec:nil, // }, // fields: fields { // core:nil, @@ -5044,18 +5606,19 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// gotVec, gotDst, err := n.LinearSearchByID(test.args.ctx, test.args.uuid, test.args.size) -// if err := checkFunc(test.want, gotVec, gotDst, err); err != nil { +// err := n.Insert(test.args.uuid, test.args.vec) +// if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } // }) // } // } // -// func Test_ngt_Insert(t *testing.T) { +// func Test_ngt_InsertWithTime(t *testing.T) { // type args struct { // uuid string // vec []float32 +// t int64 // } // type fields struct { // core core.NGT @@ -5132,6 +5695,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // args: args { // uuid:"", // vec:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -5201,6 +5765,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // args: args { // uuid:"", // vec:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -5329,7 +5894,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.Insert(test.args.uuid, test.args.vec) +// err := n.InsertWithTime(test.args.uuid, test.args.vec, test.args.t) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -5337,11 +5902,12 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_InsertWithTime(t *testing.T) { +// func Test_ngt_insert(t *testing.T) { // type args struct { -// uuid string -// vec []float32 -// t int64 +// uuid string +// vec []float32 +// t int64 +// validation bool // } // type fields struct { // core core.NGT @@ -5419,6 +5985,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // uuid:"", // vec:nil, // t:0, +// validation:false, // }, // fields: fields { // core:nil, @@ -5489,6 +6056,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // uuid:"", // vec:nil, // t:0, +// validation:false, // }, // fields: fields { // core:nil, @@ -5617,7 +6185,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.InsertWithTime(test.args.uuid, test.args.vec, test.args.t) +// err := n.insert(test.args.uuid, test.args.vec, test.args.t, test.args.validation) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -5625,12 +6193,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_insert(t *testing.T) { +// func Test_ngt_InsertMultiple(t *testing.T) { // type args struct { -// uuid string -// vec []float32 -// t int64 -// validation bool +// vecs map[string][]float32 // } // type fields struct { // core core.NGT @@ -5705,10 +6270,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// uuid:"", -// vec:nil, -// t:0, -// validation:false, +// vecs:nil, // }, // fields: fields { // core:nil, @@ -5776,10 +6338,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// uuid:"", -// vec:nil, -// t:0, -// validation:false, +// vecs:nil, // }, // fields: fields { // core:nil, @@ -5908,7 +6467,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.insert(test.args.uuid, test.args.vec, test.args.t, test.args.validation) +// err := n.InsertMultiple(test.args.vecs) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -5916,9 +6475,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_InsertMultiple(t *testing.T) { +// func Test_ngt_InsertMultipleWithTime(t *testing.T) { // type args struct { // vecs map[string][]float32 +// t int64 // } // type fields struct { // core core.NGT @@ -5994,6 +6554,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // vecs:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -6062,6 +6623,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // vecs:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -6190,7 +6752,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.InsertMultiple(test.args.vecs) +// err := n.InsertMultipleWithTime(test.args.vecs, test.args.t) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -6198,10 +6760,11 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_InsertMultipleWithTime(t *testing.T) { +// func Test_ngt_insertMultiple(t *testing.T) { // type args struct { -// vecs map[string][]float32 -// t int64 +// vecs map[string][]float32 +// now int64 +// validation bool // } // type fields struct { // core core.NGT @@ -6277,7 +6840,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // vecs:nil, -// t:0, +// now:0, +// validation:false, // }, // fields: fields { // core:nil, @@ -6346,7 +6910,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // vecs:nil, -// t:0, +// now:0, +// validation:false, // }, // fields: fields { // core:nil, @@ -6475,7 +7040,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.InsertMultipleWithTime(test.args.vecs, test.args.t) +// err := n.insertMultiple(test.args.vecs, test.args.now, test.args.validation) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -6483,11 +7048,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_insertMultiple(t *testing.T) { +// func Test_ngt_Update(t *testing.T) { // type args struct { -// vecs map[string][]float32 -// now int64 -// validation bool +// uuid string +// vec []float32 // } // type fields struct { // core core.NGT @@ -6562,9 +7126,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// vecs:nil, -// now:0, -// validation:false, +// uuid:"", +// vec:nil, // }, // fields: fields { // core:nil, @@ -6632,9 +7195,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// vecs:nil, -// now:0, -// validation:false, +// uuid:"", +// vec:nil, // }, // fields: fields { // core:nil, @@ -6763,7 +7325,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.insertMultiple(test.args.vecs, test.args.now, test.args.validation) +// err := n.Update(test.args.uuid, test.args.vec) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -6771,10 +7333,11 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_Update(t *testing.T) { +// func Test_ngt_UpdateWithTime(t *testing.T) { // type args struct { // uuid string // vec []float32 +// t int64 // } // type fields struct { // core core.NGT @@ -6851,6 +7414,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // args: args { // uuid:"", // vec:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -6920,6 +7484,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // args: args { // uuid:"", // vec:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -7048,7 +7613,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.Update(test.args.uuid, test.args.vec) +// err := n.UpdateWithTime(test.args.uuid, test.args.vec, test.args.t) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -7056,7 +7621,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_UpdateWithTime(t *testing.T) { +// func Test_ngt_update(t *testing.T) { // type args struct { // uuid string // vec []float32 @@ -7336,7 +7901,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.UpdateWithTime(test.args.uuid, test.args.vec, test.args.t) +// err := n.update(test.args.uuid, test.args.vec, test.args.t) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -7344,11 +7909,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_update(t *testing.T) { +// func Test_ngt_UpdateMultiple(t *testing.T) { // type args struct { -// uuid string -// vec []float32 -// t int64 +// vecs map[string][]float32 // } // type fields struct { // core core.NGT @@ -7423,9 +7986,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// uuid:"", -// vec:nil, -// t:0, +// vecs:nil, // }, // fields: fields { // core:nil, @@ -7493,9 +8054,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// uuid:"", -// vec:nil, -// t:0, +// vecs:nil, // }, // fields: fields { // core:nil, @@ -7624,7 +8183,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.update(test.args.uuid, test.args.vec, test.args.t) +// err := n.UpdateMultiple(test.args.vecs) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -7632,9 +8191,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_UpdateMultiple(t *testing.T) { +// func Test_ngt_UpdateMultipleWithTime(t *testing.T) { // type args struct { // vecs map[string][]float32 +// t int64 // } // type fields struct { // core core.NGT @@ -7710,6 +8270,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // vecs:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -7778,6 +8339,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // vecs:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -7906,7 +8468,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.UpdateMultiple(test.args.vecs) +// err := n.UpdateMultipleWithTime(test.args.vecs, test.args.t) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -7914,7 +8476,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_UpdateMultipleWithTime(t *testing.T) { +// func Test_ngt_updateMultiple(t *testing.T) { // type args struct { // vecs map[string][]float32 // t int64 @@ -8191,7 +8753,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.UpdateMultipleWithTime(test.args.vecs, test.args.t) +// err := n.updateMultiple(test.args.vecs, test.args.t) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -8199,10 +8761,11 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_updateMultiple(t *testing.T) { +// func Test_ngt_UpdateTimestamp(t *testing.T) { // type args struct { -// vecs map[string][]float32 -// t int64 +// uuid string +// ts int64 +// force bool // } // type fields struct { // core core.NGT @@ -8277,8 +8840,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// vecs:nil, -// t:0, +// uuid:"", +// ts:0, +// force:false, // }, // fields: fields { // core:nil, @@ -8346,8 +8910,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// vecs:nil, -// t:0, +// uuid:"", +// ts:0, +// force:false, // }, // fields: fields { // core:nil, @@ -8476,7 +9041,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.updateMultiple(test.args.vecs, test.args.t) +// err := n.UpdateTimestamp(test.args.uuid, test.args.ts, test.args.force) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -8484,11 +9049,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_UpdateTimestamp(t *testing.T) { +// func Test_ngt_Delete(t *testing.T) { // type args struct { -// uuid string -// ts int64 -// force bool +// uuid string // } // type fields struct { // core core.NGT @@ -8564,8 +9127,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // uuid:"", -// ts:0, -// force:false, // }, // fields: fields { // core:nil, @@ -8634,8 +9195,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // uuid:"", -// ts:0, -// force:false, // }, // fields: fields { // core:nil, @@ -8764,7 +9323,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.UpdateTimestamp(test.args.uuid, test.args.ts, test.args.force) +// err := n.Delete(test.args.uuid) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -8772,9 +9331,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_Delete(t *testing.T) { +// func Test_ngt_DeleteWithTime(t *testing.T) { // type args struct { // uuid string +// t int64 // } // type fields struct { // core core.NGT @@ -8850,6 +9410,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // uuid:"", +// t:0, // }, // fields: fields { // core:nil, @@ -8918,6 +9479,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // uuid:"", +// t:0, // }, // fields: fields { // core:nil, @@ -9046,7 +9608,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.Delete(test.args.uuid) +// err := n.DeleteWithTime(test.args.uuid, test.args.t) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -9054,10 +9616,11 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_DeleteWithTime(t *testing.T) { +// func Test_ngt_delete(t *testing.T) { // type args struct { -// uuid string -// t int64 +// uuid string +// t int64 +// validation bool // } // type fields struct { // core core.NGT @@ -9134,6 +9697,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // args: args { // uuid:"", // t:0, +// validation:false, // }, // fields: fields { // core:nil, @@ -9203,6 +9767,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // args: args { // uuid:"", // t:0, +// validation:false, // }, // fields: fields { // core:nil, @@ -9331,7 +9896,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.DeleteWithTime(test.args.uuid, test.args.t) +// err := n.delete(test.args.uuid, test.args.t, test.args.validation) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -9339,11 +9904,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_delete(t *testing.T) { +// func Test_ngt_DeleteMultiple(t *testing.T) { // type args struct { -// uuid string -// t int64 -// validation bool +// uuids []string // } // type fields struct { // core core.NGT @@ -9418,9 +9981,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// uuid:"", -// t:0, -// validation:false, +// uuids:nil, // }, // fields: fields { // core:nil, @@ -9488,9 +10049,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// uuid:"", -// t:0, -// validation:false, +// uuids:nil, // }, // fields: fields { // core:nil, @@ -9619,7 +10178,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.delete(test.args.uuid, test.args.t, test.args.validation) +// err := n.DeleteMultiple(test.args.uuids...) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -9627,9 +10186,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_DeleteMultiple(t *testing.T) { +// func Test_ngt_DeleteMultipleWithTime(t *testing.T) { // type args struct { // uuids []string +// t int64 // } // type fields struct { // core core.NGT @@ -9705,6 +10265,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // uuids:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -9773,6 +10334,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // uuids:nil, +// t:0, // }, // fields: fields { // core:nil, @@ -9901,7 +10463,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.DeleteMultiple(test.args.uuids...) +// err := n.DeleteMultipleWithTime(test.args.uuids, test.args.t) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -9909,10 +10471,11 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_DeleteMultipleWithTime(t *testing.T) { +// func Test_ngt_deleteMultiple(t *testing.T) { // type args struct { -// uuids []string -// t int64 +// uuids []string +// now int64 +// validation bool // } // type fields struct { // core core.NGT @@ -9988,7 +10551,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_1", // args: args { // uuids:nil, -// t:0, +// now:0, +// validation:false, // }, // fields: fields { // core:nil, @@ -10057,7 +10621,8 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // name: "test_case_2", // args: args { // uuids:nil, -// t:0, +// now:0, +// validation:false, // }, // fields: fields { // core:nil, @@ -10186,7 +10751,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.DeleteMultipleWithTime(test.args.uuids, test.args.t) +// err := n.deleteMultiple(test.args.uuids, test.args.now, test.args.validation) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -10194,11 +10759,9 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_deleteMultiple(t *testing.T) { +// func Test_ngt_RegenerateIndexes(t *testing.T) { // type args struct { -// uuids []string -// now int64 -// validation bool +// ctx context.Context // } // type fields struct { // core core.NGT @@ -10273,9 +10836,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // { // name: "test_case_1", // args: args { -// uuids:nil, -// now:0, -// validation:false, +// ctx:nil, // }, // fields: fields { // core:nil, @@ -10343,9 +10904,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // return test { // name: "test_case_2", // args: args { -// uuids:nil, -// now:0, -// validation:false, +// ctx:nil, // }, // fields: fields { // core:nil, @@ -10474,7 +11033,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.deleteMultiple(test.args.uuids, test.args.now, test.args.validation) +// err := n.RegenerateIndexes(test.args.ctx) // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } @@ -10482,10 +11041,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // } // -// func Test_ngt_RegenerateIndexes(t *testing.T) { -// type args struct { -// ctx context.Context -// } +// func Test_ngt_loadStatistics(t *testing.T) { // type fields struct { // core core.NGT // eg errgroup.Group @@ -10540,12 +11096,11 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // } // type test struct { // name string -// args args // fields fields // want want // checkFunc func(want, error) error -// beforeFunc func(*testing.T, args) -// afterFunc func(*testing.T, args) +// beforeFunc func(*testing.T) +// afterFunc func(*testing.T) // } // defaultCheckFunc := func(w want, err error) error { // if !errors.Is(err, w.err) { @@ -10558,9 +11113,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // /* // { // name: "test_case_1", -// args: args { -// ctx:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -10612,10 +11164,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T, args args) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // }, @@ -10626,9 +11178,6 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // func() test { // return test { // name: "test_case_2", -// args: args { -// ctx:nil, -// }, // fields: fields { // core:nil, // eg:nil, @@ -10680,10 +11229,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // }, // want: want{}, // checkFunc: defaultCheckFunc, -// beforeFunc: func(t *testing.T, args args) { +// beforeFunc: func(t *testing.T,) { // t.Helper() // }, -// afterFunc: func(t *testing.T, args args) { +// afterFunc: func(t *testing.T,) { // t.Helper() // }, // } @@ -10697,10 +11246,10 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // tt.Parallel() // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) // if test.beforeFunc != nil { -// test.beforeFunc(tt, test.args) +// test.beforeFunc(tt) // } // if test.afterFunc != nil { -// defer test.afterFunc(tt, test.args) +// defer test.afterFunc(tt) // } // checkFunc := test.checkFunc // if test.checkFunc == nil { @@ -10756,7 +11305,7 @@ func createRandomData(num int, cfg *createRandomDataConfig) []index { // statisticsCache: test.fields.statisticsCache, // } // -// err := n.RegenerateIndexes(test.args.ctx) +// err := n.loadStatistics() // if err := checkFunc(test.want, err); err != nil { // tt.Errorf("error = %v", err) // } diff --git a/pkg/discoverer/k8s/handler/grpc/option.go b/pkg/discoverer/k8s/handler/grpc/option.go index 9a7280bcff..b18a7f0a3e 100644 --- a/pkg/discoverer/k8s/handler/grpc/option.go +++ b/pkg/discoverer/k8s/handler/grpc/option.go @@ -18,11 +18,10 @@ package grpc import ( - "os" - "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net" + "github.com/vdaas/vald/internal/os" "github.com/vdaas/vald/pkg/discoverer/k8s/service" ) diff --git a/pkg/gateway/filter/handler/grpc/option.go b/pkg/gateway/filter/handler/grpc/option.go index f3e96f0b64..0d240a6d5d 100644 --- a/pkg/gateway/filter/handler/grpc/option.go +++ b/pkg/gateway/filter/handler/grpc/option.go @@ -18,7 +18,6 @@ package grpc import ( - "os" "runtime" "github.com/vdaas/vald/internal/client/v1/client/filter/egress" @@ -26,6 +25,7 @@ import ( "github.com/vdaas/vald/internal/client/v1/client/vald" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net" + "github.com/vdaas/vald/internal/os" "github.com/vdaas/vald/internal/sync/errgroup" ) diff --git a/pkg/gateway/lb/handler/grpc/handler.go b/pkg/gateway/lb/handler/grpc/handler.go index f6ef4fdb42..10021e53e4 100644 --- a/pkg/gateway/lb/handler/grpc/handler.go +++ b/pkg/gateway/lb/handler/grpc/handler.go @@ -20,7 +20,6 @@ package grpc import ( "context" "fmt" - "io" "math" "slices" "strconv" @@ -33,6 +32,7 @@ import ( "github.com/vdaas/vald/internal/core/algorithm" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/info" + "github.com/vdaas/vald/internal/io" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net" "github.com/vdaas/vald/internal/net/grpc" diff --git a/pkg/gateway/lb/handler/grpc/option.go b/pkg/gateway/lb/handler/grpc/option.go index aa1d3b8ecd..2e97e25115 100644 --- a/pkg/gateway/lb/handler/grpc/option.go +++ b/pkg/gateway/lb/handler/grpc/option.go @@ -18,12 +18,12 @@ package grpc import ( - "os" "runtime" "time" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net" + "github.com/vdaas/vald/internal/os" "github.com/vdaas/vald/internal/sync/errgroup" "github.com/vdaas/vald/internal/timeutil" "github.com/vdaas/vald/pkg/gateway/lb/service" diff --git a/pkg/gateway/mirror/handler/grpc/handler.go b/pkg/gateway/mirror/handler/grpc/handler.go index 7065b1e177..c424ac6a65 100644 --- a/pkg/gateway/mirror/handler/grpc/handler.go +++ b/pkg/gateway/mirror/handler/grpc/handler.go @@ -16,7 +16,6 @@ package grpc import ( "context" "fmt" - "io" "reflect" "sync/atomic" @@ -24,6 +23,7 @@ import ( "github.com/vdaas/vald/apis/grpc/v1/payload" "github.com/vdaas/vald/apis/grpc/v1/vald" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/io" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc" "github.com/vdaas/vald/internal/net/grpc/codes" diff --git a/pkg/gateway/mirror/handler/grpc/option.go b/pkg/gateway/mirror/handler/grpc/option.go index 5832e37be9..e2d14869db 100644 --- a/pkg/gateway/mirror/handler/grpc/option.go +++ b/pkg/gateway/mirror/handler/grpc/option.go @@ -14,12 +14,12 @@ package grpc import ( - "os" "runtime" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net" + "github.com/vdaas/vald/internal/os" "github.com/vdaas/vald/internal/sync/errgroup" "github.com/vdaas/vald/pkg/gateway/mirror/service" ) diff --git a/pkg/gateway/mirror/service/gateway.go b/pkg/gateway/mirror/service/gateway.go index 51b4a7ad2a..6d708b91ad 100644 --- a/pkg/gateway/mirror/service/gateway.go +++ b/pkg/gateway/mirror/service/gateway.go @@ -16,13 +16,13 @@ package service import ( "context" "reflect" - "strings" "github.com/vdaas/vald/internal/client/v1/client/mirror" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc" "github.com/vdaas/vald/internal/observability/trace" + "github.com/vdaas/vald/internal/strings" "github.com/vdaas/vald/internal/sync/errgroup" ) diff --git a/pkg/gateway/mirror/service/gateway_test.go b/pkg/gateway/mirror/service/gateway_test.go index 526132ecd0..ed53443040 100644 --- a/pkg/gateway/mirror/service/gateway_test.go +++ b/pkg/gateway/mirror/service/gateway_test.go @@ -200,7 +200,7 @@ package service // } // } // -// func Test_gateway_ForwardedContext(t *testing.T) { +// func Test_gateway_forwardedContext(t *testing.T) { // type args struct { // ctx context.Context // podName string @@ -301,7 +301,7 @@ package service // podName: test.fields.podName, // } // -// got := g.ForwardedContext(test.args.ctx, test.args.podName) +// got := g.forwardedContext(test.args.ctx, test.args.podName) // if err := checkFunc(test.want, got); err != nil { // tt.Errorf("error = %v", err) // } diff --git a/pkg/index/job/correction/service/corrector.go b/pkg/index/job/correction/service/corrector.go index 5bcf7a6e96..d403551c5e 100644 --- a/pkg/index/job/correction/service/corrector.go +++ b/pkg/index/job/correction/service/corrector.go @@ -17,7 +17,6 @@ import ( "cmp" "context" "fmt" - "io" "os" "reflect" "slices" @@ -31,6 +30,7 @@ import ( "github.com/vdaas/vald/internal/db/kvs/pogreb" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/file" + "github.com/vdaas/vald/internal/io" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/net/grpc" "github.com/vdaas/vald/internal/net/grpc/codes" diff --git a/pkg/index/job/readreplica/rotate/service/rotator.go b/pkg/index/job/readreplica/rotate/service/rotator.go index ef24e67889..a57c7ecbfa 100644 --- a/pkg/index/job/readreplica/rotate/service/rotator.go +++ b/pkg/index/job/readreplica/rotate/service/rotator.go @@ -17,7 +17,6 @@ import ( "context" "fmt" "reflect" - "strings" "time" "github.com/vdaas/vald/internal/errors" @@ -27,6 +26,7 @@ import ( "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/observability/trace" "github.com/vdaas/vald/internal/safety" + "github.com/vdaas/vald/internal/strings" "github.com/vdaas/vald/internal/sync/errgroup" "k8s.io/utils/ptr" ) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 7f3a192f22..ea31fe1a60 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -144,9 +144,9 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "async-stream" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" dependencies = [ "async-stream-impl", "futures-core", @@ -155,9 +155,9 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", @@ -217,12 +217,12 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f43644eed690f5374f1af436ecd6aea01cd201f6fbdf0178adaf6907afb2cec" +checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" dependencies = [ "async-trait", - "axum-core 0.4.4", + "axum-core 0.4.5", "bytes", "futures-util", "http 1.1.0", @@ -261,9 +261,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" dependencies = [ "async-trait", "bytes", @@ -364,7 +364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "regex-automata 0.4.7", + "regex-automata 0.4.8", "serde", ] @@ -429,7 +429,7 @@ dependencies = [ "humantime", "ignore", "im-rc", - "indexmap 2.5.0", + "indexmap 2.6.0", "itertools 0.12.1", "jobserver", "lazycell", @@ -565,9 +565,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.22" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" dependencies = [ "jobserver", "libc", @@ -582,24 +582,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.18" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" +checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.18" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" +checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", - "terminal_size", + "terminal_size 0.4.0", ] [[package]] @@ -769,9 +769,9 @@ checksum = "026ac6ceace6298d2c557ef5ed798894962296469ec7842288ea64674201a2d1" [[package]] name = "curl" -version = "0.4.46" +version = "0.4.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e2161dd6eba090ff1594084e95fd67aeccf04382ffea77999ea94ed42ec67b6" +checksum = "d9fb4d13a1be2b58f14d60adba57c9834b78c62fd86c3e76a148f732686e9265" dependencies = [ "curl-sys", "libc", @@ -784,9 +784,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.76+curl-8.10.1" +version = "0.4.77+curl-8.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00462dbe9cbb9344e1b2be34d9094d74e3b8aac59a883495b335eafd02e25120" +checksum = "f469e8a5991f277a208224f6c7ad72ecb5f986e36d09ae1f2c1bb9259478a480" dependencies = [ "cc", "libc", @@ -1978,8 +1978,8 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -2005,7 +2005,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.5.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -2024,7 +2024,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.5.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -2047,6 +2047,12 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "hashlink" version = "0.9.1" @@ -2162,9 +2168,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -2287,7 +2293,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.7", + "regex-automata 0.4.8", "same-file", "walkdir", "winapi-util", @@ -2319,12 +2325,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.0", ] [[package]] @@ -2626,7 +2632,7 @@ dependencies = [ "supports-color", "supports-hyperlinks", "supports-unicode", - "terminal_size", + "terminal_size 0.3.0", "textwrap", "thiserror", "unicode-width", @@ -2776,9 +2782,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "opener" @@ -3080,6 +3089,12 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -3238,23 +3253,23 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -3268,13 +3283,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -3285,9 +3300,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" @@ -3717,9 +3732,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -3771,9 +3786,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -3801,6 +3816,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "terminal_size" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" +dependencies = [ + "rustix", + "windows-sys 0.59.0", +] + [[package]] name = "textwrap" version = "0.16.1" @@ -3981,7 +4006,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -4023,7 +4048,7 @@ checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", - "axum 0.7.6", + "axum 0.7.7", "base64 0.22.1", "bytes", "h2 0.4.6", @@ -4203,9 +4228,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-bom" diff --git a/tests/performance/max_vector_dim_test.go b/tests/performance/max_vector_dim_test.go index 1eb434ce49..d39db3e5f4 100644 --- a/tests/performance/max_vector_dim_test.go +++ b/tests/performance/max_vector_dim_test.go @@ -68,17 +68,15 @@ func init_ngt_service(dim int) (service.NGT, error) { } func parse(raw string) (key string, value int) { - text := strings.ReplaceAll(raw[:len(raw)-2], " ", "") - keyValue := strings.Split(text, ":") - val := 0 - if keyValue[1] != "" { - val, err := strconv.Atoi(keyValue[1]) + k, v, ok := strings.Cut(strings.ReplaceAll(raw[:len(raw)-2], " ", ""), ":") + if ok { + val, err := strconv.Atoi(v) if err != nil { - panic(err) + return k, 0 } - return keyValue[0], val + return k, val } - return keyValue[0], val + return k, 0 } func TestMain(m *testing.M) { diff --git a/versions/CMAKE_VERSION b/versions/CMAKE_VERSION index 7061f71e70..5f448421f9 100644 --- a/versions/CMAKE_VERSION +++ b/versions/CMAKE_VERSION @@ -1 +1 @@ -3.30.3 +3.30.4 diff --git a/versions/GO_VERSION b/versions/GO_VERSION index 49e0a31d49..14bee92c9e 100644 --- a/versions/GO_VERSION +++ b/versions/GO_VERSION @@ -1 +1 @@ -1.23.1 +1.23.2 diff --git a/versions/HDF5_VERSION b/versions/HDF5_VERSION index 85b169d0cb..2248db12d7 100644 --- a/versions/HDF5_VERSION +++ b/versions/HDF5_VERSION @@ -1 +1 @@ -hdf5_1.14.4.3 +hdf5_1.14.5 diff --git a/versions/JAEGER_OPERATOR_VERSION b/versions/JAEGER_OPERATOR_VERSION index 5f46e11eed..4b9cd6e7dc 100644 --- a/versions/JAEGER_OPERATOR_VERSION +++ b/versions/JAEGER_OPERATOR_VERSION @@ -1 +1 @@ -2.56.0 +2.57.0 diff --git a/versions/PROMETHEUS_STACK_VERSION b/versions/PROMETHEUS_STACK_VERSION index c3998b266a..4acff0a40e 100644 --- a/versions/PROMETHEUS_STACK_VERSION +++ b/versions/PROMETHEUS_STACK_VERSION @@ -1 +1 @@ -63.1.0 +65.0.0 diff --git a/versions/TELEPRESENCE_VERSION b/versions/TELEPRESENCE_VERSION index b8e248f40b..7329e21c3b 100644 --- a/versions/TELEPRESENCE_VERSION +++ b/versions/TELEPRESENCE_VERSION @@ -1 +1 @@ -2.19.1 +2.20.0 diff --git a/versions/actions/ACTIONS_CACHE b/versions/actions/ACTIONS_CACHE index 4d54daddb6..ee74734aa2 100644 --- a/versions/actions/ACTIONS_CACHE +++ b/versions/actions/ACTIONS_CACHE @@ -1 +1 @@ -4.0.2 +4.1.0 diff --git a/versions/actions/ACTIONS_CHECKOUT b/versions/actions/ACTIONS_CHECKOUT index 6aba2b245a..fae6e3d04b 100644 --- a/versions/actions/ACTIONS_CHECKOUT +++ b/versions/actions/ACTIONS_CHECKOUT @@ -1 +1 @@ -4.2.0 +4.2.1 diff --git a/versions/actions/ACTIONS_UPLOAD_ARTIFACT b/versions/actions/ACTIONS_UPLOAD_ARTIFACT index fdc6698807..cca25a93cd 100644 --- a/versions/actions/ACTIONS_UPLOAD_ARTIFACT +++ b/versions/actions/ACTIONS_UPLOAD_ARTIFACT @@ -1 +1 @@ -4.4.0 +4.4.1 diff --git a/versions/actions/CODECOV_CODECOV_ACTION b/versions/actions/CODECOV_CODECOV_ACTION index a84947d6ff..6016e8addc 100644 --- a/versions/actions/CODECOV_CODECOV_ACTION +++ b/versions/actions/CODECOV_CODECOV_ACTION @@ -1 +1 @@ -4.5.0 +4.6.0 diff --git a/versions/actions/DOCKER_SETUP_BUILDX_ACTION b/versions/actions/DOCKER_SETUP_BUILDX_ACTION index 9575d51bad..a76ccff2a6 100644 --- a/versions/actions/DOCKER_SETUP_BUILDX_ACTION +++ b/versions/actions/DOCKER_SETUP_BUILDX_ACTION @@ -1 +1 @@ -3.6.1 +3.7.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE b/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE index ef0f38abe1..b8e248f40b 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE +++ b/versions/actions/GITHUB_CODEQL_ACTION_ANALYZE @@ -1 +1 @@ -2.19.0 +2.19.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD b/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD index ef0f38abe1..b8e248f40b 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD +++ b/versions/actions/GITHUB_CODEQL_ACTION_AUTOBUILD @@ -1 +1 @@ -2.19.0 +2.19.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_INIT b/versions/actions/GITHUB_CODEQL_ACTION_INIT index ef0f38abe1..b8e248f40b 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_INIT +++ b/versions/actions/GITHUB_CODEQL_ACTION_INIT @@ -1 +1 @@ -2.19.0 +2.19.1 diff --git a/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF b/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF index ef0f38abe1..b8e248f40b 100644 --- a/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF +++ b/versions/actions/GITHUB_CODEQL_ACTION_UPLOAD_SARIF @@ -1 +1 @@ -2.19.0 +2.19.1 diff --git a/versions/actions/GITHUB_ISSUE_METRICS b/versions/actions/GITHUB_ISSUE_METRICS index 92536a9e48..4eba2a62eb 100644 --- a/versions/actions/GITHUB_ISSUE_METRICS +++ b/versions/actions/GITHUB_ISSUE_METRICS @@ -1 +1 @@ -3.12.0 +3.13.0